Search in sources :

Example 21 with DBColumnRepNode

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

the class ColumnViewerDND method installDND.

/**
 * DOC xqliu Comment method "installDND". bug 8791 2009-08-31.
 *
 * @param myTable
 */
public static void installDND(final Table targetControl) {
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    DQRespositoryView findView = (DQRespositoryView) activePage.findView(DQRespositoryView.ID);
    final CommonViewer commonViewer = findView.getCommonViewer();
    final LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
    int operations = DND.DROP_COPY | DND.DROP_MOVE;
    Transfer[] transfers = new Transfer[] { transfer };
    DropTarget dropTarget = new DropTarget(targetControl, operations);
    dropTarget.setTransfer(transfers);
    DropTargetListener dndListener = new TableDropTargetEffect(targetControl) {

        ISelectionReceiver receiver = null;

        @Override
        public void dragEnter(DropTargetEvent event) {
            super.dragEnter(event);
            IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
            Object object = selection.getFirstElement();
            // MOD klliu 2011-03-08 bug 19286
            if (object instanceof DBColumnRepNode) {
                receiver = new ColumnReceiverTable();
            }
            if (receiver == null) {
                event.detail = DND.DROP_NONE;
            } else {
                event.feedback = DND.FEEDBACK_EXPAND;
                receiver.doDropValidation(event, commonViewer);
            }
        }

        @Override
        public void dragOver(DropTargetEvent event) {
            if (receiver == null) {
                return;
            }
            super.dragOver(event);
            receiver.doDropValidation(event, commonViewer);
        }

        @Override
        public void drop(DropTargetEvent event) {
            if (receiver == null) {
                return;
            }
            int index = targetControl.getItemCount();
            super.drop(event);
            if (event.item == null) {
                index = -1;
            } else {
                // Widget widget = event.widget;
                // Object data = event.data;
                TableItem item = (TableItem) event.item;
                TableItem[] items = targetControl.getItems();
                for (int i = 0; i < items.length; i++) {
                    if (items[i] == item) {
                        index = i;
                        break;
                    }
                }
            }
            receiver.drop(event, commonViewer, index);
        }
    };
    dropTarget.addDropListener(dndListener);
}
Also used : CommonViewer(org.eclipse.ui.navigator.CommonViewer) TableItem(org.eclipse.swt.widgets.TableItem) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DropTarget(org.eclipse.swt.dnd.DropTarget) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) TableDropTargetEffect(org.eclipse.swt.dnd.TableDropTargetEffect)

Example 22 with DBColumnRepNode

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

the class DQRepositoryViewLabelProvider method getImage.

