use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.
the class CatalogSchemaComparisonLevel method getLeftResource.
@Override
protected Resource getLeftResource() throws ReloadCompareException {
Package selectedPackage = getPackageFromObject(selectedObj);
// if (selectedObj instanceof RepositoryNode) {
// selectedPackage = (Package) RepositoryNodeHelper.getMetadataElement((RepositoryNode) selectedObj);
// } else {
// selectedPackage = (Package) selectedObj;
// }
// MOD mzhao 2009-01-20 Extract method findMatchedPackage to
// DQStructureComparer class
// for common use.
Package findMatchPackage = DQStructureComparer.findMatchedPackage(selectedPackage, copyedDataProvider);
List<ColumnSet> columnSets = new ArrayList<ColumnSet>();
if (isCompareTabel) {
columnSets.addAll(PackageHelper.getTables(findMatchPackage));
}
if (isCompareView) {
columnSets.addAll(PackageHelper.getViews(findMatchPackage));
}
Resource leftResource = copyedDataProvider.eResource();
// ComparatorsFactory.sort(columnSets,
// ComparatorsFactory.MODELELEMENT_COMPARATOR_ID);
leftResource.getContents().clear();
for (ColumnSet columnSet : columnSets) {
// MOD mzhao 2009-01-20 Extract method clearSubNode to
// DQStructureComparer class
// for common use.
DQStructureComparer.clearSubNode(columnSet);
leftResource.getContents().add(columnSet);
}
// }
EMFSharedResources.getInstance().saveResource(leftResource);
return upperCaseResource(leftResource);
}
use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.
the class CatalogSchemaComparisonLevel method reloadElementOfPackage.
/**
* DOC rli Comment method "reloadElementOfPackage".
*
* @param toReloadObj
* @return
* @throws ReloadCompareException
*/
private List<ColumnSet> reloadElementOfPackage(Package toReloadObj) throws ReloadCompareException {
List<ColumnSet> columnSetList = new ArrayList<ColumnSet>();
try {
// MOD by msjian bug 2011-5-16 20875, the reload element is not added correctly
Catalog catalogObj = SwitchHelpers.CATALOG_SWITCH.doSwitch(toReloadObj);
Schema schemaObj = SwitchHelpers.SCHEMA_SWITCH.doSwitch(toReloadObj);
if (schemaObj != null) {
List<ModelElement> elementList = schemaObj.getOwnedElement();
if (elementList != null && elementList.size() > 0) {
elementList.clear();
}
List<TdTable> tables = DqRepositoryViewService.getTables(tempReloadProvider, schemaObj, null, true, true);
SchemaHelper.addTables(tables, schemaObj);
columnSetList.addAll(tables);
List<TdView> views = DqRepositoryViewService.getViews(tempReloadProvider, schemaObj, null, true, true);
SchemaHelper.addViews(views, schemaObj);
columnSetList.addAll(views);
} else {
List<ModelElement> elementList = catalogObj.getOwnedElement();
if (elementList != null && elementList.size() > 0) {
elementList.clear();
}
List<TdTable> tables = DqRepositoryViewService.getTables(tempReloadProvider, catalogObj, null, true, true);
CatalogHelper.addTables(tables, catalogObj);
columnSetList.addAll(tables);
List<TdView> views = DqRepositoryViewService.getViews(tempReloadProvider, catalogObj, null, true, true);
CatalogHelper.addViews(views, catalogObj);
columnSetList.addAll(views);
}
// else {
// List<TdTable> tables = DqRepositoryViewService.getTables(tempReloadProvider, (Schema) toReloadObj, null,
// true);
// SchemaHelper.addTables(tables, (Schema) toReloadObj);
// columnSetList.addAll(tables);
//
// List<TdView> views = DqRepositoryViewService.getViews(tempReloadProvider, (Schema) toReloadObj, null,
// true);
// SchemaHelper.addViews(views, (Schema) toReloadObj);
// columnSetList.addAll(views);
//
// }
} catch (Exception e1) {
throw new ReloadCompareException(e1);
}
// EMFSharedResources.getInstance().saveResource(tempReloadProvider.eResource());
return columnSetList;
}
use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.
the class SubelementCompareAction method findMatchedModelElement.
/**
* DOC klliu Comment method "findMatchedModelElement". don't understand this method!!!
*
* @param parent
* @param similarElement
* @return
*/
private ModelElement findMatchedModelElement(EObject parent, EObject similarElement) {
if (parent instanceof Connection) {
if (similarElement instanceof Schema) {
Schema schema = (Schema) similarElement;
// Case of MS SQL Server.
if (selectedOjbect instanceof Catalog) {
// ??????
List<Schema> schemas = CatalogHelper.getSchemas((Catalog) selectedOjbect);
if (schemas != null && schemas.size() > 0) {
for (Schema tdSchema : schemas) {
if (tdSchema.getName().equalsIgnoreCase((schema).getName())) {
return tdSchema;
}
}
}
}
// case of MS SQL Server, Postgresql......
EObject eContainer = schema.eContainer();
if (eContainer != null && eContainer instanceof Catalog) {
List<Catalog> catalogs = ConnectionHelper.getCatalogs((Connection) parent);
for (Catalog catalog : catalogs) {
if (((Catalog) eContainer).getName().equals(catalog.getName())) {
List<Schema> schemas = CatalogHelper.getSchemas(catalog);
if (schemas != null && schemas.size() > 0) {
for (Schema tdSchema : schemas) {
if (tdSchema.getName().equalsIgnoreCase((schema).getName())) {
return tdSchema;
}
}
}
}
}
}
// Case of Oracle
List<Schema> schames = ConnectionHelper.getSchema((Connection) parent);
for (Schema schame : schames) {
if (schame.getName().equalsIgnoreCase((schema).getName())) {
return schame;
}
}
}
// Case of Mysql
if (similarElement instanceof Catalog) {
List<Catalog> catalogs = ConnectionHelper.getCatalogs((Connection) parent);
for (Catalog catalog : catalogs) {
if (catalog.getName().equalsIgnoreCase(((Catalog) similarElement).getName())) {
return catalog;
}
}
}
} else if (parent instanceof Package) {
// MOD klliu bug 15822 resolve proxy caused two Instance,so we must use one Instance
if (parent != null && parent.eIsProxy()) {
parent = EObjectHelper.resolveObject(parent);
}
// MOD mzhao bug 8581 2009-08-05
List<ColumnSet> columnSets = new ArrayList<ColumnSet>();
columnSets.addAll(PackageHelper.getTables((Package) parent));
columnSets.addAll(PackageHelper.getViews((Package) parent));
for (ModelElement columnSet : columnSets) {
if (((ColumnSet) columnSet).getName().equalsIgnoreCase(((ColumnSet) similarElement).getName())) {
return columnSet;
}
}
}
return null;
}
use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.
the class AnalysisColumnCompareTreeViewer method setColumnABForMatchingIndicator.
/**
* DOC rli Comment method "setColumnAB".
*/
public void setColumnABForMatchingIndicator(RowMatchingIndicator rowMatchingIndicator, List<RepositoryNode> columnsA, List<RepositoryNode> columnsB) {
if (columnsA.size() != 0 && columnsA.get(0).getObject() instanceof MetadataColumnRepositoryObject) {
RepositoryNode node = columnsA.get(0);
MetadataColumnRepositoryObject columnObject = (MetadataColumnRepositoryObject) node.getObject();
TdColumn column = ((TdColumn) columnObject.getTdColumn());
ColumnSet columnSetOwner = ColumnHelper.getColumnOwnerAsColumnSet(column);
rowMatchingIndicator.setAnalyzedElement(columnSetOwner);
}
rowMatchingIndicator.getColumnSetA().clear();
for (RepositoryNode reposNode : columnsA) {
rowMatchingIndicator.getColumnSetA().add((TdColumn) ((MetadataColumnRepositoryObject) reposNode.getObject()).getTdColumn());
}
rowMatchingIndicator.getColumnSetB().clear();
for (RepositoryNode reposNode : columnsB) {
rowMatchingIndicator.getColumnSetB().add((TdColumn) ((MetadataColumnRepositoryObject) reposNode.getObject()).getTdColumn());
}
}
use of orgomg.cwm.resource.relational.ColumnSet in project tdq-studio-se by Talend.
the class RowMatchExplorer method getRowsNotMatchStatement.
/**
* get Rows for NotMatched Statement.
*
* @return
*/
public String getRowsNotMatchStatement() {
ColumnSet tablea = (ColumnSet) indicator.getAnalyzedElement();
String tableA = tablea.getName();
// $NON-NLS-1$
String query = "SELECT A.*" + dbmsLanguage.from();
if (ColumnsetPackage.eINSTANCE.getRowMatchingIndicator() == indicator.eClass()) {
ColumnSet tableb = ColumnHelper.getColumnOwnerAsColumnSet(((RowMatchingIndicator) indicator).getColumnSetB().get(0));
String tableB = tableb.getName();
EList<TdColumn> columnSetA = ((RowMatchingIndicator) indicator).getColumnSetA();
EList<TdColumn> columnSetB = ((RowMatchingIndicator) indicator).getColumnSetB();
// $NON-NLS-1$
String clauseA = " (SELECT *" + dbmsLanguage.from() + getFullyQualifiedTableName(tablea);
// $NON-NLS-1$
String clauseB = " (SELECT *" + dbmsLanguage.from() + getFullyQualifiedTableName(tableb);
String where = null;
// $NON-NLS-1$
String onClause = " ON ";
String realWhereClause = dbmsLanguage.where();
for (int i = 0; i < columnSetA.size(); i++) {
where = dbmsLanguage.and();
if (i == 0) {
where = dbmsLanguage.where();
} else {
onClause += where;
realWhereClause += where;
}
realWhereClause += // $NON-NLS-1$
" B" + dbmsLanguage.getDelimiter() + dbmsLanguage.quote(columnSetB.get(i).getName()) + dbmsLanguage.isNull();
onClause += // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
" (A" + dbmsLanguage.getDelimiter() + dbmsLanguage.quote(columnSetA.get(i).getName()) + "=" + " B" + dbmsLanguage.getDelimiter() + dbmsLanguage.quote(columnSetB.get(i).getName()) + // $NON-NLS-1$
") ";
}
clauseA += (tableA.equals(tableB) ? whereDataFilter(tableA, (getdataFilterIndex(null) == AnalysisHelper.DATA_FILTER_A ? AnalysisHelper.DATA_FILTER_A : AnalysisHelper.DATA_FILTER_B)) : whereDataFilter(tableA, null)) + // $NON-NLS-1$
") A";
clauseB += (tableB.equals(tableA) ? whereDataFilter(tableB, (getdataFilterIndex(null) == AnalysisHelper.DATA_FILTER_A ? AnalysisHelper.DATA_FILTER_B : AnalysisHelper.DATA_FILTER_A)) : whereDataFilter(tableB, null)) + // $NON-NLS-1$
") B";
// MOD qiongli 2012-8-14 TDQ-5907.
if (dbmsLanguage instanceof HiveDbmsLanguage) {
// $NON-NLS-1$
query += clauseA + " LEFT OUTER JOIN " + clauseB + onClause + realWhereClause;
} else {
// $NON-NLS-1$
query += clauseA + " LEFT JOIN " + clauseB + onClause + realWhereClause;
}
}
return getComment(MENU_VIEW_NOT_MATCH_ROWS) + query;
}
Aggregations