pack.setName("orders"); //$NON-NLS-1$
pack.setNsPrefix("ord"); //$NON-NLS-1$
pack.setNsURI("http://www.jresearchsoft.com/schemas/orders"); //$NON-NLS-1$
EcoreUtil.setAnnotation(pack, UamPackage.eNS_URI, "#description", "test application"); //$NON-NLS-1$ //$NON-NLS-2$
PObject order = UamFactory.eINSTANCE.createPObject();
order.setId("order_pobject"); //$NON-NLS-1$
order.setName("order"); //$NON-NLS-1$
EcoreUtil.setAnnotation(order, UamPackage.eNS_URI, "#class_name", "com.jresearchsoft.uam.client.tests.Order"); //$NON-NLS-1$ //$NON-NLS-2$
EcoreUtil.setAnnotation(order, UamPackage.eNS_URI, "#mapper_name", "com.jresearchsoft.uam.client.mappers.impl.JavaInstanceMapper"); //$NON-NLS-1$ //$NON-NLS-2$
EcoreUtil.setAnnotation(order, UamPackage.eNS_URI, "#description", "customer order"); //$NON-NLS-1$ //$NON-NLS-2$
pack.getEClassifiers().add(order);
// region is an attribute for pObject and
EAttribute region = EcoreFactory.eINSTANCE.createEAttribute();
region.setName("region"); //$NON-NLS-1$
EcoreUtil.setAnnotation(region, UamPackage.eNS_URI, "#description", "region where the order comes"); //$NON-NLS-1$ //$NON-NLS-2$
region.setEType(EcorePackage.eINSTANCE.getEString());
order.getEStructuralFeatures().add(region);
// user id is an attribute - id of the current user
EAttribute userID = EcoreFactory.eINSTANCE.createEAttribute();
EcoreUtil.setAnnotation(userID, UamPackage.eNS_URI, IAttributeConstant.ANNOTATION_KEY_RUNTIME, "true"); //$NON-NLS-1$
userID.setName("userId"); //$NON-NLS-1$
userID.setEType(EcorePackage.eINSTANCE.getEString());
order.getEStructuralFeatures().add(userID);
// Now we create basic operations and add them to order
POperation createOp = UamFactory.eINSTANCE.createPOperation();
createOp.setId("create_operation"); //$NON-NLS-1$
createOp.setName("create"); //$NON-NLS-1$
POperation viewOp = UamFactory.eINSTANCE.createPOperation();
viewOp.setId("view_operation"); //$NON-NLS-1$
viewOp.setName("view"); //$NON-NLS-1$
POperation deleteOp = UamFactory.eINSTANCE.createPOperation();
deleteOp.setId("delete_operation"); //$NON-NLS-1$
deleteOp.setName("delete"); //$NON-NLS-1$
POperation updateOp = UamFactory.eINSTANCE.createPOperation();
updateOp.setId("update_operation"); //$NON-NLS-1$
updateOp.setName("update"); //$NON-NLS-1$
order.getEOperations().add(createOp);
order.getEOperations().add(viewOp);
order.getEOperations().add(deleteOp);
order.getEOperations().add(updateOp);
final String USER_EXPRESSION = "context orders::user_permission inv: login=object.userId"; //$NON-NLS-1$
final String REGION_EXPRESSION = "context orders::regional_permission inv: region=object.region"; //$NON-NLS-1$
Permission regionalPermission = UamFactory.eINSTANCE.createPermission();