Home » Modeling » OCL » import platform-resource to completeoclfile
import platform-resource to completeoclfile [message #1017213] |
Mon, 11 March 2013 08:05 |
Ba sti Messages: 18 Registered: February 2013 |
Junior Member |
|
|
Hello,
I´m trying to create a CompleteOCL-file to validate a Profile that is applied on a uml-model. The profile is saved in a external uml-file so i have to import this file to the completeOCL-file, but eclipse says that this is an unresolved import:
"Unresolved import 'platform:/resource/Profile/Profile.uml' : Failed to load 'pivot:/platform/resource/Profile/Profile.uml' : Unnamed package"
This is my ocl-file:
import uml: 'http://www.eclipse.org/uml2/3.0.0/UML#/'
import signal: 'platform:/resource/Profile/Profile.uml'
context uml::Class
inv Defined:
let stereo: Stereotype= self.getAppliedStereotype('Profile::Protokoll') in not stereo.oclIsUndefined()implies (self.getValue(stereo,'ID').oclAsType(Integer) > 0
I´m running this file with a CompleteOCLEObjectValidator in standalone(but running it inside eclipse makes no difference) and when i tried to run this with the file above i get the error:
"0 [main] ERROR idation.CompleteOCLEObjectValidator - Failed to load 'file:/D:/PapyrusWorkspacee/standalone_validierer/src/profile.ocl
2: Unresolved import 'platform:/resource/Profile/Profile.uml' : The path '/Profile/Profile.uml' is unmapped"
Thats my validator:
CompleteOCLStandaloneSetup.doSetup();
OCLstdlib.install();
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.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
resourceSet.getPackageRegistry().put("pathmap://Papyrus.profile.uml",UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(resourceSet.getResourceFactoryRegistry().DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
URI uri = URI.createFileURI(args[0]);
URI ocluri = URI.createFileURI(args[1]);
EPackage.Registry.INSTANCE.put(args[0],UMLPackage.eINSTANCE);
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);
if(m==null){
System.err.println("Model: load failed!");
System.exit(1);
}
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());
}
I´m using the KeplerM5-release..
What´s the problem with this import?
Is it necessary to do some special registrations in the java-file/the project containing it?
Regards,
Basti
|
|
|
Re: import platform-resource to completeoclfile [message #1017594 is a reply to message #1017213] |
Tue, 12 March 2013 06:56 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
Getting UML registrations correct is extremely difficult and so I
contributed what became UMLResourcesUtil.init(). If you can do better
you are welcome to do so and then contribute it back to Eclipse.
Imperfections in UMLResourcesUtil.init() are addressed by a further
contribution exploiting a recent EMF enhancement that you may find in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=401682.
Your code contains pathmap://Papyrus.profile.uml which is odd and has no
obvious resolution.
resourceSet.getPackageRegistry().put("pathmap://Papyrus.profile.uml",UMLPackage.eINSTANCE);
appears to suggest that wherever your profile is encountered, the UML
metamodel should be consulted for its resolution.
Regards
Ed Willink
On 11/03/2013 08:05, Ba sti wrote:
> Hello,
> I´m trying to create a CompleteOCL-file to validate a Profile that is
> applied on a uml-model. The profile is saved in a external uml-file so
> i have to import this file to the completeOCL-file, but eclipse says
> that this is an unresolved import:
> "Unresolved import 'platform:/resource/Profile/Profile.uml' : Failed
> to load 'pivot:/platform/resource/Profile/Profile.uml' : Unnamed package"
> This is my ocl-file:
>
> import uml: 'http://www.eclipse.org/uml2/3.0.0/UML#/'
> import signal: 'platform:/resource/Profile/Profile.uml'
>
> context uml::Class
> inv Defined:
> let stereo: Stereotype=
> self.getAppliedStereotype('Profile::Protokoll') in not
> stereo.oclIsUndefined()implies
> (self.getValue(stereo,'ID').oclAsType(Integer) > 0 I´m running this
> file with a CompleteOCLEObjectValidator in standalone(but running it
> inside eclipse makes no difference) and when i tried to run this with
> the file above i get the error:
> "0 [main] ERROR idation.CompleteOCLEObjectValidator - Failed to
> load 'file:/D:/PapyrusWorkspacee/standalone_validierer/src/profile.ocl
> 2: Unresolved import 'platform:/resource/Profile/Profile.uml' : The
> path '/Profile/Profile.uml' is unmapped"
> Thats my validator:
>
> CompleteOCLStandaloneSetup.doSetup();
> OCLstdlib.install();
>
> 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.getPackageRegistry().put(EcorePackage.eNS_URI,
> EcorePackage.eINSTANCE);
>
> resourceSet.getPackageRegistry().put("pathmap://Papyrus.profile.uml",UMLPackage.eINSTANCE);
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(resourceSet.getResourceFactoryRegistry().DEFAULT_EXTENSION,
> new XMIResourceFactoryImpl());
>
> URI uri = URI.createFileURI(args[0]);
> URI ocluri = URI.createFileURI(args[1]);
> EPackage.Registry.INSTANCE.put(args[0],UMLPackage.eINSTANCE);
> 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);
> if(m==null){
> System.err.println("Model: load failed!");
> System.exit(1);
> }
>
> 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());
> }
> I´m using the KeplerM5-release..
> What´s the problem with this import? Is it necessary to do some
> special registrations in the java-file/the project containing it?
>
> Regards,
> Basti
|
|
| | |
Goto Forum:
Current Time: Wed Sep 25 22:35:42 GMT 2024
Powered by FUDForum. Page generated in 0.04430 seconds
|