|Extract transitive closure path from match [message #1653781]
||Fri, 06 March 2015 11:30
| Nasuki Matamoto
Registered: November 2014
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
[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
Registered: July 2015
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.
Powered by FUDForum
. Page generated in 0.01927 seconds