Search in sources :

Example 41 with MetadataColumnRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject in project tdq-studio-se by Talend.

the class ColumnWizard method composePredefinedColumnIndicator.

protected ModelElementIndicator[] composePredefinedColumnIndicator(IndicatorEnum[] allowedEnum) {
    List<IRepositoryNode> nodes;
    // from the right menu
    if (selectionPage == null) {
        nodes = Arrays.asList(((AnalysisLabelParameter) parameter).getColumnNodes());
    } else {
        // TDQ-11240: get all the column nodes
        nodes = Arrays.asList(RepositoryNodeHelper.getAllColumnNodes(selectionPage.nodes.toArray(new IRepositoryNode[selectionPage.nodes.size()])));
    }
    ModelElementIndicator[] predefinedColumnIndicator = new ModelElementIndicator[nodes.size()];
    for (int i = 0; i < nodes.size(); i++) {
        IRepositoryNode columnNode = nodes.get(i);
        ModelElementIndicator columnIndicator = ModelElementIndicatorHelper.createModelElementIndicator(columnNode);
        for (IndicatorEnum oneEnum : allowedEnum) {
            columnIndicator.addTempIndicatorEnum(oneEnum);
            if (oneEnum.getChildren() != null) {
                for (IndicatorEnum childEnum : oneEnum.getChildren()) {
                    // MOD by zshen:need language to decide DatePatternFrequencyIndicator whether can be choose by
                    // user.
                    IRepositoryViewObject object = columnNode.getObject();
                    ModelElement element = null;
                    if (object instanceof MetadataColumnRepositoryObject) {
                        element = ((MetadataColumnRepositoryObject) object).getTdColumn();
                    } else if (object instanceof MetadataXmlElementTypeRepositoryObject) {
                        element = ((MetadataXmlElementTypeRepositoryObject) object).getModelElement();
                    }
                    if (element != null && ModelElementIndicatorRule.patternRule(childEnum, element, ExecutionLanguage.SQL)) {
                        columnIndicator.addTempIndicatorEnum(childEnum);
                    }
                }
            }
        }
        columnIndicator.storeTempIndicator();
        predefinedColumnIndicator[i] = columnIndicator;
    }
    return predefinedColumnIndicator;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) MetadataXmlElementTypeRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject) AnalysisLabelParameter(org.talend.dq.analysis.parameters.AnalysisLabelParameter) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 42 with MetadataColumnRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject in project tdq-studio-se by Talend.

the class AnalysisSubFolderRepNode method doSwichNode.

/**
 * DOC klliu Comment method "doSwichNode".
 *
 * @param analyzedElement
 * @return
 */
private IRepositoryNode doSwichNode(ModelElement analyzedElement, AnalysisSubFolderRepNode childNodeFolder) {
    Property anaEleProperty = PropertyHelper.getProperty(analyzedElement);
    IRepositoryViewObject medataViewObject = null;
    try {
        medataViewObject = ProxyRepositoryFactory.getInstance().getLastVersion(anaEleProperty.getId());
    } catch (Exception e) {
        log.error(e);
    }
    // }
    if (medataViewObject != null) {
        if (analyzedElement instanceof DatabaseConnection) {
            DBConnectionRepNode connNode = new DBConnectionRepNode(medataViewObject, this, ENodeType.REPOSITORY_ELEMENT, getProject());
            connNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CONNECTIONS);
            connNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CONNECTIONS);
            medataViewObject.setRepositoryNode(connNode);
            return connNode;
        } else if (analyzedElement instanceof Catalog) {
            RepositoryNode catalogNode = DQRepNodeCreateFactory.createDBCatalogRepNode(new MetadataCatalogRepositoryObject(medataViewObject, (Catalog) analyzedElement), this, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
            catalogNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_CATALOG);
            catalogNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_CATALOG);
            medataViewObject.setRepositoryNode(catalogNode);
            return catalogNode;
        } else if (analyzedElement instanceof Schema) {
            RepositoryNode schemaNode = new DBSchemaRepNode(new MetadataSchemaRepositoryObject(medataViewObject, (Schema) analyzedElement), this, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
            schemaNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_SCHEMA);
            schemaNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_SCHEMA);
            medataViewObject.setRepositoryNode(schemaNode);
            return schemaNode;
        } else if (analyzedElement instanceof TdTable) {
            DBTableRepNode tableNode = new DBTableRepNode(new TdTableRepositoryObject(medataViewObject, (TdTable) analyzedElement), childNodeFolder, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
            tableNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_TABLE);
            tableNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_TABLE);
            medataViewObject.setRepositoryNode(tableNode);
            return tableNode;
        } else if (analyzedElement instanceof TdView) {
            DBViewRepNode viewNode = new DBViewRepNode(new TdViewRepositoryObject(medataViewObject, (TdView) analyzedElement), childNodeFolder, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
            viewNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_VIEW);
            viewNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_VIEW);
            medataViewObject.setRepositoryNode(viewNode);
            return viewNode;
        } else if (analyzedElement instanceof MetadataColumn) {
            RepositoryNode columnNode = null;
            if (analyzedElement instanceof TdColumn) {
                columnNode = new DBColumnRepNode(new MetadataColumnRepositoryObject(medataViewObject, (MetadataColumn) analyzedElement), childNodeFolder, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
            } else {
                columnNode = new DFColumnRepNode(new MetadataColumnRepositoryObject(medataViewObject, (MetadataColumn) analyzedElement), this, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
            }
            columnNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_COLUMN);
            columnNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_COLUMN);
            medataViewObject.setRepositoryNode(columnNode);
            return columnNode;
        }
    }
    return null;
}
Also used : TdTable(org.talend.cwm.relational.TdTable) Schema(orgomg.cwm.resource.relational.Schema) MetadataCatalogRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataCatalogRepositoryObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TdViewRepositoryObject(org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject) Catalog(orgomg.cwm.resource.relational.Catalog) MetadataSchemaRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataSchemaRepositoryObject) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn) TdView(org.talend.cwm.relational.TdView) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject) Property(org.talend.core.model.properties.Property)

