use of org.obeonetwork.dsl.database.sqlgen.DatabaseGen in project InformationSystem by ObeoNetwork.
the class DatabaseEvolutionScriptGenerationTestSuite method generateEvolutionScripts.
private List<File> generateEvolutionScripts(Comparison dbevolution) {
final File targetBaseFolder = new File("sql-gen/");
System.out.println("Generating to: " + targetBaseFolder.getAbsolutePath());
// // Initialize a resourceset to be sure the model is contained within
// a
// // resource (or Acceleo will throw a NPE)
// ResourceSet set = new ResourceSetImpl();
// Resource resource = new ResourceImpl();
// resource.getContents().add(dbevolution);
// set.getResources().add(resource);
List<File> generatedFiles = new ArrayList<>();
try {
DatabaseGen databaseGen = new DatabaseGen(dbevolution, targetBaseFolder, Collections.emptyList());
databaseGen.doGenerate(new BasicMonitor());
// for (String maybeGeneratedFileName : DatabaseGen.SQL_FILES) {
// File maybeGeneratedFile = new File(databaseGen.getTargetFolder(),
// maybeGeneratedFileName);
// if (maybeGeneratedFile.exists()) {
// generatedFiles.add(maybeGeneratedFile);
// }
// }
generatedFiles.add(new File(databaseGen.getTargetFolder(), "all.sql"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return generatedFiles;
}
use of org.obeonetwork.dsl.database.sqlgen.DatabaseGen in project InformationSystem by ObeoNetwork.
the class AbstractSQLGenerationTest method assertGenerationEquals.
public void assertGenerationEquals(TableContainer source, TableContainer target, String expectationsFolderPath) {
File targetFolder = createTargetFolder();
File expectationsFolder = createExpectationsFolder(expectationsFolderPath);
try {
// Compare
Comparison comparison = DatabaseCompareService.compare(source, target);
// and generate sql scripts based on the comparison
DatabaseGen generator = new DatabaseGen(comparison, targetFolder, Collections.emptyList());
generator.doGenerate(new BasicMonitor());
} catch (Exception e) {
deleteFile(targetFolder);
deleteFile(expectationsFolder);
fail("Comparison failed with an exception : " + e.getMessage());
}
compareFolders(targetFolder, expectationsFolder);
// Delete targetFolder and expectationsFolder
deleteFile(targetFolder);
deleteFile(expectationsFolder);
}
use of org.obeonetwork.dsl.database.sqlgen.DatabaseGen in project InformationSystem by ObeoNetwork.
the class ExportAsSQLScriptsAction method exportComparison.
public void exportComparison(final Comparison comparison) {
final IResource containingFolder = getContainingFolder(comparison);
if (containingFolder == null) {
// No containing folder means the user aborted the export action
return;
}
final File targetFolder = getTargetfolder(containingFolder);
if (targetFolder == null) {
return;
}
// Initialize a resourceset to be sure the model is contained within a resource (or Acceleo will throw a NPE)
ResourceSet set = new ResourceSetImpl();
Resource resource = new ResourceImpl();
resource.getContents().add(comparison);
set.getResources().add(resource);
WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
@Override
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
try {
DatabaseGen databaseGen = new DatabaseGen(comparison, targetFolder, Collections.emptyList());
databaseGen.doGenerate(new BasicMonitor());
} catch (IOException e) {
MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "SQL Generation", "A problem occured during the generation. See Error Log view for more details.");
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
}
// Refreshing the target folder
try {
containingFolder.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (CoreException e) {
IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
Activator.getDefault().getLog().log(status);
}
}
};
// Launch operation
try {
PlatformUI.getWorkbench().getProgressService().run(true, false, operation);
} catch (Exception e) {
MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "SQL Generation", "A problem occured during the generation. See Error Log view for more details.");
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
}
}
Aggregations