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 static String getAttributeByName(GraphEntity ge, String attributeName) { for (GraphAttribute ga : ge.getAllAttrs()) { if (ga.getName().equals(attributeName)) { return ga.getSimpleValue(); } } return ""; }
public static GraphEntity getADL(String humanId, Browser browser) { GraphEntity result = null; try { GraphEntity[] entities = browser.getAllEntities(); for (GraphEntity adl : entities) { if (adl.getType().equalsIgnoreCase(ADLProfile_SPEC_DIAGRAM)) { Vector<GraphRelationship> rels = adl.getAllRelationships("ProfileOf"); for (GraphRelationship rel : rels) { GraphEntity connectedHuman = Utils.getTargetEntity(adl, rel); if (connectedHuman != null && connectedHuman.getID().equalsIgnoreCase(humanId)) { return adl; } } } } } catch (Throwable ex) { ex.printStackTrace(); } return result; } }
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 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 void generateActivityClasses(Sequences seq) throws NullEntity, NotFound { for (GraphEntity ge : browser.getAllEntities()) { if (ge.getType().equals(ACTIVITY_TYPE)) { GraphAttribute ga = ge .getAttributeByName(SEQ_TASK_DIAGRAM_FIELD); if (ga != null) { String actDiagId = Utils.replaceBadChars(ga.getSimpleValue()); if (actDiagId != null && !actDiagId.equals("")) { Repeat rep = new Repeat("activities"); seq.addRepeat(rep); rep.add(new Var("aID", Utils.replaceBadChars(ge.getID()))); rep.add(new Var("aType", Utils.replaceBadChars(ge.getType()))); rep.add(new Var("aDesc", Utils.getAttributeByName(ge, "Description"))); rep.add(new Var("stID", Utils.replaceBadChars(actDiagId))); continue; } } logger.log(Level.SEVERE, "The {0} activity doesn't have sequential task diagram!", new Object[]{ge.getID()}); System.exit(0); } } }
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; }
ens.add(new Var("link",""+ge.getID())); r.add(ens); ens.add(new Var("link",""+ge.getID())); ens.add(new Var("name", ge.getID())); ens.add(new Var("tipo", ge.getType())); try { ens.add(new Var("description", ge.getAttributeByName("Description").getSimpleValue())); Vector mentioned=new Vector(); for (int l=0;l<dges.length;l++){ found=dges[l].getID().equals(ge.getID()); if (found && !mentioned.contains(gs[m].getName())){ Repeat diagram=new Repeat("relateddiagrams"); GraphRelationship[] gr = ge.getRelationships(); for (int i = 0; i < gr.length; i++) { Repeat rels = new Repeat("relationship"); Repeat rroles = new Repeat("roles"); rroles.add(new Var("name", groles[h].getName())); rroles.add(new Var("player", groles[h].getPlayer().getID())); rels.add(rroles);
private static Vector<String> checkFields(GraphEntity ent1, GraphEntity ent2, Vector alreadyVerified) { GraphAttribute[] attsEnt1 = ent1.getAllAttrs(); GraphAttribute[] attsEnt2 = ent2.getAllAttrs(); Vector<String> differences=new Vector<String>(); differences, gaE1, gaE2); else { differences.add("entity "+ent1.getID()+":"+ent1.getType()+" has an attribute named "+gaE1.getName()+" with different type in the second spec");
private Vector<Graph> getPDDiagramsForActor(GraphEntity actor) { Vector<Graph> patientGraphs = new Vector<Graph>(); Vector<GraphRelationship> rels = actor.getAllRelationships("ProfileOf"); for (GraphRelationship rel : rels) { GraphEntity target; try { target = Utils.getSourceEntity(actor, rel); if (target.getType().equals("ParkinsonsProfile")) { GraphAttribute diagNameAtt = target.getAttributeByName("ParkinsonSpecDiag"); if (diagNameAtt != null && diagNameAtt.getSimpleValue() != null && browser.getGraph(diagNameAtt.getSimpleValue()) != null) { patientGraphs.add(browser.getGraph(diagNameAtt.getSimpleValue())); } } } catch (NotFound e) { // TODO Auto-generated catch block e.printStackTrace(); } } return patientGraphs; }
public static List<GraphEntity> getEntities(Browser b, String typeName) { List<GraphEntity> result = new ArrayList<GraphEntity>(); for(GraphEntity ge: b.getAllEntities()) { if(ge.getType().equals(typeName)) { result.add(ge); } } return result; }
private String getActorSymptomInSimdiagram(Graph graph, GraphEntity actor, GraphEntity symptom) { try { for (GraphEntity entity : graph.getEntities()) { if (entity.getType().equals("HumanInitialization") && Utils.getRelatedElementsVectorInSameDiagram(entity, "RelatedHuman", "RelatedHumantarget").contains(actor)) { Vector<GraphEntity> symptomsInitialized = Utils.getRelatedElementsVectorInSameDiagram(entity, "InitializesSymptom", "InitializesSymptomtarget"); for (GraphEntity symptominialization : symptomsInitialized) { boolean initializedSympom = Utils.getRelatedElementsVectorInSameDiagram(symptominialization, "InitializedSymptom", "InitializedSymptomtarget").contains(symptom); if (initializedSympom) { String levelValue = symptominialization.getAttributeByName("SymptomLevel").getSimpleValue(); switch (levelValue) { case "LOW": return "phat.agents.filters.Symptom.Level.LOW"; case "MEDIUM": return "phat.agents.filters.Symptom.Level.MEDIUM"; case "HIGH": return "phat.agents.filters.Symptom.Level.HIGH"; } } } } } } catch (NullEntity | NotFound e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
public static boolean containedInto(Browser bimp1, Browser bimp2){ GraphEntity[] entities = bimp1.getAllEntities(); boolean allIncluded=true; int k=0; while (allIncluded && k<entities.length){ GraphEntity ent1 = entities[k]; GraphEntity ent2 = bimp2.findEntity(ent1.getID()); allIncluded=allIncluded && ent2!=null; allIncluded = allIncluded && containedIntoAttributes(allIncluded, ent1, ent2); Vector<GraphRelationship> relationships1 = ent1.getAllRelationships(); Vector<GraphRelationship> relationships2 = ent2.getAllRelationships(); int j=0; allIncluded=allIncluded && relationships1.size()==relationships2.size(); while (allIncluded && j<relationships1.size()){ GraphRelationship gr1=relationships1.elementAt(j); boolean found=false; for (int l=0;l<relationships2.size() && !found;l++){ GraphRelationship gr2=relationships2.elementAt(l); found=found || (gr2.getID().equals(gr1.getID()) && containedIntoAttributes(allIncluded, gr1, gr2)); } allIncluded=allIncluded && found; j++; } k++; } return allIncluded; }
public static GraphRelationship[] getRelatedElementsRels( GraphEntity element, String relationshipname) { Vector rels = element.getAllRelationships(); Enumeration enumeration = rels.elements(); Vector related = new Vector(); while (enumeration.hasMoreElements()) { GraphRelationship gr = (GraphRelationship) enumeration .nextElement(); if (gr.getType().toLowerCase() .equals(relationshipname.toLowerCase())) { related.add(gr); } } return toGRArray(related.toArray()); }
private static boolean hasField(GraphEntity task, String fieldName) { GraphAttribute d; try { d = task.getAttributeByName(fieldName); } catch (NotFound ex) { return false; } return true;//d != null && !d.getSimpleValue().equals(""); }
public static GraphEntity getSourceEntity(GraphEntity ge, String relationType) { try { for (GraphRelationship gr : ge.getRelationships()) { if (gr.getType().equals(relationType)) { return getSourceEntity(ge, gr); } } } catch (Throwable ex) { ex.printStackTrace(); } return null; }
private static String getCondition(GraphEntity geCond) { String type = geCond.getType(); if (type.equals(CTIME_TYPE)) { GraphAttribute gaHours = null; try { gaHours = geCond.getAttributeByName(HOURS_FIELD); } catch (NotFound ex) { logger.log(Level.SEVERE, "Entity {0} hasn't got attribute {1}", new Object[]{geCond.getID(), HOURS_FIELD}); System.exit(-1); logger.log(Level.WARNING, "Attribute {1} of entity {0} is no set. Defulat value \"0\".", new Object[]{HOURS_FIELD, geCond.getID()}); try { gaMins = geCond .getAttributeByName("MinutesField"); } catch (NotFound ex) { logger.log(Level.SEVERE, "Entity {0} hasn't got attribute {1}", new Object[]{geCond.getID(), "MinutesField"}); System.exit(-1); logger.log(Level.WARNING, "Attribute {1} of entity {0} is no set. Defulat value \"0\".", new Object[]{"MinutesField", geCond.getID()}); try { gaSecs = geCond .getAttributeByName(SECS_FIELD);
System.out.println("interactionDiagrams=" + interactionProfiles.size()); for (GraphEntity ge : interactionProfiles) { System.out.println("-" + ge.getID()); GraphAttribute ga = null; try { ga = ge.getAttributeByName("InteractionSpecDiagField"); if (ga != null && !ga.getSimpleValue().equals("")) { System.out.println("\t-" + ga.getSimpleValue()); System.out.println("\t-" + interactionGraph.getName()); for (GraphEntity mle : Utils.getEntities(interactionGraph, "MessageListenedEvent")) { GraphAttribute message = mle.getAttributeByName("Message"); if (!"".equals(message.getSimpleValue())) { List<String> words = new ArrayList<>();
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; } }
public static boolean hasAnyEntity(Browser b, String typeName) { boolean result = false; for(GraphEntity ge: b.getAllEntities()) { if(ge.getType().equals(typeName)) { result = true; break; } } return result; }