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; }
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(); } });
/** * Description of the Method * *@param args Description of Parameter *@exception Exception Description of Exception */ public static void main(String args[]) throws Exception { String file = args[0]; Browser b = new BrowserImp(file); Graph[] gs = b.getGraphs(); for (int k = 0; k < gs.length; k++) { System.err.println(gs[k].getType() + ":" + gs[k].getName()); } }
public static Vector< String> getPossibleRelationships( String[] connectedEntities, Graph graph) throws NotFound{ Vector<GraphCell> entities=new Vector<GraphCell>(); for (String entityID:connectedEntities) { DefaultGraphCell entity = findEntity(entityID,graph); if (entity==null) throw new ingenias.exception.NotFound("Entity "+entityID+" that you tried to connect did not exist in the graph "+graph.getName()); entities.add(findEntity(entityID,graph)); } GraphCell[] selected=new GraphCell[entities.size()]; selected=entities.toArray(selected); Object[] relObjArray = graph.getGraph().getPossibleRelationships(selected); Vector<String> result = new Vector<String>(); for (Object rel:relObjArray){ result.add(rel.toString()); } return result; }
public void generateAllSeqTasks() throws NotFound { System.out.println("generateAllSeqTasks............................."); for (Graph std : Utils.getGraphsByType("SequentialTaskDiagram", browser)) { System.out.println(">" + std.getType() + ":" + Utils.replaceBadChars(std.getID())); Repeat rep = new Repeat("tasks"); rep.add(new Var("stID", Utils.replaceBadChars(std.getID()))); rep.add(new Var("stType", Utils.replaceBadChars(std.getType()))); sequence.addRepeat(rep); generateSeqTaskDiagram(std, rep); } System.out.println(".............................generateAllSeqTasks"); }
( (ProjectProperty)this.getProperty("htmldoc:output")). value)); r.add(new Var("name", gs[k].getName())); r.add(new Var("fname", this.toSafeName(gs[k].getName()))); r.add(new Var("image", toSafeName(gs[k].getName()) + ".png")); r.add(new Var("tipo", gs[k].getType())); gs[k].getAttributeByName("Description").getSimpleValue())); GraphEntity[] gesWithDups = g.getEntitiesWithDuplicates(); for (int j = 0; j < gesWithDups.length; j++) { Repeat ens = new Repeat("mapentities"); GraphEntity[] ges = g.getEntities(); GraphEntity[] dges; try { dges = gs[m].getEntities(); boolean found=false; Vector mentioned=new Vector(); for (int l=0;l<dges.length;l++){ found=dges[l].getID().equals(ge.getID()); if (found && !mentioned.contains(gs[m].getName())){ Repeat diagram=new Repeat("relateddiagrams"); diagram.add(new Var("diagramname",toSafeName(gs[m].getName()))); diagram.add(new Var("diagramtype",gs[m].getType())); ens.add(diagram); mentioned.add(gs[k].getName());
Repeat rp1=null; this.setProgress((int) (k*increment)); String[] path=gs[k].getPath(); boolean already=true; while (already){ Graph g = gs[k]; rp2 = new Repeat("graph"); rp2.add(new Var("name", ingenias.generator.util.Conversor.replaceInvalidCharsForID(g.getName()))); rp2.add(new Var("fname", this.toSafeName(g.getName()))); rp2.add(new Var("tipo", g.getType())); rp2.add(new Var("image", toSafeName(g.getName()) + ".png")); g.generateImage( ( (ProjectProperty)this.getProperty("htmldoc:output")). value + "/" + toSafeName(g.getName()) + ".png"); rp1.add(rp2);
public void generateADLClasses(Sequences sequence) throws NotFound { for (Graph adlSpec : Utils.getGraphsByType("ADLSpecDiagram", browser)) { try { if (adlSpec.getEntities().length > 0) { Repeat adlsRep = new Repeat("adls"); adlsRep.add(new Var("adlID", Utils.replaceBadChars(adlSpec.getID()))); adlsRep.add(new Var("adlType", Utils.replaceBadChars(adlSpec.getType()))); adlsRep.add(new Var("adlDesc", Utils.replaceBadChars(adlSpec.getType()))); sequence.addRepeat(adlsRep); for (GraphEntity timeInterval : adlSpec.getEntities()) { if (timeInterval.getType().equals(TIME_INTERVAL_TYPE)) { String timeIntervalName = timeInterval.getID();
public void generateFSMProgramBehaviorClasses(Sequences seq) { System.out.println("\n\ngenerateFSMProgramBehaviorClasses..."); for (Graph diagram : Utils.getGraphsByType(DEVICE_BEHAVIOR_DIAGRAM, browser)) { System.out.println("Diagram: " + diagram.getID()); logger.log(Level.INFO, "Processing diagram {0}...", new Object[]{diagram.getID()}); Repeat repProgBehav = new Repeat("programBehavior"); repProgBehav.add(new Var("seName", Utils.replaceBadChars(diagram.getID()))); seq.addRepeat(repProgBehav); try { GraphEntity[] diagramEntities = diagram.getEntities(); for (GraphRelationship gr : diagram.getRelationships()) { if (gr.getType().equals(PROGRAM_TRANSITION_REL)) { processProgTransition(gr, repProgBehav); logger.log(Level.SEVERE, "Diagram {0} is empty!", new Object[]{diagram.getID()}); System.exit(-1);
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 static Graph getGraphByName(String name, Browser browser) { for (Graph g : browser.getGraphs()) { if (g.getName().equals(name)) { return g; } } return null; }
GraphRelationship[] grels=g.getRelationships(); ges = g.getEntities();
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; }
GraphRelationship gr = (GraphRelationship) enumeration .nextElement(); String[] path = gr.getGraph().getPath(); boolean found = false; for (int k = 0; k < path.length && !found; k++) {
private Vector<String[]> getSymptomLevel(GraphEntity symptom, GraphEntity actor) { String result = "phat.agents.filters.Symptom.Level.NONE"; Vector<String[]> results = new Vector<String[]>(); Collection<Graph> graphs = Utils.getGraphsByType("SimulationDiagram", browser); for (Graph graph : graphs) { if (Utils.contains(graph, actor)) { String level = getActorSymptomInSimdiagram(graph, actor, symptom); if (level != null) { results.add(new String[]{level, graph.getID()}); } else { results.add(new String[]{"phat.agents.filters.Symptom.Level.NONE", graph.getID()}); } } } return results; }
public GraphEntity createModelEntity(String diagramType, String id,Graph diagram) throws InvalidEntity{ ModelEntity modelEntity; try { modelEntity = (ModelEntity) Class.forName("ingenias.editor.entities."+diagramType+"ModelEntity").getConstructor(new Class[]{String.class}).newInstance(id); GraphEntityImp gei=new GraphEntityImp(modelEntity,null,diagram.getGraph(),ids); return gei; } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | ClassNotFoundException e) { throw new InvalidEntity(e); // TODO Auto-generated catch block } catch (NullEntity e) { throw new InvalidEntity(e); } }
public void generateFSMSymptomEvolutionClasses(Sequences seq) { for (Graph diagran : Utils.getGraphsByType(SYMPTOM_EVOLUTION_DIAGRAM, browser)) { logger.log(Level.INFO, "Processing diagram {0}...", new Object[]{diagran.getID()}); Repeat rep = new Repeat("symptomEvolution"); rep.add(new Var("seName", Utils.replaceBadChars(diagran.getID()))); seq.addRepeat(rep); try { GraphEntity[] diagramEntities = diagran.getEntities(); for (GraphRelationship gr : diagran.getRelationships()) { Collection<GraphEntity> conds = new ArrayList<>(); GraphEntity source = null; logger.log(Level.SEVERE, "Diagram {0} is empty!", new Object[]{diagran.getID()}); System.exit(-1);
private void generateTimeIntervalClasses(Sequences seq) throws NullEntity, NotFound { 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")) {
public static Vector<Hashtable<String,String>> getPossibleRoleAssignment(String relationshipType, String[] connectedEntities, Graph graph, Browser browser) throws NotFound{ Vector<GraphCell> entities=new Vector<GraphCell>(); for (String entityID:connectedEntities) { DefaultGraphCell entity = findEntity(entityID,graph); if (entity==null) throw new ingenias.exception.NotFound("Entity "+entityID+" that you tried to connect did not exist in the graph "+graph.getName()); entities.add(entity); } GraphCell[] selected=new GraphCell[entities.size()]; selected=entities.toArray(selected); NAryEdge nEdge=(NAryEdge) RelationshipFactory.getNRelationshipInstance(relationshipType, selected,browser); Vector<Hashtable<String, String>> result = convertToVectorHashtable(connectedEntities, selected, nEdge); return result; }
private void registerFirstProgState(Graph deviceBehavDiag, Repeat repFather) { GraphEntity ge = Utils.getFirstEntity(deviceBehavDiag, PROGRAM_STATE); if (ge == null) { logger.log(Level.SEVERE, "The diagram {0} is empty or doesn't know " + "which entity is the first one!", new Object[]{deviceBehavDiag.getID()}); System.exit(0); } Repeat repFirst = new Repeat("firstProgState"); repFather.add(repFirst); repFirst.add(new Var("psID", Utils.replaceBadChars(ge.getID()))); }