Examples of StorableVertex


Examples of vg.core.storableGraph.StorableVertex

      public void actionPerformed(ActionEvent e) {
        StorableSubGraph ssg = PathsSearcher.this.view.getSelectionSubGraph();
        if (ssg != null) {
          List<StorableVertex> lsv = ssg.getVertices();
          if (lsv != null && lsv.size() == 2) {
            StorableVertex sv = lsv.get(0);
            StorableVertex sv2 = lsv.get(1);

            Object[] possibilities = { "from " + sv.getId() + " to " + sv2.getId(), "from " + sv2.getId() + " to " + sv.getId() };
            Object o = JOptionPane.showInputDialog(null, "Path ", "Select direction", JOptionPane.PLAIN_MESSAGE, null,
                possibilities, possibilities[0]);
            if (o == null)
              return;
            if (o.equals(possibilities[0]))
View Full Code Here

Examples of vg.core.storableGraph.StorableVertex

          return;
        StorableSubGraph ssg = CycleSearcher.this.view.getSelectionSubGraph();
        if (ssg != null) {
          List<StorableVertex> lsv = ssg.getVertices();
          if (lsv != null && lsv.size() == 1) {
            StorableVertex sv = lsv.get(0);
            CycleSearcher.this.view.showCycles(sv);
          }
        }
      }
    });
View Full Code Here

