Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Pivot OCL Evaluation
Pivot OCL Evaluation [message #826908] Thu, 22 March 2012 16:40 Go to next message
ModelGeek Mising name is currently online ModelGeek Mising name
Messages: 516
Registered: June 2011
Senior Member
Hi,

I have a ecore model with annotations pointing to pivot(http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot). I am trying to instantiate that model and evaluate an ocl expression.

org.eclipse.ocl.examples.pivot.OCL.initialize(null);
org.eclipse.ocl.examples.pivot.OCL newInstance = org.eclipse.ocl.examples.pivot.OCL.newInstance(new PivotEnvironmentFactory(contextModelInstance.eResource().getResourceSet().getPackageRegistry(), new MetaModelManager(contextModelInstance.eResource().getResourceSet()))); org.eclipse.ocl.examples.pivot.helper.OCLHelper oclHelper = newInstance.createOCLHelper();
try {
ExpressionInOcl createQuery = oclHelper.createQuery(expression);
long start = System.currentTimeMillis();
Value evaluate = newInstance.evaluate(context, createQuery);
long end = System.currentTimeMillis();
String print = print(evaluate.asObject());
print+=":::Execution Time = " + ((double)(end-start)/1000) + " Sec";
return print;
} catch (org.eclipse.ocl.examples.pivot.ParserException ex) {
Exceptions.printStackTrace(ex);
}

but i am getting following exception

Caused by: java.lang.ExceptionInInitializerError
at org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot$Factory.<init>(UML2Ecore2Pivot.java:48)
at org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot$Factory.<init>(UML2Ecore2Pivot.java:47)
at org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot.<clinit>(UML2Ecore2Pivot.java:124)
at org.eclipse.ocl.examples.pivot.manager.MetaModelManager.<clinit>(MetaModelManager.java:386)

on the bold line in my code.

Do you have any idea why is that?

Regards,
Re: Pivot OCL Evaluation [message #826954 is a reply to message #826908] Thu, 22 March 2012 17:50 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4095
Registered: July 2009
Senior Member
Hi

Your earlier message suggested that UML was missing. The Pivot model
prototypes full UML alignment of UML so it uses UML, but it should be
optional. However your snippets provide insufficient detail to deduce
your problem.

Please post something compilable.

Regards

Ed Willink


On 22/03/2012 12:40, ModelGeek Mising name wrote:
> Hi,
>
> I have a ecore model with annotations pointing to
> pivot(http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot). I am trying to
> instantiate that model and evaluate an ocl expression.
>
> org.eclipse.ocl.examples.pivot.OCL.initialize(null);
> org.eclipse.ocl.examples.pivot.OCL newInstance =
> org.eclipse.ocl.examples.pivot.OCL.newInstance(new
> PivotEnvironmentFactory(contextModelInstance.eResource().getResourceSet().getPackageRegistry(),
> new
> MetaModelManager(contextModelInstance.eResource().getResourceSet())));
> org.eclipse.ocl.examples.pivot.helper.OCLHelper oclHelper =
> newInstance.createOCLHelper();
> try {
> ExpressionInOcl createQuery =
> oclHelper.createQuery(expression);
> long start = System.currentTimeMillis();
> Value evaluate = newInstance.evaluate(context, createQuery);
> long end = System.currentTimeMillis();
> String print = print(evaluate.asObject());
> print+=":::Execution Time = " + ((double)(end-start)/1000)
> + " Sec";
> return print;
> } catch (org.eclipse.ocl.examples.pivot.ParserException ex) {
> Exceptions.printStackTrace(ex);
> }
>
> but i am getting following exception
>
> Caused by: java.lang.ExceptionInInitializerError
> at
> org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot$Factory.<init>(UML2Ecore2Pivot.java:48)
> at
> org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot$Factory.<init>(UML2Ecore2Pivot.java:47)
> at
> org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot.<clinit>(UML2Ecore2Pivot.java:124)
> at
> org.eclipse.ocl.examples.pivot.manager.MetaModelManager.<clinit>(MetaModelManager.java:386)
>
> on the bold line in my code.
>
> Do you have any idea why is that?
>
> Regards,
Re: Pivot OCL Evaluation [message #827379 is a reply to message #826954] Fri, 23 March 2012 08:44 Go to previous messageGo to next message
ModelGeek Mising name is currently online ModelGeek Mising name
Messages: 516
Registered: June 2011
Senior Member
modelPackage = EcoreFactory.eINSTANCE.createEPackage();
modelPackage.setName("temp");
modelPackage.setNsPrefix("Test");
modelPackage.setNsURI("http://www.eclipse.org/mdt/ocl/oclinecore/tutorial");
EAnnotation mainOCLAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
mainOCLAnnotation.setSource("http://www.eclipse.org/emf/2002/Ecore");
mainOCLAnnotation.getDetails().put("invocationDelegates", "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot");
mainOCLAnnotation.getDetails().put("settingDelegates", "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot");
//mainOCLAnnotation.getDetails().put("settingDelegates", "org.eclipse.ocl.ecore.OCL");
mainOCLAnnotation.getDetails().put("validationDelegates", "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot");
modelPackage.getEAnnotations().add(mainOCLAnnotation);
EClass eClass = EcoreFactory.eINSTANCE.createEClass();
eClass.setName(prmClass.getName());
modelPackage.getEClassifiers().add(eClass);
EAttribute eAttribute= EcoreFactory.eINSTANCE.createEAttribute();
eAttribute.setName("test");
eAttribute.setUpperBound(1);
eAttribute.setLowerBound(1);
eAttribute.setEType(EcorePackage.eINSTANCE.getELongObject());
eClass.getEStructuralFeatures().add(eAttribute);
eAttribute.setDerived(true);
eAttribute.setVolatile(true);
EAnnotation driveAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
driveAnnotation.setSource("http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot");
//driveAnnotation.setSource("org.eclipse.ocl.ecore.OCL");
driveAnnotation.getDetails().put("derivation", "2*2");
eAttribute.getEAnnotations().add(driveAnnotation);

//////instantiation of ecore model
EFactory iModelPackage = modelPackage.getEFactoryInstance();
EObject eObject = iModelPackage.create(eClass);

URI uri = "some path";
URI uri1 = "some path";

ResourceSet resourceSet1 = new ResourceSetImpl();
resourceSet1.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
Resource resource1 = resourceSet1.createResource(uri1);
resource1.getContents().add(modelPackage);

ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
Resource resource = resourceSet.createResource(uri);
resource.getContents().add(iModelPackage);

////////////////////////// evaluate
org.eclipse.ocl.examples.pivot.OCL.initialize(null);
org.eclipse.ocl.examples.pivot.OCL newInstance = org.eclipse.ocl.examples.pivot.OCL.newInstance(new PivotEnvironmentFactory(iModelPackage.eResource().getResourceSet().getPackageRegistry(), new MetaModelManager(iModelPackage.eResource().getResourceSet())));
org.eclipse.ocl.examples.pivot.helper.OCLHelper oclHelper = newInstance.createOCLHelper();
try {
ExpressionInOcl createQuery = oclHelper.createQuery("2*2");
long start = System.currentTimeMillis();
Value evaluate = newInstance.evaluate(eObject, createQuery);
long end = System.currentTimeMillis();
String print = print(evaluate.asObject());
print+=":::Execution Time = " + ((double)(end-start)/1000) + " Sec";
return print;
} catch (org.eclipse.ocl.examples.pivot.ParserException ex) {
Exceptions.printStackTrace(ex);
}

/////////////////////////// delegate
String oclDelegateURI = OCLDelegateDomain.OCL_DELEGATE_URI_PIVOT;
EOperation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.put
(oclDelegateURI, new OCLInvocationDelegateFactory.Global());
EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put
(oclDelegateURI, new OCLSettingDelegateFactory.Global());
Object eGet = eObject.eGet(eAttribute, false);


now in case if i use evalution/delegate part i get

Caused by: java.lang.ExceptionInInitializerError
at org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot$Factory.<init>(UML2Ecore2Pivot.java:48)
at org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot$Factory.<init>(UML2Ecore2Pivot.java:47)
at org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot.<clinit>(UML2Ecore2Pivot.java:124)

hope it is compilable...

thanks for assistance

regards,

[Updated on: Fri, 23 March 2012 08:49]

Report message to a moderator

Re: Pivot OCL Evaluation [message #827434 is a reply to message #827379] Fri, 23 March 2012 10:17 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4095
Registered: July 2009
Senior Member
> hope it is compilable...
Hardly, no function names, no imports no package declarations .....

Compilable requires (zipped) files that compile.

Regards

Ed Willink
Re: Pivot OCL Evaluation [message #827493 is a reply to message #827434] Fri, 23 March 2012 12:00 Go to previous messageGo to next message
ModelGeek Mising name is currently online ModelGeek Mising name
Messages: 516
Registered: June 2011
Senior Member
Hi,

Here is complete file containing main method. I did not attach jar files(JUNO) are there are many jar files and i hope you already have them on your machine.

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EFactory;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.ocl.examples.pivot.delegate.*;
import org.eclipse.ocl.examples.domain.values.Value;
import org.eclipse.ocl.examples.pivot.ExpressionInOcl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.ocl.examples.pivot.manager.MetaModelManager;
import org.eclipse.ocl.examples.pivot.utilities.PivotEnvironmentFactory;

public class TestPivot {
private EPackage modelPackage = null;
private EClass eClass = null;
private EAttribute eAttribute = null;
private EFactory iModelPackage = null;
private EObject eObject = null;
private String oclDelegateURI = OCLDelegateDomain.OCL_DELEGATE_URI_PIVOT;
private ResourceSet ecoreResourceSet;
private ResourceSet xmiResourceSet;
public void makeMataModel() {
modelPackage = EcoreFactory.eINSTANCE.createEPackage();
modelPackage.setName("temp");
modelPackage.setNsPrefix("Test");
modelPackage.setNsURI("http://www.eclipse.org/mdt/ocl/oclinecore/tutorial");
EAnnotation mainOCLAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
mainOCLAnnotation.setSource("http://www.eclipse.org/emf/2002/Ecore");
mainOCLAnnotation.getDetails().put("invocationDelegates", oclDelegateURI);
mainOCLAnnotation.getDetails().put("settingDelegates", oclDelegateURI);
mainOCLAnnotation.getDetails().put("validationDelegates", oclDelegateURI);
modelPackage.getEAnnotations().add(mainOCLAnnotation);
eClass = EcoreFactory.eINSTANCE.createEClass();
eClass.setName("TestClass");
eAttribute= EcoreFactory.eINSTANCE.createEAttribute();
eAttribute.setName("test");
eAttribute.setUpperBound(1);
eAttribute.setLowerBound(1);
eAttribute.setEType(EcorePackage.eINSTANCE.getELongObject());
eAttribute.setDerived(true);
eAttribute.setVolatile(true);
EAnnotation driveAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
driveAnnotation.setSource(oclDelegateURI);
driveAnnotation.getDetails().put("derivation", "2*2");
eAttribute.getEAnnotations().add(driveAnnotation);
eClass.getEStructuralFeatures().add(eAttribute);
modelPackage.getEClassifiers().add(eClass);
URI uri1 = URI.createFileURI("test.ecore");
ecoreResourceSet = new ResourceSetImpl();
ecoreResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
Resource resource1 = ecoreResourceSet.createResource(uri1);
resource1.getContents().add(modelPackage);

}

public void createModel() {
iModelPackage = modelPackage.getEFactoryInstance();
eObject = iModelPackage.create(eClass);
URI uri = URI.createFileURI("test.xmi");
xmiResourceSet = new ResourceSetImpl();
xmiResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
Resource resource = xmiResourceSet.createResource(uri);
resource.getContents().add(iModelPackage);
resource.getContents().add(eObject);
}

public void evaluate() {
//try with null or object both result same exception
//org.eclipse.ocl.examples.pivot.OCL.initialize(null);
org.eclipse.ocl.examples.pivot.OCL.initialize(xmiResourceSet);
org.eclipse.ocl.examples.pivot.OCL newInstance = org.eclipse.ocl.examples.pivot.OCL.newInstance(new PivotEnvironmentFactory(iModelPackage.eResource().getResourceSet().getPackageRegistry(), new MetaModelManager(iModelPackage.eResource().getResourceSet())));
org.eclipse.ocl.examples.pivot.helper.OCLHelper oclHelper = newInstance.createOCLHelper();
try {
ExpressionInOcl createQuery = oclHelper.createQuery("2*2");
long start = System.currentTimeMillis();
Value evaluate = newInstance.evaluate(eObject, createQuery);
long end = System.currentTimeMillis();
String print = evaluate.asObject().toString();
print+=":::Execution Time = " + ((double)(end-start)/1000) + " Sec";
System.out.println("value = " + print);
} catch (org.eclipse.ocl.examples.pivot.ParserException ex) {
ex.printStackTrace();
}
}

public void useDelegates() {
//try with null or object both result same exception
//org.eclipse.ocl.examples.pivot.OCL.initialize(null);
org.eclipse.ocl.examples.pivot.OCL.initialize(xmiResourceSet);
EOperation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.put
(oclDelegateURI, new OCLInvocationDelegateFactory.Global());
EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put
(oclDelegateURI, new OCLSettingDelegateFactory.Global());
Object eGet = eObject.eGet(eAttribute, false);
System.out.println("value = " + eGet.toString());

}

public static void main(String args[]) {
TestPivot tp = new TestPivot();
tp.makeMataModel();
tp.createModel();
tp.evaluate();
tp.useDelegates();
}
}

here both evaluate() and useDeletegates() methods are throwing the same exception
I have also tried to
org.eclipse.ocl.examples.pivot.OCL.initialize(null); but it has the same exception


java.lang.ExceptionInInitializerError
at org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot$Factory.<init>(UML2Ecore2Pivot.java:48)
at org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot$Factory.<init>(UML2Ecore2Pivot.java:47)
at org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot.<clinit>(UML2Ecore2Pivot.java:124)
at org.eclipse.ocl.examples.pivot.manager.MetaModelManager.<clinit>(MetaModelManager.java:386)
........
........
.....
Caused by: org.eclipse.emf.common.util.WrappedException: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Feature 'xmi' not found. (jar:file:/C:/project/AbstractModellerPrm/lib/org.eclipse.uml2.uml_4.0.0.v20120130-1013.jar!/org/eclipse/uml2/uml/internal/impl/uml.ecore, 3, 129)
at org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.loadPackage(UMLPackageImpl.java:17007)
at org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.init(UMLPackageImpl.java:1903)
at org.eclipse.uml2.uml.UMLPackage.<clinit>(UMLPackage.java:82)
... 14 more
Caused by: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Feature 'xmi' not found. (jar:file:/C:/project/AbstractModellerPrm/lib/org.eclipse.uml2.uml_4.0.0.v20120130-1013.jar!/org/eclipse/uml2/uml/internal/impl/uml.ecore, 3, 129)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:77)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:185)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:240)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1505)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1284)
at org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.loadPackage(UMLPackageImpl.java:17005)

