Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » illegal operation signature: (oclContents())
illegal operation signature: (oclContents()) [message #1074581] Sat, 27 July 2013 06:02 Go to next message
Archevo tarek is currently offline Archevo tarek
Messages: 20
Registered: July 2013
Junior Member
Hi ed,
I was investigating your proposition for the closure operation, and i tested many requests in Xtext ocl console on a dynamic instance (xmi file), and it works, like:

self->asSet()->closure(oclContents()->select(oclIsKindOf(model::Activity)))->select(a:model::Activity| a.oclIsKindOf(model::Assign))->size()

but when i try to test it in my java code, it gives an exception on the use of the oclContents() operation. I thought that it is a problem of API version of the org.eclipse.ocl that i changed to 3.2.0, but without success:


org.eclipse.ocl.SemanticException: illegal operation signature: (oclContents())
at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:358)
at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:328)
at org.eclipse.ocl.internal.helper.HelperUtil.checkForErrors(HelperUtil.java:518)
at org.eclipse.ocl.internal.helper.HelperUtil.parseQuery(HelperUtil.java:165)
at org.eclipse.ocl.internal.helper.OCLHelperImpl.createQuery(OCLHelperImpl.java:176)
at arch.evol.qu.ConstraintParser.testquery(ConstraintParser.java:153)
at arch.evol.qu.CheckEvolutionChange.ParseContract(CheckEvolutionChange.java:173)
at arch.evol.qu.CheckEvolutionChange$1.widgetSelected(CheckEvolutionChange.java:96)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at arch.evol.qu.MainInterface$2.widgetSelected(MainInterface.java:91)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at arch.evol.qu.MainInterface.open(MainInterface.java:41)
at arch.evol.qu.MainInterface.main(MainInterface.java:26)

I changed also many API versions that OCL API depends on.
I'm using eclipse-modeling-juno-SR1

