Examples of ODocument


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

  @Test
  public void commandWrongParameterNames() {
    database = ODatabaseDocumentPool.global().acquire(url, "admin", "admin");

    ODocument doc = database.newInstance();

    try {
      doc.field("a:b", 10);
      Assert.assertFalse(true);
    } catch (IllegalArgumentException e) {
      Assert.assertTrue(true);
    }

    try {
      doc.field("a,b", 10);
      Assert.assertFalse(true);
    } catch (IllegalArgumentException e) {
      Assert.assertTrue(true);
    }
View Full Code Here

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

  @Test
  public void testTransientField() {
    database = ODatabaseDocumentPool.global().acquire(url, "admin", "admin");
    database.open("admin", "admin");

    ODocument doc = new ODocument(database, "Profile");
    doc.field("nick", "LucaPhotoTest");
    doc.field("photo", "testPhoto"); // THIS IS DECLARED TRANSIENT IN SCHEMA (see SchemaTest.java)
    doc.save();

    // RELOAD FROM THE CACHE
    doc.reload(null, false);
    Assert.assertEquals(doc.field("nick"), "LucaPhotoTest");
    Assert.assertTrue(doc.containsField("photo"));

    // RELOAD FROM DISK
    doc.reload();
    Assert.assertEquals(doc.field("nick"), "LucaPhotoTest");
    Assert.assertFalse(doc.containsField("photo")); // THIS IS DECLARED TRANSIENT IN SCHEMA (see SchemaTest.java)

    database.close();
  }
View Full Code Here

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

    database.close();
  }

  @Test
  public void testDirtyChild() {
    ODocument parent = new ODocument();

    ODocument child1 = new ODocument().addOwner(parent);
    parent.field("child1", child1);

    Assert.assertTrue(child1.hasOwners());

    ODocument child2 = new ODocument().addOwner(child1);
    child1.field("child2", child2);

    Assert.assertTrue(child2.hasOwners());

    // BEFORE FIRST TOSTREAM
    Assert.assertTrue(parent.isDirty());
    parent.toStream();
    // AFTER TOSTREAM
    Assert.assertTrue(parent.isDirty());
    // CHANGE FIELDS VALUE (Automaticaly set dirty this child)
    child1.field("child2", new ODocument());
    Assert.assertTrue(parent.isDirty());

  }
View Full Code Here

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

  }

  @Test
  public void testInvalidFetchplanLoad() {
    database = ODatabaseDocumentPool.global().acquire(url, "admin", "admin");
    ODocument doc = database.newInstance();
    doc.field("test", "test");
    doc.save();
    ORID docRid = doc.getIdentity().copy();
    // RELOAD THE DOCUMENT, THIS WILL PUT IT IN L1 CACHE
    doc = database.load(docRid, "*:-1");
    doc = testInvalidFetchPlanInvalidateL1Cache(doc, docRid);
    doc = testInvalidFetchPlanInvalidateL1Cache(doc, new ORecordId(1, 0));
    doc = testInvalidFetchPlanInvalidateL1Cache(doc, new ORecordId(1, 1));
    doc = testInvalidFetchPlanInvalidateL1Cache(doc, new ORecordId(1, 2));
    doc = testInvalidFetchPlanInvalidateL1Cache(doc, new ORecordId(2, 0));
    doc = testInvalidFetchPlanInvalidateL1Cache(doc, new ORecordId(2, 1));
    doc = testInvalidFetchPlanInvalidateL1Cache(doc, new ORecordId(2, 2));
    doc = testInvalidFetchPlanInvalidateL1Cache(doc, new ORecordId(3, 0));
    doc = testInvalidFetchPlanInvalidateL1Cache(doc, new ORecordId(3, 1));
    doc = testInvalidFetchPlanInvalidateL1Cache(doc, new ORecordId(3, 2));
    doc = testInvalidFetchPlanInvalidateL1Cache(doc, new ORecordId(4, 0));
    doc = testInvalidFetchPlanInvalidateL1Cache(doc, new ORecordId(4, 1));
    // CLOSE DB AND RE-TEST THE LOAD TO MAKE SURE
    database.close();
    database = null;
    database = ODatabaseDocumentPool.global().acquire(url, "admin", "admin");
    doc = testInvalidFetchPlanClearL1Cache(doc, docRid);
    doc = testInvalidFetchPlanClearL1Cache(doc, new ORecordId(1, 0));
    doc = testInvalidFetchPlanClearL1Cache(doc, new ORecordId(1, 1));
    doc = testInvalidFetchPlanClearL1Cache(doc, new ORecordId(1, 2));
    doc = testInvalidFetchPlanClearL1Cache(doc, new ORecordId(2, 0));
    doc = testInvalidFetchPlanClearL1Cache(doc, new ORecordId(2, 1));
    doc = testInvalidFetchPlanClearL1Cache(doc, new ORecordId(2, 2));
    doc = testInvalidFetchPlanClearL1Cache(doc, new ORecordId(3, 0));
    doc = testInvalidFetchPlanClearL1Cache(doc, new ORecordId(3, 1));
    doc = testInvalidFetchPlanClearL1Cache(doc, new ORecordId(3, 2));
    doc = testInvalidFetchPlanClearL1Cache(doc, new ORecordId(4, 0));
    doc = testInvalidFetchPlanClearL1Cache(doc, new ORecordId(4, 1));
    doc = database.load(docRid);
    doc.delete();
    database.close();
  }
