public GraphEntity findEntity(String id){ GraphEntity[] ents=this.getAllEntities(); boolean found=false; int k=0; for (k=0;k<ents.length &&!found;k++){ found=ents[k].getID().equals(id); } if (found) return ents[k-1]; else return null; }
private String getSymptomEvoName(GraphEntity symptom) { String result = Utils.getAttributeByName(symptom, "SymptomEvoField"); if (result.equals("")) { logger.log(Level.WARNING, "There are not Symptom Evolution Diagram for symptom {0}", new Object[]{symptom.getID()}); return null; } else { //return "new "+Utils.replaceBadChars(result)+"(agent,"+Utils.replaceBadChars(symptom.getID())+")"; return result; } }
private static String getVarValue(GraphEntity task, String varRel, String value) { GraphEntity ge = Utils.getTargetEntity(task, varRel); String resultValue = value.equals("null") ? "null" : "\"" + value + "\""; if (ge != null) { String varValue = "getParent().getMetadata(\"" + Utils.replaceBadChars(ge.getID()) + "\")"; return varValue + " != null ? " + varValue + " : " + resultValue; } return resultValue; } }
public static String getFieldValue(GraphEntity task, String fieldName, String def, boolean mandatory) { GraphAttribute at = null; try { at = task.getAttributeByName(fieldName); } catch (NotFound ex) { } if (at == null || at.getSimpleValue().equals("")) { if (mandatory) { logger.log(Level.SEVERE, "Attribute {0} of {1} is empty!", new Object[]{fieldName, task.getID()}); System.exit(0); } else { logger.log(Level.WARNING, "Attribute {0} of {1} is empty!", new Object[]{fieldName, task.getID()}); return def; } } return Utils.getValue(at); }
public static boolean isTargetOfAnyRelationship(GraphEntity ge) throws NullEntity { for (GraphRelationship gr : ge.getRelationships()) { for (GraphRole gRole : gr.getRoles()) { if (gRole.getPlayer().getID().equals(ge.getID()) && gRole.getName().endsWith("target")) { return true; } } } return false; }
public static GraphEntity getTargetEntity(GraphEntity ge, GraphRelationship gr) throws NullEntity { GraphRole gRole = getTargetRole(gr.getRoles()); System.out.println("Roles:"); for (GraphRole r : gr.getRoles()) { System.out.println("-" + r.getName() + "->" + r.getPlayer().getID()); } System.out.println("gRole = " + gRole.getPlayer().getID()); if (gRole != null && !gRole.getPlayer().getID().equals(ge.getID())) { return gRole.getPlayer(); } return null; }
public static Vector<GraphEntity> getProfilesTypeOf(String humanId, String profileType, Browser browser) { Vector<GraphEntity> result = new Vector<GraphEntity>(); try { GraphEntity[] entities = browser.getAllEntities(); for (GraphEntity adl : entities) { if (adl.getType().equalsIgnoreCase(profileType)) { GraphEntity human = Utils.getTargetEntity(adl, "ProfileOf"); if (human != null && human.getID().equals(humanId)) { result.add(adl); } } } } catch (Throwable ex) { ex.printStackTrace(); } return result; }
public GraphEntity findEntity(String sourceTaskID) { GraphEntity[] entities; try { entities = getEntities(); GraphEntity found=null; for (GraphEntity ge:entities){ if (ge.getID().equalsIgnoreCase(sourceTaskID)) found=ge; } return found; } catch (NullEntity e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
public static GraphEntity getTargetEntity(GraphEntity ge, String relationType, GraphRelationship[] rel) { try { for (GraphRelationship gr : rel) { if (gr.getType().equals(relationType)) { GraphRole sRole = getSourceRole(gr.getRoles()); GraphRole gRole = getTargetRole(gr.getRoles()); if (sRole != null && sRole.getPlayer().getID().equals(ge.getID()) && gRole != null && !gRole.getPlayer().getID().equals(ge.getID())) { return gRole.getPlayer(); } } } } catch (Throwable ex) { ex.printStackTrace(); } return null; }
public static GraphEntity getProfileTypeOf(String humanId, String profileType, Browser browser) { GraphEntity result = null; try { GraphEntity[] entities = browser.getAllEntities(); for (GraphEntity adl : entities) { if (adl.getType().equalsIgnoreCase(profileType)) { GraphEntity human = Utils.getTargetEntity(adl, "ProfileOf"); if (human != null && human.getID().equals(humanId)) { return adl; } } } } catch (Throwable ex) { ex.printStackTrace(); } return result; }
public static Collection<GraphEntity> getTargetsEntity(GraphEntity ge, String relationType) { List<GraphEntity> result = new ArrayList<>(); try { for (GraphRelationship gr : ge.getRelationships()) { if (gr.getType().equals(relationType)) { for (GraphRole gRole : getTargetsRole(gr.getRoles())) { if (gRole != null && gRole.getPlayer().getID() != ge.getID()) { result.add(gRole.getPlayer()); } } } } } catch (Throwable ex) { ex.printStackTrace(); } return result; }
public static GraphEntity getSourceEntity(GraphEntity ge, GraphRelationship gr) { GraphRole gRole = getSourceRole(gr.getRoles()); try { if (gRole != null && gRole.getPlayer().getID() != ge.getID()) { return gRole.getPlayer(); } } catch (NullEntity e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
public static Collection<GraphEntity> getSourcesEntity(GraphEntity ge, String relationType) { List<GraphEntity> result = new ArrayList<GraphEntity>(); try { for (GraphRelationship gr : ge.getRelationships()) { if (gr.getType().equals(relationType)) { for (GraphRole gRole : getSourcesRole(gr.getRoles())) { if (gRole != null && gRole.getPlayer().getID() != ge.getID()) { result.add(gRole.getPlayer()); } } } } } catch (Throwable ex) { ex.printStackTrace(); } return result; }
private void generateCondTransitions(GraphEntity activity, Repeat repFather) { for (GraphEntity previousIf : Utils.getSourcesEntity(activity, TRUE_FLOW_REL)) { if (previousIf.getType().equals(IF_FLOW_CONTROL_TYPE)) { propagateCond(activity, previousIf, "new CompositeAndCondition(" + Utils.replaceBadChars(previousIf.getID()) + ")", repFather); } } for (GraphEntity previousIf : Utils.getSourcesEntity(activity, FALSE_FLOW_REL)) { if (previousIf.getType().equals(IF_FLOW_CONTROL_TYPE)) { propagateCond(activity, previousIf, "new NegateCondition(new CompositeAndCondition(" + Utils.replaceBadChars(previousIf.getID()) + "))", repFather); } } }
public static String getValue(GraphAttribute attribute) { if (attribute.isCollectionValue()) { try { return replaceBadChars(attribute.getCollectionValue().getElementAt(0).getID()); } catch (NullEntity ex) { Logger.getLogger(TaskGenerator.class.getName()).log(Level.SEVERE, null, ex); } } if(attribute.isEntityValue()) { return replaceBadChars(attribute.getSimpleValue()); } return attribute.getSimpleValue(); }
private void registerFirstProgState(Graph deviceBehavDiag, Repeat repFather) { GraphEntity ge = Utils.getFirstEntity(deviceBehavDiag, PROGRAM_STATE); if (ge == null) { logger.log(Level.SEVERE, "The diagram {0} is empty or doesn't know " + "which entity is the first one!", new Object[]{deviceBehavDiag.getID()}); System.exit(0); } Repeat repFirst = new Repeat("firstProgState"); repFather.add(repFirst); repFirst.add(new Var("psID", Utils.replaceBadChars(ge.getID()))); }
private void generateDirectTransitions(GraphEntity activity, Repeat repFather) { for (GraphEntity previousAct : Utils.getSourcesEntity(activity, NEXT_ACTIVITY_REL)) { if (previousAct.getType().equals(ACTIVITY_TYPE)) { // registers a transition between activities without any // condition Repeat rep2 = new Repeat("regTrans"); repFather.add(rep2); rep2.add(new Var("actSource", Utils.replaceBadChars(previousAct.getID()))); rep2.add(new Var("actTarget", Utils.replaceBadChars(activity.getID()))); } } }
private Repeat createNewProgState(GraphEntity progState) { Repeat progStateRep = new Repeat("progStates"); System.out.println("\t\tProgState: " + progState.getID() + ":" + progState.getType()); progStateRep.add(new Var("psID", Utils.replaceBadChars(progState.getID()))); progStateRep.add(new Var("psType", Utils.replaceBadChars(progState.getType()))); progStateRep.add(new Var("psDesc", Utils.getAttributeByName(progState, "Description"))); return progStateRep; } }
public void generateAgents(Sequences seq) throws NullEntity, NotFound { new ADLsGenerator(browser).generateADLClasses(seq); for (Graph diagram : Utils.getGraphsByType(HUMAN_PROFILE_SPEC_DIAGRAM, browser)) { for (GraphEntity actor : Utils.getEntities(diagram, "Human")) { Repeat rep = new Repeat("actors"); seq.addRepeat(rep); rep.add(new Var("aName", Utils.replaceBadChars(actor.getID()))); String humanId = actor.getID(); new InteractionDiagramGenerator(browser).generateEventProcessor(humanId, rep); PDGenerator.linkPDManager(humanId, rep, browser); new PDGenerator(browser).generatePD(seq, actor); } } } }
private void generateCondition(Graph adlSpec, Repeat repFather) throws NullEntity { for (GraphEntity condition : adlSpec.getEntities()) { if (condition.getType().equals(IF_FLOW_CONTROL_TYPE)) { Collection<GraphEntity> conds = Utils.getTargetsEntity(condition, IF_FLOW_COND_REL); String condSentence = ConditionGenerator.generateAndCondition(conds); String condId = Utils.replaceBadChars(condition.getID()); Repeat conditions = new Repeat("conditions"); repFather.add(conditions); conditions.add(new Var("condId", condId)); conditions.add(new Var("condInst", condSentence)); } } }