use of org.obeonetwork.dsl.database.Schema in project InformationSystem by ObeoNetwork.
the class SchemaPropertiesEditionComponent method initPart.
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
* org.eclipse.emf.ecore.resource.ResourceSet)
*/
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
setInitializing(true);
if (editingPart != null && key == partKey) {
editingPart.setContext(elt, allResource);
final Schema schema = (Schema) elt;
final SchemaPropertiesEditionPart schemaPart = (SchemaPropertiesEditionPart) editingPart;
// init values
if (isAccessible(DatabaseViewsRepository.Schema.Properties.name))
schemaPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, schema.getName()));
if (isAccessible(DatabaseViewsRepository.Schema.Properties.comments))
schemaPart.setComments(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, schema.getComments()));
// init filters
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
use of org.obeonetwork.dsl.database.Schema in project InformationSystem by ObeoNetwork.
the class GenerateSQLFromDatabaseHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
// We have to compute an emfdiff file from a comparison with an empty database
// ---
// First let's create an empty model containing only
Resource resource = new DatabaseResourceImpl(URI.createURI("memory:/empty_database"));
TableContainer rootContainer = getFirstTableContainer(selection);
TableContainer newContainer = null;
if (rootContainer instanceof DataBase) {
newContainer = copyDatabase((DataBase) rootContainer);
resource.getContents().add(newContainer);
} else if (rootContainer instanceof Schema) {
newContainer = copySchema((Schema) rootContainer);
resource.getContents().add(newContainer);
}
// Then compare the two models
Comparison comparison = null;
try {
comparison = DatabaseCompareService.compare(rootContainer, newContainer);
} catch (Exception e) {
}
// The diff model can now be used to generate the SQL script
if (comparison != null) {
ExportAsSQLScriptsAction action = new ExportAsSQLScriptsAction();
action.exportComparison(comparison);
}
return null;
}
use of org.obeonetwork.dsl.database.Schema in project InformationSystem by ObeoNetwork.
the class GenerateSQLFromDatabaseHandler method copySchema.
private Schema copySchema(Schema schema) {
Schema newSchema = DatabaseFactory.eINSTANCE.createSchema();
newSchema.setName(schema.getName());
return newSchema;
}
use of org.obeonetwork.dsl.database.Schema in project InformationSystem by ObeoNetwork.
the class MpdToMldBidiRules method createSchema.
private void createSchema(Schema sourceSchema, DataBase targetDatabase) {
Schema targetSchema = getFromInputTraceabilityMap(sourceSchema, DatabasePackage.Literals.SCHEMA);
if (targetSchema != null) {
// Reuse existing schema
} else {
// We have to create a new schema
targetSchema = DatabaseFactory.eINSTANCE.createSchema();
targetDatabase.getSchemas().add(targetSchema);
}
addToOutputTraceability(sourceSchema, targetSchema);
targetSchema.setName(sourceSchema.getName());
targetSchema.setComments(sourceSchema.getComments());
createTables(sourceSchema, targetSchema);
createViews(sourceSchema, targetSchema);
}
use of org.obeonetwork.dsl.database.Schema in project InformationSystem by ObeoNetwork.
the class MpdToMldBidiRules method processTableContainer.
private void processTableContainer(TableContainer sourceTableContainer, TableContainer targetTableContainer) {
createTables(sourceTableContainer, targetTableContainer);
if (sourceTableContainer instanceof DataBase) {
DataBase sourceDatabase = (DataBase) sourceTableContainer;
for (Schema sourceSchema : sourceDatabase.getSchemas()) {
if (targetTableContainer instanceof DataBase) {
DataBase targetDatabase = (DataBase) targetTableContainer;
createSchema(sourceSchema, targetDatabase);
} else {
createTables(sourceSchema, targetTableContainer);
}
}
}
}
Aggregations