Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Problem xmi reference to another xmi
[Acceleo] Problem xmi reference to another xmi [message #985539] Thu, 15 November 2012 08:32 Go to next message
Guillaume Lincé is currently offline Guillaume Lincé
Messages: 6
Registered: November 2012
Junior Member
Hello,

As I have already explained in this topic (http://www.eclipse.org/forums/index.php/t/430863/), we use Acceleo to generate html from two models (TVL and FCSS). The FCSS xmi has references to the TVL xmi. We load the TVL model as an argument to the project then load the FCSS model programmatically (using an invoke to a java method). We have to load the TVL xmi firt since the FCSS model is optional. We managed to resolve the references from the FCSS XMI to the TVL XMI. However, it seems that the acceleo project uses another instance of the TVL xmi and therefore the references used in FCSS XMI instance don't match with TVL XMI elements loaded by Acceleo. For example, when we try to compare a Hierarchical_Feature (a model element in TVL) and the reference to this model element in FCSS:

<p>reference: [feature.feature.head/]</p>
<p>hierarchical: [aHierarchicalFeature/]</p>
<p>Equals? [feature.feature.head = aHierarchicalFeature/]</p>


We get this result:

reference: be.ac.fundp.info.tVL.impl.Hierarchical_FeatureImpl@66fe372d (name: SWR) (optional: false)

hierarchical: be.ac.fundp.info.tVL.impl.Hierarchical_FeatureImpl@3f328d2e (name: SWR) (optional: false)

Equals? false


As you can see, they are not equal although they should be.

What can we do to solve this issue?

Thanks for you help,

Guillaume
Re: [Acceleo] Problem xmi reference to another xmi [message #985573 is a reply to message #985539] Thu, 15 November 2012 08:56 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4025
Registered: July 2009
Senior Member
Hi

You need to make sure that you share the same ResourceSet to avoid
reloading. If in doubt, instrument XMLResource to see where the extra
resource is created.

Regards

Ed Willink


On 15/11/2012 13:32, Guillaume Lincé wrote:
> Hello,
>
> As I have already explained in this topic
> (http://www.eclipse.org/forums/index.php/t/430863/), we use Acceleo to
> generate html from two models (TVL and FCSS). The FCSS xmi has
> references to the TVL xmi. We load the TVL model as an argument to the
> project then load the FCSS model programmatically (using an invoke to
> a java method). We have to load the TVL xmi firt since the FCSS model
> is optional. We managed to resolve the references from the FCSS XMI to
> the TVL XMI. However, it seems that the acceleo project uses another
> instance of the TVL xmi and therefore the references used in FCSS XMI
> instance don't match with TVL XMI elements loaded by Acceleo. For
> example, when we try to compare a Hierarchical_Feature (a model
> element in TVL) and the reference to this model element in FCSS:
>
>
> <p>reference: [feature.feature.head/]</p>
> <p>hierarchical: [aHierarchicalFeature/]</p>
> <p>Equals? [feature.feature.head = aHierarchicalFeature/]</p>
>
>
> We get this result:
>
>
> reference: be.ac.fundp.info.tVL.impl.Hierarchical_FeatureImpl@66fe372d
> (name: SWR) (optional: false)
>
> hierarchical:
> be.ac.fundp.info.tVL.impl.Hierarchical_FeatureImpl@3f328d2e (name:
> SWR) (optional: false)
>
> Equals? false
>
>
> As you can see, they are not equal although they should be.
>
> What can we do to solve this issue?
>
> Thanks for you help,
>
> Guillaume
Re: [Acceleo] Problem xmi reference to another xmi [message #985680 is a reply to message #985539] Thu, 15 November 2012 11:44 Go to previous messageGo to next message
Guillaume Lincé is currently offline Guillaume Lincé
Messages: 6
Registered: November 2012
Junior Member
Thanks for your reply. Since the problem comes from the ResourceSet, I tried to load both models in the same java service with the same ResourceSet. I get both models and the references match de TVL model elements. However, as this service returns an ArrayList of EObject, I don't know how to get it when invoking the java service in acceleo.
Here is the query:

[query public getBothModels(filePathTVL:String,filePathFCSS:String) :Sequence(EObject)
	= invoke('TVLtoHTML5.main.FCSSModelGetter', 'getTVLModel(java.lang.String,java.lang.String)', Sequence{filePathTVL,filePathFCSS}) /]


As you can see, I try to get it as a Sequence but it doesn't work, the result is empty. I also tried with a Collection, Bag, OrderedSet and Set without success. Is there a type in acceleo that matches the ArrayList? Or should I use another type of collection in my java service?

Thanks,

Guillaume
Re: [Acceleo] Problem xmi reference to another xmi [message #985684 is a reply to message #985680] Thu, 15 November 2012 11:54 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4025
Registered: July 2009
Senior Member
Hi

I've successfully used HashSet for an OCL Set, LinkedHashSet for an OCL
OrderedSet. ARe you sure you're using the right ArrayList?

No idea what you mean by the acceleo service.

You don't provide the Java function or the Acceleo error message so
those cannot be commented on.

Generally these problems are always a declaration mismatch;
unfortunately, the Bug requesting Acceleo diagnosis of inconsistent
declarations is still open.

Regards

Ed Willink


On 15/11/2012 16:44, Guillaume Lincé wrote:
> Thanks for your reply. Since the problem comes from the ResourceSet, I
> tried to load both models in the same java service with the same
> ResourceSet. I get both models and the references match de TVL model
> elements. However, as this service returns an ArrayList of EObject, I
> don't know how to get it when invoking the java service in acceleo.
> Here is the query:
>
>
> [query public getBothModels(filePathTVL:String,filePathFCSS:String)
> :Sequence(EObject)
> = invoke('TVLtoHTML5.main.FCSSModelGetter',
> 'getTVLModel(java.lang.String,java.lang.String)',
> Sequence{filePathTVL,filePathFCSS}) /]
>
>
> As you can see, I try to get it as a Sequence but it doesn't work, the
> result is empty. I also tried with a Collection, Bag, OrderedSet and
> Set without success. Is there a type in acceleo that matches the
> ArrayList? Or should I use another type of collection in my java service?
>
> Thanks,
>
> Guillaume
>
Re: [Acceleo] Problem xmi reference to another xmi [message #985727 is a reply to message #985539] Thu, 15 November 2012 15:26 Go to previous messageGo to next message
Guillaume Lincé is currently offline Guillaume Lincé
Messages: 6
Registered: November 2012
Junior Member
I just tried a HashSet for an OCL Set and it's working. Actually, I had an error remaining in my query where I invoked the java service... Didn't see it before.

Thanks again,

Guillaume
Re: [Acceleo] Problem xmi reference to another xmi [message #985806 is a reply to message #985727] Fri, 16 November 2012 03:58 Go to previous message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1623
Registered: July 2009
Senior Member
Guillaume,

A question would be : why are you manually loading the second model through a Java service? As long as EMF can resolve the reference from one model to the next (the URIs are good), Acceleo will simply follow that reference (which is what it does since you give an example where you get the results of both (java service and acceleo navigation) printed correctly.

Please make sure that you really need to load your model twice. Otherwise, simply reuse the one that's loaded by EMF through simple navigation. When you look at the content of your resource set, you should only have a single resource for a given URI, which is not the case in your example if I am not mistaken on what you are doing. Having multiple resources loaded for one URI is much too error prone (as you could realize with the "==" returning false...).

Laurent Goubet
Obeo
Previous Topic:[Acceleo] generation exception after deploy
Next Topic:NPE in AcceleoGenerator
Goto Forum:
  


Current Time: Wed Aug 20 02:53:39 EDT 2014

Powered by FUDForum. Page generated in 0.01953 seconds