Examples of vg.core.storableGraph.StorableVertex

          vertexStatement = connection.prepare(request,false);
          while(vertexStatement.step()) {
            int db_id_vertex = vertexStatement.columnInt(0);
            String id_vertex = vertexStatement.columnString(1);
            Integer db_id_innder_graph = (Integer)vertexStatement.columnValue(2);
            StorableVertex v = new StorableVertex(db_id_vertex, id_vertex);
            v.setInnerGraph(db_id_innder_graph);
            listVertex.add(v);
            //attributes-----------------
            SQLiteStatement attrStatement = null;
            request = "select s2.db_id, s2.name, s2.value, s2.value_type " +
                      "from com_vertex_attribute s1, attribute s2 " +
                      "where s1.db_id_vertex = " + Integer.valueOf(db_id_vertex).toString() + " and s2.db_id = s1.db_id_attribute;";
            attrStatement = connection.prepare(request,false);
            while(attrStatement.step()) {
              int db_id_attr = attrStatement.columnInt(0);
              String db_name = attrStatement.columnString(1);
              String db_value = attrStatement.columnString(2);
              String db_type = attrStatement.columnString(3);
              v.addStorableAttribute(new StorableAttribute(db_id_attr, db_name, db_value, db_type));
            }
            attrStatement.dispose();

          }
          vertexStatement.dispose();
          //edges--------------------------
          ArrayList<StorableEdge>listEdge = new ArrayList<StorableEdge>();
          SQLiteStatement edgeStatement = null;

          request = "select s2.db_id, s2.id, s2.db_id_source, db_id_target " +
                    "from com_subgraph_edge s1, edge s2 " +
                    "where s1.db_id_subgraph = " + Integer.valueOf(id_subgraph).toString() + " and s2.db_id = s1.db_id_edge;";
          edgeStatement = connection.prepare(request,false);
          while(edgeStatement.step()) {
            int db_id_edge = edgeStatement.columnInt(0);
            String id_edge = edgeStatement.columnString(1);
            Integer db_id_source = (Integer)edgeStatement.columnValue(2);
            Integer db_id_target = (Integer)edgeStatement.columnValue(3);
            if(db_id_source != null && db_id_target != null) {
              StorableVertex source = null, target = null;
              for(StorableVertex bufVertex : listVertex) {
                if(bufVertex.getStorableId() == db_id_source) {
                  source = bufVertex;
                }
                if(bufVertex.getStorableId() == db_id_target) {
View Full Code Here

Examples of vg.core.storableGraph.StorableVertex

        vertexStatement = connection.prepare(request,false);
        while(vertexStatement.step()) {
          int db_id_vertex = vertexStatement.columnInt(0);
          String id_vertex = vertexStatement.columnString(1);
          Integer db_id_innder_graph = (Integer)vertexStatement.columnValue(2);
          StorableVertex v = new StorableVertex(db_id_vertex, id_vertex);
          v.setInnerGraph(db_id_innder_graph);
          listVertex.add(v);
          //attributes-----------------
          SQLiteStatement attrStatement = null;
          try {         
            request = "select s2.db_id, s2.name, s2.value, s2.value_type " +
                      "from com_vertex_attribute s1, attribute s2 " +
                      "where s1.db_id_vertex = " + Integer.valueOf(db_id_vertex).toString() + " and s1.db_id_attribute = s2.db_id;";
            attrStatement = connection.prepare(request,false);
            while(attrStatement.step()) {
              int db_id_attr = attrStatement.columnInt(0);
              String db_name = attrStatement.columnString(1);
              String db_value = attrStatement.columnString(2);
              String db_type = attrStatement.columnString(3);
              v.addStorableAttribute(new StorableAttribute(db_id_attr, db_name, db_value, db_type));
            }
          } catch(SQLiteException ex) {
            VisualGraph.log.printException(ex);
          } finally {
            if(attrStatement != null) {
                attrStatement.dispose();
            }
          }
        }
        vertexStatement.dispose();
        //edges--------------------------
        ArrayList<StorableEdge>listEdge = new ArrayList<StorableEdge>();
        SQLiteStatement edgeStatement = null;

        request = "select s2.db_id, s2.id, s2.db_id_source, db_id_target " +
                  "from com_subgraph_edge s1, edge s2 " +
                  "where s1.db_id_subgraph = " + Integer.valueOf(id_subgraph).toString() + " and s1.db_id_edge = s2.db_id;";
        edgeStatement = connection.prepare(request,false);
        while(edgeStatement.step()) {
          int db_id_edge = edgeStatement.columnInt(0);
          String id_edge = edgeStatement.columnString(1);
          Integer db_id_source = (Integer)edgeStatement.columnValue(2);
          Integer db_id_target = (Integer)edgeStatement.columnValue(3);
          if(db_id_source != null && db_id_target != null) {
            StorableVertex source = null, target = null;
            for(StorableVertex bufVertex : listVertex) {
              if(bufVertex.getStorableId() == db_id_source) {
                source = bufVertex;
              }
              if(bufVertex.getStorableId() == db_id_target) {
View Full Code Here

Examples of vg.core.storableGraph.StorableVertex

  public synchronized StorableSubGraph getStorableSubGraph(final ArrayList<Integer> vertexId) {
    if(vertexId != null && vertexId.size() > 0) {
      final ArrayList<StorableVertex>vertexes = new ArrayList<StorableVertex>();
      final HashMap<Integer, StorableVertex>mapVertexes = new HashMap<Integer, StorableVertex>();
      for(Integer buf : vertexId) {
        StorableVertex v = this.getStorableVertex(buf);
        if(v != null) {
          vertexes.add(v);
          mapVertexes.put(buf, v);
        }
      }
View Full Code Here

Examples of vg.core.storableGraph.StorableVertex

    if (rootKey == null)
      return null;
    return(this.getStorableSubGraph(rootKey));
  }
  public synchronized StorableVertex getStorableVertex(final int vertexId) {
    StorableVertex v = null;
    SQLiteJob<StorableVertex> job = this.currConnection.execute(new SQLiteJob<StorableVertex>() {
      protected StorableVertex job(SQLiteConnection connection) throws Throwable {
        String request = "select s1.db_id, s1.id, s1.db_id_inner_graph " + "from vertex s1 "
            + "where s1.db_id = " + Integer.valueOf(vertexId).toString() + ";";
        SQLiteStatement currStatement = connection.prepare(request, false);
        StorableVertex v = null;
        if (currStatement != null && currStatement.step()) {
          int db_id = currStatement.columnInt(0);
          String id = currStatement.columnString(1);
          Integer db_id_inner_graph = (Integer) currStatement.columnValue(2);
          v = new StorableVertex(db_id, id);
          v.setInnerGraph(db_id_inner_graph);
        }
        currStatement.dispose();
        return v;
      }
    });
    v = job.complete();
    if (job.getError() != null) {
      VisualGraph.log.printError(job.getError().getMessage());
      VisualGraph.windowMessage.errorMessage("Can't execute SQL request. It is developer's bug.",
          "Search panel error");
    }
 
    if (v != null) {
      SQLiteJob<List<StorableAttribute>> attrJob = this.currConnection
          .execute(new SQLiteJob<List<StorableAttribute>>() {
            protected List<StorableAttribute> job(SQLiteConnection connection) throws Throwable {
              String request = "select s2.db_id, s2.name, s2.value, s2.value_type "
                  + "from com_vertex_attribute s1, attribute s2 " + "where s1.db_id_vertex = "
                  + Integer.valueOf(vertexId).toString() + " and s2.db_id = s1.db_id_attribute;";

              SQLiteStatement currStatement = connection.prepare(request);
              List<StorableAttribute> attrs = new ArrayList<StorableAttribute>();
              if (currStatement != null) {
                while (currStatement.step()) {
                  int db_id_attr = currStatement.columnInt(0);
                  String name = currStatement.columnString(1);
                  String value = currStatement.columnString(2);
                  String type = currStatement.columnString(3);
                  StorableAttribute attr = new StorableAttribute(db_id_attr, name, value, type);
                  attrs.add(attr);
                }
              }
              return attrs;
            }
          });
      List<StorableAttribute> attrs = attrJob.complete();
      for (StorableAttribute attr : attrs) {
        v.addStorableAttribute(attr);
      }
      if (attrJob.getError() != null) {
        VisualGraph.log.printError(job.getError().getMessage());
        VisualGraph.windowMessage.errorMessage("Can't execute SQL request. It is developer's bug.",
            "Search panel error");
View Full Code Here

Examples of vg.core.storableGraph.StorableVertex

   */
  private int searchGraphId() {
    if(this.currentView == null) return(-1);
    List<StorableVertex> lsv = this.currentView.getStorableSubGraph().getVertices();
    if(lsv == null) return(-1);
    StorableVertex sv = lsv.get(0);
    if(sv == null) return(-1);
    int vsi = sv.getStorableId();
    String request = "select s1.db_id_graph " +
                 "from com_graph_subgraph s1, com_subgraph_vertex s2 " +
                 "where s2.db_id_subgraph = s1.db_id_subgraph and s2.db_id_vertex = " + Integer.valueOf(vsi).toString() + ";";
    int id = -1; // id of graph
    List<List<Object>> result = this.parameter.model.executeSQLRequest(request);
View Full Code Here

Examples of vg.core.storableGraph.StorableVertex

  private void buildTitleAndGraphId() {
    if (this.subGraph != null && this.model != null) {
      List<StorableVertex> lsv = this.subGraph.getVertices();
      if (lsv != null && lsv.size() != 0) {
        // find subgraph id
        StorableVertex sv = lsv.get(0);
        // int gid = -1; // graph id
        int vid = sv.getStorableId(); // vertex id
        int sid = -1; // subgraph id
        String firstRequest = "select s1.db_id_subgraph " + "from com_subgraph_vertex s1 "
            + "where s1.db_id_vertex = " + Integer.valueOf(vid).toString() + ";";
        List<List<Object>> firstResult = this.model.executeSQLRequest(firstRequest);
        if (firstResult != null && !firstResult.isEmpty()) {
          sid = (Integer) firstResult.get(0).get(0);
        }

        // find graph id
        String thirdRequest = "select distinct s1.db_id_graph " + "from com_graph_subgraph s1 "
            + "where s1.db_id_subgraph = " + Integer.valueOf(sid) + ";";
        List<List<Object>> thirdResult = this.model.executeSQLRequest(thirdRequest);
        if (thirdResult != null && !thirdResult.isEmpty()) {
          this.graphId = (Integer) thirdResult.get(0).get(0);
        }
        // find vertex, which has innderId = sid
        if (sid >= 0) {
          String secondRequest = "select s1.db_id " + "from vertex s1 " + "where s1.db_id_inner_graph = "
              + Integer.valueOf(sid).toString() + ";";
          List<List<Object>> secondResult = this.model.executeSQLRequest(secondRequest);
          if (secondResult != null && !secondResult.isEmpty()) {
            int rid = (Integer) secondResult.get(0).get(0); // result id
            StorableVertex rsv = this.model.getStorableVertex(rid); // root storable vertex
            // find attribute 'name'
            List<StorableAttribute> lsa = rsv.getAttributes();
            if (lsa != null) {
              for (StorableAttribute bufSA : lsa) {
                if (bufSA.equals("name")) {
                  String value = bufSA.getValue();
                  if (value != null) {
                    this.title = bufSA.getValue() + " by name";
                  }
                  return;
                }
              }
            }
            // other find id of vertex
            String buf = rsv.getId();
            if (buf != null && buf.length() > 0) {
              this.title = buf + " by id";
              return;
            }
          } else {
View Full Code Here

Examples of vg.core.storableGraph.StorableVertex

    int id = -1;
    if(type == GraphComboBox.DEF_VIEW) {
      if(this.currentStorableSubGraph == null) return;
      List<StorableVertex> lsv = this.currentStorableSubGraph.getVertices();
      if(lsv == null) return;
      StorableVertex sv = lsv.get(0);
      if(sv == null) return;
      int vsi = sv.getStorableId();
      String request = "select s1.db_id_graph " +
                   "from com_graph_subgraph s1, com_subgraph_vertex s2 " +
                   "where s2.db_id_subgraph = s1.db_id_subgraph and s2.db_id_vertex = " + Integer.valueOf(vsi).toString() + ";";

      List<List<Object>> result = this.parameter.model.executeSQLRequest(request);
View Full Code Here

Examples of vg.core.storableGraph.StorableVertex

          ResultSet resultVertex = vertexStatement.executeQuery(request);
          while(resultVertex.next()) {
            int db_id_vertex = resultVertex.getInt(1);
            String id_vertex = resultVertex.getString(2);
            Integer db_id_innder_graph = (Integer)resultVertex.getObject(3);
            StorableVertex v = new StorableVertex(db_id_vertex, id_vertex);
            v.setInnerGraph(db_id_innder_graph);
            listVertex.add(v);
            //attributes-----------------
            Statement attrStatement = null;
            try {
              attrStatement = this.currConnection.createStatement();
              request = "select s2.db_id, s2.name, s2.value " +
                        "from com_vertex_attribute s1, attribute s2 " +
                        "where s1.db_id_vertex = " + (new Integer(db_id_vertex)).toString() + " and s2.db_id = s1.db_id_attribute;";
              ResultSet resultAttribute = attrStatement.executeQuery(request);
              while(resultAttribute.next()) {
                int db_id_attr = resultAttribute.getInt(1);
                String db_name = resultAttribute.getString(2);
                String db_value = resultAttribute.getString(3);
                v.addStorableAttribute(new StorableAttribute(db_id_attr, db_name, db_value));
              }
            } catch(SQLException ex) {
              VisualGraph.log.printException(ex);
            } finally {
              if(attrStatement != null) {
                  try {
                    attrStatement.close();
                  } catch(SQLException ex) {
                    VisualGraph.log.printException(ex);
                  }
              }
            }
          }
        } catch (SQLException ex) {
           VisualGraph.log.printException(ex);
        } finally {
          if(vertexStatement != null) {
              try {
                vertexStatement.close();
              } catch(SQLException ex) {
                VisualGraph.log.printException(ex);
              }
          }
        }
        //edges--------------------------
        ArrayList<StorableEdge>listEdge = new ArrayList<StorableEdge>();
        Statement edgeStatement = null;
        try {
          edgeStatement = this.currConnection.createStatement();
          request = "select s2.db_id, s2.id, s2.db_id_source, db_id_target " +
                    "from com_subgraph_edge s1, edge s2 " +
                    "where s1.db_id_subgraph = " + (new Integer(id_subgraph)).toString() + " and s2.db_id = s1.db_id_edge;";
          ResultSet resultEdge = edgeStatement.executeQuery(request);
          while(resultEdge.next()) {
            int db_id_edge = resultEdge.getInt(1);
            String id_edge = resultEdge.getString(2);
            Integer db_id_source = (Integer)resultEdge.getObject(3);
            Integer db_id_target = (Integer)resultEdge.getObject(4);
            if(db_id_source != null && db_id_target != null) {
              StorableVertex source = null, target = null;
              for(StorableVertex bufVertex : listVertex) {
                if(bufVertex.getStorableId() == db_id_source) {
                  source = bufVertex;
                }
                if(bufVertex.getStorableId() == db_id_target) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.