Extract transitive closure path from match [message #1653781] |
Fri, 06 March 2015 06:30  |
Eclipse User |
|
|
|
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 06:32] by Moderator
|
|
|
Re: Extract transitive closure path from match [message #1656020 is a reply to message #1653781] |
Sat, 07 March 2015 04:54   |
Eclipse User |
|
|
|
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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03734 seconds