/** * Apply the objective constraint. This should modify the two elements in relation! * * @param subjectVariable * @param objectVariable * @return */ public boolean performObjective( CubeAgent agent, Variable subjectVariable, Variable objectVariable) { Object instance1_uuid = subjectVariable.getValue(); Object instance2_uuid = objectVariable.getValue(); if (instance1_uuid != null && instance2_uuid != null) { RuntimeModelController rmController = agent.getRuntimeModelController(); if (rmController != null) { try { String scope_id = rmController.getPropertyValue(instance1_uuid.toString(), Scope.CORE_SCOPE_ID); if (rmController.addReferencedElement( instance1_uuid.toString(), Scope.CORE_SCOPE_MASTER, instance2_uuid.toString())) { if (rmController.addReferencedElement( instance2_uuid.toString(), scope_id, instance1_uuid.toString())) { return true; } } } catch (InvalidNameException ex) { ex.printStackTrace(); } } } return false; }
public boolean check(CubeAgent agent, Variable subjectVariable, Variable objectVariable) { Object instance1_uuid = subjectVariable.getValue(); Object instance2_uuid = objectVariable.getValue(); if (instance1_uuid != null && instance2_uuid != null) { RuntimeModelController rmController = agent.getRuntimeModelController(); if (rmController != null) { if (rmController.hasReferencedElement( instance1_uuid.toString(), Scope.CORE_SCOPE_MASTER, instance2_uuid.toString())) { return true; } } } return false; }
public void init(CubeAgent agent, Variable subjectVariable, Variable objectVariable) { Object instance1_uuid = subjectVariable.getValue(); if (instance1_uuid != null) { RuntimeModelController rmController = agent.getRuntimeModelController(); if (rmController != null) { List<String> tmp = rmController.getReferencedElements(instance1_uuid.toString(), Scope.CORE_SCOPE_MASTER); for (String s : rmController.getReferencedElements( instance1_uuid.toString(), Scope.CORE_SCOPE_MASTER)) { objectVariable.setValue(s); } } } }
/** * Find value from object variable. * * @param subjectVariable * @param objectVariable * @return */ public String find(CubeAgent agent, Variable subjectVariable, Variable objectVariable) { Object instance2_uuid = objectVariable.getValue(); if (instance2_uuid != null) { RuntimeModelController rmController = agent.getRuntimeModelController(); if (rmController != null) { List<String> sleaders = rmController.getReferencedElements( instance2_uuid.toString(), subjectVariable.getProperty(Scope.CORE_SCOPE_ID)); for (String s : sleaders) { if (!subjectVariable.hasValue(s)) { return s; } } } } return null; }