use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class SwitchContextGroupNameImplTest method createCatalog.
/**
* DOC talend Comment method "createCatalog".
*
* @param catalogName
*/
private void createCatalog(String catalogName) {
Connection connection = createDatabaseConnectionItem.getConnection();
Catalog createCatalog = CatalogHelper.createCatalog(catalogOld);
ConnectionHelper.addCatalog(createCatalog, connection);
((DatabaseConnection) connection).setSID(contextCatalogName);
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class SwitchContextGroupNameImplTest method testUpdateContextGroupSuccessMssql.
/**
* Test method for
* {@link org.talend.repository.ui.utils.SwitchContextGroupNameImpl#updateContextGroup(org.talend.core.model.properties.ConnectionItem)}
* . sqlserver case
*/
@Test
public void testUpdateContextGroupSuccessMssql() {
createCatalogSchema(schemaOld);
boolean updateContextGroup = SwitchContextGroupNameImpl.getInstance().updateContextGroup(createDatabaseConnectionItem, ContextTpeyNameNew);
Connection connection = createDatabaseConnectionItem.getConnection();
List<Catalog> catalogs = ConnectionHelper.getCatalogs(connection);
List<Schema> schemas = CatalogHelper.getSchemas(catalogs.get(0));
assertTrue(updateContextGroup);
assertTrue(schemas.size() == 1);
assertTrue(schemas.get(0).getName().equalsIgnoreCase(schemaNew));
assertTrue(catalogs.size() == 1);
assertTrue(catalogs.get(0).getName().equalsIgnoreCase(catalogNew));
}
use of orgomg.cwm.resource.relational.Catalog in project tdq-studio-se by Talend.
the class ReadItemConnectionFile method test.
@Test
public void test() {
EMFUtil emfUtil = new EMFUtil();
File file = new File("data/my_0.1.item");
System.out.println("Loading file " + file.getAbsolutePath());
ResourceSet rs = emfUtil.getResourceSet();
Resource r = rs.getResource(URI.createFileURI(file.getAbsolutePath()), true);
// TreeIterator<EObject> allContents = r.getAllContents();
// while (allContents.hasNext()) {
// EObject metadata = allContents.next();
// System.out.println(metadata);
// }
// should contain the connection, then catalog/schema, then tables, then columns
EList<EObject> contents = r.getContents();
// switch class that returns a connection when it finds one.
ConnectionSwitch<Connection> connectionFinder = new ConnectionSwitch<Connection>() {
/*
* (non-Javadoc)
*
* @see
* org.talend.core.model.metadata.builder.connection.util.ConnectionSwitch#caseConnection(org.talend.core
* .model.metadata.builder.connection.Connection)
*/
@Override
public Connection caseConnection(Connection object) {
return object;
}
};
// loop on all the content of the resource
for (EObject eObject : contents) {
Connection connection = connectionFinder.doSwitch(eObject);
if (connection != null) {
Set<Catalog> allCatalogs = ConnectionHelper.getAllCatalogs(connection);
for (Catalog catalog : allCatalogs) {
System.out.println("## Catalog: " + catalog.getName());
System.out.println("\t## Tables");
List<TdTable> tables = CatalogHelper.getTables(catalog);
for (TdTable tdTable : tables) {
System.out.println("\t\t" + tdTable.getName());
List<TdColumn> columns = TableHelper.getColumns(tdTable);
if (!columns.isEmpty()) {
System.out.println("\t\t\t## Columns");
}
for (TdColumn tdColumn : columns) {
System.out.println("\t\t\t\t" + tdColumn.getName());
}
}
System.out.println("\t## Views");
List<TdView> views = CatalogHelper.getViews(catalog);
for (TdView tdView : views) {
System.out.println("\t\t" + tdView.getName());
List<TdColumn> columns = ViewHelper.getColumns(tdView);
if (!columns.isEmpty()) {
System.out.println("\t\t\t## Columns");
}
for (TdColumn tdColumn : columns) {
System.out.println("\t\t\t\t" + tdColumn.getName());
}
}
}
}
}
}
use of orgomg.cwm.resource.relational.Catalog 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.Catalog in project tdq-studio-se by Talend.
the class ModelElementCompareEditorLauncher method open.
@Override
public void open(IPath file) {
try {
// final EObject snapshot = ModelUtils.load(file.toFile(), new ResourceSetImpl());
// if (snapshot instanceof ComparisonResourceSnapshot) {
CompareConfiguration comapreConfiguration = new CompareConfiguration();
comapreConfiguration.setDefaultLabelProvider(new ICompareInputLabelProvider() {
@Override
public Image getAncestorImage(Object input) {
return null;
}
@Override
public String getAncestorLabel(Object input) {
// $NON-NLS-1$
return "";
}
@Override
public Image getLeftImage(Object input) {
return null;
}
@Override
public String getLeftLabel(Object input) {
// $NON-NLS-1$
String showLabel = Messages.getString("ModelElementCompareEditorLauncher.LocalStructure", connectionName);
if (compareEachOther) {
// $NON-NLS-1$
showLabel = Messages.getString("ModelElementCompareEditorLauncher.FirstElement");
}
return showLabel;
}
@Override
public Image getRightImage(Object input) {
return null;
}
@Override
public String getRightLabel(Object input) {
// $NON-NLS-1$
String showLabel = Messages.getString("ModelElementCompareEditorLauncher.DistantStructure");
if (compareEachOther) {
// $NON-NLS-1$
showLabel = Messages.getString("ModelElementCompareEditorLauncher.SecondElement");
}
return showLabel;
}
@Override
public Image getImage(Object element) {
return null;
}
@Override
public String getText(Object element) {
// $NON-NLS-1$
return Messages.getString("ModelElementCompareEditorLauncher.TextLabel");
}
@Override
public void addListener(ILabelProviderListener listener) {
// needn't to do anything ???
}
@Override
public void dispose() {
// needn't to do anything ???
}
@Override
public boolean isLabelProperty(Object element, String property) {
return false;
}
@Override
public void removeListener(ILabelProviderListener listener) {
// needn't to do anything ???
}
});
// ModelElementCompareEditorInput compEditorInput = new ModelElementCompareEditorInput(
// (ComparisonResourceSnapshot) snapshot, comapreConfiguration, selectedObject);
// MOD mzhao bug 8581 Add the specific title for comparison
// editor.
// $NON-NLS-1$
String editorTitle = Messages.getString("ModelElementCompareEditorLauncher.Compare");
if (selectedObject instanceof IFile) {
editorTitle = PrvResourceFileHelper.getInstance().findProvider((IFile) selectedObject).getName();
} else if (selectedObject instanceof IFolderNode) {
editorTitle = ((ModelElement) ((IFolderNode) selectedObject).getParent()).getName();
} else if (selectedObject instanceof Catalog) {
editorTitle = ((Catalog) selectedObject).getName();
} else if (selectedObject instanceof IRepositoryViewObject) {
editorTitle = ((ConnectionItem) ((IRepositoryViewObject) selectedObject).getProperty().getItem()).getConnection().getName();
} else if (selectedObject instanceof Connection) {
editorTitle = ((Connection) selectedObject).getName();
}
// compEditorInput.setTitle(editorTitle);
// CompareUI.openCompareEditor(compEditorInput);
// compEditorInput.hookLeftPanelContextMenu(compareEachOther);
// compEditorInput.hookToolBar(compareEachOther);
// }
// } catch (IOException e) {
} catch (Exception e) {
// Fichier non lisible
System.out.println(e);
assert false;
}
}
Aggregations