|
|
Re: How can I monitor my application using EMF and VIATRA query language? [message #1849875 is a reply to message #1849840] |
Sun, 06 February 2022 20:02 |
atepheh kh Messages: 17 Registered: December 2021 |
Junior Member |
|
|
Hello,
Thanks for your reply.
I created a model using EMF and generate its code. By using my model APIs, I create an Object and initialize it. Now I want to load my object to Viatra query engine and query on it. How can I load my object?
For example If my model object name is web, I should use code below to initialize my engine?
// phase 1: (managed) ViatraQueryEngine
ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(web));
[Updated on: Mon, 07 February 2022 08:18] Report message to a moderator
|
|
|
|
|
Re: How can I monitor my application using EMF and VIATRA query language? [message #1849891 is a reply to message #1849886] |
Mon, 07 February 2022 17:07 |
Zoltan Ujhelyi Messages: 392 Registered: July 2015 |
Senior Member |
|
|
Hi,
looking at your code, the answer is that instead of loading the model from a resource, you could do something as follows (I did not compile it, so there might be slight issues):
ResourceSet rs = new ResourceSetImpl();
Resource resource = rs.createResource(URI.createURI("uri name")); // as long as you are not planning to save the model, it is not important what the URI is
MainPage main = ...; // Use the code you have already created
...
resource.getContents().add(main); // If I have read your metamodel correctly, this should be enough as all other model elements are reachable with containment references starting from main; if not, add them as well
After that point, the created ResourceSet can be used as the model scope for the query engine.
Best regards,
Zoltán
|
|
|
|
|
Re: How can I monitor my application using EMF and VIATRA query language? [message #1850032 is a reply to message #1849911] |
Fri, 11 February 2022 15:07 |
atepheh kh Messages: 17 Registered: December 2021 |
Junior Member |
|
|
Hello dear,
I fixed the "resource is null" error by using the following code:
ResourceSet rs = new ResourceSetImpl();
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml",new XMIResourceFactoryImpl());
Resource resource = rs.createResource(URI.createURI("test.xml"));
// create my model
MainPage main = ...
Webpage web = factory.createWebpage();
web.getMainpage().add(main);
resource.getContents().add(web);
scope = new EMFScope(resource);
But now, when I want to initialize ViatraQueryEngine with scope I facing with this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/collections/impl/map/mutable/UnifiedMap
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1010)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:855)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:753)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:676)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:634)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1010)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:855)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:753)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:676)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:634)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1010)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:855)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:753)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:676)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:634)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
at org.eclipse.viatra.query.runtime.matchers.util.EclipseCollectionsFactory.createMultiLookup(EclipseCollectionsFactory.java:125)
at org.eclipse.viatra.query.runtime.matchers.util.CollectionsFactory.createMultiLookup(CollectionsFactory.java:122)
at org.eclipse.viatra.query.runtime.internal.apiimpl.ViatraQueryEngineImpl.<init>(ViatraQueryEngineImpl.java:104)
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngineManager.getQueryEngine(ViatraQueryEngineManager.java:104)
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngineManager.getQueryEngine(ViatraQueryEngineManager.java:84)
at org.eclipse.viatra.query.runtime.api.ViatraQueryEngine.on(ViatraQueryEngine.java:68)
at com.myapplication.runtime.model.RuntimeModel.queryOnModel(RuntimeModel.java:64)
at com.myapplication.runtime.model.RuntimeModel.createModel(RuntimeModel.java:56)
at com.myapplication.runtime.model.Main.main(Main.java:8)
Caused by: java.lang.ClassNotFoundException: org.eclipse.collections.impl.map.mutable.UnifiedMap
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
... 36 more
[Updated on: Fri, 11 February 2022 17:18] Report message to a moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05016 seconds