public static Vector<GraphEntity> getRelatedElementsVectorInSameDiagram( GraphEntity agent, String relationshipname, String role) throws NullEntity { GraphRelationship[] rels = agent.getRelationships(); Vector related = new Vector(); for (GraphRelationship gr : rels) { if (gr.getType().toLowerCase() .equals(relationshipname.toLowerCase())) { GraphRole[] roles = gr.getRoles(); for (int k = 0; k < roles.length; k++) { if (roles[k].getName().toLowerCase() .equals(role.toLowerCase())) { related.add(roles[k].getPlayer()); } } } } return new Vector(new HashSet(related)); }
GraphRelationship gr = (GraphRelationship) enumeration .nextElement(); String[] path = gr.getGraph().getPath(); boolean found = false; for (int k = 0; k < path.length && !found; k++) { && gr.getType().toLowerCase() .equals(relationshipname.toLowerCase())) { GraphRole[] roles = gr.getRoles(); for (int k = 0; k < roles.length; k++) { if (roles[k].getName().toLowerCase()
public static GraphEntity getTargetEntity(GraphEntity ge, String relationType) { try { System.out.println("Relations:"); for (GraphRelationship gr : ge.getRelationships()) { System.out.println("\t" + gr.getType()); if (gr.getType().equals(relationType)) { GraphEntity result = getTargetEntity(ge, gr); if (result != null) { return result; } } } } catch (Throwable ex) { ex.printStackTrace(); } return null; }
public static Vector<GraphRole> getRolesFromRelationship( GraphRelationship rel, String role) { Vector<GraphRole> related = new Vector<GraphRole>(); GraphRole[] roles = rel.getRoles(); for (int k = 0; k < roles.length; k++) { if (roles[k].getName().toLowerCase().equals(role.toLowerCase())) { related.add(roles[k]); } } return related; }
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; }
GraphEntity source = null; GraphEntity target = null; System.out.println("\trel=" + gr.getID() + ":" + gr.getType()); for (GraphRole gRole : gr.getRoles()) { System.out.println("\t\trole=" + gRole.getID() + ":" + gRole.getName() + ":" + gRole.getPlayer().getID() + ":" + gRole.getPlayer().getType());
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()); }
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 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; }
public static GraphEntity getTargetEntity(GraphEntity ge, GraphRelationship gr) throws NullEntity { GraphRole gRole = getTargetRole(gr.getRoles()); System.out.println("Roles:"); for (GraphRole r : gr.getRoles()) { System.out.println("-" + r.getName() + "->" + r.getPlayer().getID()); } System.out.println("gRole = " + gRole.getPlayer().getID()); if (gRole != null && !gRole.getPlayer().getID().equals(ge.getID())) { return gRole.getPlayer(); } return null; }
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 getSourceEntity(GraphEntity ge, GraphRelationship gr) { GraphRole gRole = getSourceRole(gr.getRoles()); try { if (gRole != null && gRole.getPlayer().getID() != ge.getID()) { return gRole.getPlayer(); } } catch (NullEntity e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
if (gr.getType().equals(PROGRAM_TRANSITION_REL)) { processProgTransition(gr, repProgBehav);