Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Unexpected behaviour with audit rules.
Unexpected behaviour with audit rules. [message #518365] Wed, 03 March 2010 21:44 Go to next message
Eclipse UserFriend
Originally posted by: murbieta.gpi.com.ar

HI, i'm adding an audit rule in the gmfmap that doesn't behave as
expected in the generated gmf editor. The model is quite simple, Steps
may have several Actions (as a containment feature) and these last can't
have an already assigned id even if this belongs to a different Step. My
audit rule checks this business constrain with the following query:

not StepType.allInstances()->exists(s:StepType |
s.actionsDerived->exists (b : ActionType | b <> self implies b.id = self.id)
)


My test case runs ok, but when using the diagram it fails when i try to
add an Action to the single available Step which doesn't have registered
any Action before.
Thanks in advance.

The test case is the following:

public void testBasic() throws Exception {

Map extents = new HashMap();
StepType createStepType = ModelFactory.eINSTANCE.createStepType();
StepType createStepType2 = ModelFactory.eINSTANCE.createStepType();
List<StepType> lists= new ArrayList<StepType>();
//lists.add(createStepType);
lists.add(createStepType2);
extents.put(ModelPackage.eINSTANCE.getStepType(), lists);

ActionType singleActionType = ModelFactory.eINSTANCE.createActionType();
singleActionType.setId("unique");
ActionType davidActionType = ModelFactory.eINSTANCE.createActionType();
davidActionType.setId("David Copperfield");


ActionType myActionType = ModelFactory.eINSTANCE.createActionType ();
myActionType.setId("David Copperfield2");
createStepType.getActionsDerived().add(myActionType);


ActionType aActionType = ModelFactory.eINSTANCE.createActionType();
aActionType.setId("The Pickwick Papers");
createStepType2.getActionsDerived().add(aActionType);
aActionType = ModelFactory.eINSTANCE.createActionType();
aActionType.setId("David Copperfield");
createStepType2.getActionsDerived().add(aActionType);
aActionType = ModelFactory.eINSTANCE.createActionType();
aActionType.setId("Nicholas Nickleby");
createStepType2.getActionsDerived().add(aActionType);

org.eclipse.emf.ocl.query.Query query ;
query= QueryFactory.eINSTANCE.createQuery(
"not StepType.allInstances()->exists(s:StepType |" +
"s.actionsDerived->exists (b : ActionType | b <> self implies b.id
= self.id) " +
") "
,
ModelPackage.eINSTANCE.getActionType());

query.setExtentMap(extents);


Boolean evaluate = (Boolean) query.evaluate(singleActionType);
assertTrue(evaluate);
System.out.println(evaluate);

evaluate = (Boolean) query.evaluate(davidActionType);
System.out.println(evaluate);
assertFalse(evaluate);


}
Re: Unexpected behaviour with audit rules. [message #519214 is a reply to message #518365] Mon, 08 March 2010 05:34 Go to previous message
Jevon  is currently offline Jevon Friend
Messages: 164
Registered: July 2009
Senior Member
Hi Matias,

How and where does it "fail"? You may want to include a stack trace if
this is the problem.

Cheers
Jevon

Matias Urbieta wrote:
> HI, i'm adding an audit rule in the gmfmap that doesn't behave as
> expected in the generated gmf editor. The model is quite simple, Steps
> may have several Actions (as a containment feature) and these last can't
> have an already assigned id even if this belongs to a different Step. My
> audit rule checks this business constrain with the following query:
>
> not StepType.allInstances()->exists(s:StepType |
> s.actionsDerived->exists (b : ActionType | b <> self implies b.id =
> self.id)
> )
>
>
> My test case runs ok, but when using the diagram it fails when i try to
> add an Action to the single available Step which doesn't have registered
> any Action before.
> Thanks in advance.
>
> The test case is the following:
>
> public void testBasic() throws Exception {
>
> Map extents = new HashMap();
> StepType createStepType = ModelFactory.eINSTANCE.createStepType();
> StepType createStepType2 = ModelFactory.eINSTANCE.createStepType();
> List<StepType> lists= new ArrayList<StepType>();
> //lists.add(createStepType);
> lists.add(createStepType2);
> extents.put(ModelPackage.eINSTANCE.getStepType(), lists);
>
> ActionType singleActionType =
> ModelFactory.eINSTANCE.createActionType();
> singleActionType.setId("unique");
> ActionType davidActionType = ModelFactory.eINSTANCE.createActionType();
> davidActionType.setId("David Copperfield");
>
>
> ActionType myActionType = ModelFactory.eINSTANCE.createActionType ();
> myActionType.setId("David Copperfield2");
> createStepType.getActionsDerived().add(myActionType);
>
>
> ActionType aActionType = ModelFactory.eINSTANCE.createActionType();
> aActionType.setId("The Pickwick Papers");
> createStepType2.getActionsDerived().add(aActionType);
> aActionType = ModelFactory.eINSTANCE.createActionType();
> aActionType.setId("David Copperfield");
> createStepType2.getActionsDerived().add(aActionType);
> aActionType = ModelFactory.eINSTANCE.createActionType();
> aActionType.setId("Nicholas Nickleby");
> createStepType2.getActionsDerived().add(aActionType);
>
> org.eclipse.emf.ocl.query.Query query ;
> query= QueryFactory.eINSTANCE.createQuery(
> "not StepType.allInstances()->exists(s:StepType |" +
> "s.actionsDerived->exists (b : ActionType | b <> self implies
> b.id = self.id) " +
> ") "
> ,
> ModelPackage.eINSTANCE.getActionType());
>
> query.setExtentMap(extents);
>
>
> Boolean evaluate = (Boolean) query.evaluate(singleActionType);
> assertTrue(evaluate);
> System.out.println(evaluate);
>
> evaluate = (Boolean) query.evaluate(davidActionType);
> System.out.println(evaluate);
> assertFalse(evaluate);
>
>
> }
Previous Topic:Link Mapping without Source or Target Feature
Next Topic:Mapping UI with domain models
Goto Forum:
  


Current Time: Thu Nov 15 14:33:15 GMT 2018

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

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

Back to the top