Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » CompleteOCL standalone validation of uml model
CompleteOCL standalone validation of uml model [message #1011884] Wed, 20 February 2013 12:24 Go to next message
Ba sti is currently offline Ba sti
Messages: 17
Registered: February 2013
Junior Member
Hi all,
I´m trying to do a OCL-validation of a umlmodel in a standalone application. I tried to do this with the CompleteOCLEObjectValidator and all works fine for validating constraints with functions included in oclstdlib or with attributes of my model, such as "self.name = 'SysMLmodel'". But if i try to validate a constraint using a function that is not in the oclstdlib,e.g "self.allOwnedElements()" the result is always "OCL validation result of 'PackImport' is invalid". I debugged this an thats because of no Implementation of "allOwnedElements" is found. I´m using indigo..
Here is my code:
Quote:

public class TestValidator extends CompleteOCLEObjectValidator{

public TestValidator(EPackage ePackage, URI oclURI) {
super(ePackage, oclURI);
// TODO Auto-generated constructor stub
}

public static void main(String[] args){

CompleteOCLStandaloneSetup.doSetup();
OCLstdlibStandaloneSetup.doSetup();
EssentialOCLStandaloneSetup.doSetup();

OCLstdlib.install();
UMLPackage uml = UMLPackage.eINSTANCE;
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("uml", new XMIResourceFactoryImpl());
resourceSet.getPackageRegistry().put(SysmlPackage.eNS_URI, SysmlPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(BlocksPackage.eNS_URI, BlocksPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(resourceSet.getResourceFactoryRegistry().DEFAULT_EXTENSION, new XMIResourceFactoryImpl());

URI uri = URI.createFileURI("D:/.../model.uml");
EPackage.Registry.INSTANCE.put("D:/.../model.uml",UMLPackage.eINSTANCE);
URI ocluri = URI.createFileURI("D:/.../test.ocl");
Resource resource = resourceSet.createResource(uri);
try {
resource.load(null);
System.out.println("Model: load complete");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Model m = (Model) EcoreUtil.getObjectByType(resource.getContents(), UMLPackage.Literals.MODEL);

org.eclipse.ocl.uml.OCL.initialize(null);
org.eclipse.ocl.examples.pivot.OCL.initialize(null);
org.eclipse.ocl.examples.pivot.uml.UML2Pivot.initialize(null);
String oclDelegateURI2 = OCLDelegateDomain.OCL_DELEGATE_URI_PIVOT;
EOperation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI2,
new OCLInvocationDelegateFactory.Global());
EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI2,
new OCLSettingDelegateFactory.Global());
EValidator.ValidationDelegate.Registry.INSTANCE.put(oclDelegateURI2,
new OCLValidationDelegateFactory.Global());

CompleteOCLEObjectValidator val = new TestValidator(UMLPackage.eINSTANCE,ocluri);
EValidator.Registry.INSTANCE.put(UMLPackage.eINSTANCE,val);
EValidator.Registry.INSTANCE.put(SysmlPackage.eINSTANCE,val);
Diagnostic diag = Diagnostician.INSTANCE.validate(m);
System.out.println(diag.getMessage());
for(Diagnostic object : diag.getChildren()){
System.err.println(object.getMessage());
}
}

}

How do I get the functions, like allOwnedElements(), registered in my Application?

best regards,
Basti
Re: CompleteOCL standalone validation of uml model [message #1011937 is a reply to message #1011884] Wed, 20 February 2013 14:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
HI

Support for UML with the new-pivot based OCL that goes hand-in-hand with
the Xtext tooling is steadily improving.

The additional MDT/UML2 utility functions were not available in the Juno
release. If you use the Kepler M5 download you should have more joy; I
hope. Otherwise I've got some debugging to do.

If you're prepared to install the Kepler M5 versions of EMF, UML2,
Xtext, OCL etc you can probably continue to use Indigo.

Regards

Ed Willink

On 20/02/2013 14:23, Ba sti wrote:
> Hi all,
> I´m trying to do a OCL-validation of a umlmodel in a standalone
> application. I tried to do this with the CompleteOCLEObjectValidator
> and all works fine for validating constraints with functions included
> in oclstdlib or with attributes of my model, such as "self.name =
> 'SysMLmodel'". But if i try to validate a constraint using a function
> that is not in the oclstdlib,e.g "self.allOwnedElements()" the result
> is always "OCL validation result of 'PackImport' is invalid". I
> debugged this an thats because of no Implementation of
> "allOwnedElements" is found. I´m using indigo..
> Here is my code:
> Quote:
>> public class TestValidator extends CompleteOCLEObjectValidator{
>>
>> public TestValidator(EPackage ePackage, URI oclURI) {
>> super(ePackage, oclURI);
>> // TODO Auto-generated constructor stub
>> }
>>
>> public static void main(String[] args){
>>
>> CompleteOCLStandaloneSetup.doSetup();
>> OCLstdlibStandaloneSetup.doSetup();
>> EssentialOCLStandaloneSetup.doSetup();
>>
>> OCLstdlib.install();
>> UMLPackage uml = UMLPackage.eINSTANCE;
>> ResourceSet resourceSet = new ResourceSetImpl();
>>
>> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("uml",
>> new XMIResourceFactoryImpl());
>> resourceSet.getPackageRegistry().put(SysmlPackage.eNS_URI,
>> SysmlPackage.eINSTANCE);
>> resourceSet.getPackageRegistry().put(BlocksPackage.eNS_URI,
>> BlocksPackage.eINSTANCE);
>> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
>> UMLPackage.eINSTANCE);
>>
>> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(resourceSet.getResourceFactoryRegistry().DEFAULT_EXTENSION,
>> new XMIResourceFactoryImpl());
>>
>> URI uri = URI.createFileURI("D:/.../model.uml");
>>
>> EPackage.Registry.INSTANCE.put("D:/.../model.uml",UMLPackage.eINSTANCE);
>> URI ocluri = URI.createFileURI("D:/.../test.ocl");
>> Resource resource = resourceSet.createResource(uri);
>> try {
>> resource.load(null);
>> System.out.println("Model: load complete");
>> } catch (IOException e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> }
>> Model m = (Model)
>> EcoreUtil.getObjectByType(resource.getContents(),
>> UMLPackage.Literals.MODEL);
>>
>> org.eclipse.ocl.uml.OCL.initialize(null);
>> org.eclipse.ocl.examples.pivot.OCL.initialize(null);
>> org.eclipse.ocl.examples.pivot.uml.UML2Pivot.initialize(null);
>> String oclDelegateURI2 =
>> OCLDelegateDomain.OCL_DELEGATE_URI_PIVOT;
>>
>> EOperation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI2,
>> new OCLInvocationDelegateFactory.Global());
>>
>> EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI2,
>> new OCLSettingDelegateFactory.Global());
>>
>> EValidator.ValidationDelegate.Registry.INSTANCE.put(oclDelegateURI2,
>> new OCLValidationDelegateFactory.Global());
>>
>> CompleteOCLEObjectValidator val = new
>> TestValidator(UMLPackage.eINSTANCE,ocluri);
>> EValidator.Registry.INSTANCE.put(UMLPackage.eINSTANCE,val);
>> EValidator.Registry.INSTANCE.put(SysmlPackage.eINSTANCE,val);
>> Diagnostic diag = Diagnostician.INSTANCE.validate(m);
>> System.out.println(diag.getMessage());
>> for(Diagnostic object : diag.getChildren()){
>> System.err.println(object.getMessage());
>> }
>> }
>>
>> }
>
> How do I get the functions, like allOwnedElements(), registered in my
> Application?
>
> best regards,
> Basti
Re: CompleteOCL standalone validation of uml model [message #1012315 is a reply to message #1011937] Thu, 21 February 2013 10:31 Go to previous messageGo to next message
Ba sti is currently offline Ba sti
Messages: 17
Registered: February 2013
Junior Member
Hi,
thanks for your reply!

While trying to install these new versions, i got serveral conflicts like this one:
Software currently installed: Eclipse SDK 3.7.2.M20120208-0800 (org.eclipse.sdk.ide 3.7.2.M20120208-0800)
Only one of the following can be installed at once:
Equinox Launcher 1.3.0.v20130125-144918 (org.eclipse.equinox.launcher 1.3.0.v20130125-144918)
Equinox Launcher 1.2.0.v20110502 (org.eclipse.equinox.launcher 1.2.0.v20110502)
How can i update the current versions, so eclipse is able to install the new features?

Regards,

Basti
Re: CompleteOCL standalone validation of uml model [message #1012323 is a reply to message #1012315] Thu, 21 February 2013 10:50 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
Hi

You trimmed the opaque error report and so I can't tell which tool has
an Indigo problem.

Regards




On 21/02/2013 10:31, Ba sti wrote:
> Hi, thanks for your reply!
>
> While trying to install these new versions, i got serveral conflicts
> like this one:
> Software currently installed: Eclipse SDK 3.7.2.M20120208-0800
> (org.eclipse.sdk.ide 3.7.2.M20120208-0800)
> Only one of the following can be installed at once: Equinox
> Launcher 1.3.0.v20130125-144918 (org.eclipse.equinox.launcher
> 1.3.0.v20130125-144918)
> Equinox Launcher 1.2.0.v20110502 (org.eclipse.equinox.launcher
> 1.2.0.v20110502)
> How can i update the current versions, so eclipse is able to install
> the new features?
>
> Regards,
>
> Basti
Re: CompleteOCL standalone validation of uml model [message #1012389 is a reply to message #1012323] Thu, 21 February 2013 13:21 Go to previous message
Ba sti is currently offline Ba sti
Messages: 17
Registered: February 2013
Junior Member
Hi,
Now I´m using the Kepler M5 release and with that, my Application works fine..
Thanks for your help!

Regards
Previous Topic:Limitations of OCL
Next Topic:OCL for XCore
Goto Forum:
  


Current Time: Thu Sep 18 05:49:13 GMT 2014

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

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