Search in sources :

Example 21 with ColumnSet

use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.

the class AbstractComparisonLevel method upperCase.

private void upperCase(EObject eObject) {
    Package pckg = SwitchHelpers.PACKAGE_SWITCH.doSwitch(eObject);
    ColumnSet columnSet = SwitchHelpers.COLUMN_SET_SWITCH.doSwitch(eObject);
    TdColumn column = SwitchHelpers.COLUMN_SWITCH.doSwitch(eObject);
    if (column != null) {
        // $NON-NLS-1$
        column.setName(column.getName() == null ? "" : column.getName().toUpperCase());
        // $NON-NLS-1$
        column.setLabel(column.getLabel() == null ? "" : column.getLabel().toUpperCase());
        column.getSqlDataType().setName(// $NON-NLS-1$
        column.getSqlDataType().getName() == null ? "" : column.getSqlDataType().getName().toUpperCase());
        // $NON-NLS-1$
        column.setContentType(column.getContentType() == null ? "" : column.getContentType().toUpperCase());
        // $NON-NLS-1$
        column.setSourceType(column.getSourceType() == null ? "" : column.getSourceType().toUpperCase());
    } else if (pckg != null) {
        // $NON-NLS-1$
        pckg.setName(pckg.getName() == null ? "" : pckg.getName().toUpperCase());
    } else if (columnSet != null) {
        // $NON-NLS-1$
        columnSet.setName(columnSet.getName() == null ? "" : columnSet.getName().toUpperCase());
    }
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) Package(orgomg.cwm.objectmodel.core.Package)

Example 22 with ColumnSet

use of orgomg.cwm.resource.relational.ColumnSet 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 23 with ColumnSet

use of orgomg.cwm.resource.relational.ColumnSet 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 24 with ColumnSet

use of orgomg.cwm.resource.relational.ColumnSet 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 25 with ColumnSet

use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.

the class UpdateRelationalSwitch method caseForeignKey.

@Override
public Boolean caseForeignKey(ForeignKey object) {
    ColumnSet columnSet = (ColumnSet) object.eContainer();
    if (columnSet == null) {
        return Boolean.FALSE;
    }
    ForeignKey rightColumn = null;
    if (rightElement instanceof ForeignKey) {
        rightColumn = (ForeignKey) rightElement;
    } else {
        return Boolean.FALSE;
    }
    object.setName(rightColumn.getName());
    object.getFeature().clear();
    List<StructuralFeature> refColumns = new ArrayList<StructuralFeature>();
    for (StructuralFeature newColumn : rightColumn.getFeature()) {
        for (Feature column : columnSet.getFeature()) {
            if (column.getName().equalsIgnoreCase(newColumn.getName())) {
                refColumns.add((StructuralFeature) column);
                break;
            }
        }
    }
    object.getFeature().addAll(refColumns);
    return Boolean.TRUE;
}
Also used : StructuralFeature(orgomg.cwm.objectmodel.core.StructuralFeature) ArrayList(java.util.ArrayList) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) ForeignKey(orgomg.cwm.resource.relational.ForeignKey) Feature(orgomg.cwm.objectmodel.core.Feature) StructuralFeature(orgomg.cwm.objectmodel.core.StructuralFeature)

Aggregations

ColumnSet (orgomg.cwm.resource.relational.ColumnSet)55 TdColumn (org.talend.cwm.relational.TdColumn)35 Package (orgomg.cwm.objectmodel.core.Package)14 ArrayList (java.util.ArrayList)12 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)11 Connection (org.talend.core.model.metadata.builder.connection.Connection)9 RepositoryNode (org.talend.repository.model.RepositoryNode)9 ReloadCompareException (org.talend.cwm.compare.exception.ReloadCompareException)7 TdTable (org.talend.cwm.relational.TdTable)7 Catalog (orgomg.cwm.resource.relational.Catalog)7 Schema (orgomg.cwm.resource.relational.Schema)7 Resource (org.eclipse.emf.ecore.resource.Resource)6 EObject (org.eclipse.emf.ecore.EObject)5 ReturnCode (org.talend.utils.sugars.ReturnCode)5 Indicator (org.talend.dataquality.indicators.Indicator)4 IRepositoryNode (org.talend.repository.model.IRepositoryNode)4 List (java.util.List)3 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)3 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)3 DuplicateCountIndicator (org.talend.dataquality.indicators.DuplicateCountIndicator)3