use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class DBViewRepNode method getParentViewObject.
/*
* (non-Javadoc)
*
* @see org.talend.dq.nodes.DQRepositoryNode#getParentViewObject()
*/
@Override
protected IRepositoryViewObject getParentViewObject() {
IRepositoryViewObject packageViewObject = null;
Package parentPackage = PackageHelper.getParentPackage(getTdView());
if (parentPackage instanceof Catalog) {
packageViewObject = new MetadataCatalogRepositoryObject(tdViewRepositoryObject.getViewObject(), (Catalog) parentPackage);
} else if (parentPackage instanceof Schema) {
packageViewObject = new MetadataSchemaRepositoryObject(tdViewRepositoryObject.getViewObject(), (Schema) parentPackage);
}
return packageViewObject;
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class UniquePkAndFkTask method getTables.
private TypedReturnCode<List<TdTable>> getTables(ModelElement element) {
TypedReturnCode<List<TdTable>> returnCode = new TypedReturnCode<List<TdTable>>(false);
List<TdTable> tableList = new ArrayList<TdTable>();
returnCode.setObject(tableList);
if (element == null)
return returnCode;
if (element instanceof Catalog) {
for (ModelElement subElement : ((Catalog) element).getOwnedElement()) {
TypedReturnCode<List<TdTable>> newreturnCode = getTables(subElement);
tableList.addAll(newreturnCode.getObject());
if (newreturnCode.isOk()) {
returnCode.setOk(newreturnCode.isOk());
}
}
} else if (element instanceof Schema) {
for (ModelElement subElement : ((Schema) element).getOwnedElement()) {
TypedReturnCode<List<TdTable>> newreturnCode = getTables(subElement);
tableList.addAll(newreturnCode.getObject());
if (newreturnCode.isOk()) {
returnCode.setOk(newreturnCode.isOk());
}
}
} else if (element instanceof TdTable) {
tableList.add((TdTable) element);
if (checkPkAndFk((TdTable) element)) {
returnCode.setOk(true);
}
}
return returnCode;
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class TestComparisonLevelFactoryTest method createCatalogRepNode.
private RepositoryNode createCatalogRepNode() {
IRepositoryViewObject lastVersion = null;
// $NON-NLS-1$
databaseConnectionItem = UnitTestBuildHelper.createDatabaseConnectionItem("testCompareLevelConnection", null, false);
Assert.assertNotNull(databaseConnectionItem);
Assert.assertNotNull(databaseConnectionItem.getProperty());
String propertyID = databaseConnectionItem.getProperty().getId();
// $NON-NLS-1$
Catalog createCatalog = createCatalog("catalog1");
try {
lastVersion = factory.getLastVersion(propertyID);
lastVersion = new MetadataCatalogRepositoryObject(lastVersion, createCatalog);
} catch (PersistenceException 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);
return dbCatalogRepNode;
}
use of orgomg.cwm.resource.relational.Catalog in project tbd-studio-se by Talend.
the class HBaseMetadataProvider method fillConnection.
@Override
public void fillConnection(DatabaseConnection connection) {
Catalog defaultCatalog = CatalogHelper.createCatalog(getDefaultCatalogName());
ConnectionHelper.addPackage(defaultCatalog, connection);
connection.setSID(getDefaultCatalogName());
}
use of orgomg.cwm.resource.relational.Catalog in project tbd-studio-se by Talend.
the class MapRDBMetadataProvider method getTableFromConnection.
private TdTable getTableFromConnection(IMetadataConnection metadataConnection, String tableName) {
List<Catalog> catalogs = CatalogHelper.getCatalogs(((DatabaseConnection) metadataConnection.getCurrentConnection()).getDataPackage());
Catalog catalog = null;
for (Catalog c : catalogs) {
if (c.getName() != null && c.getName().equals(getDefaultCatalogName())) {
catalog = c;
break;
}
}
if (catalog != null) {
List<TdTable> exsitTables = CatalogHelper.getTables(catalog);
for (TdTable tb : exsitTables) {
if (tableName != null && tb.getLabel().equals(tableName)) {
return tb;
}
}
}
return null;
}
Aggregations