public static String getAttributeByName(GraphEntity ge, String attributeName, String defaultValue) { for (GraphAttribute ga : ge.getAllAttrs()) { if (ga.getName().equals(attributeName)) { return (ga.getSimpleValue().equals("")) ? defaultValue : ga.getSimpleValue(); } } return defaultValue; }
private String getSymptomClass(GraphEntity symptom) { String result = "Symptom"; try { GraphAttribute typeGA = symptom.getAttributeByName("PDSymptomTypeField"); String symptType = typeGA.getSimpleValue(); if (!symptType.equals("")) { if (symptType.equals("Tremor")) { result = "TremorSymptom"; } } } catch (NotFound ex) { logger.log(Level.SEVERE, null, ex); } return result; }
public static String getADLName(String humanId, Browser browser) throws NotFound { GraphEntity ge = getADL(humanId, browser); if (ge != null) { GraphAttribute ga = ge.getAttributeByName("ADLSpecField"); if(ga != null && !ga.getSimpleValue().equals("")) { return Utils.replaceBadChars(ga.getSimpleValue()); } } return null; }
public static String getAttributeByName(GraphEntity ge, String attributeName) { for (GraphAttribute ga : ge.getAllAttrs()) { if (ga.getName().equals(attributeName)) { return ga.getSimpleValue(); } } return ""; }
private static String isCanBeInterrupted(GraphEntity task) { try { GraphAttribute ga = task .getAttributeByName("CanBeInterruptedField"); String value = ga.getSimpleValue(); if (value.equals("No")) { return "false"; } } catch (NotFound e) { // TODO Auto-generated catch block e.printStackTrace(); } return "true"; }
try { ga = ge.getAttributeByName("InteractionSpecDiagField"); if (ga != null && !ga.getSimpleValue().equals("")) { System.out.println("\t-" + ga.getSimpleValue()); Graph interactionGraph = Utils.getGraphByName(ga.getSimpleValue(), browser); if (interactionGraph != null) { 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<>(); words.addAll(Arrays.asList(message.getSimpleValue().split("[\\s,?!]"))); result.add(words);
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(); }
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); }
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; }
GraphAttribute sd = sp .getAttributeByName("SocialSpecDiagField"); if (sd.getSimpleValue() != null) { System.out.println("Diagram name = " + sd.getSimpleValue()); Graph socialProfile = Utils.getGraphByName( sd.getSimpleValue(), browser); GraphEntity pi = getEntity(socialProfile, "PersonalInfo"); .getAttributeByName("AgeField"); if (ageAt != null && !ageAt.getSimpleValue().equals("")) { int age = Integer.parseInt(ageAt .getSimpleValue()); if (age > 60) { return "ElderLP";
public static void linkPDManager(String humanId, Repeat repFather, Browser browser) { GraphEntity dmGraph = Utils.getProfileTypeOf(humanId, PARKINSON_PROFILE, browser); if (dmGraph != null) { try { GraphAttribute pdSpec = dmGraph.getAttributeByName("ParkinsonSpecDiag"); Repeat rep = new Repeat("filterManager"); repFather.add(rep); rep.add(new Var("fmName", Utils.replaceBadChars(pdSpec.getSimpleValue()))); } catch (NotFound ex) { Logger.getLogger(PDGenerator.class.getName()).log(Level.SEVERE, null, ex); } } } }
private static void evaluateSimpleValueField(GraphEntity ent1, Vector<String> differences, GraphAttribute gaE1, GraphAttribute gaE2) { boolean found; String simpleValue1=null; String simpleValue2=null; simpleValue1=gaE1.getSimpleValue(); simpleValue2=gaE2.getSimpleValue(); if (simpleValue1==null && simpleValue1==null){ found=true; } else if (simpleValue1==null && simpleValue2!=null){ differences.add("entity " +ent1.getID()+":"+ent1.getType()+" has a null value for attribute "+ gaE1.getName()+" instead the second spec has "+simpleValue2); } else if (simpleValue1!=null && simpleValue2==null){ differences.add("entity " +ent1.getID()+":"+ent1.getType()+" has not the same values for attribute "+ gaE1.getName()+":"+simpleValue1+" instead the second spec has null"); } else if (simpleValue1!=null && simpleValue2!=null && !simpleValue1.equals(simpleValue2)){ differences.add("entity " +ent1.getID()+":"+ent1.getType()+" has a value \""+simpleValue1+"\" for attribute "+ gaE1.getName()+" instead the second spec has \""+simpleValue2+"\""); } }
if (distanceGA != null && !distanceGA.getSimpleValue().equals("")) { distance = distanceGA.getSimpleValue(); if (elevationGA != null && !elevationGA.getSimpleValue().equals("")) { elevation = elevationGA.getSimpleValue(); if (frontGA != null && !frontGA.getSimpleValue().equals("")) { if (frontGA.getSimpleValue().equals("No")) { front = "false";
GraphAttribute seedworld = ge.getAttributeByName("SimulationSeedField"); if (seedworld != null && !seedworld.getSimpleValue().equals("")) { System.out.println("\n\n\nSEED = " + seedworld.getSimpleValue() + "\n\n\n"); Repeat setSeed = new Repeat("setSeed"); rep.add(setSeed); setSeed.add(new Var("seedValue", seedworld.getSimpleValue())); if (houseType != null && !houseType.getSimpleValue().equals("")) { houseTypeString = houseType.getSimpleValue(); GraphAttribute sec = iniDate.getAttributeByName("SecondField"); rep.add(new Var("year", year.getSimpleValue())); rep.add(new Var("month", month.getSimpleValue())); rep.add(new Var("day", day.getSimpleValue())); rep.add(new Var("hour", hour.getSimpleValue())); rep.add(new Var("min", min.getSimpleValue())); rep.add(new Var("sec", sec.getSimpleValue())); if (width != null && !width.getSimpleValue().equals("") && height != null && !height.getSimpleValue().equals("")) { System.out.println("\n\n\nSEED = " + seedworld.getSimpleValue() + "\n\n\n"); Repeat setResolution = new Repeat("setResolution"); rep.add(setResolution); setResolution.add(new Var("displayHeight", height.getSimpleValue())); setResolution.add(new Var("displayWidth", width.getSimpleValue()));
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; }
attr1.getName().equals(attr2.getName()); if (found){ found = found || (attr1.getSimpleValue()!=null && attr2.getSimpleValue()!=null && attr1.getSimpleValue().equals(attr2.getSimpleValue())); if (!found){ try {
public void generateActivities(Graph activitiesSpec, Sequences seq) throws NotFound, NullEntity { GraphEntity ge = Utils.getFirstEntity(activitiesSpec); if (ge.getType().equals("BActivity")) { GraphEntity nActivity = Utils.getTargetEntity(ge, "NextActivity"); if (nActivity == null) { return; } GraphAttribute ga = ge.getAttributeByName("SeqTaskDiagramField"); Graph taskSpecDiagram = Utils.getGraphByName(ga.getSimpleValue(), getBrowser()); /*if (taskSpecDiagram != null) { TaskGenerator taskGenerator = new TaskGenerator(getBrowser(), seq); taskGenerator.generate("", taskSpecDiagram); }*/ } }
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); } } }
.getAttributeByName(ACTIVITY_SPEC_FIELD); if (ga != null) { String actDiagId = ga.getSimpleValue(); if (actDiagId != null && !actDiagId.equals("")) { Graph actDiagram = Utils.getGraphByName(actDiagId,
private void generateDeviceAgentsInitialization(Graph simDiag, Repeat simInitRep) throws NullEntity, NotFound { for (GraphEntity progPool : Utils.getEntities(simDiag, INIT_PROGRAM_POOL)) { for (GraphEntity deviceEntity : Utils.getTargetsEntity(progPool, "device")) { Repeat importADLRep = new Repeat("importDevices"); simInitRep.add(importADLRep); String deviceId = deviceEntity.getID(); Repeat agentRep = new Repeat("deviceAgentRep"); simInitRep.add(agentRep); simInitRep.add(new Var("daID", deviceId)); GraphCollection gc = progPool.getAttributeByName("ProgramPoolField").getCollectionValue(); for (int i = 0; i < gc.size(); i++) { String progId = gc.getElementAt(i).getAttributeByName("modelID").getSimpleValue(); Repeat progRep = new Repeat("progsRep"); progRep.add(new Var("progId", progId)); agentRep.add(progRep); } } } }