Home » Modeling » OCL » problem evaluating query
problem evaluating query [message #18984] |
Thu, 19 April 2007 15:38 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Hello everyone,
I am using OCL 1.0 (EMFT) to evaluate a query against an emf model. I was
performing a query over a model, passing two loaded Resources (.ecore and
emf model) as parameters. Furthermore, my code looks like this:
public List<EObject> getElementsByType(String eClassName) {
(...)
Map<EClassifier, Set<?>> extents = new HashMap<EClassifier, Set<?>>();
Set instances = new HashSet();
EClassifier archClassifier = getClassifier(ARCHITECTURAL_DESCRIPTION);
// Return an empty list.
if (archClassifier == null || archDescription == null) {
return null;
}
extents.put(archClassifier, instances);
// Query architectural description node for all the instances
// of the specified class name.
String oclExpression = "self.has->select(x |
x.oclIsKindOf("+eClassName+"))";
Query query =
QueryFactory.eINSTANCE.createQuery(oclExpression,archClassif ier);
query.setExtentMap(extents);
Collection result = (Collection) query.evaluate(archDescription);
if (result != null) {
elementsList.addAll(result);
}
(...)
}
Two weeks ago this code was working. But now I get an exception like this
at the query.evaluate() call:
"java.lang.IllegalArgumentException: The feature 'has' is not a valid
feature at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenGet(BasicEO bjectImpl.java:645) "
And this feature is present in both, archClassifier (EClassifier) and
archDescription (EObject):
(archDescription)
[org.eclipse.emf.ecore.impl.EReferenceImpl@1332109 (name: has) (ordered:
true, unique: true, lowerBound: 0, upperBound: -1) (changeable: true,
volatile: false, transient: false, defaultValueLiteral: null, unsettable:
false, derived: false) (containment: true, resolveProxies: false)]
(archClassifier)
[org.eclipse.emf.ecore.impl.EReferenceImpl@4adb34 (name: has) (ordered:
true, unique: true, lowerBound: 0, upperBound: -1) (changeable: true,
volatile: false, transient: false, defaultValueLiteral: null, unsettable:
false, derived: false) (containment: true, resolveProxies: false)]
What I would like to know is why that feature is not being recognized, and
what am I doing wrong.
I'd appreciate any kind of help or advise.
Thanks in advance,
Joana Trindade
|
|
|
Problem with BasicEObjectImpl::eOpenGet [was: problem evaluating query] [message #19026 is a reply to message #18984] |
Thu, 19 April 2007 17:50 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Joana,
Which version of EMF are you running at run-time, and with which version was
your model generated? Are you using dyamic EMF? (i.e., is archDescription
a DynamicEObjectImpl of type archClassifier?)
I can't think of anything that has changed recently in EMF that would cause
this (and, of course, OCL 1.0 in EMFT hasn't changed at all in several
months). You may get more help from the EMF newsgroup (which I've included
in this thread) ...
Cheers,
Christian
Joana M. F. Trindade wrote:
> Hello everyone,
>
> I am using OCL 1.0 (EMFT) to evaluate a query against an emf model. I was
> performing a query over a model, passing two loaded Resources (.ecore and
> emf model) as parameters. Furthermore, my code looks like this:
>
> public List<EObject> getElementsByType(String eClassName) {
> (...)
> Map<EClassifier, Set<?>> extents = new HashMap<EClassifier, Set<?>>();
> Set instances = new HashSet();
> EClassifier archClassifier = getClassifier(ARCHITECTURAL_DESCRIPTION);
>
> // Return an empty list.
> if (archClassifier == null || archDescription == null) {
> return null;
> }
>
> extents.put(archClassifier, instances);
>
> // Query architectural description node for all the instances
> // of the specified class name.
> String oclExpression = "self.has->select(x |
> x.oclIsKindOf("+eClassName+"))";
> Query query =
> QueryFactory.eINSTANCE.createQuery(oclExpression,archClassif ier);
> query.setExtentMap(extents);
>
> Collection result = (Collection) query.evaluate(archDescription);
> if (result != null) {
> elementsList.addAll(result);
> }
> (...)
> }
>
> Two weeks ago this code was working. But now I get an exception like this
> at the query.evaluate() call:
> "java.lang.IllegalArgumentException: The feature 'has' is not a valid
> feature at
>
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenGet(BasicEO bjectImpl.java:645) "
>
>
> And this feature is present in both, archClassifier (EClassifier) and
> archDescription (EObject):
>
> (archDescription)
> [org.eclipse.emf.ecore.impl.EReferenceImpl@1332109 (name: has) (ordered:
> true, unique: true, lowerBound: 0, upperBound: -1) (changeable: true,
> volatile: false, transient: false, defaultValueLiteral: null, unsettable:
> false, derived: false) (containment: true, resolveProxies: false)]
>
> (archClassifier)
> [org.eclipse.emf.ecore.impl.EReferenceImpl@4adb34 (name: has) (ordered:
> true, unique: true, lowerBound: 0, upperBound: -1) (changeable: true,
> volatile: false, transient: false, defaultValueLiteral: null, unsettable:
> false, derived: false) (containment: true, resolveProxies: false)]
>
> What I would like to know is why that feature is not being recognized, and
> what am I doing wrong.
>
> I'd appreciate any kind of help or advise.
>
> Thanks in advance,
> Joana Trindade
|
|
|
Goto Forum:
Current Time: Mon Feb 10 22:29:07 GMT 2025
Powered by FUDForum. Page generated in 0.02943 seconds
|