public boolean filter(final Vertex iObject) { return !(iObject instanceof OrientVertex && ((OrientVertex) iObject).getRecord() == null); }
@Override @SuppressWarnings("unchecked") public T vertexToObject(final Vertex vertex) { final OrientVertex orientVertex = (OrientVertex) vertex; return documentToObject(orientVertex.getRecord()); } }
OrientVertex v=g.getVertex("#9:0"); ODocument d=v.getRecord(); String json=d.toJSON();
@Override public Set<String> getPropertyKeys() { graph.setCurrentGraphInThreadLocal(); final ODocument doc = getRecord(); final Set<String> result = new HashSet<String>(); for (String field : doc.fieldNames()) if (graph.isUseVertexFieldsForEdgeLabels()) { if (!field.startsWith(CONNECTION_OUT_PREFIX) && !field.startsWith(CONNECTION_IN_PREFIX)) result.add(field); } else if (!field.equals(OrientBaseGraph.CONNECTION_OUT) && !field.equals(OrientBaseGraph.CONNECTION_IN)) result.add(field); return result; }
@Override public boolean hasNext() { if(vertex == null) { while (iterator.hasNext()) { vertex = (OrientVertex) iterator.next(); if (vertex != null && klass.isSuperClassOf(vertex.getRecord().getSchemaClass())) { return true; } } } else { return true; } return false; }
/** * Returns all the Property names as Set of String. out, in and label are not returned as properties even if are part of the * underlying document because are considered internal properties. */ @Override public Set<String> getPropertyKeys() { final OrientBaseGraph graph = setCurrentGraphInThreadLocal(); final ODocument doc = getRecord(); final Set<String> result = new HashSet<String>(); for (String field : doc.fieldNames()) if (graph != null && settings.isUseVertexFieldsForEdgeLabels()) { if (!field.startsWith(CONNECTION_OUT_PREFIX) && !field.startsWith(CONNECTION_IN_PREFIX)) result.add(field); } else if (!field.equals(OrientBaseGraph.CONNECTION_OUT) && !field.equals(OrientBaseGraph.CONNECTION_IN)) result.add(field); return result; }
@Override public void shortestPath(final Vertex v1, Integer i) { final OrientVertex v2 = (OrientVertex) getVertex(i); List<ORID> result = new OSQLFunctionShortestPath().execute(graph, null, null, new Object[] { ((OrientVertex) v1).getRecord(), v2.getRecord(), Direction.OUT, 5 }, new OBasicCommandContext()); result.size(); }
protected String getMenuItem(OrientGraph graph, String menuItemId) throws Exception { String json = null; Vertex menuItem = graph.getVertexByKey("MenuItem.menuItemId", menuItemId); if(menuItem != null) { json = ((OrientVertex)menuItem).getRecord().toJSON(); } return json; }
/** * (Blueprints Extension) Returns the Vertex's label. By default OrientDB binds the Blueprints Label concept to Vertex Class. To * disable this feature execute this at database level <code>alter database custom useClassForVertexLabel=false </code> */ @Override public String getLabel() { setCurrentGraphInThreadLocal(); if (settings.isUseClassForVertexLabel()) { final String clsName = getRecord().getClassName(); if (!OrientVertexType.CLASS_NAME.equals(clsName)) // RETURN THE CLASS NAME return clsName; } return getRecord().field(OrientElement.LABEL_FIELD_NAME); }
/** * (Blueprints Extension) Returns the Vertex type as OrientVertexType object. */ @Override public OrientVertexType getType() { final OrientBaseGraph graph = getGraph(); return new OrientVertexType(graph, getRecord().getSchemaClass()); }
/** * Returns a OTraverse object to start traversing from the current vertex. */ public OTraverse traverse() { setCurrentGraphInThreadLocal(); return new OTraverse().target(getRecord()); }
/** * Returns a OTraverse object to start traversing from the current vertex. */ public OTraverse traverse() { graph.setCurrentGraphInThreadLocal(); return new OTraverse().target(getRecord()); }
public String toString() { graph.setCurrentGraphInThreadLocal(); final String clsName = getRecord().getClassName(); if (clsName.equals(CLASS_NAME)) return StringFactory.vertexString(this); return StringFactory.V + "(" + clsName + ")" + StringFactory.L_BRACKET + getId() + StringFactory.R_BRACKET; }
/** * Returns a string representation of the vertex. */ public String toString() { setCurrentGraphInThreadLocal(); final ODocument record = getRecord(); if (record == null) return "<invalid record " + rawElement.getIdentity() + ">"; final String clsName = record.getClassName(); if (OrientVertexType.CLASS_NAME.equals(clsName)) return StringFactory.vertexString(this); return StringFactory.V + "(" + clsName + ")" + StringFactory.L_BRACKET + getId() + StringFactory.R_BRACKET; }
public static String getJsonByRid(String rid) { String json = null; OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { ODocument doc = graph.getVertex(rid).getRecord(); if(doc != null) json = doc.toJSON(); } catch (Exception e) { logger.error("Exception:", e); throw e; } finally { graph.shutdown(); } return json; }
protected String getMenu(OrientGraph graph, String host) { String json = null; Map<String, Object> menuMap = (Map<String, Object>)ServiceLocator.getInstance().getMemoryImage("menuMap"); ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>)menuMap.get("cache"); if(cache != null) { json = (String)cache.get(host); } if(json == null) { Vertex menu = graph.getVertexByKey("Menu.host", host); if(menu != null) { json = ((OrientVertex)menu).getRecord().toJSON("rid,fetchPlan:[*]in_Create:-2 [*]out_Create:-2 [*]in_Update:-2 [*]out_Update:-2 [*]in_Own:-2 [*]out_Own:4"); } if(json != null) { if(cache == null) { cache = new ConcurrentLinkedHashMap.Builder<Object, Object>() .maximumWeightedCapacity(1000) .build(); menuMap.put("cache", cache); } cache.put(host, json); } } return json; }
protected static String getMenu(OrientGraph graph, String host) { String json = null; Map<String, Object> menuMap = (Map<String, Object>) ServiceLocator.getInstance().getMemoryImage("menuMap"); ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>)menuMap.get("cache"); if(cache != null) { json = (String)cache.get(host); } if(json == null) { Vertex menu = graph.getVertexByKey("Menu.host", host); if(menu != null) { json = ((OrientVertex)menu).getRecord().toJSON("rid,fetchPlan:out_Own.in_Create:-2 out_Own:2"); } if(json != null) { if(cache == null) { cache = new ConcurrentLinkedHashMap.Builder<Object, Object>() .maximumWeightedCapacity(1000) .build(); menuMap.put("cache", cache); } cache.put(host, json); } } return json; }
protected String getRoleById(String roleId) { String json = null; OrientGraph graph = ServiceLocator.getInstance().getGraph(); try { OrientVertex role = (OrientVertex)graph.getVertexByKey("Role.roleId", roleId); if(role != null) { json = role.getRecord().toJSON(); } } catch (Exception e) { logger.error("Exception:", e); throw e; } finally { graph.shutdown(); } return json; }
protected CacheObject getPageById(OrientGraph graph, String pageId) { CacheObject co = null; Map<String, Object> pageMap = ServiceLocator.getInstance().getMemoryImage("pageMap"); ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>)pageMap.get("cache"); if(cache == null) { cache = new ConcurrentLinkedHashMap.Builder<Object, Object>() .maximumWeightedCapacity(1000) .build(); pageMap.put("cache", cache); } else { co = (CacheObject)cache.get(pageId); } if(co == null) { OrientVertex page = (OrientVertex)graph.getVertexByKey("Page.pageId", pageId); if(page != null) { String json = page.getRecord().toJSON(); co = new CacheObject(page.getProperty("@version").toString(), json); cache.put(pageId, co); } } return co; }