Search in sources :

Example 56 with Resource

use of org.eclipse.emf.ecore.resource.Resource in project tdi-studio-se by Talend.

the class JSONRepositoryContentHandler method create.

@Override
public Resource create(IProject project, Item item, int classifierID, IPath path) throws PersistenceException {
    Resource itemResource = null;
    ERepositoryObjectType type;
    switch(classifierID) {
        case JsonPackage.JSON_FILE_CONNECTION_ITEM:
            if (item != null && item instanceof JSONFileConnectionItem) {
                type = JSONRepositoryNodeType.JSON;
                itemResource = create(project, (JSONFileConnectionItem) item, path, type);
                return itemResource;
            }
        default:
            return itemResource;
    }
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) JSONFileConnectionItem(org.talend.repository.model.json.JSONFileConnectionItem) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 57 with Resource

use of org.eclipse.emf.ecore.resource.Resource in project benchmarx by eMoflon.

the class MediniQVTFamiliesToPersonsConfig method saveModels.

/**
	 * Allows to save the current state of the source and target models
	 * 
	 * @param name : Filename 
	 */
public void saveModels(String name) {
    ResourceSet set = new ResourceSetImpl();
    set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
    URI srcURI = URI.createFileURI(RESULTPATH + "/" + name + "Family.xmi");
    URI trgURI = URI.createFileURI(RESULTPATH + "/" + name + "Person.xmi");
    Resource resSource = set.createResource(srcURI);
    Resource resTarget = set.createResource(trgURI);
    EObject colSource = EcoreUtil.copy(getSourceModel());
    EObject colTarget = EcoreUtil.copy(getTargetModel());
    resSource.getContents().add(colSource);
    resTarget.getContents().add(colTarget);
    try {
        resSource.save(null);
        resTarget.save(null);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) EObject(org.eclipse.emf.ecore.EObject) XMIResourceFactoryImpl(org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IOException(java.io.IOException) URI(org.eclipse.emf.common.util.URI)

Example 58 with Resource

use of org.eclipse.emf.ecore.resource.Resource in project benchmarx by eMoflon.

the class EMoflonFamiliesToPersons method initiateSynchronisationDialogue.

@Override
public void initiateSynchronisationDialogue() {
    BasicConfigurator.configure();
    helper = new F2PSyncHelper();
    Resource r = helper.getResourceSet().createResource(URI.createURI("sourceModel"));
    FamilyRegister familiesRoot = FamiliesFactory.eINSTANCE.createFamilyRegister();
    r.getContents().add(familiesRoot);
    // Fix default preferences (which can be overwritten)
    setConfigurator(new Configurator<Decisions>().makeDecision(Decisions.PREFER_CREATING_PARENT_TO_CHILD, true).makeDecision(Decisions.PREFER_EXISTING_FAMILY_TO_NEW, true));
    // perform batch to establish consistent starting state
    helper.setSrc(familiesRoot);
    helper.integrateForward();
    helper.setMute(true);
}
Also used : FamilyRegister(Families.FamilyRegister) Resource(org.eclipse.emf.ecore.resource.Resource) Decisions(org.benchmarx.examples.familiestopersons.testsuite.Decisions)

Aggregations

Resource (org.eclipse.emf.ecore.resource.Resource)58 URI (org.eclipse.emf.common.util.URI)23 IOException (java.io.IOException)18 IResource (org.eclipse.core.resources.IResource)11 EObject (org.eclipse.emf.ecore.EObject)10 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)10 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)9 PersistenceException (org.talend.commons.exception.PersistenceException)8 XmiResourceManager (org.talend.core.repository.utils.XmiResourceManager)8 ArrayList (java.util.ArrayList)7 CoreException (org.eclipse.core.runtime.CoreException)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 XMIResourceFactoryImpl (org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl)7 List (java.util.List)6 IProject (org.eclipse.core.resources.IProject)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 IFile (org.eclipse.core.resources.IFile)5 TalendXMIResource (org.talend.commons.runtime.model.emf.TalendXMIResource)5 ByteArrayResource (org.talend.core.model.properties.helper.ByteArrayResource)5 CwmResource (org.talend.model.emf.CwmResource)5