Unexpected behaviour with audit rules. [message #518365] |
Wed, 03 March 2010 21:44 |
Eclipse User |
|
|
|
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);
}
|
|
|
|
Powered by
FUDForum. Page generated in 0.03232 seconds