Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [EML] Standalone: Match Trace from other module
[EML] Standalone: Match Trace from other module [message #730197] Tue, 27 September 2011 20:56 Go to next message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 240
Registered: October 2009
Location: Mexico
Senior Member

Hello,

I am trying to get a stand alone Merge to work. In my case I have a stand alone ECL and a stand alone EML class, which use the respective Epsilon modules. In both cases the initialization procedure is similar: add the correct ecl/eml source file, load the required models, execute the module.

I first use my ECLExecutor to obtain the match trace of two models according to the provided ecl rules. I save this match trace so I an then feed it to my EMLExecutor.

In my EMLExecutor implementation I have added a method to add the match trace:

public void setMatchTrace(Object matchTrace) throws ExecutorException {
		
	if(matchTrace.getClass() != MatchTrace.class) {
			throw new ExecutorException("Match trace is not of the correct type (org.eclipse.epsilon.ecl.trace.MatchTrace");
	}
	if(module == null)
		module = createModule();
	EmlContext context = (EmlContext) module.getContext();
	context.setMatchTrace((MatchTrace)matchTrace);
}

which I call and pass the match trace returned by my ECLExecutor. I add the models to my EMLExecutor and execute it. It all seems to go fine until I look at the merged model, which is not the expected model (compared to the one obtained from running the same rules in an ant).

Debugging my application and looking at the Match Trace and EML module I think I have found the cause of the merge not working as expected. In the MatchTrace, the a match for a an element called "System" references to elements of Type Structural, with ids 547 and 222. However, when I look at the models loaded in the EML module, the "System" elements that are supposed to match have ids 481 and 591.

If ids are used to identify matches then I guess this will never work. Would the solution be somehow reuse the models in the ECL module in the EML module? Like asking the ecl context for the list of models and passing them to the eml context?

Thanks,

Horacio


Horacio Hoyos Rodriguez
Kinori Tech
Need professional support for Epsilon, EMF?
Go to: https://kinori.tech
Re: [EML] Standalone: Match Trace from other module [message #730929 is a reply to message #730197] Thu, 29 September 2011 14:51 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 240
Registered: October 2009
Location: Mexico
Senior Member

Hello,

I tried my idea and the result was worst.. so I guess my reasoning is not completely correct.

Doing some more tests (with my initial approach) I found out that when called from my stand alone classes the equivalents() methods all return empty sequences. I am pretty sure this has something to do with the context.. but I can't tell what. Any insights are welcome!

Regards,

Horacio


Horacio Hoyos Rodriguez
Kinori Tech
Need professional support for Epsilon, EMF?
Go to: https://kinori.tech
Re: [EML] Standalone: Match Trace from other module [message #731308 is a reply to message #730929] Fri, 30 September 2011 15:18 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 240
Registered: October 2009
Location: Mexico
Senior Member

Hello,

I finally got it working! I took a look at the workflow epsilon task classes (since they do work) and got some ideas from there. I think it is both a context and match trace trick. So here is how it worked for me:

1. If your merge uses transformation rules to merge unmatched elements load the models for the ecl module with the alias used in these rules:
eclExecutor.addSourceModel("hilesS", structureModel,  URI.createURI("http://hiles.uniandes.edu.co/1.0/HiLeS"), Arrays.asList("hilesSB"));
eclExecutor.addSourceModel("hilesB", behaviorModel,  URI.createURI("http://hiles.uniandes.edu.co/1.0/HiLeS"), Arrays.asList("hilesSB"));


2. In the eml module, load the match trace that resulted form the ecl module, looking at the ant tasks I added a call to the getReduced method (don't really know what this does)
Object matchTrace = eclExecutor.getResult();
emlExecutor.setMatchTrace(matchTrace);

ant the setMatchTrace method
public void setMatchTrace(Object matchTrace) throws ExecutorException {
		
    if(matchTrace.getClass() != MatchTrace.class) {
        throw new ExecutorException("Match trace is not of the correct type (org.eclipse.epsilon.ecl.trace.MatchTrace");
    }
    if(module == null)
        module = createModule();
    EmlContext context = (EmlContext) module.getContext();
    context.setMatchTrace(((MatchTrace)matchTrace).getReduced());
}

3. In the eml module load the models used in the ecl module, i.e. get the models from the ecl module and load them to the eml context:
List<IModel> models = eclExecutor.getModels();
emlExecutor.addContextModels(models);

and the addContextModels (EmlExecutor)
public void addContextModels(List<IModel> models) {
    for(IModel model : models)
        this.module.getContext().getModelRepository().addModel(model);
}


4. Execute the eml module

-----

For some reason, I guess some magic behavior of emf models (probably regarding the id given to elements as mentioned in my first entry), if you dispose the models in the ecl module and load them again (using the createEmfModel method) the merge does not work.

I hope someone finds this useful. I will be happy to send the executors source code if any one needs them (under epsilon license).

Best regards,

Horacio


Horacio Hoyos Rodriguez
Kinori Tech
Need professional support for Epsilon, EMF?
Go to: https://kinori.tech
Re: [EML] Standalone: Match Trace from other module [message #731856 is a reply to message #731308] Mon, 03 October 2011 10:33 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Hi Horacio,

The reason why merge doesn't work when you dispose and reload the models is because the match trace references EObjects, and when the models are reloaded new EObjects are created. Although the new EObjects refer to the same elements in the XMI, they are not equal to the EObjects in the match trace as far as Java is concerned.

Cheers,
Dimitris
Re: [EML] Standalone: Match Trace from other module [message #1727719 is a reply to message #731308] Fri, 25 March 2016 17:39 Go to previous message
Mohammadreza Sharbaf is currently offline Mohammadreza SharbafFriend
Messages: 22
Registered: February 2016
Junior Member

Hi Horacio

I am trying to get a standalone Merge to work and see your post. Can you send to your executors source code or sample of your standalone project?

Best regards,
Mohammadreza
Previous Topic:EvlUnsatisfiedConstraint - only UnsatisfiedConstraint sources available
Next Topic:assign a EEnumLiteral
Goto Forum:
  


Current Time: Fri Mar 29 11:20:16 GMT 2024

Powered by FUDForum. Page generated in 0.03257 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top