|
|
|
Re: Resolve EValues from a qvtotrace file [message #940978 is a reply to message #940537] |
Fri, 12 October 2012 05:37 |
Ed Merks Messages: 33224 Registered: July 2009 |
Senior Member |
|
|
Comments below.
On 11/10/2012 8:38 PM, Ed Willink wrote:
> Hi
>
> EMF will generally resolve proxies when you reference them.
>
> This is a lazy activity, so you can see unresolved proxies in the
> debugger.
>
> You can use EcoreUtil.resolveAll() to force eager resolution.
If that still doesn't work, it's good to use the debugger to examine the
resource set's resource to see which set of URIs have been loaded and
looking in the contents of each of those to see if they have contents.
If one or more don't, you can look in ResourceImpl.errors to see why the
resource failed to load.
>
> If the proxies remain, you generally have a package registration
> problem preventing loading of your models.
Well, unresolved proxies are generally caused by failure to load the
referenced resource; that may be caused by the absence of a model by
which to interpret the contents of a resource, but that's not the only
reason.
>
> Regards
>
> Ed Willink
>
> On 11/10/2012 19:12, Goood Guy wrote:
>> Hi,
>> I would like to deserialize an QVTo file and access the source and
>> the target model elements from the mappings. This is the code I've
>> got so far:
>>
>>
>> URI uriTrace = URI.createURI("testModel/testmodel.qvtotrace");
This looks like asking for trouble. If the resource contains any
relative URIs, they're not going to be resolved (URI.resolve) because
this URI is not absolute (URI.isAbsolute).
Change this to be an absolute URI. I.e.,
platform:/resource/<project>/<path-to-IFile> or file:/<path-to-io.java.File.
>> ResourceSet resourcesSet = new ResourceSetImpl();
>> Resource resource = resourcesSet.getResource(tracefileURI, true);
>> trace = (Trace) resource.getContents().get(0);
>>
>> for(TraceRecord record : trace.getTraceRecords()){
>> EMappingOperation mappingOperation = record.getMappingOperation();
>> EObject contextElement =null;
>> EObject resultElement =null;
>> try {
>> contextElement =
>> record.getContext().getContext().getValue().getModelElement();
>>
>> resultElement =
>> record.getResult().getResult().get(0).getValue().getModelElement();
>>
>>
>> } catch (NullPointerException e) {
>> //do nothing, skip record
>> }
>>
>>
>> But contextElement and resultElement always contains a
>> EObjectImpl-Object with an eProxyURI that points to the element from
>> the source/target model.
>>
>> How can I resolve the proxy? I am not sure if this is an EMF related
>> issue or QVTo specific.
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05103 seconds