JPL-IMCE / gov.nasa.jpl.imce.oml

Ontology Modeling Language (OML) Workbench
14 stars 1 forks source link

OMLZipResourceFactory instantiation and OMLZipResource.load() does not handle 'platform' URI #252

Closed dyates closed 6 years ago

dyates commented 6 years ago
sjiherzig commented 6 years ago

Please have a look at the unit tests - OMLZipResourceFactory no longer needs to be registered. Simply use the OMLStandaloneSetup.doSetup(). As a resource set, it is best to use an XtextResourceSet for loading both .omlzip and .oml files - you may need to pass the content type when calling getResource(...) on the resource set (content-type: "oml", "omlzip", etc. (it's the second argument)). For saving, you may still want to use OMLZipResourceSet.

Regarding the second issue: a workaround would be to resolve the platform URI to a file URI. This is tricky, but not impossible. I'm not sure whether this works, but you could also try to add the platform URI to the catalog, and then use a http:// scheme to resolve the file.

NicolasRouquette commented 6 years ago

Please include a stack trace & version of the software corresponding to the problem you're reporting about.

Regarding the first point, I struggled for a while to get the OMLZipResource & its factory to work. OMLZipResourceFactory uses an injected argument constructor just like org.eclipse.xtext.resource.XtextResourceFactory does.

This works with programmatic API as @sjiherzig mentions; there are several test cases demonstrating that. In the Eclipse UI, there is a different phenomena gong on with the Eclipse builder; or more precisely, either the modeling and/or xtext resource builder. It is unclear to why there are two different factory patterns in Eclipse.

I am not opposed to switching to a no-argument factory; however, it remains to be demonstrated with appropriate unit tests that this works for both programmatic API use as we've done in the unit tests and with new UI unit tests that have yet to be written to replicate the original issue.

The second point is a related to the first; that is, in the context of the Eclipse UI w/ resource builders, either the modeling or xtext builder or both attempt to load an *.omlzip resource using an Eclipse platform-scheme URI. Had you included a stack trace, I believe it would point to OMLZipResource.load(Map<?,?> options) which attempts to determine whether the resource uri needs to be resolved through the catalog or not. Unfortunately, Eclipse' platform-scheme URI returns false for the local file test: if (uri.file) .... A third case is needed for Eclipse' platform and convert that URI into a local file location.