use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class MultiColAnalysisCreationTest method getColumns.
/**
* DOC scorreia Comment method "getColumn".
*
* @param dataManager
* @return
* @throws Exception
*/
private List<TdColumn> getColumns(Connection dataManager) throws Exception {
List<Catalog> tdCatalogs = CatalogHelper.getCatalogs(dataManager.getDataPackage());
Catalog catalog = null;
for (Catalog tdCatalog : tdCatalogs) {
if (CATALOG.equals(tdCatalog.getName())) {
catalog = tdCatalog;
break;
}
}
Assert.assertNotNull(catalog);
Assert.assertFalse(tdCatalogs.isEmpty());
// $NON-NLS-1$
System.out.println("analysed Catalog: " + catalog.getName());
List<TdTable> tables = DqRepositoryViewService.getTables(dataManager, catalog, TABLE, true, false);
// store tables in catalog
CatalogHelper.addTables(tables, catalog);
Assert.assertFalse(tables.isEmpty());
TdTable tdTable = tables.get(0);
// $NON-NLS-1$
System.out.println("analyzed Table: " + tdTable.getName());
List<TdColumn> columns;
columns = DqRepositoryViewService.getColumns(dataManager, tdTable, null, true);
// MOD scorreia 2009-01-29 columns are stored in the table
// TableHelper.addColumns(tdTable, columns);
Assert.assertFalse(columns.isEmpty());
List<TdColumn> usedCols = new ArrayList<TdColumn>();
for (TdColumn tdColumn : columns) {
for (String c : COLUMNS) {
if (tdColumn.getName().equals(c)) {
usedCols.add(tdColumn);
}
}
}
// set DM type for each used column
for (TdColumn tdColumn : usedCols) {
final int javaType = tdColumn.getJavaType();
if (Java2SqlType.isNumbericInSQL(javaType)) {
MetadataHelper.setDataminingType(DataminingType.INTERVAL, tdColumn);
} else if (Java2SqlType.isTextInSQL(javaType)) {
MetadataHelper.setDataminingType(DataminingType.NOMINAL, tdColumn);
}
}
return usedCols;
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class ExportConnectionToTOSActionRealTest method addCataPackage.
private static Catalog addCataPackage(String packageName, DatabaseConnectionItem connItem) throws PersistenceException {
Connection connection = connItem.getConnection();
Catalog createCatalog = CatalogHelper.createCatalog(packageName);
ConnectionHelper.addCatalog(createCatalog, connection);
return createCatalog;
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class ExportConnectionToTOSActionRealTest method testRuncase2.
/**
* Test method for {@link org.talend.dataprofiler.core.ui.action.actions.ExportConnectionToTOSAction#run()}.
*
* @throws PersistenceException
*
* case2: create new connection from schema below catalog case
*/
@Test
public void testRuncase2() throws PersistenceException {
// connectionNode
DatabaseConnectionItem createOldConnectionItem = createConnectionItem("ExportConnectionToTOSActionRealTest2", null, false, // $NON-NLS-1$
true);
initCatalogList(createOldConnectionItem);
initSchemaOfCagalogList(createOldConnectionItem);
IRepositoryViewObject createdByUs = factory.getLastVersion(createOldConnectionItem.getProperty().getId());
Assert.assertTrue(createdByUs != null);
// $NON-NLS-1$
Assert.assertTrue("ExportConnectionToTOSActionRealTest2".equals(createdByUs.getLabel()));
// ~connectionNode
List<Package> packageList = new ArrayList<Package>();
packageList.add(schema1);
createAction = PowerMockito.spy(new ExportConnectionToTOSAction(packageList));
PowerMockito.doNothing().when(createAction).openSuccessInformation();
PowerMockito.doNothing().when(createAction).refreshViewerAndNode();
createAction.run();
IRepositoryViewObject createByAction = getNewCreatedConnectionByName(createOldConnectionItem.getConnection().getLabel() + "_" + // $NON-NLS-1$
schema1.getName());
DatabaseConnectionItem item = (DatabaseConnectionItem) createByAction.getProperty().getItem();
Connection newConnection = item.getConnection();
Catalog exportedCatalog = CatalogHelper.getCatalog(newConnection, catalog1.getName());
Assert.assertTrue(exportedCatalog != null);
Assert.assertTrue(newConnection.getLabel().equals(// $NON-NLS-1$
createOldConnectionItem.getConnection().getLabel() + "_" + schema1.getName()));
Assert.assertTrue(exportedCatalog != catalog1);
factory.deleteObjectPhysical(createByAction);
factory.deleteObjectPhysical(createdByUs);
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class DBConnectionDuplicateHandleTest method compareResult.
/**
* DOC zshen Comment method "compareResult".
*
* @param newConnectionItem
* @param oldConnectionItem
*/
private void compareResult(DatabaseConnectionItem newConnectionItem, DatabaseConnectionItem oldConnectionItem) {
Connection newConnection = newConnectionItem.getConnection();
Connection oldConnection = oldConnectionItem.getConnection();
// check connection has been persistenced
Assert.assertTrue(newConnection != null);
Assert.assertTrue(newConnection.eResource() != null);
Assert.assertTrue(!newConnection.eIsProxy());
Assert.assertTrue(oldConnection != null);
Assert.assertTrue(oldConnection.eResource() != null);
Assert.assertTrue(!oldConnection.eIsProxy());
// check name and label has been set
Assert.assertEquals(oldConnection.getName(), oldConnectionName);
Assert.assertEquals(oldConnection.getLabel(), oldConnectionName);
Assert.assertEquals(newConnection.getName(), newConnectionName);
Assert.assertEquals(newConnection.getLabel(), newConnectionName);
// check catalog size is same
List<Catalog> newCatalogs = ConnectionHelper.getCatalogs(newConnection);
List<Catalog> oldCatalogs = ConnectionHelper.getCatalogs(oldConnection);
Assert.assertTrue(newCatalogs.size() == 2);
Assert.assertTrue(oldCatalogs.size() == 2);
// check the structor of connection is valid
// $NON-NLS-1$
Catalog oldCatalog1 = CatalogHelper.getCatalog(oldConnection, "catalog1");
// $NON-NLS-1$
Catalog newCatalog1 = CatalogHelper.getCatalog(newConnection, "catalog1");
// $NON-NLS-1$
Catalog oldCatalog2 = CatalogHelper.getCatalog(oldConnection, "catalog2");
// $NON-NLS-1$
Catalog newCatalog2 = CatalogHelper.getCatalog(newConnection, "catalog2");
Assert.assertTrue(oldCatalog1 != null);
Assert.assertTrue(newCatalog1 != null);
Assert.assertTrue(oldCatalog2 != null);
Assert.assertTrue(newCatalog2 != null);
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class AbstractCommonActionProviderRealProjectTest method testGetConnectionCase7.
/**
* Test method for
* {@link org.talend.dataprofiler.core.ui.action.provider.AbstractCommonActionProvider#getConnection(java.lang.Object)}
* . case7 :input parameter is DBViewFolderRepNode
*/
@Test
public void testGetConnectionCase7() {
// create FileConnection
// connection
IRepositoryViewObject lastVersion = null;
String propertyID = createConnectionItem(connectionName, null, null);
// $NON-NLS-1$
Catalog createCatalog = createCatalog("catalog1");
try {
lastVersion = factory.getLastVersion(propertyID);
lastVersion = new MetadataCatalogRepositoryObject(lastVersion, createCatalog);
} catch (PersistenceException e) {
log.error(e, e);
Assert.fail(e.getMessage());
}
// ~connection data
// ~FileConnection
// create DFColumnFolderRepNode
Assert.assertFalse(lastVersion == null);
RepositoryNode dbCatalogRepNode = DQRepNodeCreateFactory.createDBCatalogRepNode(lastVersion, null, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
DBViewFolderRepNode dbViewFolderRepNode = new DBViewFolderRepNode(null, dbCatalogRepNode, null, null);
// ~DFColumnFolderRepNode
AbstractCommonActionProvider provider = new AbstractCommonActionProvider();
Connection connection = provider.getConnection(dbViewFolderRepNode);
Assert.assertTrue(connection != null);
}
Aggregations