Extract transitive closure path from match [message #1653781] |
Fri, 06 March 2015 11:30 |
ihave question Messages: 32 Registered: November 2014 |
Member |
|
|
Hello!
For validation purposes I check wether algebraic loops are present within the model using transitive closoure ( linksTo+(A,A) )
How do I use the getPathFinder/TransitiveClosureHelper to get a path (which should be a loop) from A to itself within an MatchProcessor?
I want to show the path to the user so he can tear it up
Regards,
[Updated on: Fri, 06 March 2015 11:32] Report message to a moderator
|
|
|
Re: Extract transitive closure path from match [message #1656020 is a reply to message #1653781] |
Sat, 07 March 2015 09:54 |
Zoltan Ujhelyi Messages: 392 Registered: July 2015 |
Senior Member |
|
|
Hi,
I tried to collect the required steps to use TransitiveClosureHelper. My description will use the API from 0.9.0 (the relevant APIs have changed a bit in 0.9.0, so for older versions the description here will need to be adapted).
First of all, I would not want to initialize a TransitiveClosureHelper inside an IMatchProcessor; more specifically, I would create a single instance and reuse it between different executions of the match processor. As the helper is also incremental, this would be safe.
I was not the original developer, so I am not 100% sure about this, but as far as I understood, this feature only works for the transitive closure of EReferences, not on the transitive closure of patterns. For EReferences, consider the following snippet for initializing the pathFinder; and then share it with your match processor.
IncQueryEngine engine = ...; //Use any IncQueryEngine over any EMF model
Set<EReference> eReferenceSet = ...; //Create a set of EReferences you have to consider for the transitive closure
NavigationHelper baseIndex = EMFScope.getUnderlyingEMFIndex(engine);
TransitiveClosureHelper tcHelper = IncQueryBaseFactory.createTransitiveClosureHelper(baseIndex, eReferenceSet);
final IGraphPathFinder<EObject> pathFinder = tcHelper.getPathFinder(); //you can share this instance with your matchprocessor instance
I hope, this was helpful. If not, feel free to ask for clarifications.
Cheers,
Zoltán
|
|
|
Re: Extract transitive closure path from match [message #1658522 is a reply to message #1656020] |
Sun, 08 March 2015 11:26 |
ihave question Messages: 32 Registered: November 2014 |
Member |
|
|
Thank you! Yes I'm only interested in the actual objects wich form a link.
Just two questions:
Algebraic loops only form cycles with stateless functions. Now,
I have also stateful functions, which terminate a cycle, so only algebraic ones (which are errors) are matched.
Did I understand you correctly that the helper class will return any path (let's say two cycles are present: algebraic A -B - C - A and stateful A - B - *S* - C - A)
So I would get both paths and have to do the filtering myself?
2nd Question: The helper is incremental -> Inside the cycle processor, can i simply add the variable to the reference set and retrieve the path? Because in your snippet you set the reference set globally and just share the helper with the processor ...
Otherwise I would have the paradoxical situation:
I want to retrieve the cycle -> I have to set the start/end (referenceSet) of the cycle before I know that a cycle exists!
Regards,
[Updated on: Sun, 08 March 2015 11:30] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.22198 seconds