Search in sources :

Example 6 with ScaffoldInfo

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;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ScaffoldInfo(fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo)

Example 7 with 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());
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) ScaffoldInfo(fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo)

Example 8 with ScaffoldInfo

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;
    }
}
Also used : Transformation(fr.gouv.mindef.safran.database.transfo.Transformation) RecordingCommand(org.eclipse.emf.transaction.RecordingCommand) EObject(org.eclipse.emf.ecore.EObject) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) CDOResource(org.eclipse.emf.cdo.eresource.CDOResource) ScaffoldInfo(fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo)

Example 9 with ScaffoldInfo

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;
}
Also used : Root(org.obeonetwork.dsl.entity.Root) TableContainer(org.obeonetwork.dsl.database.TableContainer) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) Resource(org.eclipse.emf.ecore.resource.Resource) ScaffoldInfo(fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) Namespace(org.obeonetwork.dsl.environment.Namespace)

Example 10 with ScaffoldInfo

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;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) ScaffoldInfo(fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo)

Aggregations

ScaffoldInfo (fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo)11 EObject (org.eclipse.emf.ecore.EObject)7 Resource (org.eclipse.emf.ecore.resource.Resource)5 InternalEObject (org.eclipse.emf.ecore.InternalEObject)2 Transformation (fr.gouv.mindef.safran.database.transfo.Transformation)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 CDOResource (org.eclipse.emf.cdo.eresource.CDOResource)1 URI (org.eclipse.emf.common.util.URI)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 XMLResource (org.eclipse.emf.ecore.xmi.XMLResource)1 ComposedAdapterFactory (org.eclipse.emf.edit.provider.ComposedAdapterFactory)1 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)1 RecordingCommand (org.eclipse.emf.transaction.RecordingCommand)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 ISelection (org.eclipse.jface.viewers.ISelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 Session (org.eclipse.sirius.business.api.session.Session)1 DAnalysisSessionEObject (org.eclipse.sirius.viewpoint.DAnalysisSessionEObject)1 TableContainer (org.obeonetwork.dsl.database.TableContainer)1