public static Graph getGraphByName(String name, Browser browser) { for (Graph g : browser.getGraphs()) { if (g.getName().equals(name)) { return g; } } return null; }
/** * It obtains all entities in the specification whose type represented as * string is the same as the string passed as parameter * * @param type The type the application is looking for * @return * @throws NotInitialised */ public static GraphEntity[] generateEntitiesOfType(String type, Browser browser) throws NotInitialised { Graph[] gs = browser.getGraphs(); Sequences p = new Sequences(); GraphEntity[] ges = browser.getAllEntities(); HashSet actors = new HashSet(); for (int k = 0; k < ges.length; k++) { if (ges[k].getType().equals(type)) { actors.add(ges[k]); } } return toGEArray(actors.toArray()); }
public static Vector<String> findAllDifferences(Browser bimp1, Browser bimp2){ GraphEntity[] entities = bimp1.getAllEntities(); boolean allIncluded=true; Vector<String> differences=new Vector<String>(); int k=0; while (k<entities.length){ GraphEntity ent1 = entities[k]; GraphEntity ent2 = bimp2.findEntity(ent1.getID()); allIncluded=allIncluded && ent2!=null; if (ent2==null){ differences.add("entity "+ent1.getID()+":"+ent1.getType()+" does not exist"); } else { differences.addAll(checkEntity(ent1, ent2, new Vector())); } k++; } return differences; }
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; }
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; }
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; }
Graph interactionSpec = browser.getGraph(interactionDiagName); if (interactionSpec != null && interactionSpec.getEntities().length > 0) { for (GraphEntity ge : Utils.getEntities(interactionSpec, "EventProcessor")) {
public static GraphAttributeFactory createDefaultGraphFactory(Browser browser) throws NotInitialised{ return new GraphAttributeFactory(browser.getState()); }
public static Collection<Graph> getGraphsByType(String type, Browser browser) { Collection<Graph> result = new Vector<>(); for (Graph g : browser.getGraphs()) { if (g.getType().equals(type)) { result.add(g); } } return result; }
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; }
System.out.println("GENERATE ADL: " + humanId); System.out.println("ADL = " + adlDiagName); Graph adlSpec = browser.getGraph(adlDiagName); if (adlSpec != null && adlSpec.getEntities().length > 0) { System.out.println("ADL no empty!");
public static GraphFactory createDefaultGraphFactory(Browser browser) throws NotInitialised{ return new GraphFactory(browser.getState()); }
public Vector<GraphRelationship> getAllRelationships(){ HashSet<GraphRelationship> result=new HashSet<GraphRelationship>(); Graph[] g=null; g = browser.getGraphs(); for (int k=0;k<g.length;k++){ HashSet rel=this.getRelationshipsFromAGraph(((GraphImp)g[k]).getGraph()); result.addAll(rel); } return new Vector<GraphRelationship>(result); }
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 GraphRelationshipFactory createDefaultGraphFactory(Browser browser) throws NotInitialised{ return new GraphRelationshipFactory(browser.getState()); }
public Vector getAllRelationships(String relType){ HashSet<GraphRelationship> result=new HashSet<GraphRelationship>(); Graph[] g=null; g = browser.getGraphs(); for (int k=0;k<g.length;k++){ HashSet<GraphRelationship> rel=this.getRelationshipsFromAGraph(((GraphImp)g[k]).getGraph()); for (GraphRelationship gr:rel){ if (gr.getType().equalsIgnoreCase(relType)) result.add(gr); } } return new Vector<GraphRelationship>(result); }
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 GraphEntityFactory createDefaultGraphFactory(Browser browser) throws NotInitialised{ return new GraphEntityFactory(browser.getState()); }