Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » import platform-resource to completeoclfile
import platform-resource to completeoclfile [message #1017213] Mon, 11 March 2013 08:05 Go to next message
Ba sti is currently offline Ba stiFriend
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 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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
Re: import platform-resource to completeoclfile [message #1017620 is a reply to message #1017594] Tue, 12 March 2013 08:18 Go to previous messageGo to next message
Ba sti is currently offline Ba stiFriend
Messages: 18
Registered: February 2013
Junior Member
Hi,
yes there is a little problem with this pathmap, but its not such a big problem so this is ok.. the validator works fine..
my problem is the completeOcl-file with this unresolved import
I now have registerd my "platform:/resource/Profile/Profile.uml" in the EPackageRegistry and now there is no more error with the unmapped path while running the validator, but i still get the errormessage "Unresolved import 'platform:/resource/Profile/Profile.uml' : Failed to load 'pivot:/platform/resource/Profile/Profile.uml' : Unnamed package"
in the ocl-file at line 2. What´s the meaning of unnamed package and how can i resolve this import?

Regards,
Basti
Re: import platform-resource to completeoclfile [message #1017662 is a reply to message #1017620] Tue, 12 March 2013 09:30 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI

As I wrote before:

> 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.

I do not have time to debug everyone's code just because they think they
can do better than the solution I provided.

Until you provide a demonstrable example using the recommended approach,
I cannot help you further.

An unnamed package is one without a name and this may arise as a result
of a demand-created package when using inappropriate registrations.

My solution took me a long time to develop. You should expect to take an
equally long time to learn how to make your different/better solution work.

Regards

Ed Willink

On 12/03/2013 08:18, Ba sti wrote:
> Hi,
> yes there is a little problem with this pathmap, but its not such a
> big problem so this is ok.. the validator works fine..
> my problem is the completeOcl-file with this unresolved import
> I now have registerd my "platform:/resource/Profile/Profile.uml" in
> the EPackageRegistry and now there is no more error with the unmapped
> path while running the validator, but i still get the errormessage
> "Unresolved import 'platform:/resource/Profile/Profile.uml' : Failed
> to load 'pivot:/platform/resource/Profile/Profile.uml' : Unnamed package"
> in the ocl-file at line 2. What´s the meaning of unnamed package and
> how can i resolve this import?
>
> Regards,
> Basti
Previous Topic:CompleteOCL to XMI
Next Topic:Operation with Set(Real) as arguments is not recognized, Is this a bug?
Goto Forum:
  


Current Time: Fri Mar 29 10:51:23 GMT 2024

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

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

Back to the top