@Override
public Image getImage(Object element) {
    Image image = super.getImage(element);
    if (element instanceof IRepositoryNode) {
        IRepositoryNode node = (IRepositoryNode) element;
        if (node instanceof ReportAnalysisRepNode) {
            image = ImageLib.getImage(ImageLib.ANALYSIS_OBJECT);
        } else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
            image = ImageLib.getImage(ImageLib.EXCHANGE);
        } else if (node instanceof RecycleBinRepNode) {
            image = ImageLib.getImage(ImageLib.RECYCLEBIN_EMPTY);
        } else {
            IRepositoryViewObject viewObject = node.getObject();
            ENodeType type = node.getType();
            if (type.equals(ENodeType.SYSTEM_FOLDER)) {
                if (EResourceConstant.REFERENCED_PROJECT.getName().equals(node.getProperties(EProperties.LABEL))) {
                    image = ImageLib.getImage(ImageLib.REFERENCED_PROJECT);
                } else {
                    String label = viewObject.getLabel();
                    if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
                        image = ImageLib.getImage(ImageLib.DATA_PROFILING);
                    } else if (label.equals(EResourceConstant.METADATA.getName())) {
                        image = ImageLib.getImage(ImageLib.METADATA);
                    } else if (node instanceof DBConnectionFolderRepNode) {
                        image = ImageLib.getImage(ImageLib.CONNECTION);
                    } else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
                        image = ImageLib.getImage(ImageLib.FILE_DELIMITED);
                    } else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
                        image = ImageLib.getImage(ImageLib.LIBRARIES);
                    } else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
                        image = ImageLib.getImage(ImageLib.EXCHANGE);
                    } else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
                        image = ImageLib.getImage(ImageLib.HADOOP_CLUSTER);
                    } else if (label.equals(EResourceConstant.CONTEXT.getName())) {
                        image = ImageLib.getImage(ImageLib.CONTEXT);
                    } else {
                        image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                    }
                }
            } else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
                image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
            } else if (type.equals(ENodeType.REFERENCED_PROJECT)) {
                image = ImageLib.getImage(ImageLib.REFERENCED_PROJECT);
            } else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
                // TDQ-7560 when the image is a overlay image,use originalImageName to get the corresponding one.
                String originalImageName = null;
                if (node instanceof DBConnectionRepNode) {
                    originalImageName = ImageLib.TD_DATAPROVIDER;
                    if (!RepositoryNodeHelper.isSupportedConnection(node) || isNeedAddDriverConnection(node)) {
                        image = ImageLib.createErrorIcon(originalImageName);
                    } else if (isInvalidJDBCConnection(node)) {
                        image = ImageLib.createInvalidIcon(originalImageName);
                    } else {
                        image = ImageLib.getImage(originalImageName);
                    }
                } else if (node instanceof DFConnectionRepNode) {
                    originalImageName = ImageLib.FILE_DELIMITED;
                } else if (node instanceof AnalysisRepNode) {
                    originalImageName = ImageLib.ANALYSIS_OBJECT;
                    image = addWarnIconIfNeeded(node, originalImageName);
                } else if (node instanceof ReportRepNode) {
                    originalImageName = ImageLib.REPORT_OBJECT;
                    image = addWarnIconIfNeeded(node, originalImageName);
                } else if (node instanceof SysIndicatorDefinitionRepNode) {
                    originalImageName = ImageLib.IND_DEFINITION;
                } else if (node instanceof PatternRepNode) {
                    originalImageName = ImageLib.PATTERN_REG;
                } else if (node instanceof RuleRepNode) {
                    if (((RuleRepNode) node).getRule() instanceof MatchRuleDefinition) {
                        originalImageName = ImageLib.MATCH_RULE_ICON;
                    } else {
                        originalImageName = ImageLib.DQ_RULE;
                    }
                } else if (node instanceof SourceFileRepNode) {
                    originalImageName = ImageLib.SOURCE_FILE;
                } else if (node instanceof HadoopClusterConnectionRepNode) {
                    originalImageName = ImageLib.HADOOP_CLUSTER;
                } else if (node instanceof HDFSOfHCConnectionNode) {
                    originalImageName = ImageLib.HDFS;
                } else if (node instanceof HiveOfHCConnectionNode) {
                    originalImageName = ImageLib.HIVE_LINK;
                } else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
                    originalImageName = ImageLib.EXCHANGE;
                } else if (node instanceof ContextRepNode) {
                    originalImageName = ImageLib.CONTEXT;
                } else if (node instanceof RepositoryNode) {
                    // MOD qiongli 2011-1-18 get image for nodes in recycle bin
                    Image imageNode = getImageByContentType((RepositoryNode) node);
                    if (image != null) {
                        image = imageNode;
                    }
                }
                if (originalImageName != null && !(node instanceof DBConnectionRepNode || node instanceof AnalysisRepNode || node instanceof ReportRepNode)) {
                    image = ImageLib.getImage(originalImageName);
                }
                // exchange folder did not contain viewObject.
                if (viewObject != null) {
                    // MOD yyi 2011-04-07 19696: "Lock element"
                    ERepositoryStatus status = ProxyRepositoryFactory.getInstance().getStatus(viewObject);
                    Context ctx = CoreRuntimePlugin.getInstance().getContext();
                    RepositoryContext rc = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
                    // will be enhanced later by TDI-29265.
                    if (rc.isEditableAsReadOnly()) {
                        if (status == ERepositoryStatus.LOCK_BY_USER) {
                            status = ERepositoryStatus.DEFAULT;
                        }
                    }
                    if (ERepositoryStatus.DEFAULT != status && originalImageName != null) {
                        if (ERepositoryStatus.LOCK_BY_USER == status) {
                            image = ImageLib.createLockedByOwnIcon(originalImageName);
                        } else if (ERepositoryStatus.LOCK_BY_OTHER == status) {
                            image = ImageLib.createLockedByOtherIcon(originalImageName);
                        }
                    }
                }
            } else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
                if (node instanceof DBCatalogRepNode) {
                    image = ImageLib.getImage(ImageLib.CATALOG);
                } else if (node instanceof DBSchemaRepNode) {
                    image = ImageLib.getImage(ImageLib.SCHEMA);
                } else if (node instanceof DBTableFolderRepNode) {
                    image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                } else if (node instanceof DBViewFolderRepNode) {
                    image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                } else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
                    image = ImageLib.getImage(ImageLib.TABLE);
                } else if (node instanceof DBViewRepNode) {
                    image = ImageLib.getImage(ImageLib.VIEW);
                } else if (node instanceof DBColumnRepNode) {
                    if (((DBColumnRepNode) node).isKey()) {
                        image = ImageLib.getImage(ImageLib.PK_COLUMN);
                    } else {
                        image = ImageLib.getImage(ImageLib.TD_COLUMN);
                    }
                } else if (node instanceof DFColumnRepNode) {
                    image = ImageLib.getImage(ImageLib.TD_COLUMN);
                } else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
                    image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                } else if (node instanceof JrxmlTempleteRepNode) {
                    image = ImageLib.getImage(ImageLib.JRXML_ICON);
                }
            }
        }
    }
    return image;
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) RepositoryContext(org.talend.core.context.RepositoryContext) HDFSOfHCConnectionNode(org.talend.dq.nodes.hadoopcluster.HDFSOfHCConnectionNode) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) Image(org.eclipse.swt.graphics.Image) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) DBViewFolderRepNode(org.talend.dq.nodes.DBViewFolderRepNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ReportRepNode(org.talend.dq.nodes.ReportRepNode) ExchangeComponentRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PatternRepNode(org.talend.dq.nodes.PatternRepNode) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) Context(org.talend.core.context.Context) RepositoryContext(org.talend.core.context.RepositoryContext) DBTableFolderRepNode(org.talend.dq.nodes.DBTableFolderRepNode) DFColumnFolderRepNode(org.talend.dq.nodes.DFColumnFolderRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) HiveOfHCConnectionNode(org.talend.dq.nodes.hadoopcluster.HiveOfHCConnectionNode) RuleRepNode(org.talend.dq.nodes.RuleRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) JrxmlTempleteRepNode(org.talend.dq.nodes.JrxmlTempleteRepNode) RecycleBinRepNode(org.talend.dq.nodes.RecycleBinRepNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) ExchangeCategoryRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) HadoopClusterConnectionRepNode(org.talend.dq.nodes.hadoopcluster.HadoopClusterConnectionRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) ContextRepNode(org.talend.dq.nodes.ContextRepNode)

