Search in sources :

Example 31 with ColumnSet

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

the class CatalogSchemaComparisonLevel method getRightResource.

@Override
protected Resource getRightResource() throws ReloadCompareException {
    Package selectedPackage = getPackageFromObject(selectedObj);
    // if (selectedObj instanceof RepositoryNode) {
    // selectedPackage = (Package) RepositoryNodeHelper.getMetadataElement((RepositoryNode) selectedObj);
    // } else {
    // selectedPackage = (Package) selectedObj;
    // }
    // MOD Extract method findMatchedPackage to DQStructureComparer class
    // for common use.
    Package toReloadObj = DQStructureComparer.findMatchedPackage(selectedPackage, tempReloadProvider);
    Resource rightResource = null;
    rightResource = tempReloadProvider.eResource();
    rightResource.getContents().clear();
    List<ColumnSet> columnSetList = reloadElementOfPackage(toReloadObj);
    if (isCompareTabel) {
        for (ColumnSet columnset : TableHelper.getTables(columnSetList)) {
            DQStructureComparer.clearSubNode(columnset);
            rightResource.getContents().add(columnset);
        }
    }
    if (isCompareView) {
        for (ColumnSet columnset : ViewHelper.getViews(columnSetList)) {
            DQStructureComparer.clearSubNode(columnset);
            rightResource.getContents().add(columnset);
        }
    }
    EMFSharedResources.getInstance().saveResource(rightResource);
    return upperCaseResource(rightResource);
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) Package(orgomg.cwm.objectmodel.core.Package)

Example 32 with ColumnSet

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

the class DQStructureComparer method clearSubNode.

public static void clearSubNode(ModelElement needReloadElement) {
    Connection dataProvider = SwitchHelpers.CONNECTION_SWITCH.doSwitch(needReloadElement);
    if (dataProvider != null) {
        List<Catalog> tdCatalogs = ConnectionHelper.getCatalogs(dataProvider);
        for (Catalog catalog : tdCatalogs) {
            clearSubNode(catalog);
        }
        List<Schema> tdSchemas = ConnectionHelper.getSchema(dataProvider);
        for (Schema schema : tdSchemas) {
            clearSubNode(schema);
        }
        return;
    }
    Catalog tdCatalog = SwitchHelpers.CATALOG_SWITCH.doSwitch(needReloadElement);
    if (tdCatalog != null) {
        List<Schema> schemas = CatalogHelper.getSchemas(tdCatalog);
        for (Schema schema : schemas) {
            clearSubNode(schema);
        }
        if (schemas.size() == 0) {
            tdCatalog.getOwnedElement().clear();
        }
        return;
    }
    Schema tdSchema = SwitchHelpers.SCHEMA_SWITCH.doSwitch(needReloadElement);
    if (tdSchema != null) {
        tdSchema.getOwnedElement().clear();
        return;
    }
    ColumnSet columnSet = SwitchHelpers.COLUMN_SET_SWITCH.doSwitch(needReloadElement);
    if (columnSet != null) {
        columnSet.getFeature().clear();
        columnSet.getTaggedValue().clear();
        // ~MOD mzhao 2009-03-12 Clear primary key(contains in ownedElement)
        // as well. If not clear, it will cause
        // exception: not contained in
        // a resource...
        columnSet.getOwnedElement().clear();
        return;
    }
    TdColumn column = SwitchHelpers.COLUMN_SWITCH.doSwitch(needReloadElement);
    if (column != null) {
        column.getTaggedValue().clear();
        // ~MOD mzhao 2009-03-12 Clear primary key as well. If not clear, it
        // will cause exception: not contained in
        // a resource...
        column.getUniqueKey().clear();
        // ~
        // ~MOD mzhao 2009-04-08 Clear foreign key.
        column.getKeyRelationship().clear();
        return;
    }
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) Schema(orgomg.cwm.resource.relational.Schema) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) Catalog(orgomg.cwm.resource.relational.Catalog)

Example 33 with ColumnSet

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

the class DQStructureComparer method findMatchedColumn.

/**
 * DOC mzhao Find the matched column of toMatchDataProvider.
 *
 * @param column
 * @param toMatchDataProvider
 * @return
 * @throws ReloadCompareException
 */
