Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Using OCL in xcore(Create OCL contrains for a xcore model)
Using OCL in xcore [message #1842996] Fri, 09 July 2021 14:25 Go to next message
Steve Peters is currently offline Steve PetersFriend
Messages: 4
Registered: September 2020
Junior Member
Hello,

I'm testing with xcore and now I want to create some OCL constraints for the xcore model.

I've created the xcore model file with some sample elements and then I created an OCL file with the wizard. The wizard recognized immediately my xcore file and generated the following output.

import 'Library.xcore'

package library

context Library
--
-- example invariant with a custom error message to verify that
-- the 'name' property of all 'library::Library' instances is non-null
--
inv NonNull_name('The \'name\' property of "' + self.toString() + '" is null'):
	name <> null

endpackage


My example Library model Library.xcore

@Ecore(nsURI="http://www.eclipse.org/testlib")
@GenModel(
	editDirectory="/xcoretest/src-gen",
	editorDirectory="/xcoretest/src-gen"
)
package org.example.library

class Library{
	String name
	contains Book[] books opposite library
	contains Writer[] writers
}

class Book{
	String title
	container Library library opposite books
	refers Writer author 
}

class Writer {
	String name
}


Then I get the following error:

Unresolved import 'Library.xcore' : java.io.IOException: Errors
in 'platform:/resource/xcoretest/model/Library.xcore'
0: Non
Ecore XPackage for Ecore2AS.update
0: Non Ecore GenModel for
Ecore2AS.update
0: Non Ecore JvmGenericType for Ecore2AS.update
0:
Non Ecore JvmGenericType for Ecore2AS.update
0: Non Ecore JvmGenericType
for Ecore2AS.update
0: Non Ecore JvmGenericType for Ecore2AS.update
0:
Non Ecore JvmGenericType for Ecore2AS.update
0: Non Ecore JvmGenericType

Is it not possible to use directly ocl with xcore? Do I need a Genmodel for it? Why does the wizard offers me the option to use xcore file?

Thx
Re: Using OCL in xcore [message #1842998 is a reply to message #1842996] Fri, 09 July 2021 16:58 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7265
Registered: July 2009
Senior Member
Hi

The OCLinEcore editor supports editiong OCL within Ecore models. Provided your Xcore is saved as a *.ecore file, you can open with the OCLinEcore Editor and tweak your OCL. If you then want to go back to Xcore you should see the EAnnotations.

Regards

Ed Willink
Re: Using OCL in xcore [message #1843003 is a reply to message #1842998] Sat, 10 July 2021 12:16 Go to previous messageGo to next message
Steve Peters is currently offline Steve PetersFriend
Messages: 4
Registered: September 2020
Junior Member
To create an ecore file from a xcore, add OCLs and export it back to xcore is not really useful because it overrides my implementations.

But thank you for your idea.
Re: Using OCL in xcore [message #1843004 is a reply to message #1843003] Sat, 10 July 2021 15:25 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7265
Registered: July 2009
Senior Member
Hi

I'm not sure what you mean by override implementations. Normally the implementations are in the Java and so are preserved by GenModel and so when re-GenModelled the OCL gives extra Java without affecting standard / custom Java.

But if you're using OCL, I can't see that Xcore can give you sufficient benefit to outweigh the advantages of OCLinEcore's syntax checking / editing. / code generation.

Regards

Ed Willink
Previous Topic:Error when running ecore codegen with tycho
Next Topic:generate a diagram for a model instance
Goto Forum:
  


Current Time: Sat Sep 18 07:02:49 GMT 2021

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

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

Back to the top