|
|
Re: [Eugenia] Negation [message #759097 is a reply to message #759070] |
Sat, 26 November 2011 11:05 |
|
[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
|
|
|
|
Powered by
FUDForum. Page generated in 0.04968 seconds