Package com.orientechnologies.orient.core.db.document

Examples of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx


    super(1000000, 20, CreateObjectsThread.class);
  }

  @Override
  public void init() {
    database = new ODatabaseDocumentTx(System.getProperty("url")).open("admin", "admin");
    foundObjects = database.countClusterElements("Account");

    System.out.println("\nTotal objects in Animal cluster before the test: " + foundObjects);
  }
View Full Code Here


    private ODocument         record;
    private Date              date = new Date();

    @Override
    public void init() {
      database = new ODatabaseDocumentTx(System.getProperty("url")).open("admin", "admin");
      record = database.newInstance();
      database.declareIntent(new OIntentMassiveInsert());
      database.begin(TXTYPE.NOTX);
    }
View Full Code Here

  public boolean execute(final OHttpRequest iRequest) throws Exception {
    String[] urlParts = checkSyntax(iRequest.url, 2, "Syntax error: document/<database>");

    iRequest.data.commandInfo = "Create document";

    ODatabaseDocumentTx db = null;

    ODocument doc = null;

    try {
      db = getProfiledDatabaseInstance(iRequest);
View Full Code Here

  public boolean execute(final OHttpRequest iRequest) throws Exception {
    final String[] urlParts = checkSyntax(iRequest.url, 1, "Syntax error: *.action");

    iRequest.data.commandInfo = "Execute action";

    ODatabaseDocumentTx db = null;
    ODocument doc = new ODocument().fromJSON(iRequest.content);

    // ASSURE TO MAKE THE RECORD ID INVALID
    ((ORecordId) doc.getIdentity()).clusterPosition = ORID.CLUSTER_POS_INVALID;

View Full Code Here

    iRequest.data.commandDetail = text;

    if (!text.toLowerCase().startsWith("select"))
      throw new IllegalArgumentException("Only SQL Select commands are valid using Query command");

    ODatabaseDocumentTx db = null;

    final List<ORecord<?>> response;

    try {
      db = getProfiledDatabaseInstance(iRequest);

      response = (List<ORecord<?>>) db.command(new OSQLSynchQuery<ORecordSchemaAware<?>>(text, limit).setFetchPlan(fetchPlan))
          .execute();

    } finally {
      if (db != null)
        OSharedDocumentDatabase.release(db);
View Full Code Here

    String[] urlParts = checkSyntax(iRequest.url, 3, "Syntax error: class/<database>/<class-name>");

    iRequest.data.commandInfo = "Create class";
    iRequest.data.commandDetail = urlParts[2];

    ODatabaseDocumentTx db = null;

    try {
      db = getProfiledDatabaseInstance(iRequest);

      if (db.getMetadata().getSchema().getClass(urlParts[2]) != null)
        throw new IllegalArgumentException("Class '" + urlParts[2] + "' already exists");

      final OClass cls = db.getMetadata().getSchema().createClass(urlParts[2]);
      db.getMetadata().getSchema().save();

      sendTextContent(iRequest, OHttpUtils.STATUS_CREATED_CODE, OHttpUtils.STATUS_CREATED_DESCRIPTION, null,
          OHttpUtils.CONTENT_TEXT_PLAIN, cls.getId());

    } finally {
View Full Code Here

        "Syntax error: class/<database>/<class-name>[/<limit>]<br/>Limit is optional and is setted to 20 by default. Set expressely to 0 to have no limits.");

    iRequest.data.commandInfo = "Browse class";
    iRequest.data.commandDetail = urlParts[2];

    ODatabaseDocumentTx db = null;

    try {
      db = getProfiledDatabaseInstance(iRequest);

      if (db.getMetadata().getSchema().getClass(urlParts[2]) == null)
        throw new IllegalArgumentException("Invalid class '" + urlParts[2] + "'");

      final int limit = urlParts.length > 3 ? Integer.parseInt(urlParts[3]) : 20;

      final List<ORecord<?>> response = new ArrayList<ORecord<?>>();
      for (ORecord<?> rec : db.browseClass(urlParts[2])) {
        if (limit > 0 && response.size() >= limit)
          break;

        response.add(rec);
      }
View Full Code Here

    String[] urlParts = checkSyntax(iRequest.url, 2, "Syntax error: database/<database>");

    iRequest.data.commandInfo = "Create database";
    iRequest.data.commandDetail = urlParts[1];

    ODatabaseDocumentTx db = null;

    try {
      if (OSharedDocumentDatabase.getDatabasePools().containsKey(urlParts[1]))
        throw new IllegalArgumentException("Can't create the database '" + urlParts[1] + "' because it already exists");

      db = new ODatabaseDocumentTx("local:${ORIENTDB_HOME}/databases/" + urlParts[1] + "/" + urlParts[1]);
      db.create();

    } finally {
      if (db != null)
        db.close();
    }

    sendTextContent(iRequest, OHttpUtils.STATUS_OK_CODE, OHttpUtils.STATUS_OK_DESCRIPTION, null, OHttpUtils.CONTENT_TEXT_PLAIN,
        null);
    return false;
View Full Code Here

    url = iURL;
  }

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

    long tot = database.countClass("Account");

    // DELETE ALL THE Account OBJECTS
    int i = 0;
    for (ODocument rec : database.browseClass("Account")) {
      rec.delete();
      i++;
    }

    Assert.assertEquals(i, tot);
    Assert.assertEquals(database.countClass("Account"), 0);

    database.close();
  }
View Full Code Here

    database.close();
  }

  @Test(dependsOnMethods = "setup")
  public void createRecords() throws IOException {
    ODatabaseDocumentTx database = new ODatabaseDocumentTx(url);
    database.open("admin", "admin");

    ODocument record1 = new ODocument(database, "Account");
    record1.field("name", "Creation test").save();

    ODocument record2 = new ODocument(database, "Account");
    record2.field("name", "Update test").save();

    ODocument record3 = new ODocument(database, "Account");
    record3.field("name", "Delete test").save();

    database.close();
  }
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx

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.