protected void delBranchDb(String branchType, Map<String, Object> data) throws Exception { String className = branchType.substring(0, 1).toUpperCase() + branchType.substring(1); OrientGraph graph = ServiceLocator.getInstance().getGraph(); try{ graph.begin(); OrientVertex branch = getBranchByHostId(graph, branchType, (String)data.get("host"), (String)data.get("categoryId")); if(branch != null) { graph.removeVertex(branch); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); } finally { graph.shutdown(); } }
@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(); }
private OrientVertex createVertex(OClass vertexClass, OClass edgeClass) { OrientGraph tx = orientGraphProvider.get(); OrientVertex newVertex = tx.addVertex(vertexClass.getName(), (String) null); OrientVertex vertex = tx.getVertex(documentModel.getObject().getIdentity()); tx.addEdge(null, vertex, newVertex, edgeClass.getName()); tx.commit();tx.begin(); return newVertex; }
private void createEdge(List<ODocument> documents, OClass edgeClass) { OrientGraph tx = orientGraphProvider.get(); for (ODocument createTo : documents) { tx.addEdge(null, tx.getVertex(documentModel.getObject().getIdentity()), tx.getVertex(createTo.getIdentity()), edgeClass.getName()); } tx.commit();tx.begin(); }
protected void delHostConfigDb(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try{ graph.begin(); OrientVertex config = getConfigByHostId(graph, (String)data.get("host"), (String)data.get("configId")); if(config != null) { graph.removeVertex(config); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); } finally { graph.shutdown(); } }
@Override protected void performMultiAction(AjaxRequestTarget target, List<ODocument> objects) { super.performMultiAction(target, objects); OrientGraph tx = orientGraphProvider.get(); for (ODocument doc : objects) { ORID id = doc.getIdentity(); OrientVertex vertex = tx.getVertex(id); removeEdges(tx, vertex); } tx.commit();tx.begin(); sendActionPerformed(); }
@Override protected void performMultiAction(AjaxRequestTarget target, List<ODocument> objects) { super.performMultiAction(target, objects); OrientGraph tx = orientGraphProvider.get(); for (ODocument doc : objects) { ORID id = doc.getIdentity(); tx.removeVertex(tx.getVertex(id)); } tx.commit();tx.begin(); sendActionPerformed(); }
protected void updComment(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); if(comment != null) { comment.setProperty("content", data.get("content")); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); } finally { graph.shutdown(); } }
protected void delConfigDb(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try{ graph.begin(); Vertex config = graph.getVertexByKey("Config.configId", (String)data.get("configId")); if(config != null) { graph.removeVertex(config); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); } finally { graph.shutdown(); } }
protected void updRole(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); Vertex user = graph.getVertexByKey("User.userId", data.get("userId")); if(user != null) { user.setProperty("roles", data.get("roles")); user.setProperty("updateDate", data.get("updateDate")); Vertex updateUser = graph.getVertexByKey("User.userId", data.get("updateUserId")); updateUser.addEdge("Update", user); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); throw e; } finally { graph.shutdown(); } }
protected void updPassword(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); Vertex user = graph.getVertexByKey("User.userId", data.get("userId")); user.setProperty("updateDate", data.get("updateDate")); Vertex credential = user.getProperty("credential"); if (credential != null) { credential.setProperty("password", data.get("password")); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); throw e; } finally { graph.shutdown(); } }
protected void delMenuItem(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); Vertex menuItem = graph.getVertexByKey("MenuItem.menuItemId",data.get("menuItemId")); if(menuItem != null) { graph.removeVertex(menuItem); } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); throw e; } finally { graph.shutdown(); } // no need to refresh cache as there is no reference to this menuItem anywhere. }
protected void addConfigDb(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try{ graph.begin(); Vertex createUser = graph.getVertexByKey("User.userId", data.remove("createUserId")); OrientVertex config = graph.addVertex("class:Config", data); createUser.addEdge("Create", config); graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); } finally { graph.shutdown(); } }
protected void addHostConfigDb(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try{ graph.begin(); Vertex createUser = graph.getVertexByKey("User.userId", data.remove("createUserId")); OrientVertex hostConfig = graph.addVertex("class:HostConfig", data); createUser.addEdge("Create", hostConfig); graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); } finally { graph.shutdown(); } }
protected void addRole(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); Vertex createUser = graph.getVertexByKey("User.userId", data.remove("createUserId")); OrientVertex role = graph.addVertex("class:Role", data); createUser.addEdge("Create", role); graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); throw e; } finally { graph.shutdown(); } }
protected void delUser(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); Vertex user = graph.getVertexByKey("User.userId", data.get("userId")); if(user != null) { graph.removeVertex(user.getProperty("credential")); graph.removeVertex(user); } } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); throw e; } finally { graph.shutdown(); } }
protected void revokeRefreshToken(Map<String, Object> data) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); Vertex user = graph.getVertexByKey("User.userId", data.get("userId")); if(user != null) { Vertex credential = user.getProperty("credential"); if(credential != null) { credential.removeProperty("clientRefreshTokens"); } } graph.commit(); } catch (Exception e) { logger.error("Exception:", e); graph.rollback(); throw e; } finally { graph.shutdown(); } }
public static Vertex delVertexByRid(String rid) throws Exception { Vertex v = null; OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); v = graph.getVertex(rid); graph.removeVertex(v); graph.commit(); } catch (Exception e) { graph.rollback(); logger.error("Exception:", e); throw e; } finally { graph.shutdown(); } return v; }
protected void delRole(String roleId) throws Exception { OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { graph.begin(); Vertex role = graph.getVertexByKey("Role.roleId", roleId); if(role != null) { graph.removeVertex(role); } 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(); } }