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 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)); }
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 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 Collection<GraphEntity> getSourcesEntity(GraphEntity ge, String relationType) { List<GraphEntity> result = new ArrayList<GraphEntity>(); try { for (GraphRelationship gr : ge.getRelationships()) { if (gr.getType().equals(relationType)) { for (GraphRole gRole : getSourcesRole(gr.getRoles())) { if (gRole != null && gRole.getPlayer().getID() != ge.getID()) { result.add(gRole.getPlayer()); } } } } } catch (Throwable ex) { ex.printStackTrace(); } return result; }
public static Collection<GraphEntity> getTargetsEntity(GraphEntity ge, String relationType) { List<GraphEntity> result = new ArrayList<>(); try { for (GraphRelationship gr : ge.getRelationships()) { if (gr.getType().equals(relationType)) { for (GraphRole gRole : getTargetsRole(gr.getRoles())) { if (gRole != null && gRole.getPlayer().getID() != ge.getID()) { result.add(gRole.getPlayer()); } } } } } catch (Throwable ex) { ex.printStackTrace(); } return result; }
private void processFilterSequence(Graph graph, GraphEntity firstFilter, Repeat rep) { String cond = ConditionGenerator.generateAndCondition(Utils.getTargetsEntity(firstFilter, "FPrecondition")); rep.add(new Var("filterCond", cond)); rep.add(new Var("filterCond", cond)); GraphEntity nextFilter = Utils.getTargetEntity(firstFilter, NEXT_FILTER_REL, firstFilter.getRelationships()); if (nextFilter != null) { processFilterSequence(graph, nextFilter, rep); } }
GraphRelationship[] gr = ge.getRelationships(); for (int i = 0; i < gr.length; i++) { Repeat rels = new Repeat("relationship");