Search in sources :

Example 21 with DQRepositoryNode

use of org.talend.dq.nodes.DQRepositoryNode 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 22 with DQRepositoryNode

use of org.talend.dq.nodes.DQRepositoryNode in project tdq-studio-se by Talend.

the class AnalysisTableTreeViewer method setInput.

/**
 * DOC xqliu Comment method "setInput".
 *
 * @param objs
 */
@Override
public void setInput(Object[] objs) {
    List<DBTableRepNode> tableNodeList = RepositoryNodeHelper.getTableNodeList(objs);
    List<TableIndicator> tableIndicatorList = new ArrayList<TableIndicator>();
    // MOD by zshen for 2011.06.13 add the support for the view.
    List<DBViewRepNode> viewNodeList = RepositoryNodeHelper.getViewNodeList(objs);
    if (tableNodeList.size() == 0 && viewNodeList.size() == 0) {
        // feature 22206 : fixed another bug, when deselect all, the view is not changed
        this.tableIndicators = tableIndicatorList.toArray(new TableIndicator[tableIndicatorList.size()]);
        this.setElements(tableIndicators);
        return;
    }
    List<RepositoryNode> setList = new ArrayList<RepositoryNode>();
    Connection tdProvider = null;
    for (DBTableRepNode tableNode : tableNodeList) {
        if (tdProvider == null) {
            tdProvider = ConnectionHelper.getTdDataProvider(TableHelper.getParentCatalogOrSchema(tableNode.getTdTable()));
        }
        if (tdProvider == null) {
            MessageUI.openError(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.TableProviderIsNull", // $NON-NLS-1$
            tableNode.getLabel()));
        } else if (this.getAnalysis().getContext().getConnection() != null && !tdProvider.equals(this.getAnalysis().getContext().getConnection())) {
            MessageUI.openError(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.TableDataProviderIsInvalid", // $NON-NLS-1$
            tableNode.getLabel()));
        } else {
            setList.add(tableNode);
        }
    }
    for (DBViewRepNode tableNode : viewNodeList) {
        if (tdProvider == null) {
            tdProvider = ConnectionHelper.getTdDataProvider(TableHelper.getParentCatalogOrSchema(tableNode.getTdView()));
        }
        if (tdProvider == null) {
            MessageUI.openError(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.TableProviderIsNull", // $NON-NLS-1$
            tableNode.getLabel()));
        } else if (this.getAnalysis().getContext().getConnection() != null && !tdProvider.equals(this.getAnalysis().getContext().getConnection())) {
            MessageUI.openError(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.TableDataProviderIsInvalid", // $NON-NLS-1$
            tableNode.getLabel()));
        } else {
            setList.add(tableNode);
        }
    }
    for (TableIndicator tableIndicator : tableIndicators) {
        // ADDED yyin 20120606 TDQ-5343
        NamedColumnSet selectedTable = tableIndicator.getColumnSet();
        DQRepositoryNode tableNode = null;
        if (selectedTable instanceof TdTable) {
            tableNode = RepositoryNodeHelper.recursiveFindTdTable(((TdTable) selectedTable));
        } else if (selectedTable instanceof TdView) {
            tableNode = RepositoryNodeHelper.recursiveFindTdView(((TdView) selectedTable));
        }
        // ~
        if (setList.contains(tableNode)) {
            tableIndicatorList.add(tableIndicator);
            setList.remove(tableNode);
        }
    }
    for (RepositoryNode set : setList) {
        TableIndicator tableIndicator = null;
        if (set instanceof DBViewRepNode) {
            tableIndicator = TableIndicator.createTableIndicatorWithRowCountIndicator(((DBViewRepNode) set).getTdView());
        } else if (set instanceof DBTableRepNode) {
            tableIndicator = TableIndicator.createTableIndicatorWithRowCountIndicator(((DBTableRepNode) set).getTdTable());
        } else {
            continue;
        }
        tableIndicatorList.add(tableIndicator);
    }
    this.tableIndicators = tableIndicatorList.toArray(new TableIndicator[tableIndicatorList.size()]);
    this.setElements(tableIndicators);
}
Also used : TableIndicator(org.talend.dataprofiler.core.model.TableIndicator) TdTable(org.talend.cwm.relational.TdTable) ArrayList(java.util.ArrayList) Connection(org.talend.core.model.metadata.builder.connection.Connection) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) TdView(org.talend.cwm.relational.TdView) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) NamedColumnSet(orgomg.cwm.resource.relational.NamedColumnSet)

