Search in sources :

Example 71 with TdColumn

use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.

the class TableViewComparisonLevel method getLeftResource.

@Override
protected Resource getLeftResource() throws ReloadCompareException {
    ColumnSet selectedColumnSet = null;
    if (selectedObj instanceof DBColumnFolderRepNode) {
        DBColumnFolderRepNode columnFolderRepNode = (DBColumnFolderRepNode) selectedObj;
        selectedColumnSet = columnFolderRepNode.getColumnSet();
    } else if (selectedObj instanceof RepositoryNode) {
        selectedColumnSet = (ColumnSet) RepositoryNodeHelper.getMetadataElement((RepositoryNode) selectedObj);
    } else {
        selectedColumnSet = (ColumnSet) selectedObj;
    }
    ColumnSet findMatchedColumnSet = DQStructureComparer.findMatchedColumnSet(selectedColumnSet, copyedDataProvider);
    List<TdColumn> columnList = new ArrayList<TdColumn>();
    columnList.addAll(ColumnSetHelper.getColumns(findMatchedColumnSet));
    Resource leftResource = copyedDataProvider.eResource();
    leftResource.getContents().clear();
    for (TdColumn column : columnList) {
        DQStructureComparer.clearSubNode(column);
        leftResource.getContents().add(column);
    }
    EMFSharedResources.getInstance().saveResource(leftResource);
    return upperCaseResource(leftResource);
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) ArrayList(java.util.ArrayList) Resource(org.eclipse.emf.ecore.resource.Resource) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) RepositoryNode(org.talend.repository.model.RepositoryNode) DQDBFolderRepositoryNode(org.talend.dq.nodes.DQDBFolderRepositoryNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode)

Example 72 with TdColumn

use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.

the class RemoveTdRelationalSwitch method casePrimaryKey.

@Override
public Boolean casePrimaryKey(PrimaryKey object) {
    ColumnSet columnSet = (ColumnSet) object.eContainer();
    if (columnSet == null) {
        return Boolean.FALSE;
    }
    // MOD zshen 2010.06.10 for feature 12842
    TdColumn column = null;
    if (leftElement instanceof TdColumn) {
        column = (TdColumn) leftElement;
    } else {
        return Boolean.FALSE;
    }
    if (object.getFeature().size() <= 1) {
        columnSet.getOwnedElement().remove(object);
    } else {
        object.getFeature().remove(column);
    }
    column.getUniqueKey().remove(object);
    return Boolean.TRUE;
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) ColumnSet(orgomg.cwm.resource.relational.ColumnSet)

Example 73 with TdColumn

use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.

the class RemoveTdRelationalSwitch method caseForeignKey.

@Override
public Boolean caseForeignKey(ForeignKey object) {
    ColumnSet columnSet = (ColumnSet) object.eContainer();
    if (columnSet == null) {
        return Boolean.FALSE;
    }
    // MOD zshen 2010.06.10 for feature 12842
    TdColumn column = null;
    if (leftElement instanceof TdColumn) {
        column = (TdColumn) leftElement;
    } else {
        return Boolean.FALSE;
    }
    if (object.getFeature().size() <= 1) {
        columnSet.getOwnedElement().remove(object);
    } else {
        object.getFeature().remove(column);
    }
    column.getKeyRelationship().remove(object);
    return Boolean.TRUE;
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) ColumnSet(orgomg.cwm.resource.relational.ColumnSet)

Example 74 with TdColumn

use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.

the class ColumnDependencyExplorer method getDetailedInvalidValuesStatement.

private String getDetailedInvalidValuesStatement() {
    // MOD by zshen fixed 12039 to distinguish the same name of column.
    String genericSQL = dbmsLanguage.getFDGenericInvalidDetailedValues();
    ColumnDependencyIndicator cdIndicator = ((ColumnDependencyIndicator) this.indicator);
    TdColumn columnA = cdIndicator.getColumnA();
    TdColumn columnB = cdIndicator.getColumnB();
    if (columnA.getName().equals(columnB.getName())) {
        genericSQL = genericSQL.replaceFirst(GenericSQLHandler.COLUMN_NAMES_A, // $NON-NLS-1$
        dbmsLanguage.quote(columnA.getName()) + " AS " + columnA.getName() + // $NON-NLS-1$
        "_A");
        genericSQL = genericSQL.replaceFirst(GenericSQLHandler.COLUMN_NAMES_B, // $NON-NLS-1$
        dbmsLanguage.quote(columnB.getName()) + " AS " + columnA.getName() + // $NON-NLS-1$
        "_B");
    }
    return getStatement(genericSQL);
}
Also used : ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator) TdColumn(org.talend.cwm.relational.TdColumn)

Example 75 with TdColumn

use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.

the class ColumnDependencyExplorer method getDetailedValidValuesStatement.

private String getDetailedValidValuesStatement() {
    // MOD by zshen fixed 12039 to distinguish the same name of column.
    String genericSQL = dbmsLanguage.getFDGenericValidDetailedValues();
    ColumnDependencyIndicator cdIndicator = ((ColumnDependencyIndicator) this.indicator);
    TdColumn columnA = cdIndicator.getColumnA();
    TdColumn columnB = cdIndicator.getColumnB();
    if (columnA.getName().equals(columnB.getName())) {
        genericSQL = genericSQL.replaceFirst(GenericSQLHandler.COLUMN_NAMES_A, // $NON-NLS-1$
        dbmsLanguage.quote(columnA.getName()) + " AS " + columnA.getName() + // $NON-NLS-1$
        "_A");
        genericSQL = genericSQL.replaceFirst(GenericSQLHandler.COLUMN_NAMES_B, // $NON-NLS-1$
        dbmsLanguage.quote(columnB.getName()) + " AS " + columnA.getName() + // $NON-NLS-1$
        "_B");
    }
    return getStatement(genericSQL);
}
Also used : ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator) TdColumn(org.talend.cwm.relational.TdColumn)

Aggregations

TdColumn (org.talend.cwm.relational.TdColumn)182 ArrayList (java.util.ArrayList)49 TdTable (org.talend.cwm.relational.TdTable)49 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)40 Test (org.junit.Test)37 ColumnSet (orgomg.cwm.resource.relational.ColumnSet)35 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)28 RepositoryNode (org.talend.repository.model.RepositoryNode)26 IRepositoryNode (org.talend.repository.model.IRepositoryNode)23 Indicator (org.talend.dataquality.indicators.Indicator)20 Catalog (orgomg.cwm.resource.relational.Catalog)19 Connection (org.talend.core.model.metadata.builder.connection.Connection)17 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)16 TdSqlDataType (org.talend.cwm.relational.TdSqlDataType)16 Analysis (org.talend.dataquality.analysis.Analysis)16 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)15 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)14 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)14 Package (orgomg.cwm.objectmodel.core.Package)14 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)13