@Override public Edge addEdge(final String label, final Vertex inVertex) { return addEdge(label, (OrientVertex) inVertex, null, null, (Object[]) null); }
/** * Creates an edge between current Vertex and a target Vertex setting label as Edge's label. iClassName is the Edge's class used * if different by label. * * @param label Edge's label or class * @param inVertex Outgoing target vertex * @param iClassName Edge's class name * * @return The new Edge created */ public OrientEdge addEdge(final String label, final OrientVertex inVertex, final String iClassName) { return addEdge(label, inVertex, iClassName, null, (Object[]) null); }
public OrientEdge addEdge(final String label, final OrientVertex inVertex, final String iClassName) { return addEdge(label, inVertex, iClassName, null, (Object[]) null); }
/** * Creates an edge between current Vertex and a target Vertex setting label as Edge's label. The fields parameter is an Array of * fields to set on Edge upon creation. Fields must be a odd pairs of key/value or a single object as Map containing entries as * key/value pairs. * * @param label Edge's label or class * @param inVertex Outgoing target vertex * @param fields Fields must be a odd pairs of key/value or a single object as Map containing entries as key/value pairs * * @return The new Edge created */ public OrientEdge addEdge(final String label, final OrientVertex inVertex, final Object[] fields) { return addEdge(label, inVertex, null, null, fields); }
public OrientEdge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) { String className = null; if (id != null && id instanceof String && id.toString().startsWith(CLASS_PREFIX)) // GET THE CLASS NAME className = id.toString().substring(CLASS_PREFIX.length()); // SAVE THE ID TOO? final Object[] fields = saveOriginalIds && id != null ? new Object[] { OrientElement.DEF_ORIGINAL_ID_FIELDNAME, id } : null; return ((OrientVertex) outVertex).addEdge(label, (OrientVertex) inVertex, className, null, fields); }
/** * Creates an edge between current Vertex and a target Vertex setting label as Edge's label. * * @param label Edge's label or class * @param inVertex Outgoing target vertex * * @return The new Edge created */ @Override public Edge addEdge(final String label, Vertex inVertex) { if (inVertex instanceof PartitionVertex) // WRAPPED: GET THE BASE VERTEX inVertex = ((PartitionVertex) inVertex).getBaseVertex(); return addEdge(label, (OrientVertex) inVertex, null, null, (Object[]) null); }
return ((OrientVertex) outVertex).addEdge(label, (OrientVertex) inVertex, className, clusterName, fields);
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(); } }
v.addEdge("E", graphContext.lastVertexToConnect); resultEdges.current.incrementAndGet();
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 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 addMenuItem(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); Vertex user = graph.getVertexByKey("User.userId", data.remove("createUserId")); List<String> addMenuItems = (List<String>)data.remove("addMenuItems"); OrientVertex menuItem = graph.addVertex("class:MenuItem", data); if(addMenuItems != null && addMenuItems.size() > 0) { // find vertex for each menuItem id and create edge to it. for(String menuItemId: addMenuItems) { Vertex childMenuItem = graph.getVertexByKey("MenuItem.menuItemId", menuItemId); menuItem.addEdge("Own", childMenuItem); } } user.addEdge("Create", menuItem); graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); throw e; } 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(); } }
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(); } }
menu.addEdge("Own", menuItem);
user.addEdge("ReportSpam", comment);