Example 23 with DBColumnRepNode

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

the class RepNodeUtils method translateSelectedToStandardReposityoryNode.

public static List<IRepositoryNode> translateSelectedToStandardReposityoryNode(Object[] objs) {
    List<IRepositoryNode> reposList = new ArrayList<IRepositoryNode>();
    for (Object obj : objs) {
        // MOD klliu 2011-02-16 feature 15387
        if (obj instanceof DBColumnRepNode || obj instanceof DFColumnRepNode) {
            reposList.add((RepositoryNode) obj);
        } else if (obj instanceof DBTableRepNode || obj instanceof DBViewRepNode || obj instanceof DFTableRepNode) {
            List<IRepositoryNode> children = ((IRepositoryNode) obj).getChildren().get(0).getChildren();
            reposList.addAll(children);
        } else if (obj instanceof MetadataColumn) {
            // MOD qiongli TDQ-7052 if the node is filtered ,it will be return null,so should create a new node.
            RepositoryNode repNode = RepositoryNodeHelper.recursiveFind((ModelElement) obj);
            if (repNode == null) {
                repNode = RepositoryNodeHelper.createRepositoryNode((ModelElement) obj);
            }
            reposList.add(repNode);
        }
    }
    return reposList;
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode)

Example 24 with DBColumnRepNode

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

