use of fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo in project InformationSystem by ObeoNetwork.
the class ScaffoldingOperation method getScaffoldInfo.
private ScaffoldInfo getScaffoldInfo(ScaffoldType scaffoldType, EObject startingObject, EObject endingObject, Iterable<EObject> additionalObjects) {
ScaffoldInfo scaffoldInfo = ScaffoldFactory.eINSTANCE.createScaffoldInfo();
scaffoldInfo.setLeftObject(startingObject);
scaffoldInfo.setRightObject(endingObject);
for (EObject object : additionalObjects) {
scaffoldInfo.addAdditionalObjectsForTransformation(object, scaffoldType);
}
return scaffoldInfo;
}
use of fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo in project InformationSystem by ObeoNetwork.
the class AbstractSpecifyEObjectPage method setInitialInput.
public void setInitialInput(IFile file, ScaffoldType scaffoldType) {
if (file == null)
return;
// Check if the file is a ScaffoldInfo model
if ("scaffold".equals(file.getFileExtension())) {
Resource scaffoldResource = loadResource(file.getFullPath().toString());
if (scaffoldResource.getContents().isEmpty() == false) {
EObject scaffoldRoot = scaffoldResource.getContents().get(0);
if (scaffoldRoot instanceof ScaffoldInfo) {
ScaffoldInfo scaffoldInfo = (ScaffoldInfo) scaffoldRoot;
EObject object = (sourcePage == true) ? scaffoldInfo.getStartingObjectForTransformation(scaffoldType) : scaffoldInfo.getEndingObjectForTransformation(scaffoldType);
setInitialModelFilename(object.eResource().getURI().toPlatformString(true));
selectedElementURI = EcoreUtil.getURI(object);
}
}
} else if (Arrays.asList(getFileExtensions()).contains(file.getFileExtension())) {
// Check if the file extension is allowed
setInitialModelFilename(file.getFullPath().toString());
}
}
use of fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo in project InformationSystem by ObeoNetwork.
the class ScaffoldingOperation method execute.
@Override
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
if (scaffoldInfo.eResource() == null) {
// We have to create a scaffold model
Resource scaffoldResource = createScaffoldResource();
EObject newInfo = scaffoldResource.getContents().get(0);
if (newInfo instanceof ScaffoldInfo) {
scaffoldInfo = (ScaffoldInfo) newInfo;
}
}
final Transformation transformation = createTransformation();
try {
RecordingCommand transformCommand = new RecordingCommand(session.getTransactionalEditingDomain(), "Scaffolding transformation") {
@Override
protected void doExecute() {
success = transformation.transform(scaffoldInfo, scaffoldType);
}
};
session.getTransactionalEditingDomain().getCommandStack().execute(transformCommand);
} catch (RuntimeException e) {
logError("An error occured during the transformation", e);
return;
}
}
use of fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo 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 fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo in project InformationSystem by ObeoNetwork.
the class AbstractTransformationTest method buildScaffoldInfo.
private ScaffoldInfo buildScaffoldInfo(ScaffoldType transformationKind, URI inputModel, URI outputModel, Iterable<URI> references) {
EObject inputRoot = getRootObject(inputModel);
EObject outputRoot = getRootObject(outputModel);
Collection<EObject> additionalObjects = getAdditionalObjects(references);
ScaffoldInfo scaffoldInfo = ScaffoldFactory.eINSTANCE.createScaffoldInfo();
scaffoldInfo.setStartingObjectForTransformation(inputRoot, transformationKind);
scaffoldInfo.setEndingObjectForTransformation(outputRoot, transformationKind);
scaffoldInfo.clearAdditionalObjectsForTransformation(transformationKind);
for (EObject additionalObject : additionalObjects) {
scaffoldInfo.addAdditionalObjectsForTransformation(additionalObject, transformationKind);
}
return scaffoldInfo;
}
Aggregations