please help me fixing this.

Regards,


[Updated on: Fri, 23 March 2012 12:14]

Report message to a moderator

Re: Pivot OCL Evaluation [message #827557 is a reply to message #827493] Fri, 23 March 2012 13:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4095
Registered: July 2009
Senior Member
Hi

I'm not clear how you are running to get the exception trace you report,
but in order to run a 'plugin' containing your java code I need to add:

public static void main(String args[]) {
EssentialOCLStandaloneSetup.doSetup();
OCLstdlib.install();
TestPivot tp = new TestPivot();

Regards

Ed Willink


On 23/03/2012 08:00, ModelGeek Mising name wrote:
> Hi,
>
> Here is complete file containing main method. I did not attach jar
> files(JUNO) are there are many jar files and i hope you already have
> them on your machine.
>
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.ecore.EAnnotation;
> import org.eclipse.emf.ecore.EAttribute;
> import org.eclipse.emf.ecore.EClass; import
> org.eclipse.emf.ecore.EFactory;
> import org.eclipse.emf.ecore.EObject;
> import org.eclipse.emf.ecore.EOperation;
> import org.eclipse.emf.ecore.EPackage;
> import org.eclipse.emf.ecore.EcoreFactory;
> import org.eclipse.emf.ecore.EcorePackage;
> import org.eclipse.emf.ecore.EStructuralFeature;
> import org.eclipse.ocl.examples.pivot.delegate.*;
> import org.eclipse.ocl.examples.domain.values.Value;
> import org.eclipse.ocl.examples.pivot.ExpressionInOcl;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.resource.ResourceSet;
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
> import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
> import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
> import org.eclipse.ocl.examples.pivot.manager.MetaModelManager;
> import org.eclipse.ocl.examples.pivot.utilities.PivotEnvironmentFactory;
> /**
> *
> * @author khurrams
> */
> public class TestPivot {
> private EPackage modelPackage = null;
> private EClass eClass = null;
> private EAttribute eAttribute = null;
> private EFactory iModelPackage = null;
> private EObject eObject = null;
> private String oclDelegateURI =
> OCLDelegateDomain.OCL_DELEGATE_URI_PIVOT;
> public void makeMataModel() {
> modelPackage = EcoreFactory.eINSTANCE.createEPackage();
> modelPackage.setName("temp");
> modelPackage.setNsPrefix("Test");
>
> modelPackage.setNsURI("http://www.eclipse.org/mdt/ocl/oclinecore/tutorial");
> EAnnotation mainOCLAnnotation =
> EcoreFactory.eINSTANCE.createEAnnotation();
>
> mainOCLAnnotation.setSource("http://www.eclipse.org/emf/2002/Ecore");
> mainOCLAnnotation.getDetails().put("invocationDelegates",
> oclDelegateURI);
> mainOCLAnnotation.getDetails().put("settingDelegates",
> oclDelegateURI);
> mainOCLAnnotation.getDetails().put("validationDelegates",
> oclDelegateURI);
> modelPackage.getEAnnotations().add(mainOCLAnnotation);
> eClass = EcoreFactory.eINSTANCE.createEClass();
> eClass.setName("TestClass");
> eAttribute= EcoreFactory.eINSTANCE.createEAttribute();
> eAttribute.setName("test");
> eAttribute.setUpperBound(1);
> eAttribute.setLowerBound(1);
> eAttribute.setEType(EcorePackage.eINSTANCE.getELongObject());
> eAttribute.setDerived(true);
> eAttribute.setVolatile(true);
> EAnnotation driveAnnotation =
> EcoreFactory.eINSTANCE.createEAnnotation();
> driveAnnotation.setSource(oclDelegateURI);
> driveAnnotation.getDetails().put("derivation", "2*2");
> eAttribute.getEAnnotations().add(driveAnnotation);
> eClass.getEStructuralFeatures().add(eAttribute);
> modelPackage.getEClassifiers().add(eClass);
> URI uri1 = URI.createFileURI("test.ecore");
> ResourceSet resourceSet1 = new ResourceSetImpl();
>
> resourceSet1.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore",
> new EcoreResourceFactoryImpl());
> Resource resource1 = resourceSet1.createResource(uri1);
> resource1.getContents().add(modelPackage);
> }
> public void createModel() {
> iModelPackage = modelPackage.getEFactoryInstance();
> eObject = iModelPackage.create(eClass);
> URI uri = URI.createFileURI("test.xmi");
> ResourceSet resourceSet = new ResourceSetImpl();
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi",
> new XMIResourceFactoryImpl());
> Resource resource = resourceSet.createResource(uri);
> resource.getContents().add(iModelPackage);
> }
> public void evaluate() {
> //org.eclipse.ocl.examples.pivot.OCL.initialize(null);
> org.eclipse.ocl.examples.pivot.OCL newInstance =
> org.eclipse.ocl.examples.pivot.OCL.newInstance(new
> PivotEnvironmentFactory(iModelPackage.eResource().getResourceSet().getPackageRegistry(),
> new MetaModelManager(iModelPackage.eResource().getResourceSet())));
> org.eclipse.ocl.examples.pivot.helper.OCLHelper oclHelper =
> newInstance.createOCLHelper();
> try {
> ExpressionInOcl createQuery = oclHelper.createQuery("2*2");
> long start = System.currentTimeMillis();
> Value evaluate = newInstance.evaluate(eObject, createQuery);
> long end = System.currentTimeMillis();
> String print = evaluate.asObject().toString();
> print+=":::Execution Time = " + ((double)(end-start)/1000)
> + " Sec";
> System.out.println("value = " + print);
> } catch (org.eclipse.ocl.examples.pivot.ParserException ex) {
> ex.printStackTrace();
> } }
> public void useDelegates() {
> org.eclipse.ocl.examples.pivot.OCL.initialize(null);
>
> EOperation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.put
> (oclDelegateURI, new OCLInvocationDelegateFactory.Global());
>
> EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put
> (oclDelegateURI, new OCLSettingDelegateFactory.Global());
> Object eGet = eObject.eGet(eAttribute, false);
> System.out.println("value = " + eGet.toString());
> }
> public static void main(String args[]) {
> TestPivot tp = new TestPivot();
> tp.makeMataModel();
> tp.createModel();
> tp.evaluate();
> tp.useDelegates();
> }
> }
>
> here both evaluates and useDeletegates() methods are throwing the same
> exception
> java.lang.ExceptionInInitializerError
> at
> org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot$Factory.<init>(UML2Ecore2Pivot.java:48)
> at
> org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot$Factory.<init>(UML2Ecore2Pivot.java:47)
> at
> org.eclipse.ocl.examples.pivot.uml.UML2Ecore2Pivot.<clinit>(UML2Ecore2Pivot.java:124)
> at
> org.eclipse.ocl.examples.pivot.manager.MetaModelManager.<clinit>(MetaModelManager.java:386)
> .......
> .......
> ....
> Caused by: org.eclipse.emf.common.util.WrappedException:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Feature
> 'xmi' not found.
> (jar:file:/C:/project/AbstractModellerPrm/lib/org.eclipse.uml2.uml_4.0.0.v20120130-1013.jar!/org/eclipse/uml2/uml/internal/impl/uml.ecore,
> 3, 129)
> at
> org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.loadPackage(UMLPackageImpl.java:17007)
> at
> org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.init(UMLPackageImpl.java:1903)
> at org.eclipse.uml2.uml.UMLPackage.<clinit>(UMLPackage.java:82)
> ... 14 more
> Caused by: org.eclipse.emf.ecore.resource.Resource$IOWrappedException:
> Feature 'xmi' not found.
> (jar:file:/C:/project/AbstractModellerPrm/lib/org.eclipse.uml2.uml_4.0.0.v20120130-1013.jar!/org/eclipse/uml2/uml/internal/impl/uml.ecore,
> 3, 129)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:77)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:185)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:240)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1505)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1284)
> at
> org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.loadPackage(UMLPackageImpl.java:17005)
>
> please help me fixing this.
>
> Regards,
>
>
>
Re: Pivot OCL Evaluation [message #827587 is a reply to message #827557] Fri, 23 March 2012 14:39 Go to previous messageGo to next message
ModelGeek Mising name is currently online ModelGeek Mising name
Messages: 516
Registered: June 2011
Senior Member
Hi,

Actually i am using netbeans for this code. I have attached all libraries required in netbeans project(org.eclipse.emf.. , org.eclipse.ocl.example....).

Do i need add EssentialOCLStandaloneSetup.doSetup(); and stdlib.install(); even when i am not using xtext?

It is just running TestPivot class like a test case.

thanks for assistance!

Regards,

[Updated on: Fri, 23 March 2012 14:45]

Report message to a moderator

Re: Pivot OCL Evaluation [message #827618 is a reply to message #827587] Fri, 23 March 2012 15:16 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4095
Registered: July 2009
Senior Member
Hi

I have no current knowledge on NetBeans.

You currently have to use the Xtext-based parser for the new code.

EssentialOCLStandaloneSetup.doSetup()

initialises it.

OCLstdlib.install() registerts an OCL Standard Library which is now
modeled and replaceable.

Regards

Ed

On 23/03/2012 10:39, ModelGeek Mising name wrote:
> Hi,
>
> Actually i am using netbeans for this code. I have attached all
> libraries required in netbeans project(org.eclipse.emf.. ,
> org.eclipse.ocl.example....).
>
> Do i need add EssentialOCLStandaloneSetup.doSetup(); and
> stdlib.install(); even when i am not using xtext?
>
>
>
> Regards,
>
>
Re: Pivot OCL Evaluation [message #827646 is a reply to message #827618] Fri, 23 March 2012 15:57 Go to previous messageGo to next message
ModelGeek Mising name is currently online ModelGeek Mising name
Messages: 516
Registered: June 2011
Senior Member
Hi,

i have added
EssentialOCLStandaloneSetup.doSetup();
OCLstdlib.install();
in main method but now i get the following exception on EssentialOCLStandaloneSetup.doSetup();
do you any idea? what is wrong now?

thanks for helping!

Exception in thread "main" java.lang.ExceptionInInitializerError
at org.eclipse.ocl.examples.pivot.uml.UMLUtils.initializeContents(UMLUtils.java:221)
at org.eclipse.ocl.examples.pivot.uml.UMLUtils.initializeContents(UMLUtils.java:142)
at org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCLStandaloneSetup.init(EssentialOCLStandaloneSetup.java:48)
at org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCLStandaloneSetup.createInjectorAndDoEMFRegistration(EssentialOCLStandaloneSetup.java:73)
at org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCLStandaloneSetup.doSetup(EssentialOCLStandaloneSetup.java:39)
at abstractmodeller.model.prm.TestPivot.main(TestPivot.java:129)
Caused by: org.eclipse.emf.common.util.WrappedException: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Feature 'xmi' not found. (jar:file:/C:/project/AbstractModellerPrm/lib/org.eclipse.uml2.uml_4.0.0.v20120130-1013.jar!/org/eclipse/uml2/uml/internal/impl/uml.ecore, 3, 129)
at org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.loadPackage(UMLPackageImpl.java:17007)
at org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.init(UMLPackageImpl.java:1903)
at org.eclipse.uml2.uml.UMLPackage.<clinit>(UMLPackage.java:82)
... 6 more
Re: Pivot OCL Evaluation [message #827652 is a reply to message #827646] Fri, 23 March 2012 16:02 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4095
Registered: July 2009
Senior Member
Hi

The message is fairly obvious

jar:file:/C:/project/AbstractModellerPrm/lib/org.eclipse.uml2.uml_4.0.0.v20120130-1013.jar

but I'm afraid that if you want to re-use Eclipse plugins on NetBeans
you are on your own as far as debugging the plugin installation and
visibility.

Regards

Ed Willink

On 23/03/2012 11:57, ModelGeek Mising name wrote:
> Hi,
>
> i have added
> EssentialOCLStandaloneSetup.doSetup();
> OCLstdlib.install();
> in main method but now i get the following exception on
> EssentialOCLStandaloneSetup.doSetup(); do you any idea? what is wrong
> now?
>
> thanks for helping!
>
> Exception in thread "main" java.lang.ExceptionInInitializerError
> at
> org.eclipse.ocl.examples.pivot.uml.UMLUtils.initializeContents(UMLUtils.java:221)
> at
> org.eclipse.ocl.examples.pivot.uml.UMLUtils.initializeContents(UMLUtils.java:142)
> at
> org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCLStandaloneSetup.init(EssentialOCLStandaloneSetup.java:48)
> at
> org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCLStandaloneSetup.createInjectorAndDoEMFRegistration(EssentialOCLStandaloneSetup.java:73)
> at
> org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCLStandaloneSetup.doSetup(EssentialOCLStandaloneSetup.java:39)
> at abstractmodeller.model.prm.TestPivot.main(TestPivot.java:129)
> Caused by: org.eclipse.emf.common.util.WrappedException:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Feature
> 'xmi' not found.
> (jar:file:/C:/project/AbstractModellerPrm/lib/org.eclipse.uml2.uml_4.0.0.v20120130-1013.jar!/org/eclipse/uml2/uml/internal/impl/uml.ecore,
> 3, 129)
> at
> org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.loadPackage(UMLPackageImpl.java:17007)
> at
> org.eclipse.uml2.uml.internal.impl.UMLPackageImpl.init(UMLPackageImpl.java:1903)
> at org.eclipse.uml2.uml.UMLPackage.<clinit>(UMLPackage.java:82)
> ... 6 more
Previous Topic:Operation Overriding
Next Topic:org.eclipse.emf.ocl.examples.interpreter
Goto Forum:
  


Current Time: Thu Oct 23 16:04:13 GMT 2014

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

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