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 hasAnyEntity(Browser b, String typeName) { boolean result = false; for(GraphEntity ge: b.getAllEntities()) { if(ge.getType().equals(typeName)) { result = true; break; } } 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; }
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; }
/** * 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 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 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 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 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); } } }
new SymptomEvolutionGenerator(browser).generateFSMSymptomEvolutionClasses(seq); new SimulationGenerator(browser).generateSimulations(seq); GraphEntity[] entities = browser.getAllEntities(); Vector<String> errors = new Vector<String>(); for (GraphEntity norm : entities) {