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);
}
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;
}
}
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;
}
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;
}
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]);
}
}
}
}
Aggregations