Example 23 with DQRepositoryNode

use of org.talend.dq.nodes.DQRepositoryNode in project tdq-studio-se by Talend.

the class OpenItemEditorAction method computeEditorInput.

/**
 * get the ItemEditorInput according to the repNode, if there no ItemEditorInput return null.
 *
 * @param repNode
 * @param isOpenItemEditorAction
 * @return IEditorInput
 * @throws PersistenceException
 */
public IEditorInput computeEditorInput(IRepositoryNode repNode, boolean isOpenItemEditorAction) throws BusinessException {
    // TDQ-12499 msjian add : when click the node under recyclebin, no need to find a EditorInput
    if (repNode != null && !isOpenItemEditorAction) {
        IRepositoryNode currentNode = repNode;
        do {
            RepositoryNode parentNode = currentNode.getParent();
            if (parentNode != null && parentNode instanceof RecycleBinRepNode) {
                return null;
            }
            currentNode = parentNode;
        } while (currentNode != null);
    }
    // TDQ-12499~
    IEditorInput result = null;
    IRepositoryViewObject repViewObj = repNode.getObject();
    if (repViewObj != null) {
        // Connection editor
        String key = repViewObj.getRepositoryObjectType().getKey();
        Item item = repViewObj.getProperty().getItem();
        if (item instanceof TDQItem && !(item instanceof TDQFileItem)) {
            ModelElement modelElement = PropertyHelper.getModelElement(repViewObj.getProperty());
            if (modelElement.eIsProxy() && repNode != null) {
                modelElement = (ModelElement) EObjectHelper.resolveObject(modelElement);
                item = repViewObj.getProperty().getItem();
            }
            if (modelElement == null || modelElement.eResource() == null) {
                throw ExceptionFactory.getInstance().createBusinessException(((TDQItem) item).getFilename());
            }
        }
        if (ERepositoryObjectType.METADATA_CONNECTIONS.getKey().equals(key) || ConnectionUtils.isTcompJdbc(key)) {
            result = new ConnectionItemEditorInput(repNode);
            Connection connection = ((ConnectionItem) item).getConnection();
            if (connection == null || connection.getDataPackage().size() == 0) {
                throw ExceptionFactory.getInstance().createBusinessException(repViewObj);
            }
            editorID = ConnectionEditor.class.getName();
        } else if (ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT.getKey().equals(key)) {
            result = new AnalysisItemEditorInput(repNode);
            Analysis analysis = ((TDQAnalysisItem) item).getAnalysis();
            if (analysis == null || analysis.getContext() == null) {
                throw ExceptionFactory.getInstance().createBusinessException(repViewObj);
            }
            EList<ModelElement> analysedElements = analysis.getContext().getAnalysedElements();
            RepositoryNode connectionRepositoryNode = null;
            if (!analysedElements.isEmpty()) {
                Connection connection = null;
                ModelElement modelElement = analysedElements.get(0);
                if (modelElement instanceof Connection) {
                    connection = (Connection) modelElement;
                } else if (modelElement instanceof Catalog) {
                    Catalog catalog = SwitchHelpers.CATALOG_SWITCH.caseCatalog((Catalog) modelElement);
                    connection = ConnectionHelper.getConnection(catalog);
                } else if (modelElement instanceof Schema) {
                    Schema schema = SwitchHelpers.SCHEMA_SWITCH.caseSchema((Schema) modelElement);
                    if (schema != null) {
                        connection = ConnectionHelper.getConnection(schema);
                    }
                } else if (modelElement instanceof TdTable) {
                    TdTable tdTable = SwitchHelpers.TABLE_SWITCH.caseTdTable((TdTable) modelElement);
                    connection = ConnectionHelper.getConnection(tdTable);
                } else if (modelElement instanceof TdView) {
                    TdView tdView = SwitchHelpers.VIEW_SWITCH.caseTdView((TdView) modelElement);
                    connection = ConnectionHelper.getConnection(tdView);
                } else if (modelElement instanceof TdColumn) {
                    TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.caseTdColumn((TdColumn) modelElement);
                    connection = ConnectionHelper.getConnection(tdColumn);
                } else if (modelElement instanceof MetadataColumn) {
                    MetadataColumn mColumn = SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(modelElement);
                    connection = ConnectionHelper.getTdDataProvider(mColumn);
                }
                connectionRepositoryNode = RepositoryNodeHelper.recursiveFind(connection);
            }
            ((AnalysisItemEditorInput) result).setConnectionNode(connectionRepositoryNode);
            if (analysis.getParameters() != null && analysis.getParameters().getAnalysisType().equals(AnalysisType.MATCH_ANALYSIS)) {
                editorID = MatchAnalysisEditor.class.getName();
            } else {
                editorID = AnalysisEditor.class.getName();
            }
        } else if (ERepositoryObjectType.TDQ_INDICATOR_ELEMENT.getKey().equals(key)) {
            result = new IndicatorDefinitionItemEditorInput(repNode);
            TDQIndicatorDefinitionItem definitionItem = (TDQIndicatorDefinitionItem) item;
            if (definitionItem.getIndicatorDefinition().eResource() == null) {
                throw ExceptionFactory.getInstance().createBusinessException(definitionItem.getFilename());
            }
            if (UDIHelper.getUDICategory(definitionItem.getIndicatorDefinition()) == null) {
                throw ExceptionFactory.getInstance().createBusinessException(definitionItem.getFilename());
            }
            editorID = IndicatorEditor.class.getName();
        } else if (ERepositoryObjectType.TDQ_RULES_SQL.getKey().equals(key) || ERepositoryObjectType.TDQ_RULES_PARSER.getKey().equals(key) || ERepositoryObjectType.TDQ_RULES_MATCHER.getKey().equals(key)) {
            result = new BusinessRuleItemEditorInput(repNode);
            editorID = DQRuleEditor.class.getName();
        } else if (ERepositoryObjectType.TDQ_PATTERN_ELEMENT.getKey().equals(key)) {
            result = new PatternItemEditorInput(repNode);
            TDQPatternItem patternItem = (TDQPatternItem) item;
            if (patternItem.getPattern() == null || patternItem.getPattern().eResource() == null) {
                throw ExceptionFactory.getInstance().createBusinessException(patternItem.getFilename());
            }
            editorID = PatternEditor.class.getName();
        } else if (ERepositoryObjectType.TDQ_REPORT_ELEMENT.getKey().equals(key)) {
            result = new ReportItemEditorInput(repNode);
            TDQReportItem reportItem = (TDQReportItem) item;
            if (!(reportItem.getReport() instanceof TdReport)) {
                throw ExceptionFactory.getInstance().createBusinessException(reportItem.getFilename());
            }
            for (AnalysisMap anaMap : ((TdReport) reportItem.getReport()).getAnalysisMap()) {
                Analysis analysis = anaMap.getAnalysis();
                if (analysis.eResource() == null) {
                    throw ExceptionFactory.getInstance().createBusinessException(reportItem.getFilename());
                }
            }
            // $NON-NLS-1$
            editorID = "org.talend.dataprofiler.core.tdq.ui.editor.report.ReportEditror";
        } else if (ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getKey().equals(key) || ERepositoryObjectType.TDQ_JRAXML_ELEMENT.getKey().equals(key)) {
            IPath append = WorkbenchUtils.getFilePath(repViewObj.getRepositoryNode());
            DQRepositoryNode node = (DQRepositoryNode) repViewObj.getRepositoryNode();
            file = ResourceManager.getRoot().getProject(node.getProject().getTechnicalLabel()).getFile(append);
            if (!file.exists()) {
                throw ExceptionFactory.getInstance().createBusinessException(repViewObj);
            }
            if (ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getKey().equals(key)) {
                editorID = SqlExplorerUtils.SQLEDITOR_ID;
            } else {
                editorID = TDQFileEditorInput.DEFAULT_EDITOR_ID;
            }
            result = new TDQFileEditorInput(file);
            // Added TDQ-7143 yyin 20130531
            ((TDQFileEditorInput) result).setFileItem(item);
            CorePlugin.getDefault().refreshDQView(repNode);
        // ~
        }
        // ADD msjian TDQ-4209 2012-2-7 : return the editorInput of *.jrxml and *.sql files
        if (!isOpenItemEditorAction) {
            if (ERepositoryObjectType.TDQ_JRAXML_ELEMENT.getKey().equals(key) || ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getKey().equals(key)) {
                // if there don't found the correct ItemEditorInput, try to open it as a File
                result = new FileEditorInput(file);
                editorID = FileEditorInput.class.getName();
            }
        }
    // TDQ-4209~
    }
    return result;
}
Also used : TDQFileItem(org.talend.dataquality.properties.TDQFileItem) ConnectionEditor(org.talend.dataprofiler.core.ui.editor.connection.ConnectionEditor) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Schema(orgomg.cwm.resource.relational.Schema) BusinessRuleItemEditorInput(org.talend.dataprofiler.core.ui.editor.dqrules.BusinessRuleItemEditorInput) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) Item(org.talend.core.model.properties.Item) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) TDQItem(org.talend.core.model.properties.TDQItem) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) TDQFileItem(org.talend.dataquality.properties.TDQFileItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) TdView(org.talend.cwm.relational.TdView) AnalysisMap(org.talend.dataquality.reports.AnalysisMap) TDQFileEditorInput(org.talend.dataprofiler.core.ui.editor.TDQFileEditorInput) AnalysisItemEditorInput(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) ReportItemEditorInput(org.talend.dataprofiler.core.ui.editor.report.ReportItemEditorInput) ConnectionItemEditorInput(org.talend.dataprofiler.core.ui.editor.connection.ConnectionItemEditorInput) TdTable(org.talend.cwm.relational.TdTable) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IPath(org.eclipse.core.runtime.IPath) TdReport(org.talend.dataquality.reports.TdReport) Connection(org.talend.core.model.metadata.builder.connection.Connection) PatternItemEditorInput(org.talend.dataprofiler.core.ui.editor.pattern.PatternItemEditorInput) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RecycleBinRepNode(org.talend.dq.nodes.RecycleBinRepNode) Catalog(orgomg.cwm.resource.relational.Catalog) EList(org.eclipse.emf.common.util.EList) TdColumn(org.talend.cwm.relational.TdColumn) PatternEditor(org.talend.dataprofiler.core.ui.editor.pattern.PatternEditor) Analysis(org.talend.dataquality.analysis.Analysis) IndicatorEditor(org.talend.dataprofiler.core.ui.editor.indicator.IndicatorEditor) TDQFileEditorInput(org.talend.dataprofiler.core.ui.editor.TDQFileEditorInput) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TDQItem(org.talend.core.model.properties.TDQItem) IndicatorDefinitionItemEditorInput(org.talend.dataprofiler.core.ui.editor.indicator.IndicatorDefinitionItemEditorInput) IEditorInput(org.eclipse.ui.IEditorInput)

