use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.
the class DependenciesHandler method getClientDepListByResult.
/**
* get Client Dependency List.
*
* @param Analysis the analysis which we want to save
* @return The list all of client dependency(Pattern UDI Connection DQRule)
*/
public List<ModelElement> getClientDepListByResult(Analysis analysis) {
List<ModelElement> clientDependencyList = new ArrayList<ModelElement>();
DataManager connection = analysis.getContext().getConnection();
// list
if (connection != null) {
// DQRule or UDI case
clientDependencyList.addAll(AnalysisHelper.getUserDefinedIndicators(analysis));
// pattern case
clientDependencyList.addAll(AnalysisHelper.getPatterns(analysis));
clientDependencyList.add(connection);
}
return clientDependencyList;
}
use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.
the class ModelElementAnalysisHandler method addIndicator.
public boolean addIndicator(ModelElement modelElement, Indicator... indicators) {
if (!analysis.getContext().getAnalysedElements().contains(modelElement)) {
analysis.getContext().getAnalysedElements().add(modelElement);
}
for (Indicator indicator : indicators) {
// ADD TDQ-7164 msjian 2013-5-14:set default indicator parameters.
if (indicator.getParameters() == null) {
indicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
}
// TDQ-7164~
// store first level of indicators in result.
analysis.getResults().getIndicators().add(indicator);
initializeIndicator(indicator, modelElement);
}
DataManager connection = analysis.getContext().getConnection();
if (connection == null) {
// try to get one
// $NON-NLS-1$
log.error(Messages.getString("ColumnCorrelationAnalysisHandler.CONNNOTBEENSETINANALYSIS"));
connection = ModelElementHelper.getTdDataProvider(modelElement);
analysis.getContext().setConnection(connection);
}
TypedReturnCode<Dependency> rc = DependenciesHandler.getInstance().setDependencyOn(analysis, connection);
return rc.isOk();
}
use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.
the class DataExplorer method setAnalysis.
public boolean setAnalysis(Analysis analysis) {
this.analysis = analysis;
AnalysisContext context = this.analysis.getContext();
if (context == null) {
// $NON-NLS-1$
log.error(Messages.getString("DataExplorer.ANALYSISCONTEXTISNULL", analysis.getName()));
return false;
}
DataManager dataManager = context.getConnection();
if (dataManager == null) {
// $NON-NLS-1$
log.error(Messages.getString("DataExplorer.NOCONNFOUND") + analysis.getName());
return false;
}
this.dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(dataManager);
return true;
}
use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.
the class AbstractPagePart method setConnectionState.
private void setConnectionState(final AbstractAnalysisMetadataPage masterPage, final DataManager dataManager) {
DataManager newDataManager = dataManager;
final DataManager fianlDataManager;
if (newDataManager != null) {
if (newDataManager.eIsProxy()) {
newDataManager = (DataManager) EObjectHelper.resolveObject(newDataManager);
}
Property prop = PropertyHelper.getProperty(newDataManager);
// MOD gdbu 2011-8-15 bug : TDQ-3213
masterPage.reloadDataproviderAndFillConnCombo();
fianlDataManager = newDataManager;
// MOD yyin 201204 TDQ-4977
Integer index = null;
// use property.getLabel() instead of dataManager.getDisplayName() because of we set it use first one for
// TDQ-6286.
boolean isConnectionAvailble = !(prop == null);
// MOD qiongli 2011-1-7 delimitedFile connection dosen't use 'dataManager.getName()'.
if (SwitchHelpers.CONNECTION_SWITCH.doSwitch(newDataManager) != null) {
// TDQ-10765: support ref project connection name, make the format of display is: label+(@reference
// project name)
DQRepositoryNode repNode = (DQRepositoryNode) RepositoryNodeHelper.recursiveFind(prop);
if (repNode != null) {
String displayName = RepositoryNodeHelper.getAnalysisConComboDisplayName(repNode);
index = (Integer) masterPage.getConnCombo().getData(displayName + RepositoryNodeHelper.getConnectionType(newDataManager));
} else {
// when the current project(maybe local project) have no ref project, can not find the ref connection
isConnectionAvailble = false;
}
}
if (index != null) {
masterPage.getConnCombo().select(index);
}
// MOD qiongli 2011-5-16 bug 21453
if (prop != null && prop.getItem() != null && prop.getItem().getState() != null) {
masterPage.getLabelConnDeleted().setVisible(true);
if (prop.getItem().getState().isDeleted()) {
masterPage.getLabelConnDeleted().setText(// $NON-NLS-1$
DefaultMessagesImpl.getString("AbstractPagePart.LogicalDeleteWarn", prop.getDisplayName()));
} else {
if (!isConnectionAvailble) {
// when the connection is from ref project, but current project have not set ref project
masterPage.getLabelConnDeleted().setText(// $NON-NLS-1$
DefaultMessagesImpl.getString("AbstractPagePart.ChangeConnectionError1", prop.getDisplayName()));
}
}
} else {
masterPage.getLabelConnDeleted().setVisible(false);
// when the connection is from ref project, but current project have not set ref project
if (!isConnectionAvailble) {
masterPage.getLabelConnDeleted().setVisible(true);
masterPage.getLabelConnDeleted().setText(DefaultMessagesImpl.getString("AbstractPagePart.ChangeConnectionError1", // $NON-NLS-1$
EObjectHelper.getURI(newDataManager).path()));
}
}
// MOD mzhao 2009-06-09 feature 5887
if (selectionListener == null) {
selectionListener = new SelectionListener() {
private int prevSelect = masterPage.getConnCombo().getSelectionIndex();
private DataManager dataProvider = fianlDataManager;
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
ReturnCode rc = selectedObjectAvailable();
if (rc.isOk()) {
// refresh of the db connection tree
if (dataProvider.eIsProxy()) {
dataProvider = (Connection) EObjectHelper.resolveObject(dataProvider);
}
// ~
Connection connection = null;
if (dataProvider instanceof RepositoryNode) {
connection = ((ConnectionItem) ((RepositoryNode) dataProvider).getObject().getProperty().getItem()).getConnection();
} else if (dataProvider instanceof Connection) {
connection = (Connection) dataProvider;
}
connection = callChangeConnectionAction(masterPage, prevSelect, connection);
prevSelect = masterPage.getConnCombo().getSelectionIndex();
} else {
// show error message
MessageDialogWithToggle.openError(null, DefaultMessagesImpl.getString("AbstractPagePart.ChangeConnectionTitle"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("AbstractPagePart.ChangeConnectionError1", rc.getMessage()));
// reload the connection combo
masterPage.reloadDataproviderAndFillConnCombo();
// reselect the old connection
masterPage.getConnCombo().removeSelectionListener(selectionListener);
String uuid = ResourceHelper.getUUID(dataProvider);
if (uuid != null) {
int itemCount = masterPage.getConnCombo().getItemCount();
for (int i = 0; i < itemCount; i++) {
Object connectionObj = masterPage.getConnCombo().getData(String.valueOf(i));
RepositoryNode repoNode = (RepositoryNode) connectionObj;
Connection connection = getConnectionFromRepositoryNode(repoNode);
if (connection != null && uuid.endsWith(ResourceHelper.getUUID(connection))) {
masterPage.getConnCombo().select(i);
break;
}
}
}
masterPage.getConnCombo().addSelectionListener(selectionListener);
}
}
/**
* check the connection is available or not(the connection is exist and not proxy, don't check the
* connection).
*
* @return a ReturnCode, the message is the connection label
*/
private ReturnCode selectedObjectAvailable() {
// $NON-NLS-1$
ReturnCode rc = new ReturnCode("", Boolean.FALSE);
RepositoryNode repoNode = masterPage.getConnComboSelectNode();
rc.setMessage(repoNode.getLabel());
Connection connection = getConnectionFromRepositoryNode(repoNode);
if (connection != null && !connection.eIsProxy()) {
rc.setOk(true);
}
return rc;
}
/**
* DOC xqliu Comment method "getConnectionFromRepositoryNode".
*
* @param repoNode
* @return
*/
private Connection getConnectionFromRepositoryNode(RepositoryNode repoNode) {
Connection connection = null;
IRepositoryViewObject repoViewObject = repoNode.getObject();
if (repoViewObject != null) {
Property property = repoViewObject.getProperty();
if (property != null) {
Item item = property.getItem();
if (item != null && item instanceof ConnectionItem) {
connection = ((ConnectionItem) item).getConnection();
}
}
}
return connection;
}
};
masterPage.getConnCombo().addSelectionListener(selectionListener);
}
} else {
// $NON-NLS-1$
masterPage.getConnCombo().setText("unknown connection");
}
}
use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.
the class AbstractPagePart method updateBindConnection.
/**
* ADD mzhao 2009-05-05 bug:6587. MOD 20130524 TDQ-7327 yyin: even when the indicators is empty, if the tdProvider
* is not null, should also set the connection state
*/
protected void updateBindConnection(AbstractAnalysisMetadataPage masterPage, ModelElementIndicator[] indicators, Tree tree) {
// MOD mzhao 2010-07-24, avoid a NPE, feature 13221
DataManager connection = masterPage.getCurrentModelElement().getContext().getConnection();
Connection tdProvider = null;
if (connection != null) {
tdProvider = SwitchHelpers.CONNECTION_SWITCH.doSwitch(connection);
}
if (indicators != null && indicators.length != 0 && tdProvider == null) {
tdProvider = ModelElementIndicatorHelper.getTdDataProvider(indicators[0]);
}
if (tdProvider != null) {
setConnectionState(masterPage, tdProvider);
}
}
Aggregations