Search in sources :

Example 36 with ColumnSet

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

the class TableViewComparisonLevel method findDataProvider.

@Override
protected Connection findDataProvider() {
    Connection provider = null;
    if (selectedObj instanceof DBColumnFolderRepNode) {
        DBColumnFolderRepNode columnFolderRepNode = (DBColumnFolderRepNode) selectedObj;
        ColumnSet columnSet = columnFolderRepNode.getColumnSet();
        if (columnSet != null) {
            Package parentCatalogOrSchema = ColumnSetHelper.getParentCatalogOrSchema(columnSet);
            provider = ConnectionHelper.getTdDataProvider(parentCatalogOrSchema);
        }
    } else if (selectedObj instanceof RepositoryNode) {
        Item connItem = ((RepositoryNode) selectedObj).getObject().getProperty().getItem();
        provider = ((ConnectionItem) connItem).getConnection();
    } else {
        ColumnSet columnSet = (ColumnSet) selectedObj;
        Package parentCatalogOrSchema = ColumnSetHelper.getParentCatalogOrSchema(columnSet);
        provider = ConnectionHelper.getTdDataProvider(parentCatalogOrSchema);
    }
    return provider;
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Connection(org.talend.core.model.metadata.builder.connection.Connection) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) Package(orgomg.cwm.objectmodel.core.Package) RepositoryNode(org.talend.repository.model.RepositoryNode) DQDBFolderRepositoryNode(org.talend.dq.nodes.DQDBFolderRepositoryNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode)

Example 37 with ColumnSet

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

the class TableViewComparisonLevel method getRightResource.

@Override
protected Resource getRightResource() throws ReloadCompareException {
    ColumnSet selectedColumnSet = null;
    if (selectedObj instanceof RepositoryNode) {
        selectedColumnSet = (ColumnSet) RepositoryNodeHelper.getMetadataElement((RepositoryNode) selectedObj);
    } else if (selectedObj instanceof DBColumnFolderRepNode) {
        DBColumnFolderRepNode columnFolderRepNode = (DBColumnFolderRepNode) selectedObj;
        selectedColumnSet = columnFolderRepNode.getColumnSet();
    } else {
        selectedColumnSet = (ColumnSet) selectedObj;
    }
    ColumnSet findMatchedColumnSet = DQStructureComparer.findMatchedColumnSet(selectedColumnSet, tempReloadProvider);
    List<TdColumn> columns = null;
    try {
        // MOD scorreia 2009-01-29 clear content of findMatchedColumnSet
        ColumnSetHelper.setColumns(findMatchedColumnSet, EMPTY_COLUMN_LIST);
        columns = DqRepositoryViewService.getColumns(tempReloadProvider, findMatchedColumnSet, true);
    } catch (Exception e1) {
        throw new ReloadCompareException(e1);
    }
    // MOD scorreia 2009-01-29 columns are stored in the table
    // ColumnSetHelper.addColumns(findMatchedColumnSet, columns);
    URI uri = tempReloadProvider.eResource().getURI();
    Resource rightResource = null;
    rightResource = EMFSharedResources.getInstance().getResource(uri, true);
    if (rightResource == null) {
        // $NON-NLS-1$
        throw new ReloadCompareException(DefaultMessagesImpl.getString("TableViewComparisonLevel.NoFactoryFoundForURI", uri));
    }
    rightResource.getContents().clear();
    for (TdColumn column : columns) {
        DQStructureComparer.clearSubNode(column);
        rightResource.getContents().add(column);
    }
    EMFSharedResources.getInstance().saveResource(rightResource);
    return upperCaseResource(rightResource);
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) 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) URI(org.eclipse.emf.common.util.URI) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException)

Example 38 with ColumnSet

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

the class TableViewComparisonLevel method getSavedReloadObject.

@Override
protected EObject getSavedReloadObject() throws ReloadCompareException {
    ColumnSet selectedColumnSet = getCurrentColumnSet();
    ColumnSet toReloadcolumnSet = DQStructureComparer.findMatchedColumnSet(selectedColumnSet, tempReloadProvider);
    // ADD TDQ-11146 msjian: to save the TaggedValues before clear
    if (PluginChecker.isTDQLoaded()) {
        tmpConceptName = TaggedValueHelper.getValueString(TaggedValueHelper.CONCEPT_NAME, toReloadcolumnSet);
        EList<Feature> feature = toReloadcolumnSet.getFeature();
        tmpTaggedValuesMap = new HashMap<String, String[]>();
        for (Feature fea : feature) {
            String[] values = new String[] { StringUtils.EMPTY, StringUtils.EMPTY };
            values[0] = TaggedValueHelper.getValueString(TaggedValueHelper.SEMANTIC_NAME, fea);
            values[1] = TaggedValueHelper.getValueString(TaggedValueHelper.CONTENT_TYPE, fea);
            if (StringUtils.isNotBlank(values[0]) || StringUtils.isNotBlank(values[1])) {
                tmpTaggedValuesMap.put(fea.getName(), values);
            }
        }
    }
    // TDQ-11146~
    // MOD scorreia 2009-01-29 clear content of findMatchedColumnSet
    ColumnSetHelper.setColumns(toReloadcolumnSet, EMPTY_COLUMN_LIST);
    toReloadcolumnSet.getOwnedElement().clear();
    try {
        DqRepositoryViewService.getColumns(tempReloadProvider, toReloadcolumnSet, true);
        // MOD mzhao 2009-11-12 save to resoure after reload.
        util.saveResource(toReloadcolumnSet.eResource());
    } catch (Exception e1) {
        throw new ReloadCompareException(e1);
    }
    // ColumnSetHelper.setColumns(toReloadcolumnSet, columns);
    return toReloadcolumnSet;
}
Also used : ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) Feature(orgomg.cwm.objectmodel.core.Feature) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException)

Example 39 with ColumnSet

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

the class TableViewComparisonLevel method getCurrentColumnSet.

/**
 * DOC msjian Comment method "getCurrentColumnSet".
 *
 * @return
 */
private ColumnSet getCurrentColumnSet() {
    ColumnSet columnSet = null;
    if (selectedObj instanceof DBColumnFolderRepNode) {
        DBColumnFolderRepNode columnFolderRepNode = (DBColumnFolderRepNode) selectedObj;
        columnSet = columnFolderRepNode.getColumnSet();
    } else if (selectedObj instanceof ColumnSet) {
        columnSet = (ColumnSet) selectedObj;
    }
    return columnSet;
}
Also used : ColumnSet(orgomg.cwm.resource.relational.ColumnSet) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode)

Example 40 with ColumnSet

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

the class RenameComparedElementAction method getLeftResource.

// private void getDiffElements(DiffElement diffEle, List<DiffElement> diffElementList) {
// if (diffEle instanceof DiffGroup) {
// for (DiffElement subDiffEle : ((DiffGroup) diffEle).getSubDiffElements()) {
// getDiffElements(subDiffEle, diffElementList);
// }
// } else {
// diffElementList.add(diffEle);
// }
// }
private Resource getLeftResource() throws ReloadCompareException {
    ColumnSet selectedColumnSet = (ColumnSet) theSelectedElement;
    Connection copyedDataProvider = createCopyedProvider();
    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 leftResource;
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) Connection(org.talend.core.model.metadata.builder.connection.Connection) ArrayList(java.util.ArrayList) Resource(org.eclipse.emf.ecore.resource.Resource) ColumnSet(orgomg.cwm.resource.relational.ColumnSet)

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