use of org.obeonetwork.dsl.database.TableContainer in project InformationSystem by ObeoNetwork.
the class AbtractTest method diff.
protected Comparison diff(String left, String right) throws Exception {
ResourceSet rs = new ResourceSetImpl();
standaloneBootStrap(rs);
InputStream leftStream = getClass().getClassLoader().getResourceAsStream(left);
assertNotNull(leftStream);
InputStream rightStream = getClass().getClassLoader().getResourceAsStream(right);
assertNotNull(rightStream);
EObject rootSource = ModelUtils.load(leftStream, "left.database", rs);
assertNotNull(rootSource);
EObject rootTarget = ModelUtils.load(rightStream, "right.database", rs);
assertNotNull(rootTarget);
assertTrue(rootSource instanceof TableContainer);
assertTrue(rootTarget instanceof TableContainer);
return diff((TableContainer) rootSource, (TableContainer) rootTarget);
}
use of org.obeonetwork.dsl.database.TableContainer in project InformationSystem by ObeoNetwork.
the class AbstractSQLGenerationTest method loadTableContainerFromFile.
private TableContainer loadTableContainerFromFile(String folderName, String filename) {
URI uri = URI.createPlatformPluginURI(INPUT_FOLDER + folderName + "/" + filename, true);
ResourceSet set = new ResourceSetImpl();
Resource resource = set.getResource(uri, true);
for (EObject eObject : resource.getContents()) {
if (eObject instanceof TableContainer) {
return (TableContainer) eObject;
}
}
return null;
}
use of org.obeonetwork.dsl.database.TableContainer in project InformationSystem by ObeoNetwork.
the class EntityToMLD method getTargetTableContainer.
protected TableContainer getTargetTableContainer(Namespace namespace) {
if (!cacheNamespaceToTableContainer.containsKey(namespace)) {
TableContainer target = null;
// First we look for a schema with the right name
String schemaName = getSchemaNameFromNamespace(namespace);
// Look for a schema with the right name
target = getSchemaByName(schemaName);
if (target == null) {
if (defaultTarget instanceof Schema) {
if (((Schema) defaultTarget).getTables().isEmpty()) {
// We consider the schema is contained is a newly created model
// we can change its name
target = (Schema) defaultTarget;
target.setName(schemaName);
}
} else if (defaultTarget instanceof DataBase) {
DataBase database = (DataBase) defaultTarget;
if (database.getSchemas().size() == 1 && database.getSchemas().get(0).getTables().isEmpty()) {
target = database.getSchemas().get(0);
target.setName(schemaName);
}
}
// We create a schema if the target object is a database
if (target == null) {
target = createSchema(schemaName);
}
// Last solution
if (target == null && defaultTarget instanceof TableContainer) {
target = (TableContainer) defaultTarget;
}
}
cacheNamespaceToTableContainer.put(namespace, target);
}
// Ensure schema comments are retrieved from namespace
TableContainer tableContainer = cacheNamespaceToTableContainer.get(namespace);
tableContainer.setComments(namespace.getDescription());
return tableContainer;
}
use of org.obeonetwork.dsl.database.TableContainer in project InformationSystem by ObeoNetwork.
the class AbstractTransformationTest method getRootObject.
private EObject getRootObject(URI modelURI) {
ResourceSet set = getResourceSet();
Resource resource = set.getResource(modelURI, true);
for (Iterator<EObject> it = resource.getAllContents(); it.hasNext(); ) {
EObject object = it.next();
if (object instanceof TableContainer || object instanceof Root || object instanceof Namespace || object instanceof ScaffoldInfo) {
return object;
}
}
return null;
}
use of org.obeonetwork.dsl.database.TableContainer in project InformationSystem by ObeoNetwork.
the class ViewChangeBuilder method handleAddChange.
@Override
protected Diff handleAddChange(ReferenceChange change) {
Comparison comparison = change.getMatch().getComparison();
TableContainer tableContainer = (TableContainer) change.getMatch().getRight();
View view = (View) change.getValue();
return createAddView(comparison, tableContainer, view, change);
}
Aggregations