View Full Code Here

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

  }

  public void testEncoding() {
    String s = " \r\n\t:;,.|+*/\\=!?[]()'\"";

    ODocument doc = new ODocument(database);
    doc.field("test", s);
    doc.unpin();
    doc.save();

    doc.reload(null, true);
    Assert.assertEquals(doc.field("test"), s);
  }
View Full Code Here

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

  @Test
  public void insertOperator() {
    database.open("admin", "admin");

    ODocument doc = (ODocument) database.command(
        new OCommandSQL("insert into Profile (name, surname, salary, location, dummy) values ('Luca','Smith', 109.9, 13:3, name)"))
        .execute();

    Assert.assertTrue(doc != null);
View Full Code Here

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

  @Test
  public void insertWithWildcards() {
    database.open("admin", "admin");

    ODocument doc = (ODocument) database.command(
        new OCommandSQL("insert into Profile (name, surname, salary, location, dummy) values (?,?,?,?,?)")).execute("Marc",
        "Smith", 120.0, new ORecordId(13, 3), "hooray");

    Assert.assertTrue(doc != null);
    Assert.assertEquals(doc.field("name"), "Marc");
    Assert.assertEquals(doc.field("surname"), "Smith");
    Assert.assertEquals(((Number) doc.field("salary")).floatValue(), 120.0f);
    Assert.assertEquals(doc.field("location", OType.LINK), new ORecordId(13, 3));
    Assert.assertEquals(doc.field("dummy"), "hooray");

    database.close();
  }
View Full Code Here

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

  public Object execute(final ORecord<?> iCurrentRecord, final Object[] iParameters) {
    if (!(iCurrentRecord instanceof ODocument))
      // NOT DOCUMENT: IGNORE IT
      return null;

    final ODocument document = (ODocument) iCurrentRecord;

    if (engine == null) {
      try {
        engine = new GremlinScriptEngine();
      } catch (Throwable e) {
        throw new OConfigurationException("Error on loading Gremlin engine", e);
      }

      // TODO THIS COULD BE IMPROVED BY CREATING A ORIENT-GRAPH POOL (LIKE WITH OTHER DB TYPES) INSTEAD TO CREATE IT PER QUERY
      graph = new OrientGraph(iCurrentRecord.getDatabase().getURL());
      engine.getBindings(ScriptContext.ENGINE_SCOPE).put("g", graph);
    }

    final OrientElement graphElement;

    if (document.getSchemaClass().isSubClassOf(OGraphDatabase.VERTEX_CLASS_NAME))
      // VERTEX TYPE
      graphElement = new OrientVertex(graph, document);
    else if (document.getSchemaClass().isSubClassOf(OGraphDatabase.EDGE_CLASS_NAME))
      // EDGE TYPE
      graphElement = new OrientEdge(graph, document);
    else
      // UNKNOWN CLASS: IGNORE IT
      return null;
View Full Code Here

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

  @Test
  public void testMVCC() throws IOException {
    ODatabaseDocumentTx db = new ODatabaseDocumentTx(url);
    db.open("admin", "admin");

    ODocument doc = new ODocument(db, "Account");
    doc.field("version", 0);
    doc.save();

    doc.setDirty();
    doc.setVersion(1);
    try {
      doc.save();
      Assert.assertTrue(false);
    } catch (OConcurrentModificationException e) {
      Assert.assertTrue(true);
    }
View Full Code Here

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

  @Test
  public void testMixedCreateEmbedded() {
    database.open("admin", "admin");

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

    doc.save();

    doc.reload();
    Assert.assertEquals(new String((byte[]) doc.field("binary", OType.BINARY)), "Binary data");

    database.close();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.