Search in sources :

Example 1 with IModelResource

use of org.iobserve.model.persistence.IModelResource in project iobserve-analysis by research-iobserve.

the class ModelSnapshotWriter method loadModel.

private <T extends EObject> Resource loadModel(final ResourceSet resourceSet, final IModelResource<T> resourceHandler, final Class<T> clazz, final EClass eClass, final EPackage ePackage, final File baseDirectory) throws DBException {
    final T model = resourceHandler.getModelRootNode(clazz, eClass);
    final URI writeModelURI = URI.createFileURI(String.format("%s%sjpetstore", baseDirectory.toPath().toAbsolutePath().toString(), File.separator));
    final Resource resource = resourceSet.createResource(writeModelURI.appendFileExtension(ePackage.getName()));
    resource.getContents().add(model);
    return resource;
}
Also used : IModelResource(org.iobserve.model.persistence.IModelResource) Resource(org.eclipse.emf.ecore.resource.Resource) URI(org.eclipse.emf.common.util.URI)

Example 2 with IModelResource

use of org.iobserve.model.persistence.IModelResource in project iobserve-analysis by research-iobserve.

the class ModelNeo4JUtil method resolveAll.

public static synchronized void resolveAll(final ResourceSet resourceSet, final IModelResource<?>... modelResources) {
    final EList<Resource> resources = resourceSet.getResources();
    for (int i = 0; i < resources.size(); i++) {
        final Resource resource = resources.get(i);
        final TreeIterator<EObject> elements = resource.getAllContents();
        while (elements.hasNext()) {
            final EObject object = elements.next();
            ModelNeo4JUtil.resolve(object, modelResources);
        }
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IModelResource(org.iobserve.model.persistence.IModelResource) Resource(org.eclipse.emf.ecore.resource.Resource)

Aggregations

Resource (org.eclipse.emf.ecore.resource.Resource)2 IModelResource (org.iobserve.model.persistence.IModelResource)2 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1