Home » Modeling » OCL » CompleteOCL standalone validation of uml model
CompleteOCL standalone validation of uml model [message #1011884] |
Wed, 20 February 2013 12:24 |
Ba sti Messages: 18 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 |
Ed Willink Messages: 7671 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
|
|
| | | |
Goto Forum:
Current Time: Thu Sep 26 16:51:20 GMT 2024
Powered by FUDForum. Page generated in 0.04032 seconds
|