public static TdColumn findMatchedColumn(TdColumn column, Connection toMatchDataProvider) throws ReloadCompareException {
    // MOD klliu update ColumnHelper.getColumnSetOwner(column)
    ColumnSet columnSet = ColumnHelper.getColumnOwnerAsColumnSet(column);
    ColumnSet toReloadColumnSet = DQStructureComparer.findMatchedColumnSet(columnSet, toMatchDataProvider);
    List<TdColumn> columns = ColumnSetHelper.getColumns(toReloadColumnSet);
    TdColumn oldColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(column);
    TdColumn toMatchedColumn = null;
    if (oldColumn != null) {
        for (TdColumn col : columns) {
            if (oldColumn.getName().equals(col.getName())) {
                toMatchedColumn = col;
                break;
            }
        }
    }
    if (toMatchedColumn == null) {
        throw new ReloadCompareException(// $NON-NLS-1$
        DefaultMessagesImpl.getString(// $NON-NLS-1$
        "DQStructureComparer.NotFoundCorrespondColumnNode", column.getName()));
    }
    return toMatchedColumn;
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) ColumnSet(orgomg.cwm.resource.relational.ColumnSet)

Example 34 with ColumnSet

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

the class DQStructureComparer method findMatchedColumnSet.

/**
 * Find the matched columnSet of matchDataProvider.
 *
 * @param selectedColumnSet
 * @return
 * @throws ReloadCompareException
 */
public static ColumnSet findMatchedColumnSet(ColumnSet selectedColumnSet, Connection toMatchDataProvider) throws ReloadCompareException {
    Package parentCatalogOrSchema = ColumnSetHelper.getParentCatalogOrSchema(selectedColumnSet);
    // find the corresponding package from reloaded object.
    Package toReloadPackage = DQStructureComparer.findMatchedPackage(parentCatalogOrSchema, toMatchDataProvider);
    // find the corresponding columnSet from reloaded object.
    TdTable oldTable = SwitchHelpers.TABLE_SWITCH.doSwitch(selectedColumnSet);
    ColumnSet toReloadcolumnSet = null;
    if (oldTable != null) {
        List<TdTable> tables = PackageHelper.getTables(toReloadPackage);
        for (TdTable table : tables) {
            // bug 11934 MOD zshen judge the tableOwner when database is sybase.
            if (oldTable.getName().equals(table.getName())) {
                // ~11934
                toReloadcolumnSet = table;
                break;
            }
        }
    } else {
        List<TdView> views = PackageHelper.getViews(toReloadPackage);
        for (TdView view : views) {
            // bug 11934 MOD zshen judge the viewOwner when database is sybase.
            if (selectedColumnSet.getName().equals(view.getName())) {
                // ~11934
                toReloadcolumnSet = view;
                break;
            }
        }
    }
    if (toReloadcolumnSet == null) {
        throw new ReloadCompareException(// $NON-NLS-1$
        DefaultMessagesImpl.getString(// $NON-NLS-1$
        "DQStructureComparer.NotFindCorrespondNode", selectedColumnSet.getName()));
    }
    return toReloadcolumnSet;
}
Also used : TdTable(org.talend.cwm.relational.TdTable) TdView(org.talend.cwm.relational.TdView) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) Package(orgomg.cwm.objectmodel.core.Package)

Example 35 with ColumnSet

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

the class TableViewComparisonLevel method resetTaggedValues.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.cwm.compare.factory.comparisonlevel.AbstractComparisonLevel#resetTaggedValues()
     */
@Override
protected void resetTaggedValues() throws ReloadCompareException {
    super.resetTaggedValues();
    if (PluginChecker.isTDQLoaded()) {
        ColumnSet selectedColumnSet = getCurrentColumnSet();
        ColumnSet oldColumnSet = DQStructureComparer.findMatchedColumnSet(selectedColumnSet, oldDataProvider);
        // reset table's taggedvalues "CONCEPT_NAME".
        TaggedValueHelper.setTaggedValue(oldColumnSet, TaggedValueHelper.CONCEPT_NAME, tmpConceptName);
        EList<Feature> oldFeatures = oldColumnSet.getFeature();
        for (Feature fea : oldFeatures) {
            // reset the column's tagged values "SEMATIC_NAME", "Content Type".
            String[] strings = tmpTaggedValuesMap.get(fea.getName());
            if (strings != null) {
                TaggedValueHelper.setTaggedValue(fea, TaggedValueHelper.SEMANTIC_NAME, strings[0]);
                TaggedValueHelper.setTaggedValue(fea, TaggedValueHelper.CONTENT_TYPE, strings[1]);
            }
        }
    }
}
Also used : ColumnSet(orgomg.cwm.resource.relational.ColumnSet) Feature(orgomg.cwm.objectmodel.core.Feature)

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