@Override public String toJSON() { return element.toJSON(); }
@Override public String toJSON(String iFormat) { return element.toJSON(iFormat); }
OrientVertex v=g.getVertex("#9:0"); ODocument d=v.getRecord(); String json=d.toJSON();
@Override Reader getField(final ODocument document) { return new StringReader(document.<ODocument>field(super.fieldName, ODocument.class).toJSON("prettyPrint")); } };
private void doGet(OHttpRequest iRequest, OHttpResponse iResponse, String[] parts) throws IOException { if ("status".equalsIgnoreCase(parts[1])) { ODocument status = handler.status(); iResponse.send(OHttpUtils.STATUS_OK_CODE, "OK", OHttpUtils.CONTENT_JSON, status.toJSON("prettyPrint"), null); } else { throw new IllegalArgumentException(""); } }
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; }
@Override public String convertToString(ODocument value, Locale locale) { return value.getIdentity().isPersistent() ? super.convertToString(value, locale):value.toJSON(); }
@Override public String convertToString(ODocument value, Locale locale) { return value.getIdentity().isPersistent() ? super.convertToString(value, locale):value.toJSON(); }
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; }
@Override public String toJSON(String iFormat) { if (element != null) { return element.toJSON(iFormat); } else { return "{\"out\":\"" + vOut.getIdentity() + "\", \"in\":\"" + vIn.getIdentity() + "\", \"@class\":\"" + OStringSerializerHelper.encode(lightweightEdgeType.getName()) + "\"}"; } }
@Override public String toJSON() { if (element != null) { return element.toJSON(); } else { return "{\"out\":\"" + vOut.getIdentity() + "\", \"in\":\"" + vIn.getIdentity() + "\", \"@class\":\"" + OStringSerializerHelper.encode(lightweightEdgeType.getName()) + "\"}"; } }
private boolean updateCfgOnDisk() throws IOException { File f = getConfigFile(); if (f != null) { OLogManager.instance().debug(this, "Saving Command Cache config for db: %s", databaseName); OIOUtils.writeFile(f, configuration.toJSON("prettyPrint")); return true; } return false; }
@ConsoleCommand(description = "Displays the status of the cluster nodes") public void clusterStatus() throws IOException { checkForRemoteServer(); try { message("\nCluster status:"); ODocument clusterStatus = ((OrientDBRemote) OrientDBInternal.extract(orientDB)) .getClusterStatus(currentDatabaseUserName, currentDatabaseUserPassword); out.println(clusterStatus.toJSON("attribSameRow,alwaysFetchEmbedded,fetchPlan:*:0")); } catch (Exception e) { printError(e); } }
@Override public String getFinalResultAsJson() { final ODocument json = new ODocument(); json.field("type", getName()); json.field("shortestPath", result.toJSON(), OType.EMBEDDED); return json.toJSON(""); }
protected void dumpDistributedConfiguration(final boolean iForce) { if (currentDatabase == null) return; final OStorage stg = currentDatabase.getStorage(); if (stg instanceof OStorageRemote) { final ODocument distributedCfg = ((OStorageRemote) stg).getClusterConfiguration(); if (distributedCfg != null && !distributedCfg.isEmpty()) { message("\n\nDISTRIBUTED CONFIGURATION:\n" + distributedCfg.toJSON("prettyPrint")); } else if (iForce) message("\n\nDISTRIBUTED CONFIGURATION: none (OrientDB is running in standalone mode)"); } }
@Override public String getFinalResultAsJson() { final ODocument json = new ODocument(); json.field("type", getName()); json.field("vertices", resultVertices.toJSON(), OType.EMBEDDED); json.field("edges", resultEdges.toJSON(), OType.EMBEDDED); return json.toJSON(""); }
@Override public String getFinalResultAsJson() { final ODocument json = new ODocument(); json.field("type", getName()); json.field("creates", createsResult.toJSON(), OType.EMBEDDED); json.field("scans", scansResult.toJSON(), OType.EMBEDDED); json.field("reads", readsResult.toJSON(), OType.EMBEDDED); json.field("updates", updatesResult.toJSON(), OType.EMBEDDED); json.field("deletes", deletesResult.toJSON(), OType.EMBEDDED); return json.toJSON(""); }
@Test public void testQueryAndUpdate() throws Exception { ODocument doc = (ODocument) wicket.getTester().getDatabase().browseClass(TEST_REST_CLASS).current(); String ret = wicket.getTester().executeUrl("orientdb/query/db/sql/select+from+"+TEST_REST_CLASS, "GET", null); assertTrue(ret.contains(doc.toJSON())); int nextB = RANDOM.nextInt(); ret = wicket.getTester().executeUrl("orientdb/command/db/sql", "POST", "update "+TEST_REST_CLASS+" set b = "+nextB, "admin", "admin"); doc.reload(); assertEquals(nextB, (Object) doc.field("b")); wicket.getTester().signOut(); }
@Test public void testGetDocument() throws Exception { ODocument doc = (ODocument) wicket.getTester().getDatabase().browseClass(TEST_REST_CLASS).current(); ORID id = doc.getIdentity(); String ret = wicket.getTester().executeUrl("orientdb/document/db/"+id.getClusterId()+":"+id.getClusterPosition(), "GET", null); assertEquals(doc.toJSON(), ret); }