Hello Istvan,
thanks for the quick reply.
Well, it is good to know, that this is possible. But for now, I -unfortunately- don't have a simple sample project, which I can send you, it's because the to be queried sample models are quite big and complicated. But If I would have the time, I would create such a tiny project just for test purposes, so I can send you this.
In the mean time, I have managed to go a few steps further by debugging etc. The AdvancedAPI can find the patterns in my manually created xmi-file, but these are not forwarded to the IMatcherFactory, so the IncQueryMatcher can't process them.
So in the following code, after extraction of the as parameter given pattern, "if(factory!=null) { ... } fails and gives no results. Eventually the engine will be wiped at the end of the whole execution.
if (p!=null) {
try {
factory = MatcherFactoryRegistry.getMatcherFactory(p);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Pattern found!");
} else {
// Fall back to the registry in case the pattern model extraction didn't work
factory = MatcherFactoryRegistry.getMatcherFactory(queryPattern);
System.err.println("Pattern NOT found!");
}
try {
if (factory!=null) {
System.out.println("Factory NOT empty!");
try {
IncQueryMatcher<? extends IPatternMatch> matcher = factory.getMatcher(engine);
Collection<? extends IPatternMatch> matches = matcher.getAllMatches();
prettyPrintMatches(results, matches);
} catch (Exception e) {
System.err.println("Execution failed!");
e.printStackTrace();
}
} else {
System.err.println("What is wrong with the factory?!");
}
} catch (Exception e) {
e.printStackTrace();
}
the error "What is wrong with the factory?!" is printed out. With some further logging help, I have also seen, that the pattern extracted with the given parameter from the manually created xmi-file look like this:
org.eclipse.incquery.patternlanguage.patternLanguage.impl.PatternImpl@21bab424 (name: stakeholders, fileName: null)
Again, fileName is missing because there is no IncQuery-project backing this up. Beside the file name, the patterns in the manually created xmi-file are totally the same from one globalEiqModel.xmi, which is from another test project and which works fine with my same application that uses AdvancedAPI.
Only one difference comes to my mind. I had to load/import the needed model resources also manually to dynamic instance of the emfPatternLanguage.ecore and had to point "Package Import" manually to ones I needed to use. By the generated globalEiqModel.xmi they are imported automatically, since the corresponding *.eiq-file from its project imports them. Don't know, if this makes a difference.
Hope you could help me further. And please say if anything wasn't clear enough.
Again thanks and best regards,
Emre