public void alterSystem(BiopolisDiff diff, String json, boolean update) throws BiopolisGeneralException, SQLException { Long[] result = this.v_mgmnt.put(diff.sortedvertices); for (String s : diff.adjacency) { String[] a = s.split(";"); int from = Integer.parseInt(a[0]); int to = Integer.parseInt(a[1]); String queryString = "MATCH (a:MODEL_NODE), (b:MODEL_NODE) " + "WHERE (a.coreid={1} AND b.coreid={2}) CREATE (a)-[r:CHILD_EDGE]->(b) RETURN 1"; Neo4jPreparedStatement stmt = (Neo4jPreparedStatement) this.pl.getConnNeo4j().prepareStatement(queryString); stmt.setInt(1, from); stmt.setInt(2, to); try (ResultSet rs = stmt.executeQuery()) {} } if (update) { String queryString = "MATCH (a:DESIGN_NODE) set a.desci = {1} RETURN 1"; Neo4jPreparedStatement stmt = (Neo4jPreparedStatement) this.pl.getConnNeo4j().prepareStatement(queryString); stmt.setString(1, Base64.encodeBase64String(json.getBytes())); try (ResultSet rs = stmt.executeQuery()) {} } else { Map<String, Object> v = new HashMap<String, Object>(); String queryString = "CREATE (a:DESIGN_NODE { desci: {1} } ) RETURN 1"; Neo4jPreparedStatement stmt = (Neo4jPreparedStatement) this.pl.getConnNeo4j().prepareStatement(queryString); stmt.setString(1, Base64.encodeBase64String(json.getBytes())); try (ResultSet rs = stmt.executeQuery()) {} } }
public void reset() throws SQLException { String[] nodenames = { "PACKAGE_NODE", "DESIGN_NODE", "MODEL_NODE", "GALLERY_NODE", "LIBRARY_NODE", "USER_NODE" }; String[] edgenames = {"CHILD_EDGE", "OWNED_EDGE"}; for (String edgename : edgenames) { String queryString = "MATCH (a)-[r:" + edgename + "]->(b) DELETE r"; Neo4jPreparedStatement stmt = (Neo4jPreparedStatement) this.pl.getConnNeo4j().prepareStatement(queryString); try (ResultSet rs = stmt.executeQuery()) {} } for (String nodename : nodenames) { String queryString = "MATCH (a:" + nodename + ") DELETE a"; Neo4jPreparedStatement stmt = (Neo4jPreparedStatement) this.pl.getConnNeo4j().prepareStatement(queryString); try (ResultSet rs = stmt.executeQuery()) {} } this.s_mgmnt.clean(); this.seg_mgmnt.clean(); ; }