use of org.obeonetwork.dsl.database.DataBase in project InformationSystem by ObeoNetwork.
the class DataBasePropertiesEditionComponent 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 DataBase dataBase = (DataBase) elt;
final DataBasePropertiesEditionPart dataBasePart = (DataBasePropertiesEditionPart) editingPart;
// init values
if (isAccessible(DatabaseViewsRepository.DataBase_.Properties.name))
dataBasePart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, dataBase.getName()));
if (isAccessible(DatabaseViewsRepository.DataBase_.Properties.url))
dataBasePart.setUrl(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, dataBase.getUrl()));
if (isAccessible(DatabaseViewsRepository.DataBase_.Properties.comments))
dataBasePart.setComments(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, dataBase.getComments()));
if (isAccessible(DatabaseViewsRepository.DataBase_.Properties.usedLibraries)) {
usedLibrariesSettings = new ReferencesTableSettings(dataBase, TypesLibraryPackage.eINSTANCE.getTypesLibraryUser_UsedLibraries());
dataBasePart.initUsedLibraries(usedLibrariesSettings);
}
if (isAccessible(DatabaseViewsRepository.DataBase_.Properties.usedLibraries)) {
dataBasePart.addFilterToUsedLibraries(new ViewerFilter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof EObject)
return (!dataBasePart.isContainedInUsedLibrariesTable((EObject) element));
return element instanceof String && element.equals("");
}
});
dataBasePart.addFilterToUsedLibraries(new EObjectStrictFilter(TypesLibraryPackage.Literals.TYPES_LIBRARY));
// Start of user code for additional businessfilters for usedLibraries
// End of user code
}
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
use of org.obeonetwork.dsl.database.DataBase 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.DataBase 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);
}
}
}
}
use of org.obeonetwork.dsl.database.DataBase in project InformationSystem by ObeoNetwork.
the class DatabaseGen method computeTargetFolder.
private File computeTargetFolder(File folder, Comparison comparison) {
String folderName = "";
String dbtypeFolderName = "";
if (comparison != null) {
DataBase database = (DataBase) comparison.getMatches().get(0).getLeft();
TypesLibrary physicalTypesLibrary = new TypesServices().getPhysicalTypesLibrary(database);
if (physicalTypesLibrary instanceof NativeTypesLibrary) {
dbtypeFolderName += ((NativeTypesLibrary) physicalTypesLibrary).getName() + "/";
} else if (physicalTypesLibrary instanceof UserDefinedTypesLibrary) {
dbtypeFolderName += ((UserDefinedTypesLibrary) physicalTypesLibrary).getName() + "/";
}
folderName = database.getName();
if (database.getSchemas().size() > 0) {
Schema schema = database.getSchemas().get(0);
folderName = schema.getName();
}
folderName += "-";
}
java.sql.Timestamp timeStampDate = new Timestamp(System.currentTimeMillis());
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd/HH-mm-ss");
String timestamp = formatter.format(timeStampDate);
folderName += timestamp;
File targetFolder = new File(folder.getAbsolutePath() + "/" + dbtypeFolderName + folderName);
return targetFolder;
}
use of org.obeonetwork.dsl.database.DataBase in project InformationSystem by ObeoNetwork.
the class TestReverse method testMySQL.
@Test
public void testMySQL() {
DataSource dataSource = new DataSource("northwind", null);
dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/northwind");
dataSource.setJdbcUsername("root");
dataSource.setJdbcPassword(null);
dataSource.setVendor("MySQL-5");
DataBase database = DatabaseReverser.reverse(dataSource, new MultiDataBaseQueries(), null);
DataBase databaseRef = loadModel("resources/mysql/outputRef.database", "pathmap://NativeDBTypes/MySQL-5");
checkEquality(database, databaseRef);
}
Aggregations