eMoflon / emoflon-core

Core components of eMoflon
Other
5 stars 1 forks source link

SmartEMF: Model saving bug #136

Open maxkratz opened 2 years ago

maxkratz commented 2 years ago

Currently, there is a bug in the SmartEMF implementation that breaks the model saving functionality:

Exception in thread "main" java.lang.NullPointerException
    at java.base/java.io.File.<init>(File.java:278)
    at org.emoflon.smartemf.persistence.XmiParserUtil.pathOfProjectInWorkspace(XmiParserUtil.java:139)
    at org.emoflon.smartemf.persistence.XmiParserUtil.resolveURIToPath(XmiParserUtil.java:64)
    at org.emoflon.smartemf.persistence.SmartEMFResource.save(SmartEMFResource.java:72)

Code:

final ResourceSet rs = new ResourceSetImpl();
// SmartEMF
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi",
        new SmartEMFResourceFactoryImpl(System.getenv("WORKSPACE")));
final Resource r = rs.createResource(URI.createFileURI(path));
// Fetch model contents from eMoflon
r.getContents().add(root);
try {
    r.save(null);
} catch (final IOException e) {
    e.printStackTrace();
}

This behaviour only occurs if there is no XMI file before running the code. Current workaround: $ touch model.xmi