Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [Eugenia] Negation
[Eugenia] Negation [message #759019] Fri, 25 November 2011 15:40 Go to next message
Snakebyte Missing name is currently offline Snakebyte Missing nameFriend
Messages: 130
Registered: November 2011
Senior Member
What i have to do if i want to negate the following constraint ?

context Claim {
	constraint UniqueRoot {
		check : Claim.all.one(as|as.claims.includes(self))
		message : 'Could not find the root node. Maybe its not unique ?'
	}
}


I want that constraint to show up, if there is not exactly one Claim, that NOT appear in the relation "claims".

For now the constraint show up, if there is not exactly one Claim, that APPEAR in the relation "claims".

Can i use the NOT Operator on the regular expression in any way ?
Re: [Eugenia] Negation [message #759070 is a reply to message #759019] Fri, 25 November 2011 22:05 Go to previous messageGo to next message
Snakebyte Missing name is currently offline Snakebyte Missing nameFriend
Messages: 130
Registered: November 2011
Senior Member
This is the corresponding model :

@namespace(uri="argumentmodel", prefix="argumentmodel")
@gmf(foo="bar")
package ArgumentModel;

@gmf.diagram(onefile="false")
class TrustCase {
   val Claim[*] valclaims;
}

@gmf.node(label="name", phantom="true")
class Claim {
   attr String name;
   attr String description;
   @gmf.link(foo="bar")
   val ArgumentStrategy[*] connectarg;
}
@gmf.node(label="name", phantom="true")
class ArgumentStrategy {
   attr String description;
   attr String name;
   @gmf.link(incoming="true")
   ref Claim [*] claims;
}


What i want is to ensure that there is only one Claim not referenced by any ArgumentStrategy.
Re: [Eugenia] Negation [message #759097 is a reply to message #759070] Sat, 26 November 2011 11:05 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 597
Registered: January 2010
Location: Birmingham, UK
Senior Member

[quote title=Snakebyte wrote on Fri, 25 November 2011 17:05]This is the corresponding model :

@namespace(uri="argumentmodel", prefix="argumentmodel")
@gmf(foo="bar")
package ArgumentModel;

@gmf.diagram(onefile="false")
class TrustCase {
   val Claim[*] valclaims;
}

@gmf.node(label="name", phantom="true")
class Claim {
   attr String name;
   attr String description;
   @gmf.link(foo="bar")
   val ArgumentStrategy[*] connectarg;
}

@gmf.node(label="name", phantom="true")
class ArgumentStrategy {
   attr String description;
   attr String name;
   @gmf.link(incoming="true")
   ref Claim [*] claims;
}


Quote:

What i want is to ensure that there is only one Claim not referenced by any ArgumentStrategy.


The metamodel doesn't adapt very nicely to that query, but I guess this could work (untested, sorry!):

context TrustCase {
    check {
      var referencedClaims := 
        ArgumentStrategy.all.collect(a|a.claims).flatten().asSet();
      var claimsNotReferenced := self.valclaims.excludingAll(referencedClaims);
      return claimsNotReferenced.size() = 1;
    }

    message : 'Exactly one claim should not be referenced by any ArgumentStrategy'
}


Basically, we compute the set of every claim referenced in some ArgumentStrategy, and then subtract it from the set of all claims. Another way would be to go claim by claim, checking that it's not referenced from any argument strategy and then adding it to a set. However, I think that might be more expensive (and harder to read).

Edit: you're trying to validate a property of your entire model, and not just of one Claim or one ArgumentStrategy. You'll probably need to use the model entity that represents the whole model as context in EVL in those cases.

[Updated on: Sat, 26 November 2011 17:01]

Report message to a moderator

Re: [Eugenia] Negation [message #759111 is a reply to message #759097] Sat, 26 November 2011 13:47 Go to previous message
Snakebyte Missing name is currently offline Snakebyte Missing nameFriend
Messages: 130
Registered: November 2011
Senior Member
Works great, thanks.
Previous Topic:[EuGENia | EOL] delete creation tool
Next Topic:how the gmf editor supports a constraint in the ecore model
Goto Forum:
  


Current Time: Wed May 08 18:29:00 GMT 2024

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

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

Back to the top