Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Using Java APIs
Using Java APIs [message #1765516] Sun, 11 June 2017 20:40 Go to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 40
Registered: November 2012
Member
Hello,

I want to extract the context for which an OCL has been violated in a separate model. For that purpose, first, I used OCL APIs in a standalone java application to validate a UML model. The UML model is an instance of a UML profile which has some constraints.
I read the previous posts regarding that and I found out Pivot object instead of UML objects are used.
I basically used the code that one of the members previously posted in the forum (with small changes). I attach the project which includes the code, profiles and models. When I ran the code, I receive an exception that I cannot figure it out. I should say that when I validate the model by right click-> OCL->validate , it returns the validation result correctly.

Sorry if my question is very simple, but any help is appreciated.

Thanks,
Jeni
  • Attachment: OCL.zip
    (Size: 42.43KB, Downloaded 13 times)
Re: Using Java APIs [message #1765518 is a reply to message #1765516] Sun, 11 June 2017 21:07 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5429
Registered: July 2009
Senior Member
Hi

You don't tell me what to do or what to expect!

Once I fix trivial BREE/import errors and delete the Papyrus Action Language Profiles, running Ocltest.main gives plausible output; no exceptions.

(I do not understand or support Papyrus Action Language Profiles; they appear to be a way of doing what OCL already does in some strange different way.)

Regards

Ed Willink
Re: Using Java APIs [message #1765521 is a reply to message #1765518] Mon, 12 June 2017 01:09 Go to previous messageGo to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 40
Registered: November 2012
Member
Hi Ed,

Thanks for the quick reply.


For now, I just want to see which constraints are violated. Later, I will add code to extract the context of violated constraint and the violated element as an output which will be input for another application.

This time, I think I removed the unnecessary imports and Papyrus action Language profile ; but I still have the same error. Sorry for this basic question. I am learning OCL programming.
I attach the file with changes.

Once again Thank you.

  • Attachment: OCL.zip
    (Size: 28.83KB, Downloaded 14 times)
Re: Using Java APIs [message #1765528 is a reply to message #1765521] Mon, 12 June 2017 06:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5429
Registered: July 2009
Senior Member
Hi

You have provided a repro; good, but you omit critical details. What is the error?

See https://wiki.eclipse.org/OCL/ForumNetiquette

Regards

Ed Willink
Re: Using Java APIs [message #1765553 is a reply to message #1765528] Mon, 12 June 2017 12:30 Go to previous messageGo to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 40
Registered: November 2012
Member
Sorry about incomplete information. Here is the error:

org.eclipse.ocl.pivot.utilities.ParserException: Failed to load 'file:/C:/Users/umroot/Documents/OCL/TestValidation/MyProfile/MonitoringModel.profile.uml.oclas' : null
Target class: org.eclipse.uml2.uml.internal.impl.ClassImpl@2b8bd14b (name: SF1, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false) (isActive: false)
at org.eclipse.ocl.pivot.uml.internal.es2as.UML2AS$Outer.getASModel(UML2AS.java:604)
at org.eclipse.ocl.pivot.uml.internal.resource.UMLASResourceFactory.getASElement(UMLASResourceFactory.java:95)
at org.eclipse.ocl.pivot.internal.manager.PivotMetamodelManager.getASOf(PivotMetamodelManager.java:799)
at Mypackage.Ocltest.pivotValidation(Ocltest.java:123)
at Mypackage.Ocltest.main(Ocltest.java:56)
Caused by: java.lang.NullPointerException
at org.eclipse.ocl.pivot.uml.internal.es2as.UML2AS$Outer.addImportedResource(UML2AS.java:477)
at org.eclipse.ocl.pivot.uml.internal.es2as.UML2AS.addImportedPackage(UML2AS.java:973)
at org.eclipse.ocl.pivot.uml.internal.es2as.UML2AS.addImportedPackages(UML2AS.java:979)
at org.eclipse.ocl.pivot.uml.internal.es2as.UML2ASDeclarationSwitch.copyPackage(UML2ASDeclarationSwitch.java:867)
at org.eclipse.ocl.pivot.uml.internal.es2as.UML2ASDeclarationSwitch.caseProfile(UML2ASDeclarationSwitch.java:453)
at org.eclipse.uml2.uml.util.UMLSwitch.doSwitch(UMLSwitch.java:580)
at org.eclipse.ocl.pivot.uml.internal.es2as.UML2ASDeclarationSwitch.doInPackageSwitch(UML2ASDeclarationSwitch.java:948)
at org.eclipse.ocl.pivot.uml.internal.es2as.UML2ASDeclarationSwitch.doSwitch(UML2ASDeclarationSwitch.java:956)
at org.eclipse.ocl.pivot.uml.internal.es2as.UML2AS.installDeclarations(UML2AS.java:1075)
at org.eclipse.ocl.pivot.uml.internal.es2as.UML2AS$Outer.getASModel(UML2AS.java:582)
... 4 more
Target found: org.eclipse.emf.ecore.impl.DynamicEObjectImpl@5f69e2b (eClass: org.eclipse.emf.ecore.impl.EClassImpl@3b7b05a8 (name: ServiceFunctionality) (instanceClassName: null) (abstract: false, interface: false))
Exception in thread "main" java.lang.NullPointerException
at org.eclipse.ocl.pivot.utilities.AbstractEnvironmentFactory.createEvaluationVisitor(AbstractEnvironmentFactory.java:258)
at org.eclipse.ocl.pivot.utilities.OCL.createEvaluationVisitor(OCL.java:253)
at org.eclipse.ocl.pivot.utilities.OCL.evaluate(OCL.java:379)
at Mypackage.Ocltest.pivotValidation(Ocltest.java:141)
at Mypackage.Ocltest.main(Ocltest.java:56)
Re: Using Java APIs [message #1765564 is a reply to message #1765553] Mon, 12 June 2017 13:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5429
Registered: July 2009
Senior Member
Hi

What version are you using? I recall fixing an embarrassing import issue a few months ago.

But when I try again, I now see your error. When I look at /TriggerExtraction/MyProfile/MonitoringModel.profile.uml I still see all the troublesome Papyrus profiles. Looking harder I see that your Profile has profile applications.

Normally a Profile defines facilities at M2 to be applied at M1. You are applying M2 facilities at M2. I am not sure what this means? Was it intentional?

Regards

Ed Willink
Re: Using Java APIs [message #1765566 is a reply to message #1765564] Mon, 12 June 2017 13:52 Go to previous messageGo to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 40
Registered: November 2012
Member
I got eclipse Neon 2 days a go and I assume it is the latest version (eclipse.buildId=4.6.3.M20170301-0400)
I considered profile as a metamodel which is applied on a model because by profiling mechanism I am defining a new language. I know that profiles are considered as a model too which its metamodel is UML.

Do you mean that all of this is because of applying a profile on a model?

Thanks and best regards,
Mahin
Re: Using Java APIs [message #1765571 is a reply to message #1765566] Mon, 12 June 2017 14:04 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5429
Registered: July 2009
Senior Member
Hi

Investigating anyway, I see the NPE is for a 'guaranteed non-null' object. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=518129

There could be a better diagnostic and automatic skipping of missing profiles. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=518130

What I reproduce is a problem through use of a Papyrus profile that is not installed. When you moved to Neon.2 did you effectively uninstall Papyrus. Can you identify where the Papyrus profile application came from? I suspect that some facility is injecting it undesirably.

Regards

Ed Willink
Re: Using Java APIs [message #1765577 is a reply to message #1765571] Mon, 12 June 2017 14:20 Go to previous messageGo to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 40
Registered: November 2012
Member
Thanks Ed.

Previously, I had Luna with Papyrus installed. Lately, I moved to Neon and I just installed the "Modeling" plugins.
I made these profiles previously when I had Luna version, and did not installed Papyrus on Neon. Sorry for this question, How can check the Papyrus profile application?
Re: Using Java APIs [message #1765584 is a reply to message #1765577] Mon, 12 June 2017 15:04 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5429
Registered: July 2009
Senior Member
Hi

No problem. It is awkward user experiences such as yours that can reveal obscure bugs.

I have never used the Papyrus constraint profiles, so I can only guess. My suspicion is that some menu displays the extra functionality and over-enthusiastically infects your model as an undesired side effect.

You can check by looking at the *.uml. The first couple of lines have an xmlns. The almost last line has an application.

Regards

Ed Willink
Re: Using Java APIs [message #1765590 is a reply to message #1765584] Mon, 12 June 2017 15:17 Go to previous messageGo to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 40
Registered: November 2012
Member
Now I see where the action language profile which you pointed out earlier comes from. It is added automatically by Papyrus when I made the profile.

xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ActionLanguage="http://www.omg.org/spec/ALF/20120827/ActionLanguage-Profile" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.omg.org/spec/ALF/20120827/ActionLanguage-Profile pathmap://PAPYRUS_ACTIONLANGUAGE_PROFILE/ActionLanguage-Profile.profile.uml#_sYse0YZLEeKyw49uR6nx3g">
Re: Using Java APIs [message #1765598 is a reply to message #1765590] Mon, 12 June 2017 16:51 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5429
Registered: July 2009
Senior Member
Hi

I have to guess at your words "made a profile". Please raise a Papyrus Bugzilla with an exact sequence of innocuous commands that result in the excessive profile.

Regards

Ed Willink
Re: Using Java APIs [message #1765603 is a reply to message #1765598] Mon, 12 June 2017 17:51 Go to previous messageGo to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 40
Registered: November 2012
Member
Hi Ed,

Sorry, I mean creating the "MonitoringModel.profile.uml". To create that profile, I used papyrus and created the stereotypes and imported UML metaclasses.

Thanks and best regards,
Jeni
Re: Using Java APIs [message #1765629 is a reply to message #1765603] Mon, 12 June 2017 21:28 Go to previous messageGo to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 40
Registered: November 2012
Member
Hi Ed,

I wanted to thank you for helping me. As you mentioned the error was because of the action language profile which was applied (I don't know how!)
but I deleted it and it is working now.

Once again, thank you :)

Best regards,
Jeni
Re: Using Java APIs [message #1765670 is a reply to message #1765629] Tue, 13 June 2017 08:44 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5429
Registered: July 2009
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=518160 raised.
Previous Topic:Negation of OCL expressions
Next Topic:lots of errors in ocl file
Goto Forum:
  


Current Time: Fri Oct 20 03:21:39 GMT 2017

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

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