Examples of OCommandSQL


Examples of com.orientechnologies.orient.core.sql.OCommandSQL

    return rid;
  }

  private OCommandRequest formatCommand(final String iTemplate, final Object... iArgs) {
    final String text = String.format(iTemplate, iArgs);
    return new OCommandSQL(text);
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.sql.OCommandSQL

  @Test
  public void findSimpleReference() {
    if (database.isClosed())
      database.open("admin", "admin");

    Collection<ORID> result = database.command(new OCommandSQL("find references " + carID.toString())).execute();

    Assert.assertTrue(result.size() == 1);
    Assert.assertTrue(result.iterator().next().toString().equals(johnDoeID.toString()));

    result = database.command(new OCommandSQL("find references " + chuckNorrisID.toString())).execute();

    Assert.assertTrue(result.size() == 2);
    ORID rid = result.iterator().next();
    Assert.assertTrue(rid.toString().equals(ctuID.toString()) || rid.toString().equals(fbiID.toString()));
    rid = result.iterator().next();
    Assert.assertTrue(rid.toString().equals(ctuID.toString()) || rid.toString().equals(fbiID.toString()));

    result = database.command(new OCommandSQL("find references " + johnDoeID.toString())).execute();
    Assert.assertTrue(result.size() == 0);

    result.clear();
    result = null;
View Full Code Here

Examples of com.orientechnologies.orient.core.sql.OCommandSQL

  @Test
  public void findReferenceByClassAndClusters() {
    if (database.isClosed())
      database.open("admin", "admin");

    Collection<ORID> result = database.command(new OCommandSQL("find references " + janeDoeID.toString() + " [" + WORKPLACE + "]"))
        .execute();

    Assert.assertEquals(result.size(), 1);
    Assert.assertTrue(result.iterator().next().toString().equals(ctuID.toString()));

    result = database.command(
        new OCommandSQL("find references " + jackBauerID.toString() + " [" + WORKPLACE + ",cluster:" + CAR + "]")).execute();

    Assert.assertTrue(result.size() == 3);
    ORID rid = result.iterator().next();
    Assert.assertTrue(rid.toString().equals(ctuID.toString()) || rid.toString().equals(fbiID.toString())
        || rid.toString().equals(carID.toString()));
    rid = result.iterator().next();
    Assert.assertTrue(rid.toString().equals(ctuID.toString()) || rid.toString().equals(fbiID.toString())
        || rid.toString().equals(carID.toString()));
    rid = result.iterator().next();
    Assert.assertTrue(rid.toString().equals(ctuID.toString()) || rid.toString().equals(fbiID.toString())
        || rid.toString().equals(carID.toString()));

    result = database.command(
        new OCommandSQL("find references " + johnDoeID.toString() + " [" + WORKPLACE + "," + CAR + ",cluster:" + WORKER + "]"))
        .execute();

    Assert.assertTrue(result.size() == 0);

    result.clear();
View Full Code Here

Examples of com.orientechnologies.orient.core.sql.OCommandSQL

    dropClass(WORKER);
    dropClass(WORKPLACE);
  }

  private void dropClass(String iClass) {
    OCommandSQL dropClassCommand = new OCommandSQL("drop class " + iClass);
    database.command(dropClassCommand).execute();
    database.getMetadata().getSchema().save();
    database.getMetadata().getSchema().reload();
    database.reload();
    while (database.getMetadata().getSchema().existsClass(iClass)) {
View Full Code Here

Examples of com.orientechnologies.orient.core.sql.OCommandSQL

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

    Assert.assertNotNull(database.command(new OCommandSQL("INSERT INTO account (name) VALUES ('test (demo)')")).execute());

    List<ODocument> result = database.command(new OSQLSynchQuery<ODocument>("select * from account where name = 'test (demo)'"))
        .execute();

    Assert.assertEquals(result.size(), 1);
View Full Code Here

Examples of com.orientechnologies.orient.core.sql.OCommandSQL

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

    Integer records = (Integer) database.command(
        new OCommandSQL("update Profile set salary = 120.30, location = 3:2, salary_cloned = salary where surname = 'Obama'"))
        .execute();

    Assert.assertEquals(records.intValue(), 3);

    database.close();
View Full Code Here

Examples of com.orientechnologies.orient.core.sql.OCommandSQL

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

    List<ODocument> result = database.command(new OCommandSQL("select @rid as rid from Profile where surname = 'Obama'")).execute();

    Assert.assertEquals(result.size(), 3);

    Integer records = (Integer) database.command(new OCommandSQL("update Profile set salary = 133.00 where @rid = ?")).execute(
        result.get(0).field("rid"));

    Assert.assertEquals(records.intValue(), 1);

    database.close();
View Full Code Here

Examples of com.orientechnologies.orient.core.sql.OCommandSQL

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

    updatedRecords = (Integer) database.command(new OCommandSQL("update Account add addresses = #12:0")).execute();

    database.close();
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.sql.OCommandSQL

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

    final int records = (Integer) database.command(new OCommandSQL("update Account remove addresses = #12:0")).execute();

    Assert.assertEquals(records, updatedRecords);

    database.close();
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.sql.OCommandSQL

  public void updateAllOperator() {
    database.open("admin", "admin");

    Long total = database.countClass("Profile");

    Integer records = (Integer) database.command(new OCommandSQL("update Profile set sex = 'male'")).execute();

    Assert.assertEquals(records.intValue(), total.intValue());

    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.