Search in sources :

Example 41 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdq-studio-se by Talend.

the class AnalysisHandler method getColumnSetOwnerNames.

private String[] getColumnSetOwnerNames() {
    List<String> existingTables = new ArrayList<String>();
    for (ModelElement element : getAnalyzedColumns()) {
        if (element instanceof TdColumn && element.eContainer() instanceof Table) {
            String tableName = ColumnHelper.getTableFullName((TdColumn) element);
            if (!existingTables.contains(tableName)) {
                existingTables.add(tableName);
            }
        } else if (element instanceof Table) {
            String tableName = ((Table) element).getName();
            if (!existingTables.contains(tableName)) {
                existingTables.add(tableName);
            }
        } else if (element instanceof MetadataColumn) {
            // the result page
            if (!(element instanceof TdColumn)) {
                // MOD qiongli 2011-1-28,for delimited file
                try {
                    MetadataTable table = ColumnHelper.getColumnOwnerAsMetadataTable((MetadataColumn) element);
                    String tableName = table.getLabel();
                    if (!existingTables.contains(tableName)) {
                        existingTables.add(tableName);
                    }
                } catch (java.lang.NullPointerException e) {
                    // $NON-NLS-1$
                    log.error(Messages.getString("AnalysisHandler.CanNotFindColumnParent", element.getName()), e);
                }
            }
        }
    }
    return existingTables.toArray(new String[existingTables.size()]);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn) Table(orgomg.cwm.resource.relational.Table) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable)

Example 42 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdq-studio-se by Talend.

the class FileDelimitedReader method findElementPositionByColumn.

/**
 * find the position of the analysed elements in the file table's column
 */
private void findElementPositionByColumn(List<ModelElement> analysisElementList) {
    MetadataColumn mColumn = (MetadataColumn) analysisElementList.get(0);
    MetadataTable metadataTable = ColumnHelper.getColumnOwnerAsMetadataTable(mColumn);
    EList<MetadataColumn> columns = metadataTable.getColumns();
    List<String> columnLabels = new ArrayList<String>();
    for (MetadataColumn column : columns) {
        columnLabels.add(column.getLabel());
    }
    for (int j = 0; j < analysisElementList.size(); j++) {
        analysedColumnName[j] = ((MetadataColumn) analysisElementList.get(j)).getLabel();
        analysedColumnIndex[j] = columnLabels.indexOf(analysedColumnName[j]);
    }
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ArrayList(java.util.ArrayList)

Example 43 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdq-studio-se by Talend.

the class DBColumnRepNode method getParentViewObject.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.dq.nodes.DQRepositoryNode#getParentViewObject(org.talend.core.model.repository.IRepositoryViewObject)
     */
@Override
protected IRepositoryViewObject getParentViewObject() {
    IRepositoryViewObject returnViewObject = null;
    MetadataTable columnOwnerAsMetadataTable = ColumnHelper.getColumnOwnerAsMetadataTable(getTdColumn());
    if (columnOwnerAsMetadataTable instanceof TdTable) {
        returnViewObject = new TdTableRepositoryObject(metadataColumnRepositoryObject.getViewObject(), (TdTable) columnOwnerAsMetadataTable);
    } else if (columnOwnerAsMetadataTable instanceof TdView) {
        returnViewObject = new TdViewRepositoryObject(metadataColumnRepositoryObject.getViewObject(), (TdView) columnOwnerAsMetadataTable);
    }
    return returnViewObject;
}
Also used : TdTable(org.talend.cwm.relational.TdTable) TdView(org.talend.cwm.relational.TdView) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject) TdViewRepositoryObject(org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject)

Example 44 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdq-studio-se by Talend.

the class DFConnectionRepNode method createRepositoryNodeSchema.

private List<IRepositoryNode> createRepositoryNodeSchema() {
    super.getChildren().clear();
    IRepositoryViewObject object = this.getObject();
    Set<MetadataTable> tables = ConnectionHelper.getTables(((ConnectionItem) getObject().getProperty().getItem()).getConnection());
    if (tables != null && tables.size() > 0) {
        for (MetadataTable mtable : tables) {
            MetadataTableRepositoryObject mtRepObject = new MetadataTableRepositoryObject(object, mtable);
            mtRepObject.setTableName(mtable.getLabel());
            mtRepObject.setLabel(mtable.getLabel());
            mtRepObject.setId(mtable.getLabel());
            DFTableRepNode tableNode = new DFTableRepNode(mtRepObject, this, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
            tableNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_TABLE);
            tableNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_TABLE);
            mtRepObject.setRepositoryNode(tableNode);
            super.getChildren().add(tableNode);
        }
    }
    return super.getChildren();
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)

Example 45 with MetadataTable

use of org.talend.core.model.metadata.builder.connection.MetadataTable in project tdq-studio-se by Talend.

the class TreeMessageInfoDialog method getLabelProvider.