the class RespositoryDetailView method selectionChanged.

/*
     * (non-Javadoc)
     * 
     * @seeorg.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui. IWorkbenchPart,
     * org.eclipse.jface.viewers.ISelection)
     */
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    clearContainer();
    boolean isNeedcreateDefault = true;
    try {
        if (part instanceof DQRespositoryView) {
            StructuredSelection sel = (StructuredSelection) selection;
            // MOD by zshen for bug 15750 TODO 39(13) make Detail View can be used.
            Object fe = sel.getFirstElement();
            // MOD klliu 2011-02-24 if choose diffirent node ,that will load diffirent child ,so that not use up.
            if (fe instanceof AnalysisRepNode || fe instanceof ReportRepNode || fe instanceof SysIndicatorDefinitionRepNode || fe instanceof PatternRepNode || fe instanceof RuleRepNode) {
                fe = ((IRepositoryNode) fe).getObject();
            }
            if (fe instanceof IFile) {
                IFile fe2 = (IFile) fe;
                isNeedcreateDefault = createFileDetail(isNeedcreateDefault, fe2);
            } else if (fe instanceof IRepositoryViewObject) {
                isNeedcreateDefault = createFileDetail(isNeedcreateDefault, (IRepositoryViewObject) fe);
            } else if (fe instanceof DBConnectionRepNode) {
                DBConnectionRepNode connNode = (DBConnectionRepNode) fe;
                // MOD sizhaoliu TDQ-6316
                ConnectionItem connectionItem = (ConnectionItem) connNode.getObject().getProperty().getItem();
                createDataProviderDetail(connectionItem);
                isNeedcreateDefault = false;
            } else if (fe instanceof DBCatalogRepNode) {
                DBCatalogRepNode catalogNode = (DBCatalogRepNode) fe;
                Catalog catalog = catalogNode.getCatalog();
                createTdCatalogDetail(catalog);
                isNeedcreateDefault = false;
            } else if (fe instanceof DBSchemaRepNode) {
                DBSchemaRepNode schemaNode = (DBSchemaRepNode) fe;
                Schema schema = schemaNode.getSchema();
                createTdSchemaDetail(schema);
                isNeedcreateDefault = false;
            } else if (fe instanceof DBTableRepNode) {
                DBTableRepNode tableNode = (DBTableRepNode) fe;
                // MOD gdbu 2011-9-14 TDQ-3243
                if (!DQRepositoryNode.isOnFilterring()) {
                    tableNode.getChildren().get(0).getChildren();
                }
                // ~TDQ-3243
                TdTable tdTable = tableNode.getTdTable();
                createTableDetail(tdTable);
                isNeedcreateDefault = false;
            } else if (fe instanceof DBViewRepNode) {
                DBViewRepNode viewNode = (DBViewRepNode) fe;
                // MOD gdbu 2011-9-14 TDQ-3243
                if (!DQRepositoryNode.isOnFilterring()) {
                    viewNode.getChildren().get(0).getChildren();
                }
                // ~TDQ-3243
                createNameCommentDetail(viewNode.getTdView());
                isNeedcreateDefault = false;
            } else if (fe instanceof DBColumnRepNode) {
                DBColumnRepNode columnNode = (DBColumnRepNode) fe;
                TdColumn column = columnNode.getTdColumn();
                createTdColumn(column);
                isNeedcreateDefault = false;
            } else if (fe instanceof IEcosComponent) {
                IEcosComponent component = (IEcosComponent) fe;
                createEcosComponent(component);
                isNeedcreateDefault = false;
            } else if (fe instanceof RegularExpression) {
                // MOD mzhao 2009-04-20,Bug 6349.
                RegularExpression regularExpression = (RegularExpression) fe;
                createRegularExpression(regularExpression);
                isNeedcreateDefault = false;
            } else if (fe instanceof PatternLanguageRepNode) {
                // MOD mzhao 2012-08-15,feature TDQ-4037.
                PatternLanguageRepNode pattLangNode = (PatternLanguageRepNode) fe;
                createRegularExpression(pattLangNode.getRegularExpression());
                isNeedcreateDefault = false;
            } else if (fe instanceof SourceFileRepNode) {
                // MOD klliu 2001-02-28 bug 19154
                IPath filePath = WorkbenchUtils.getFilePath((SourceFileRepNode) fe);
                DQRepositoryNode node = (DQRepositoryNode) fe;
                IFile file = ResourceManager.getRoot().getProject(node.getProject().getTechnicalLabel()).getFile(filePath);
                createSqlFileDetail(file);
            } else if (fe instanceof ExchangeComponentRepNode) {
                // MOD klliu 2001-02-28 bug 19154
                IEcosComponent ecosComponent = ((ExchangeComponentRepNode) fe).getEcosComponent();
                IEcosComponent component = ecosComponent;
                createEcosComponent(component);
                isNeedcreateDefault = false;
            // ADD by msjian 2011-5-12 21186: don't check whether the selected object is "MDMConnectionRepNode"
            } else if (fe instanceof DFConnectionRepNode) {
                DFConnectionRepNode dfNode = (DFConnectionRepNode) fe;
                DelimitedFileConnection dfConnection = dfNode.getDfConnection();
                createDFconnectionName(dfNode.getObject().getLabel());
                createDataProviderDetail(dfConnection);
                isNeedcreateDefault = false;
            }
            if (PluginChecker.isTDQLoaded()) {
                if (fe instanceof EObject) {
                    createTechnicalDetail((EObject) fe);
                } else if (fe instanceof IFile) {
                    createTechnicalDetail((IFile) fe);
                } else if (fe instanceof IRepositoryViewObject) {
                    createTechnicalDetail((IRepositoryViewObject) fe);
                } else {
                    createExtDefault();
                }
            }
            if (!scomp.isDisposed()) {
                scomp.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
                composite.layout();
            }
        } else if (part instanceof CommonFormEditor) {
            CommonFormEditor editor = (CommonFormEditor) part;
            IEditorInput editorInput = editor.getEditorInput();
            if (editorInput instanceof IFileEditorInput) {
                IFileEditorInput input = (IFileEditorInput) editorInput;
                IFile file = input.getFile();
                isNeedcreateDefault = createFileDetail(isNeedcreateDefault, file);
            }
        }
        if (isNeedcreateDefault) {
            createDefault();
        }
        // feature 19053
        if (!gContainer.isDisposed()) {
            gContainer.layout();
            if (tContainer != null) {
                tContainer.layout();
            }
        }
    } catch (MissingDriverException e) {
        if (PluginChecker.isOnlyTopLoaded()) {
            MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), // $NON-NLS-1$
            DefaultMessagesImpl.getString("RespositoryDetailView.warning"), e.getErrorMessage());
        } else {
            log.error(e, e);
        }
    }
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) IFile(org.eclipse.core.resources.IFile) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Schema(orgomg.cwm.resource.relational.Schema) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) PatternLanguageRepNode(org.talend.dq.nodes.PatternLanguageRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ReportRepNode(org.talend.dq.nodes.ReportRepNode) ExchangeComponentRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode) IFileEditorInput(org.eclipse.ui.IFileEditorInput) EObject(org.eclipse.emf.ecore.EObject) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PatternRepNode(org.talend.dq.nodes.PatternRepNode) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) TdTable(org.talend.cwm.relational.TdTable) IPath(org.eclipse.core.runtime.IPath) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) RuleRepNode(org.talend.dq.nodes.RuleRepNode) Catalog(orgomg.cwm.resource.relational.Catalog) CommonFormEditor(org.talend.dataprofiler.core.ui.editor.CommonFormEditor) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) MissingDriverException(org.talend.utils.exceptions.MissingDriverException) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) TdColumn(org.talend.cwm.relational.TdColumn) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IEcosComponent(org.talend.dataprofiler.ecos.model.IEcosComponent) EObject(org.eclipse.emf.ecore.EObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IEditorInput(org.eclipse.ui.IEditorInput)

Example 25 with DBColumnRepNode

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

the class RepositoryNodeHelperRealTest method testCreateMssqlRepositoryNode.

/**
 * Test method for
 * {@link org.talend.dq.helper.RepositoryNodeHelper#createRepositoryNode(orgomg.cwm.objectmodel.core.ModelElement)}.
 * mssql case
 */
@Test
public void testCreateMssqlRepositoryNode() {
    // $NON-NLS-1$
    DatabaseConnectionItem createConnectionItem = createDataBaseConnection("conn1", null, false);
    // $NON-NLS-1$
    Catalog addCatalog = this.addCatalog(createConnectionItem.getConnection(), "catalog1");
    // $NON-NLS-1$
    Schema addSchema = this.addSchema(addCatalog, "schema1");
    // $NON-NLS-1$
    TdTable addTable = this.addTable(addSchema, "table1");
    // $NON-NLS-1$
    TdColumn addColumn = this.addColumn(addTable, "column1");
    try {
        ProxyRepositoryFactory.getInstance().save(createConnectionItem, null);
    } catch (PersistenceException e) {
        log.error(e, e);
        Assert.fail(e.getMessage());
    }
    RepositoryNode createRepositoryNode = RepositoryNodeHelper.createRepositoryNode(addColumn);
    if (createRepositoryNode != null) {
        IRepositoryViewObject object = createRepositoryNode.getObject();
        Assert.assertTrue(createRepositoryNode instanceof DBColumnRepNode);
        Assert.assertTrue(object != null);
        Assert.assertTrue(object instanceof MetadataColumnRepositoryObject);
        Assert.assertTrue(object.getId().equals(addColumn.getName()));
        Assert.assertTrue(object.getLabel().equals(addColumn.getName()));
        Assert.assertTrue(object.getRepositoryNode() != null);
        Assert.assertTrue(createRepositoryNode.getProperties(EProperties.LABEL).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
        Assert.assertTrue(createRepositoryNode.getProperties(EProperties.CONTENT_TYPE).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
        Assert.assertTrue(createRepositoryNode.getParent().getParent().getParent().getParent().getParent().getParent() != null);
    }
}
Also used : TdTable(org.talend.cwm.relational.TdTable) TdColumn(org.talend.cwm.relational.TdColumn) Schema(orgomg.cwm.resource.relational.Schema) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Catalog(orgomg.cwm.resource.relational.Catalog) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) Test(org.junit.Test)

Aggregations

DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)31 IRepositoryNode (org.talend.repository.model.IRepositoryNode)15 TdColumn (org.talend.cwm.relational.TdColumn)14 RepositoryNode (org.talend.repository.model.RepositoryNode)13 ArrayList (java.util.ArrayList)12 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)12 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)9 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)9 TdTable (org.talend.cwm.relational.TdTable)7 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)7 List (java.util.List)6 DFColumnRepNode (org.talend.dq.nodes.DFColumnRepNode)6 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)5 LocalSelectionTransfer (org.eclipse.jface.util.LocalSelectionTransfer)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 DropTarget (org.eclipse.swt.dnd.DropTarget)4 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)4 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)4 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)4 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)4