Search in sources :

Example 26 with DataManager

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;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ArrayList(java.util.ArrayList) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager)

Example 27 with DataManager

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();
}
Also used : DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) Dependency(orgomg.cwm.objectmodel.core.Dependency) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator)

Example 28 with DataManager

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;
}
Also used : DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext)

Example 29 with DataManager

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");
    }
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Connection(org.talend.core.model.metadata.builder.connection.Connection) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 30 with DataManager

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);
    }
}
Also used : Connection(org.talend.core.model.metadata.builder.connection.Connection) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager)

Aggregations

DataManager (orgomg.cwm.foundation.softwaredeployment.DataManager)37 Analysis (org.talend.dataquality.analysis.Analysis)8 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)7 IRepositoryNode (org.talend.repository.model.IRepositoryNode)6 ArrayList (java.util.ArrayList)5 Connection (org.talend.core.model.metadata.builder.connection.Connection)5 TdColumn (org.talend.cwm.relational.TdColumn)4 Indicator (org.talend.dataquality.indicators.Indicator)4 RepositoryNode (org.talend.repository.model.RepositoryNode)4 Dependency (orgomg.cwm.objectmodel.core.Dependency)4 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)4 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)3 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)3 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)3 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)3 SQLException (java.sql.SQLException)2 HashSet (java.util.HashSet)2 List (java.util.List)2 EList (org.eclipse.emf.common.util.EList)2 EObject (org.eclipse.emf.ecore.EObject)2