private void removeEdges(OrientGraph tx, OrientVertex vertex) { OrientVertex destination = tx.getVertex(documentModel.getObject().getIdentity()); Iterable<Edge> edges = vertex.getEdges(destination, Direction.BOTH); for(Edge edge : edges) { tx.removeEdge(edge); } }
@Override protected void performMultiAction(AjaxRequestTarget target, List<ODocument> objects) { OrientGraph tx = orientGraphProvider.get(); for (ODocument doc : objects) { ORID id = doc.getIdentity(); OrientEdge edge = tx.getEdge(id); tx.removeEdge(edge); } tx.commit();tx.begin(); sendActionPerformed(); }
protected void upBranchDb(String branchType, Map<String, Object> data) throws Exception { String className = branchType.substring(0, 1).toUpperCase() + branchType.substring(1); String index = className + ".categoryId"; OrientGraph graph = ServiceLocator.getInstance().getGraph(); try{ graph.begin(); OrientVertex updateUser = (OrientVertex)graph.getVertexByKey("User.userId", data.remove("updateUserId")); OrientVertex branch = (OrientVertex)graph.getVertexByKey(index, data.get("categoryId")); if(branch != null && updateUser != null) { // remove DownVote edge if there is. for (Edge edge : updateUser.getEdges(branch, Direction.OUT, "DownVote")) { if(edge.getVertex(Direction.IN).equals(branch)) graph.removeEdge(edge); } updateUser.addEdge("UpVote", branch); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); } finally { graph.shutdown(); } }
protected void downBranchDb(String branchType, Map<String, Object> data) throws Exception { String className = branchType.substring(0, 1).toUpperCase() + branchType.substring(1); String index = className + ".categoryId"; OrientGraph graph = ServiceLocator.getInstance().getGraph(); try{ graph.begin(); OrientVertex updateUser = (OrientVertex)graph.getVertexByKey("User.userId", data.remove("updateUserId")); OrientVertex branch = (OrientVertex)graph.getVertexByKey(index, data.get("categoryId")); if(branch != null && updateUser != null) { // remove UpVote edge if there is. for (Edge edge : updateUser.getEdges(branch, Direction.OUT, "UpVote")) { if(edge.getVertex(Direction.IN).equals(branch)) graph.removeEdge(edge); } updateUser.addEdge("DownVote", branch); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); } finally { graph.shutdown(); } }
protected void downVotePost(Map<String, Object> data) { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); OrientVertex updateUser = (OrientVertex) graph.getVertexByKey("User.userId", data.remove("updateUserId")); OrientVertex post = (OrientVertex) graph.getVertexByKey("Post.entityId", data.get("entityId")); if (post != null && updateUser != null) { // remove UpVote edge if there is. for (Edge edge : updateUser.getEdges(post, Direction.OUT, "UpVote")) { if (edge.getVertex(Direction.IN).equals(post)) graph.removeEdge(edge); } updateUser.addEdge("DownVote", post); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); } finally { graph.shutdown(); } }
protected void upVoteProduct(Map<String, Object> data) { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); OrientVertex updateUser = (OrientVertex) graph.getVertexByKey("User.userId", data.remove("updateUserId")); OrientVertex product = (OrientVertex) graph.getVertexByKey("Product.entityId", data.get("entityId")); if (product != null && updateUser != null) { // remove DownVote edge if there is. for (Edge edge : updateUser.getEdges(product, Direction.OUT, "DownVote")) { if (edge.getVertex(Direction.IN).equals(product)) graph.removeEdge(edge); } updateUser.addEdge("UpVote", product); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); } finally { graph.shutdown(); } }
protected void upVoteUser(Map<String, Object> data) { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); OrientVertex user = (OrientVertex)graph.getVertexByKey("User.userId", data.get("userId")); OrientVertex voteUser = (OrientVertex)graph.getVertexByKey("User.userId", data.get("voteUserId")); if(user != null && voteUser != null) { for (Edge edge : voteUser.getEdges(user, Direction.OUT, "DownVote")) { if(edge.getVertex(Direction.IN).equals(user)) graph.removeEdge(edge); } voteUser.addEdge("UpVote", user); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); throw e; } finally { graph.shutdown(); } }
protected void downVoteUser(Map<String, Object> data) { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); OrientVertex user = (OrientVertex)graph.getVertexByKey("User.userId", data.get("userId")); OrientVertex voteUser = (OrientVertex)graph.getVertexByKey("User.userId", data.get("voteUserId")); if(user != null && voteUser != null) { for (Edge edge : voteUser.getEdges(user, Direction.OUT, "UpVote")) { if(edge.getVertex(Direction.IN).equals(user)) graph.removeEdge(edge); } voteUser.addEdge("DownVote", user); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); throw e; } finally { graph.shutdown(); } }
protected void delComment(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try{ graph.begin(); String commentId = (String)data.get("commentId"); OrientVertex comment = (OrientVertex)graph.getVertexByKey("Comment.commentId", commentId); // remove the edge to this comment for (Edge edge : comment.getEdges(Direction.IN)) { graph.removeEdge(edge); } graph.removeVertex(comment); graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); } finally { graph.shutdown(); } }
protected void downVoteProduct(Map<String, Object> data) { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); OrientVertex updateUser = (OrientVertex) graph.getVertexByKey("User.userId", data.remove("updateUserId")); OrientVertex product = (OrientVertex) graph.getVertexByKey("Product.entityId", data.get("entityId")); if (product != null && updateUser != null) { // remove UpVote edge if there is. for (Edge edge : updateUser.getEdges(product, Direction.OUT, "UpVote")) { if (edge.getVertex(Direction.IN).equals(product)) graph.removeEdge(edge); } updateUser.addEdge("DownVote", product); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); } finally { graph.shutdown(); } }
protected void upVotePost(Map<String, Object> data) { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); OrientVertex updateUser = (OrientVertex) graph.getVertexByKey("User.userId", data.remove("updateUserId")); OrientVertex post = (OrientVertex) graph.getVertexByKey("Post.entityId", data.get("entityId")); if (post != null && updateUser != null) { // remove DownVote edge if there is. for (Edge edge : updateUser.getEdges(post, Direction.OUT, "DownVote")) { if (edge.getVertex(Direction.IN).equals(post)) graph.removeEdge(edge); } updateUser.addEdge("UpVote", post); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); } finally { graph.shutdown(); } }
if(edge.getVertex(Direction.IN).equals(comment)) { reported = true; graph.removeEdge(edge);
Vertex menuItem = graph.getVertexByKey("MenuItem.menuItemId", menuItemId); for (Edge edge : (Iterable<Edge>) menu.getEdges(Direction.OUT, "Own")) { if(edge.getVertex(Direction.IN).equals(menuItem)) graph.removeEdge(edge);
if(delParentId != null) { for (Edge edge : (Iterable<Edge>) branch.getEdges(Direction.IN, "Own")) { graph.removeEdge(edge); OrientVertex vertex = getBranchByHostId(graph, branchType, host, childId); for (Edge edge : (Iterable<Edge>) branch.getEdges(Direction.OUT, "Own")) { if(edge.getVertex(Direction.IN).equals(vertex)) graph.removeEdge(edge);
Vertex vertex = graph.getVertexByKey("MenuItem.menuItemId", menuItemId); for (Edge edge : (Iterable<Edge>) menuItem.getEdges(Direction.OUT, "Own")) { if(edge.getVertex(Direction.IN).equals(vertex)) graph.removeEdge(edge);
graph.removeEdge(edge); rank--; if(edge.getVertex(Direction.IN).equals(comment)) { downVoted = true; graph.removeEdge(edge); rank++;
graph.removeEdge(edge); rank++; if(edge.getVertex(Direction.IN).equals(comment)) { upVoted = true; graph.removeEdge(edge); rank--;
OrientVertex tag = graph.getVertex(oid.getRecord()); for (Edge edge : (Iterable<Edge>) product.getEdges(Direction.OUT, "HasTag")) { if(edge.getVertex(Direction.IN).equals(tag)) graph.removeEdge(edge);
OrientVertex tag = graph.getVertex(oid.getRecord()); for (Edge edge : (Iterable<Edge>) post.getEdges(Direction.OUT, "HasTag")) { if(edge.getVertex(Direction.IN).equals(tag)) graph.removeEdge(edge);