Example 43 with MetadataColumnRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject in project tdq-studio-se by Talend.

the class DBColumnFolderRepNode method createTdcolumnsNode.

/**
 * DOC klliu Comment method "createTdcolumnsNode".
 *
 * @param tdcolumns
 * @param repsNodes
 */
private void createTdcolumnsNode(List<TdColumn> tdcolumns, List<IRepositoryNode> repsNodes) {
    if (tdcolumns != null) {
        for (MetadataColumn tdColumn : tdcolumns) {
            MetadataColumnRepositoryObject metadataColumn = new MetadataColumnRepositoryObject(this.getParent().getObject(), tdColumn);
            metadataColumn.setId(tdColumn.getName());
            metadataColumn.setLabel(tdColumn.getName());
            DBColumnRepNode columnNode = new DBColumnRepNode(metadataColumn, this, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
            columnNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_COLUMN);
            columnNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_COLUMN);
            metadataColumn.setRepositoryNode(columnNode);
            repsNodes.add(columnNode);
        }
    }
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)

Example 44 with MetadataColumnRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject in project tdq-studio-se by Talend.

the class CreateDateAnalysisAction method isAllowed.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.action.AbstractPredefinedAnalysisAction#isAllowed()
     */
@Override
protected boolean isAllowed() {
    for (IRepositoryNode repositoryNode : getColumns()) {
        MetadataColumn column = ((MetadataColumnRepositoryObject) repositoryNode.getObject()).getTdColumn();
        int javaSQLType = TalendTypeConvert.convertToJDBCType(column.getTalendType());
        if (!Java2SqlType.isDateInSQL(javaSQLType)) {
            return false;
        }
    }
    if (!RepNodeUtils.isValidSelectionFromSameTable(getSelection().toList())) {
        return false;
    }
    return true;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IRepositoryNode(org.talend.repository.model.IRepositoryNode) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)

Example 45 with MetadataColumnRepositoryObject

use of org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject in project tdq-studio-se by Talend.

the class CreateDiscreteAnalysis method init.

@Override
public void init(ICommonActionExtensionSite site) {
    if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) {
        StructuredSelection selection = (StructuredSelection) site.getStructuredViewer().getSelection();
        Object fe = selection.getFirstElement();
        if (fe instanceof IRepositoryNode) {
            IRepositoryViewObject object = ((IRepositoryNode) fe).getObject();
            if (object instanceof MetadataColumnRepositoryObject) {
                MetadataColumnRepositoryObject columnObject = (MetadataColumnRepositoryObject) object;
                modelElement = columnObject.getTdColumn();
            }
        }
    }
    super.init(site);
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) ICommonViewerWorkbenchSite(org.eclipse.ui.navigator.ICommonViewerWorkbenchSite)

Aggregations

MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)46 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)30 IRepositoryNode (org.talend.repository.model.IRepositoryNode)27 RepositoryNode (org.talend.repository.model.RepositoryNode)14 TdColumn (org.talend.cwm.relational.TdColumn)13 ArrayList (java.util.ArrayList)10 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)10 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)9 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)9 Connection (org.talend.core.model.metadata.builder.connection.Connection)8 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)7 TdTable (org.talend.cwm.relational.TdTable)7 List (java.util.List)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 ICommonViewerWorkbenchSite (org.eclipse.ui.navigator.ICommonViewerWorkbenchSite)5 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)5 ReturnCode (org.talend.utils.sugars.ReturnCode)5 Test (org.junit.Test)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)3