Example 24 with DQRepositoryNode

use of org.talend.dq.nodes.DQRepositoryNode in project tdq-studio-se by Talend.

the class AnalyzeColumnSetAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    PackagesAnalyisParameter packaFilterParameter = new PackagesAnalyisParameter();
    if (nodeColumns != null) {
        DQRepositoryNode tFolder = (DQRepositoryNode) nodeColumns.getParent();
        if (tFolder != null) {
            IRepositoryNode node = tFolder.getParent();
            if (node instanceof DBCatalogRepNode) {
                IRepositoryNode connNode = ((DBCatalogRepNode) node).getParent();
                packaFilterParameter.setConnectionRepNode(connNode);
                catalogs.add(node);
                packaFilterParameter.setPackages(catalogs);
            } else if (node instanceof DBSchemaRepNode) {
                schemaNode = (DBSchemaRepNode) node;
                RepositoryNode parent = schemaNode.getParent();
                if (parent instanceof DBCatalogRepNode) {
                    catalogs.add(parent);
                    packaFilterParameter.setConnectionRepNode(parent);
                } else {
                    catalogs.add(schemaNode);
                    packaFilterParameter.setConnectionRepNode(schemaNode);
                }
                packaFilterParameter.setPackages(catalogs);
            }
        }
    }
    if (needselection) {
        IRepositoryNode firstElement = (RepositoryNode) this.selection.getFirstElement();
        IRepositoryViewObject viewObject = firstElement.getObject();
        Item item = viewObject.getProperty().getItem();
        ConnectionItem connectionItem = (ConnectionItem) item;
        Connection connection = connectionItem.getConnection();
        IRepositoryNode repositoryNode = RepositoryNodeHelper.recursiveFind(connection);
        packaFilterParameter.setConnectionRepNode(repositoryNode);
    }
    if (opencolumnSetAnalysisDialog(packaFilterParameter) == Window.OK) {
        AnalysisEditor editor = (AnalysisEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        if (editor != null) {
            ColumnSetAnalysisDetailsPage page = (ColumnSetAnalysisDetailsPage) editor.getMasterPage();
            if (this.needselection && !this.selection.isEmpty()) {
                IRepositoryNode[] nodeArray = new IRepositoryNode[selection.size()];
                Iterator it = this.selection.iterator();
                int i = 0;
                while (it.hasNext()) {
                    nodeArray[i] = (IRepositoryNode) it.next();
                    i++;
                }
                page.setTreeViewInput(nodeArray);
            } else if (!this.needselection && null != this.nodeColumns) {
                List<IRepositoryNode> column = new ArrayList<IRepositoryNode>();
                for (IRepositoryNode columnFolder : nodeColumns.getChildren()) {
                    if (columnFolder instanceof DBColumnFolderRepNode) {
                        column.addAll(columnFolder.getChildren());
                    }
                }
                page.setTreeViewInput(column.toArray());
            }
            page.doSave(null);
        }
    }
}
Also used : DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Connection(org.talend.core.model.metadata.builder.connection.Connection) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) PackagesAnalyisParameter(org.talend.dq.analysis.parameters.PackagesAnalyisParameter) ColumnSetAnalysisDetailsPage(org.talend.dataprofiler.core.ui.editor.analysis.ColumnSetAnalysisDetailsPage) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor)

Aggregations

DQRepositoryNode (org.talend.dq.nodes.DQRepositoryNode)24 IRepositoryNode (org.talend.repository.model.IRepositoryNode)11 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)8 ArrayList (java.util.ArrayList)7 Project (org.talend.core.model.general.Project)5 IPath (org.eclipse.core.runtime.IPath)4 Connection (org.talend.core.model.metadata.builder.connection.Connection)4 ConnectionItem (org.talend.core.model.properties.ConnectionItem)4 RepositoryNode (org.talend.repository.model.RepositoryNode)4 List (java.util.List)3 IProject (org.eclipse.core.resources.IProject)3 TreeItem (org.eclipse.swt.widgets.TreeItem)3 IEditorInput (org.eclipse.ui.IEditorInput)3 Item (org.talend.core.model.properties.Item)3 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)3 TdTable (org.talend.cwm.relational.TdTable)3 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)3 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)3 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)3 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)3