Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » cannot get tutorial to create error(when creating invariant and invalid object instance it still validates to true)
cannot get tutorial to create error [message #1015777] Sat, 02 March 2013 17:03 Go to next message
Michael Crawford is currently offline Michael Crawford
Messages: 1
Registered: March 2013
Junior Member
Hi,

I am following the tutorial from the docs and and having a problem where the model should not validate but does.

My .ecore file is:
import ecore : '//www.eclipse.org/emf/2002/Ecore#/';

package tutorial : tut = '//www.eclipse.org/mdt/ocl/oclinecore/tutorial'
{
class Library
{
attribute name : String;
property books#library : Book[*] { composes };
property loans : Loan[*] { composes };
property members#library : Member[*] { composes };
}

class Book
{
invariant SufficientCopies:
library.loans->select(book=self)->size() <= copies;
attribute name : String;
attribute copies : Integer;
property library#books : Library[?];
}

class Member
{
attribute name : String;
property library#members : Library[?];
}

class Loan
{
property book : Book;
property member : Member;
attribute date : ecore::EDate[?];
}
}

my .xmi file is:
<?xml version="1.0" encoding="ASCII"?>
<tut:Library
xmi:version="2.0"
xmlns:xmi="//www.omg.org/XMI"
xmlns:xsi="//www.w3.org/2001/XMLSchema-instance"
xmlns:tut="//www.eclipse.org/mdt/ocl/oclinecore/tutorial"
xsi:schemaLocation="//www.eclipse.org/mdt/ocl/oclinecore/tutorial Tutorial.ecore"
name="lib">
<books name="b1"
copies="1"/>
<books name="b2"
copies="2"/>
<loans book="//@books.1"
member="//@members.2"/>
<loans book="//@books.1"
member="//@members.2"/>
<loans book="//@books.1"
member="//@members.2"/>
<members name="m1"/>
<members name="m2"/>
<members name="m3"/>
</tut:Library>

Per the documentation this should not validate because of the SufficientCopies constraint.

Any ideas what I am doing wrong?

(note I left off http when posting because of a posting restriction)

Thanks,
Mike
Re: cannot get tutorial to create error [message #1017109 is a reply to message #1015777] Sat, 09 March 2013 12:38 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4093
Registered: July 2009
Senior Member
Hi

This works fine for me.

My best guess is that you have WTP installed that provides an additional
'Validate' menu option and so you used the 'wrong' Validate.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=197617

Otherwise you'll need to provide much more reproducibility context,.

Regards

Ed Willink




On 07/03/2013 01:40, Michael Crawford wrote:
> Hi,
>
> I am following the tutorial from the docs and and having a problem
> where the model should not validate but does.
>
> My .ecore file is:
> import ecore : '//www.eclipse.org/emf/2002/Ecore#/';
>
> package tutorial : tut = '//www.eclipse.org/mdt/ocl/oclinecore/tutorial'
> {
> class Library
> {
> attribute name : String;
> property books#library : Book[*] { composes };
> property loans : Loan[*] { composes };
> property members#library : Member[*] { composes };
> }
>
> class Book
> {
> invariant SufficientCopies:
> library.loans->select(book=self)->size() <= copies;
> attribute name : String;
> attribute copies : Integer;
> property library#books : Library[?];
> }
>
> class Member
> {
> attribute name : String;
> property library#members : Library[?];
> }
>
> class Loan
> {
> property book : Book;
> property member : Member;
> attribute date : ecore::EDate[?];
> }
> }
>
> my .xmi file is:
> <?xml version="1.0" encoding="ASCII"?>
> <tut:Library
> xmi:version="2.0"
> xmlns:xmi="//www.omg.org/XMI"
> xmlns:xsi="//www.w3.org/2001/XMLSchema-instance"
> xmlns:tut="//www.eclipse.org/mdt/ocl/oclinecore/tutorial"
> xsi:schemaLocation="//www.eclipse.org/mdt/ocl/oclinecore/tutorial
> Tutorial.ecore"
> name="lib">
> <books name="b1"
> copies="1"/>
> <books name="b2"
> copies="2"/>
> <loans book="//@books.1"
> member="//@members.2"/>
> <loans book="//@books.1"
> member="//@members.2"/>
> <loans book="//@books.1"
> member="//@members.2"/>
> <members name="m1"/>
> <members name="m2"/>
> <members name="m3"/>
> </tut:Library>
>
> Per the documentation this should not validate because of the
> SufficientCopies constraint.
>
> Any ideas what I am doing wrong?
>
> (note I left off http when posting because of a posting restriction)
>
> Thanks,
> Mike
Previous Topic:[OCLinEcore] Invalid way of specifying cardinality
Next Topic:Sharing OCL operation definitions in Acceleo/QVTo
Goto Forum:
  


Current Time: Wed Oct 22 21:42:19 GMT 2014

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

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