Package com.orientechnologies.orient.core.record.impl

Examples of com.orientechnologies.orient.core.record.impl.ODocument


  @Test(dependsOnMethods = "testBasicReadExternal")
  public void testMixedCreateExternal() {
    database.open("admin", "admin");

    ODocument doc = new ODocument(database);
    doc.field("binary", new ORecordBytes(database, "Binary data".getBytes()));

    doc.save();
    rid = doc.getIdentity();

    database.close();
  }
View Full Code Here


  @Test(dependsOnMethods = "testMixedCreateExternal")
  public void testMixedReadExternal() {
    database.open("admin", "admin");

    ODocument doc = new ODocument(database, rid);
    doc.reload();

    Assert.assertEquals("Binary data", new String(((ORecordBytes) doc.field("binary")).toStream()));

    database.close();
  }
View Full Code Here

    super(iDatabase, OGraphEdge.class.getSimpleName(), iPolymorphic);
  }

  @Override
  public OGraphEdge next(final String iFetchPlan) {
    final ODocument doc = underlying.next();

    OGraphEdge e = (OGraphEdge) database.getUserObjectByRecord(doc, null, !isReuseSameObject());
    if (e != null)
      return e;
View Full Code Here

    database.getMetadata().getSchema().save();
  }

  private void populateDatabase() {
    ODocument car = new ODocument(database, CAR);
    car.field("plate", "JINF223S");

    ODocument johnDoe = new ODocument(database, WORKER);
    johnDoe.field("name", "John");
    johnDoe.field("surname", "Doe");
    johnDoe.field("car", car);
    johnDoe.save();
    johnDoeID = johnDoe.getIdentity().copy();

    ODocument janeDoe = new ODocument(database, WORKER);
    janeDoe.field("name", "Jane");
    janeDoe.field("surname", "Doe");
    janeDoe.save();
    janeDoeID = janeDoe.getIdentity().copy();

    ODocument chuckNorris = new ODocument(database, WORKER);
    chuckNorris.field("name", "Chuck");
    chuckNorris.field("surname", "Norris");
    chuckNorris.save();
    chuckNorrisID = chuckNorris.getIdentity().copy();

    ODocument jackBauer = new ODocument(database, WORKER);
    jackBauer.field("name", "Jack");
    jackBauer.field("surname", "Bauer");
    jackBauer.save();
    jackBauerID = jackBauer.getIdentity().copy();

    ODocument ctu = new ODocument(database, WORKPLACE);
    ctu.field("name", "CTU");
    ctu.field("boss", jackBauer);
    List<ODocument> workplace1Workers = new ArrayList<ODocument>();
    workplace1Workers.add(chuckNorris);
    workplace1Workers.add(janeDoe);
    ctu.field("workers", workplace1Workers);
    ctu.save();
    ctuID = ctu.getIdentity().copy();

    ODocument fbi = new ODocument(database, WORKPLACE);
    fbi.field("name", "FBI");
    fbi.field("boss", chuckNorris);
    List<ODocument> workplace2Workers = new ArrayList<ODocument>();
    workplace2Workers.add(chuckNorris);
    workplace2Workers.add(jackBauer);
    fbi.field("workers", workplace2Workers);
    fbi.save();
    fbiID = fbi.getIdentity().copy();

    car.field("owner", jackBauer);
    car.save();
    carID = car.getIdentity().copy();
  }
View Full Code Here

public class ODocumentWrapper {
  @ODocumentInstance
  protected ODocument  document;

  public ODocumentWrapper(final ODatabaseRecord iDatabase, final ORID iRID) {
    this(new ODocument(iDatabase, iRID));
  }
View Full Code Here

  public ODocumentWrapper(final ODatabaseRecord iDatabase, final ORID iRID) {
    this(new ODocument(iDatabase, iRID));
  }

  public ODocumentWrapper(final ODatabaseRecord iDatabase, final String iClassName) {
    this(new ODocument(iDatabase, iClassName));
  }
View Full Code Here

      case LINK:
        final int pos = iFieldValueAsString.indexOf('@');
        if (pos > -1)
          // CREATE DOCUMENT
          return new ODocument(iRecord.getDatabase(), iFieldValueAsString.substring(1, pos), new ORecordId(
              iFieldValueAsString.substring(pos + 1)));
        else
          // CREATE SIMPLE RID
          return new ORecordId(iFieldValueAsString.substring(1));
View Full Code Here

  private void fetchDocument(Map<String, Integer> iFetchPlan, Object fieldValue, String fieldName, final int iCurrentLevel,
      final int iMaxFetch, final OJSONWriter json, int indentLevel, boolean includeType, boolean includeId, boolean includeVer,
      boolean includeClazz, boolean attribSameRow, boolean keepTypes, final Set<ORID> parsedRecords) throws IOException {
    if (!parsedRecords.contains(((ODocument) fieldValue).getIdentity())) {
      parsedRecords.add(((ODocument) fieldValue).getIdentity());
      final ODocument linked = (ODocument) fieldValue;
      json.beginObject(indentLevel + 1, true, fieldName);
      writeSignature(json, indentLevel, includeType, includeId, includeVer, includeClazz, attribSameRow, linked);
      processRecord(json, indentLevel, includeType, includeId, includeVer, includeClazz, attribSameRow, linked, iFetchPlan,
          keepTypes, iCurrentLevel + 1, iMaxFetch, parsedRecords);
      json.endObject(indentLevel + 1, true);
View Full Code Here

      byte[] paramBuffer = buffer.getAsByteArray();

      if (paramBuffer.length == 0)
        parameters = null;
      else {
        final ODocument param = new ODocument(database);
        param.fromStream(paramBuffer);

        Map<String, Object> params = param.field("params");

        parameters = new HashMap<Object, Object>();
        for (Entry<String, Object> p : params.entrySet()) {
          final Object value;
          if (p.getValue() instanceof String)
View Full Code Here

      buffer.add(text);

      if (parameters == null || parameters.size() == 0)
        buffer.add(new byte[0]);
      else {
        final ODocument param = new ODocument(database);
        param.field("params", parameters);
        buffer.add(param.toStream());
      }

    } catch (IOException e) {
      throw new OSerializationException("Error while marshalling OCommandRequestTextAbstract impl", e);
    }
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.record.impl.ODocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.