use of org.talend.cwm.relational.TdView in project tdq-studio-se by Talend.
the class DQStructureComparer method cleanUpResource.
private static Resource cleanUpResource(Resource resource, boolean isTos) {
boolean isTosTemp = isTos;
EList<EObject> contents = resource.getContents();
for (EObject content : contents) {
if (content instanceof TdTable) {
TdTable tdTable = (TdTable) content;
isTosTemp = tdTable.getId() != null;
tdTable.setId(null);
tdTable.setComment(null);
} else if (content instanceof TdView) {
TdView tdView = (TdView) content;
tdView.setId(null);
tdView.setComment(null);
} else if (content instanceof TdColumn) {
TdColumn tdColumn = (TdColumn) content;
tdColumn.setSourceType(null);
if (isTosTemp) {
tdColumn.setLength(10);
tdColumn.setPrecision(4);
if (tdColumn.getInitialValue() != null) {
tdColumn.getInitialValue().setBody(null);
}
tdColumn.setPattern(null);
tdColumn.setKey(false);
tdColumn.setId(PluginConstant.EMPTY_STRING);
}
}
}
return resource;
}
use of org.talend.cwm.relational.TdView 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 org.talend.cwm.relational.TdView in project tdq-studio-se by Talend.
the class OverviewResultPage method runTableAnalysis.
/**
* run TableAnalysis with view name.
*
* @param viewName
*/
protected void runTableAnalysis(String viewName) {
Package parentPack = (Package) currentSelectionSchemaIndicator.getAnalyzedElement();
TdView tdView = getView(parentPack, viewName);
if (null == tdView) {
FolderNodeHelper.getTableFolderNode(parentPack).loadChildren();
tdView = getView(parentPack, viewName);
}
DBViewRepNode dbViewRepNode = RepositoryNodeHelper.recursiveFindTdView(tdView);
new AnalyzeColumnSetAction(dbViewRepNode).run();
}
use of org.talend.cwm.relational.TdView in project tdq-studio-se by Talend.
the class RepositoryNodeHelperRealTest method testCreateMysqlViewRepositoryNode.
/**
* Test method for
* {@link org.talend.dq.helper.RepositoryNodeHelper#createRepositoryNode(orgomg.cwm.objectmodel.core.ModelElement)}.
* mysql case find View node
*/
@Test
public void testCreateMysqlViewRepositoryNode() {
// $NON-NLS-1$
DatabaseConnectionItem createConnectionItem = createDataBaseConnection("conn1", null, false);
// $NON-NLS-1$
Catalog addCatalog = this.addCatalog(createConnectionItem.getConnection(), "catalog1");
// $NON-NLS-1$
TdView addView = this.addView(addCatalog, "view1");
try {
ProxyRepositoryFactory.getInstance().save(createConnectionItem, null);
} catch (PersistenceException e) {
log.error(e, e);
Assert.fail(e.getMessage());
}
RepositoryNode createRepositoryNode = RepositoryNodeHelper.createRepositoryNode(addView);
if (createRepositoryNode != null) {
IRepositoryViewObject object = createRepositoryNode.getObject();
Assert.assertTrue(createRepositoryNode instanceof DBViewRepNode);
Assert.assertTrue(object != null);
Assert.assertTrue(object instanceof TdViewRepositoryObject);
Assert.assertTrue(object.getId().equals(addView.getName()));
Assert.assertTrue(object.getLabel().equals(addView.getName()));
Assert.assertTrue(object.getRepositoryNode() != null);
Assert.assertTrue(createRepositoryNode.getProperties(EProperties.LABEL).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
Assert.assertTrue(createRepositoryNode.getProperties(EProperties.CONTENT_TYPE).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
Assert.assertTrue(createRepositoryNode.getParent().getParent().getParent() != null);
}
}
use of org.talend.cwm.relational.TdView in project tdq-studio-se by Talend.
the class DrillDownEditorInputRealTest method testGetColumnsByTdColumnCase3.
/**
* Test method for
* {@link org.talend.dataprofiler.core.ui.editor.analysis.drilldown.DrillDownEditorInput#getColumnsByTdColumn(org.talend.cwm.relational.TdColumn)}
* . case3 :table is null
*/
@Test
public void testGetColumnsByTdColumnCase3() {
TdColumn currentTdColumn = RelationalFactory.eINSTANCE.createTdColumn();
TdColumn secondTdColumn = RelationalFactory.eINSTANCE.createTdColumn();
TdView createTdView = RelationalFactory.eINSTANCE.createTdView();
List<TdColumn> tdColumns = new ArrayList<TdColumn>();
tdColumns.add(currentTdColumn);
tdColumns.add(secondTdColumn);
DrillDownEditorInput drillDownEditorInput = new DrillDownEditorInput();
List<TdColumn> allofTdColumn = drillDownEditorInput.getColumnsByTdColumn(currentTdColumn);
Assert.assertEquals(createTdView.getColumns().size(), allofTdColumn.size());
}
Aggregations