Search in sources :

Example 1 with TypesLibraryResourceFactoryImpl

use of org.obeonetwork.dsl.typeslibrary.util.TypesLibraryResourceFactoryImpl in project InformationSystem by ObeoNetwork.

the class TestReverse method loadModel.

private static DataBase loadModel(String databaseTestPluginRelativePath, String typesLibraryPathmapUri) {
    URI uri = URI.createFileURI(databaseTestPluginRelativePath);
    DatabaseResourceFactoryImpl databaseResourceFactory = new DatabaseResourceFactoryImpl();
    Resource resourceDatabase = databaseResourceFactory.createResource(uri);
    TypesLibraryResourceFactoryImpl typesLibraryresourceFactory = new TypesLibraryResourceFactoryImpl();
    Resource typeResource = typesLibraryresourceFactory.createResource(URI.createURI(typesLibraryPathmapUri));
    ResourceSet rs = new ResourceSetImpl();
    rs.getResources().add(resourceDatabase);
    rs.getResources().add(typeResource);
    try {
        Map options = rs.getLoadOptions();
        options.put(DatabasePackage.eINSTANCE.getNsURI(), DatabasePackage.eINSTANCE);
        options.put(TypesLibraryPackage.eINSTANCE.getNsURI(), TypesLibraryPackage.eINSTANCE);
        resourceDatabase.load(options);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return (DataBase) resourceDatabase.getContents().get(0);
}
Also used : DatabaseResourceFactoryImpl(org.obeonetwork.dsl.database.util.DatabaseResourceFactoryImpl) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) Resource(org.eclipse.emf.ecore.resource.Resource) TypesLibraryResourceFactoryImpl(org.obeonetwork.dsl.typeslibrary.util.TypesLibraryResourceFactoryImpl) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI) Map(java.util.Map) DataBase(org.obeonetwork.dsl.database.DataBase)

Aggregations

Map (java.util.Map)1 URI (org.eclipse.emf.common.util.URI)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)1 DataBase (org.obeonetwork.dsl.database.DataBase)1 DatabaseResourceFactoryImpl (org.obeonetwork.dsl.database.util.DatabaseResourceFactoryImpl)1 TypesLibraryResourceFactoryImpl (org.obeonetwork.dsl.typeslibrary.util.TypesLibraryResourceFactoryImpl)1