Please, can you help me to solve the problem.
Thanks in advance.
Re: illegal operation signature: (oclContents()) [message #1074590 is a reply to message #1074581] Sat, 27 July 2013 06:31 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
Hi

The Xtext OCL console uses a prototype of a neutral OCL implementation.

oclContents() replaces the eContents() that is available in the classic
Ecore-specific implementation.

If you use the Ecore-specific implementation you needd to muse eContents().

Regards

Ed Willink



On 27/07/2013 07:02, Archevo tarek wrote:
> Hi ed,
> I was investigating your proposition for the closure operation, and i
> tested many requests in Xtext ocl console on a dynamic instance (xmi
> file), and it works, like:
>
> self->asSet()->closure(oclContents()->select(oclIsKindOf(model::Activity)))->select(a:model::Activity|
> a.oclIsKindOf(model::Assign))->size()
>
> but when i try to test it in my java code, it gives an exception on
> the use of the oclContents() operation. I thought that it is a problem
> of API version of the org.eclipse.ocl that i changed to 3.2.0, but
> without success:
>
>
> org.eclipse.ocl.SemanticException: illegal operation signature:
> (oclContents())
> at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:358)
> at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:328)
> at
> org.eclipse.ocl.internal.helper.HelperUtil.checkForErrors(HelperUtil.java:518)
> at
> org.eclipse.ocl.internal.helper.HelperUtil.parseQuery(HelperUtil.java:165)
> at
> org.eclipse.ocl.internal.helper.OCLHelperImpl.createQuery(OCLHelperImpl.java:176)
> at arch.evol.qu.ConstraintParser.testquery(ConstraintParser.java:153)
> at
> arch.evol.qu.CheckEvolutionChange.ParseContract(CheckEvolutionChange.java:173)
> at
> arch.evol.qu.CheckEvolutionChange$1.widgetSelected(CheckEvolutionChange.java:96)
> at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
> at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
> at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
> at arch.evol.qu.MainInterface$2.widgetSelected(MainInterface.java:91)
> at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
> at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
> at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
> at arch.evol.qu.MainInterface.open(MainInterface.java:41)
> at arch.evol.qu.MainInterface.main(MainInterface.java:26)
>
> I changed also many API versions that OCL API depends on.
> I'm using eclipse-modeling-juno-SR1
>
> Please, can you help me to solve the problem.
> Thanks in advance.
Re: illegal operation signature: (oclContents()) [message #1074692 is a reply to message #1074590] Sat, 27 July 2013 13:36 Go to previous messageGo to next message
Archevo tarek is currently offline Archevo tarek
Messages: 20
Registered: July 2013
Junior Member
Hi,

this my code:

 OCL<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, Constraint, EClass, EObject> ocl = null;
		ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
 
OCLHelper<EClassifier, EOperation, EStructuralFeature, Constraint> helper = (OCLHelper<EClassifier, EOperation, EStructuralFeature, Constraint>) ocl.createOCLHelper();		
 
helper.setContext(BPELPackage.Literals.PROCESS);		
 
BasicEnvironment benv =OCLUtil.getAdapter(ocl.getEnvironment(), BasicEnvironment.class);
 
benv.setOption(ProblemOption.CLOSURE_ITERATOR,ProblemHandler.Severity.OK);
 
OCLExpression<EClassifier> query = helper.createQuery("self->asSet()->closure(oclContents()->select(oclIsKindOf(Activity)))->select(a:model::Activity| a.oclIsKindOf(Assign))->size()");
 
Query queryEval = ocl.createQuery(query);
		String  categories = (String) queryEval.evaluate(process).toString();
		System.out.println(categories+ "     in testquery");


Can you give some precisions please, how can i replace oclContens() with eContents().

Thanks in advance.
Re: illegal operation signature: (oclContents()) [message #1074707 is a reply to message #1074692] Sat, 27 July 2013 14:20 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
Hi

That is not your code; iut has no import statyeements, classpath,
dependencies, hiowever your question is trivial

Chnage

OCLExpression<EClassifier> query =
helper.createQuery("self->asSet()->closure(oclContents()->select(oclIsKindOf(Activity)))->select(a:model::Activity|
a.oclIsKindOf(Assign))->size()");

to

OCLExpression<EClassifier> query =
helper.createQuery("self->asSet()->closure(eContents()->select(oclIsKindOf(Activity)))->select(a:model::Activity|
a.oclIsKindOf(Assign))->size()");

Regards

Ed Willink


On 27/07/2013 14:36, Archevo tarek wrote:
> Hi,
> this my code:
>
>
> OCL<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, Constraint, EClass, EObject>
> ocl = null;
> ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
>
> OCLHelper<EClassifier, EOperation, EStructuralFeature, Constraint>
> helper = (OCLHelper<EClassifier, EOperation, EStructuralFeature,
> Constraint>) ocl.createOCLHelper();
>
> helper.setContext(BPELPackage.Literals.PROCESS);
>
> BasicEnvironment benv =OCLUtil.getAdapter(ocl.getEnvironment(),
> BasicEnvironment.class);
>
> benv.setOption(ProblemOption.CLOSURE_ITERATOR,ProblemHandler.Severity.OK);
>
>
> OCLExpression<EClassifier> query =
> helper.createQuery("self->asSet()->closure(oclContents()->select(oclIsKindOf(Activity)))->select(a:model::Activity|
> a.oclIsKindOf(Assign))->size()");
>
> Query queryEval = ocl.createQuery(query);
> String categories = (String)
> queryEval.evaluate(process).toString();
> System.out.println(categories+ " in testquery");
>
>
> Can you give some precisions please, how can i replace oclContens()
> with eContents().
>
> Thanks in advance.
Re: illegal operation signature: (oclContents()) [message #1074719 is a reply to message #1074707] Sat, 27 July 2013 14:58 Go to previous messageGo to next message
Archevo tarek is currently offline Archevo tarek
Messages: 20
Registered: July 2013
Junior Member
Hi,
Thank you for answering me.

It is my code indeed ed. It is just an excerpt of a method, here is the imports of my class where the method public void testquery(Process process) is located:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.wsdl.WSDLException;

import org.eclipse.bpel.fnmeta.model.util.FMResourceFactoryImpl;
import org.eclipse.bpel.model.BPELFactory;
import org.eclipse.bpel.model.BPELPackage;
import org.eclipse.bpel.model.Process;
import org.eclipse.bpel.model.resource.BPELReader;
import org.eclipse.bpel.model.resource.BPELResource;
import org.eclipse.bpel.model.resource.BPELResourceFactoryImpl;
import org.eclipse.bpel.model.resource.BPELResourceImpl;
import org.eclipse.bpel.model.resource.BPELResourceSetImpl;
import org.eclipse.bpel.model.resource.BPELWriter;
import org.eclipse.bpel.model.util.WSDLUtil;
import org.eclipse.bpel.validator.Main;
import org.eclipse.bpel.validator.ModelQuery;
import org.eclipse.bpel.validator.helpers.ModelQueryImpl;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.impl.DynamicEObjectImpl;
import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.ocl.OCL;
import org.eclipse.ocl.OCLInput;
import org.eclipse.ocl.ParserException;
import org.eclipse.ocl.Query;
import org.eclipse.ocl.ecore.Constraint;
import org.eclipse.ocl.ecore.EcoreEnvironmentFactory;
import org.eclipse.ocl.expressions.OCLExpression;
import org.eclipse.ocl.helper.OCLHelper;
import org.eclipse.ocl.lpg.BasicEnvironment;
import org.eclipse.ocl.lpg.ProblemHandler;
import org.eclipse.ocl.options.ParsingOptions;
import org.eclipse.ocl.options.ProblemOption;
import org.eclipse.ocl.util.OCLUtil;
import org.eclipse.wst.wsdl.Definition;
import org.eclipse.wst.wsdl.WSDLFactory;
import org.eclipse.wst.wsdl.WSDLPackage;
import org.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl;
import org.eclipse.wst.wsdl.util.WSDLResourceImpl;
import org.eclipse.xsd.util.XSDResourceFactoryImpl;
.
..





public void testquery(Process process) throws ParserException {
OCL<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, Constraint, EClass, EObject> ocl = null;
		ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
 
OCLHelper<EClassifier, EOperation, EStructuralFeature, Constraint> helper = (OCLHelper<EClassifier, EOperation, EStructuralFeature, Constraint>) ocl.createOCLHelper();		
 
helper.setContext(BPELPackage.Literals.PROCESS);		
 
BasicEnvironment benv =OCLUtil.getAdapter(ocl.getEnvironment(), BasicEnvironment.class);
 
benv.setOption(ProblemOption.CLOSURE_ITERATOR,ProblemHandler.Severity.OK);
 
OCLExpression<EClassifier> query = helper.createQuery("self->asSet()->closure(oclContents()->select(oclIsKindOf(Activity)))->select(a:model::Activity| a.oclIsKindOf(Assign))->size()");
 
Query queryEval = ocl.createQuery(query);
		String  categories = (String) queryEval.evaluate(process).toString();
		System.out.println(categories+ "     in testquery");

}



Replacing the oclContents() directly in the request by eContents() returns the same exception, an org.eclipse.ocl.SemanticException: illegal operation signature: (eContents()).

I solve the problem like this:

I replaced this line:

helper.setContext(BPELPackage.Literals.PROCESS);
by this one:

helper.setContext(EcorePackage.Literals.EOBJECT);
So i changed the context to the EcorePackage like you suggeted to work with EObject.

And i changed the request to:

self->asSet()->closure(eContents()->select(oclIsKindOf(model::Activity)).oclAsType(ecore::EObject))->size()

It works for now.

I'm testing now this request:

self->asSet()->closure(eContents()->select(oclIsKindOf(model::Activity)).oclAsType(ecore::EObject))->select(a:model::Activity| a.oclIsKindOf(model::Assign))->size()

It sends an exception:

org.eclipse.ocl.SemanticException: Iterator variable must have same type as source element type (Set {self}->asSet()->closure(temp1 : EObject | temp1.eContents()->select(temp2 : T | temp2.oclIsKindOf(model::Activity))->collect(temp3 : T | temp3.oclAsType(ecore::EObject)))->select(a : Activity | a.oclIsKindOf(model::Assign)))

Any help, please.

Thank
Re: illegal operation signature: (oclContents()) [message #1074723 is a reply to message #1074581] Sat, 27 July 2013 15:12 Go to previous message
Archevo tarek is currently offline Archevo tarek
Messages: 20
Registered: July 2013
Junior Member
Hi ,

I just solved the pb.

I changed a:model::Activity by:

a:ecore::EObject.

Than you very much ed.
Previous Topic:closure operation
Next Topic:Transform OCL into PL/SQL
Goto Forum:
  


Current Time: Wed Sep 24 00:35:44 GMT 2014

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

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