public static boolean contains(Graph graph, GraphEntity actor) { try { for (GraphEntity ge : graph.getEntities()) { if (ge.equals(actor)) { return true; } } } catch (NullEntity e) { // TODO Auto-generated catch block e.printStackTrace(); } return false; }
/** * It obtains the entities in the graph "g" whose type is the same as * "typeName". * * @param g The graph considered * @param typeName The type being searched * @return The list of entities * @throws NullEntity */ public static List<GraphEntity> getEntities(Graph g, String typeName) throws NullEntity { GraphEntity[] ge = g.getEntities(); List<GraphEntity> result = new ArrayList<>(); for (int k = 0; k < ge.length; k++) { if (ge[k].getType().equals(typeName)) { result.add(ge[k]); } } return result; }
public static void addPararms(Graph adlSpec, Repeat repFather) throws NullEntity { for (GraphEntity act : adlSpec.getEntities()) { if (act.getType().equals(ACTIVITY_TYPE)) { addPararms(act, repFather); } } }
public static List<GraphEntity> getFirstEntities(Graph graph) { List<GraphEntity> result = new ArrayList<>();; try { for (GraphEntity ge : graph.getEntities()) { if (!isTargetOfAnyRelationship(ge)) { result.add(ge); } } } catch (NullEntity e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; }
private void generateTransitions(Graph adlSpec, Repeat repFather) throws NullEntity { for (GraphEntity activity : adlSpec.getEntities()) { if (activity.getType().equals(ACTIVITY_TYPE)) { generateDirectTransitions(activity, repFather); generateCondTransitions(activity, repFather); } } }
public static GraphEntity getFirstEntity(Graph graph) { GraphEntity result = null; try { for (GraphEntity ge : graph.getEntities()) { if (!isTargetOfAnyRelationship(ge)) { return ge; } } } catch (NullEntity e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; }
public static GraphEntity getFirstEntity(Graph graph, String type) { GraphEntity result = null; try { for (GraphEntity ge : graph.getEntities()) { if (!isTargetOfAnyRelationship(ge) && ge.getType().equals(type)) { return ge; } } } catch (NullEntity e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; }
GraphEntity[] ges=null; try { ges = current.getEntities(); } catch (NullEntity e) {
public Graph findFirstEntityOccurrence(String id){ Graph[] gs=this.getGraphs(); boolean found=false; Graph result=null; for (int k=0;k<gs.length && result==null;k++){ GraphEntity[] entities; try { entities = gs[k].getEntities(); for (int j=0;j<entities.length && result==null;j++){ if (entities[j].getID().equalsIgnoreCase(id)){ result=gs[k]; } } } catch (NullEntity e) { // TODO Auto-generated catch block e.printStackTrace(); } } return result; }
public void actionPerformed(ActionEvent e) { if (dmtn.getUserObject()instanceof Entity){ Entity ent=(Entity)dmtn.getUserObject(); StringBuffer result=new StringBuffer(); result.append("Diagrams found:<ul>"); Graph[] graphs=browser.getGraphs(); for (int k=0;k<graphs.length;k++){ GraphEntity[] ges; try { ges = graphs[k].getEntities(); boolean found=false; for (int j=0;j<ges.length &&!found;j++){ found=ges[j].getID().equals(ent.getId()); } if (found){ result.append("<li><a href=\"http://app/"+graphs[k].getName()+"/"+ent.getId()+"\">"+graphs[k].getName()+"</a>"); } } catch (NullEntity e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } result.append("</ul>"); resources.getSearchDiagramPanel().setText(result.toString()); resources.focusSearchPane(); } } });
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 String getInitialLocation(String humanId, Graph simDiagram) { try { // Graph[] diagrams = browser.getGraphs(); // for (Graph simDiagram : diagrams) { // if (simDiagram.getType().equalsIgnoreCase(SIMULATION_DIAGRAM)) { System.out.println("Diagram = " + simDiagram.getID()); for (GraphEntity hi : simDiagram.getEntities()) { if (hi.getType().equalsIgnoreCase( HUMAN_INITIALIZATION_OBJ)) { GraphEntity human = Utils.getTargetEntity(hi, "RelatedHuman"); if (human.getID().equals(humanId)) { GraphEntity initialPos = Utils.getTargetEntity( hi, "InitialLocation"); if (initialPos != null) { return initialPos.getID(); } } } } // } // } } catch (Throwable ex) { ex.printStackTrace(); } return null; } }
public void actionPerformed(ActionEvent e) { StringBuffer result=new StringBuffer(); result.append("Diagrams found:<ul>"); Graph[] graphs=bimp.getGraphs(); for (int k=0;k<graphs.length;k++){ GraphEntity[] ges; try { ges = graphs[k].getEntities(); boolean found=false; for (int j=0;j<ges.length &&!found;j++){ found=ges[j].getID().equals(ent.getId()); } if (found){ result.append("<li><a href=\"http://app/"+graphs[k].getName()+"/"+ent.getId()+"\">"+graphs[k].getName()+"</a>"); } } catch (NullEntity e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } result.append("</ul>"); resources.getSearchDiagramPanel().setText(result.toString()); resources.focusSearchPane(); } });
seq.addRepeat(repProgBehav); try { GraphEntity[] diagramEntities = diagram.getEntities();
private void generateDependencies(Repeat filterSet, Graph filterGraph, String level) { try { for (GraphEntity entity : filterGraph.getEntities()) { System.out.println("generateDependencies:" + entity.getID() + "(" + entity.getType() + ")"); GraphEntity targetGA = Utils.getTargetEntity(entity, "NextFilter"); if (targetGA != null) { System.out.println("\tnextFilter: " + targetGA.getID()); Repeat selectRep = new Repeat("nextFilterRep"); filterSet.add(selectRep); selectRep.add(new Var("sourceFilter", entity.getID())); selectRep.add(new Var("targetFilter", Utils.replaceBadChars(targetGA.getID()))); } else { System.out.println("\tnextFilter: " + targetGA); } targetGA = Utils.getTargetEntity(entity, "FAlternative"); if (targetGA != null) { System.out.println("\tAlternative: " + targetGA.getID()); Repeat selectRep = new Repeat("alternativeFilterRep"); filterSet.add(selectRep); selectRep.add(new Var("sourceFilter", entity.getID())); selectRep.add(new Var("targetFilter", Utils.replaceBadChars(targetGA.getID()))); } else { System.out.println("\tAlternative: " + targetGA); } } } catch (NullEntity ex) { Logger.getLogger(PDGenerator.class.getName()).log(Level.SEVERE, null, ex); } }
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)); } } }
private void generateActivityInstances(Graph adlSpec, Repeat repFather) throws NullEntity { for (GraphEntity activity : adlSpec.getEntities()) { if (activity.getType().equals(ACTIVITY_TYPE)) { String activityName = activity.getID(); // Defines the activity Repeat rep = new Repeat("activities"); repFather.add(rep); rep.add(new Var("actName", Utils.replaceBadChars(activityName))); Collection<GraphEntity> nextEntities = Utils.getTargetsEntity(activity, NEXT_ACTIVITY_REL); if (nextEntities.isEmpty()) { // It is a last activity, the automaton should finish after the execution Repeat rep2 = new Repeat("regLastActivityRep"); repFather.add(rep2); rep2.add(new Var("finalActivity", Utils.replaceBadChars(activityName))); } } } }
if (interactionSpec != null && interactionSpec.getEntities().length > 0) { for (GraphEntity ge : Utils.getEntities(interactionSpec, "EventProcessor")) { GraphEntity event = Utils.getTargetEntity(ge, "RelatedEvent");
for (Graph diagram : Utils.getGraphsByType(ADL_SPEC_DIAGRAM, browser)) { System.out.println("ADLDiagramName: " + diagram.getID()); for (GraphEntity ge : diagram.getEntities()) { if (ge.getType().equals("TimeInterval")) {