protected ILabelProvider getLabelProvider() {
    if (labelProvider == null) {
        labelProvider = new LabelProvider() {

            @Override
            public String getText(Object obj) {
                if (obj == null) {
                    // $NON-NLS-1$
                    return "";
                }
                if (obj instanceof ImpactNode) {
                    return ((ImpactNode) obj).toString();
                } else if (obj instanceof IFile) {
                    IFile file = (IFile) obj;
                    ModelElement modelElement = ModelElementFileFactory.getModelElement(file);
                    // MOD msjian TDQ-5909: modify to displayName
                    return modelElement != null ? PropertyHelper.getProperty(modelElement).getDisplayName() : file.getName();
                } else if (obj instanceof RepositoryViewObject) {
                    // Added 20130226 TDQ-6899 show the name for Jrxml object (which has no related ModelElement)
                    return ((IRepositoryViewObject) obj).getLabel();
                } else if (obj instanceof MetadataTable) {
                    // ADD TDQ-7146: for all type's connection table/view node
                    return ((ModelElement) obj).getName();
                }
                Property property = PropertyHelper.getProperty((ModelElement) obj);
                return property == null ? ((ModelElement) obj).getName() : property.getDisplayName();
            }

            @Override
            public Image getImage(Object obj) {
                ModelElement modelElement = null;
                if (obj instanceof ModelElement) {
                    modelElement = (ModelElement) obj;
                } else if (obj instanceof ImpactNode) {
                    modelElement = ((ImpactNode) obj).getNodeElement();
                } else if (obj instanceof IFile) {
                    modelElement = ModelElementFileFactory.getModelElement((IFile) obj);
                } else if (obj instanceof RepositoryViewObject) {
                    // Added 20130226 TDQ-6899 show the name for Jrxml object (which has no related ModelElement)
                    return ImageLib.getImage(ImageLib.JRXML_ICON);
                }
                // ~
                if (modelElement == null) {
                    if (((ImpactNode) obj).getNode() != null) {
                        return ImageLib.getImage(ImageLib.JRXML_ICON);
                    }
                    return super.getImage(obj);
                }
                Image modelElementImage = null;
                String imgName = null;
                if (modelElement instanceof Analysis) {
                    imgName = ImageLib.ANALYSIS_OBJECT;
                } else if (modelElement instanceof TdReport) {
                    imgName = ImageLib.REPORT_OBJECT;
                } else if (modelElement instanceof DatabaseConnection) {
                    imgName = ImageLib.CONNECTION;
                } else if (modelElement instanceof DelimitedFileConnection) {
                    imgName = ImageLib.FILE_DELIMITED;
                } else if (modelElement instanceof Pattern) {
                    imgName = ImageLib.PATTERN_REG;
                } else if (modelElement instanceof IndicatorDefinition) {
                    // IndicatorDefinition
                    if (modelElement instanceof DQRule) {
                        imgName = ImageLib.DQ_RULE;
                    } else if (modelElement instanceof MatchRuleDefinition) {
                        imgName = ImageLib.MATCH_RULE_ICON;
                    } else {
                        imgName = ImageLib.IND_DEFINITION;
                    }
                // TDQ-8550~
                } else if (modelElement instanceof MetadataTable) {
                    imgName = ImageLib.TABLE;
                }
                if (imgName != null) {
                    modelElementImage = ImageLib.getImage(imgName);
                }
                // add lock icon on the image
                if (modelElementImage != null) {
                    if (modelElement != null) {
                        Property property = PropertyHelper.getProperty(modelElement);
                        if (property != null) {
                            Item item = property.getItem();
                            if (item != null) {
                                if (ProxyRepositoryManager.getInstance().isLockByUserOwn(item)) {
                                    modelElementImage = ImageLib.createLockedByOwnIcon(imgName);
                                } else if (ProxyRepositoryManager.getInstance().isLockByOthers(item)) {
                                    modelElementImage = ImageLib.createLockedByOtherIcon(imgName);
                                }
                            }
                        }
                    }
                    return modelElementImage;
                }
                return super.getImage(obj);
            }
        };
    }
    return labelProvider;
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) IFile(org.eclipse.core.resources.IFile) ImpactNode(org.talend.dataprofiler.core.ui.dialog.message.DeleteModelElementConfirmDialog.ImpactNode) TdReport(org.talend.dataquality.reports.TdReport) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) Image(org.eclipse.swt.graphics.Image) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) DQRule(org.talend.dataquality.rules.DQRule) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Item(org.talend.core.model.properties.Item) Analysis(org.talend.dataquality.analysis.Analysis) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) Property(org.talend.core.model.properties.Property) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Aggregations

MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)153 ArrayList (java.util.ArrayList)53 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)51 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)25 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)23 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)22 List (java.util.List)18 Test (org.junit.Test)17 PersistenceException (org.talend.commons.exception.PersistenceException)17 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)15 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)14 TaggedValue (orgomg.cwm.objectmodel.core.TaggedValue)14 Connection (org.talend.core.model.metadata.builder.connection.Connection)12 RepositoryNode (org.talend.repository.model.RepositoryNode)12 ConnectionItem (org.talend.core.model.properties.ConnectionItem)10 TdColumn (org.talend.cwm.relational.TdColumn)9 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)9 IRepositoryNode (org.talend.repository.model.IRepositoryNode)9 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)8 HashMap (java.util.HashMap)7