Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » problem evaluating query
problem evaluating query [message #18984] Thu, 19 April 2007 15:38 Go to next message
Joana M. F. Trindade is currently offline Joana M. F. TrindadeFriend
Messages: 7
Registered: July 2009
Junior Member
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
Eclipse UserFriend
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
Previous Topic:Can OCL initialization constraints modify the system ?
Next Topic:OCL Constraints on ECore Model
Goto Forum:
  


Current Time: Fri Apr 26 16:38:30 GMT 2024

Powered by FUDForum. Page generated in 0.02675 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top