Examples of OClass


Examples of com.orientechnologies.orient.core.metadata.schema.OClass

      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]);

      sendTextContent(iRequest, OHttpUtils.STATUS_CREATED_CODE, OHttpUtils.STATUS_CREATED_DESCRIPTION, null,
          OHttpUtils.CONTENT_TEXT_PLAIN, db.getMetadata().getSchema().getClasses().size());

    } finally {
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

      db = getProfiledDatabaseInstance(iRequest);

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

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

      final OProperty prop = cls.createProperty(urlParts[3], OType.STRING);

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

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

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

    //database = new OGraphDatabase(System.getProperty("url")).create();

    record = database.newInstance();

    database.declareIntent(new OIntentMassiveInsert());
    OClass cl = database.createVertexType("Person", "OGraphVertex");
    cl.createProperty("id", OType.LONG);
    cl.createProperty("name", OType.STRING);
    cl.createProperty("surname", OType.STRING);
    cl.createProperty("birthDate", OType.DATE);
    cl.createProperty("salary", OType.FLOAT);
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

      database.begin(TXTYPE.NOTX);

      synchronized (LocalCreateDocumentMultiThreadIndexedSpeedTest.class) {
        database.command(new OCommandSQL("truncate class account")).execute();

        OClass c = database.getMetadata().getSchema().getClass("Account");
        if (c == null)
          c = database.getMetadata().getSchema().createClass("Account");

        OProperty p = database.getMetadata().getSchema().getClass("Account").getProperty("id");
        if (p == null)
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

      System.out.println("id=" + o.field("id") + "\tname=" + o.field("name"));
    }
  }

  public static void create() {
    OClass account = database.getMetadata().getSchema()
        .createClass("Account", database.getStorage().addCluster("account", OStorage.CLUSTER_TYPE.PHYSICAL));
    account.createProperty("id", OType.LONG);
    account.createProperty("val1", OType.DOUBLE);
    account.createProperty("val2", OType.DOUBLE);
    account.createProperty("val3", OType.FLOAT);
    account.createProperty("val4", OType.SHORT);
    account.createProperty("val5", OType.STRING);
    account.createProperty("name", OType.STRING);
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

  /**
   * Returns the number of the records of the class iClassName.
   */
  public long countClass(final String iClassName) {
    final OClass cls = getMetadata().getSchema().getClass(iClassName);

    if (cls == null)
      throw new IllegalArgumentException("Class '" + iClassName + "' not found in database");

    return cls.count();
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

      if (getDatabase().getMetadata().getSchema().getClasses().size() > 0)
        throw new OSecurityException("Default users and roles already installed");

      // CREATE ROLE AND USER SCHEMA CLASSES
      final OClass roleClass = getDatabase().getMetadata().getSchema().createClass("ORole");
      roleClass.createProperty("mode", OType.BYTE);
      roleClass.createProperty("rules", OType.EMBEDDEDMAP, OType.BYTE);

      final OClass userClass = getDatabase().getMetadata().getSchema().createClass("OUser");
      userClass.createProperty("name", OType.STRING).setMandatory(true).setNotNull(false);
      userClass.createProperty("password", OType.STRING).setMandatory(true).setNotNull(false);
      userClass.createProperty("roles", OType.LINKSET, roleClass);

      // CREATE ROLES AND USERS
      final ORole adminRole = createRole(ORole.ADMIN, ORole.ALLOW_MODES.ALLOW_ALL_BUT);
      final OUser adminUser = createUser(OUser.ADMIN, OUser.ADMIN, new String[] { adminRole.getName() });
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

    if (currentDatabaseName == null) {
      out.println("No database selected yet.");
      return;
    }

    final OClass cls = currentDatabase.getMetadata().getSchema().getClass(iClassName);

    if (cls == null) {
      out.println("! Class '" + iClassName + "' doesn't exist in the database '" + currentDatabaseName + "'");
      return;
    }

    out.println();
    out.println("Class................: " + cls);
    if (cls.getShortName() != null)
      out.println("Alias................: " + cls.getShortName());
    if (cls.getSuperClass() != null)
      out.println("Super class..........: " + cls.getSuperClass());
    out.println("Default cluster......: " + currentDatabase.getClusterNameById(cls.getDefaultClusterId()) + " (id="
        + cls.getDefaultClusterId() + ")");
    out.println("Supported cluster ids: " + Arrays.toString(cls.getClusterIds()));

    if (cls.getBaseClasses() != null) {
      out.print("Base classes.........: ");
      int i = 0;
      for (Iterator<OClass> it = cls.getBaseClasses(); it.hasNext();) {
        if (i > 0)
          out.print(", ");
        out.print(it.next().getName());
        ++i;
      }
      out.println();
    }

    if (cls.properties().size() > 0) {
      out.println("Properties:");
      out.println("-------------------------------+-------------+-------------------------------+-----------+-----------+----------+------+------+");
      out.println(" NAME                          | TYPE        | LINKED TYPE/CLASS             | INDEX     | MANDATORY | NOT NULL | MIN  | MAX  |");
      out.println("-------------------------------+-------------+-------------------------------+-----------+-----------+----------+------+------+");

      for (OProperty p : cls.properties()) {
        try {
          out.printf(" %-30s| %-12s| %-30s| %-10s| %-10s| %-9s| %-5s| %-5s|\n", p.getName(), p.getType(),
              p.getLinkedClass() != null ? p.getLinkedClass() : p.getLinkedType(), p.getIndex() != null ? p.getIndex()
                  .getUnderlying().getType() : "", p.isMandatory(), p.isNotNull(), p.getMin() != null ? p.getMin() : "",
              p.getMax() != null ? p.getMax() : "");
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

    if (currentDatabaseName == null) {
      out.println("No database selected yet.");
      return;
    }

    final OClass cls = currentDatabase.getMetadata().getSchema().getClass(iClassName);

    if (cls == null) {
      out.println("! Class '" + iClassName + "' doesn't exist in the database '" + currentDatabaseName + "'");
      return;
    }

    out.println();
    out.println("Class................: " + cls + " (id=" + cls.getId() + ")");
    if (cls.getSuperClass() != null)
      out.println("Super class..........: " + cls.getSuperClass());
    out.println("Default cluster......: " + currentDatabase.getClusterNameById(cls.getDefaultClusterId()) + " (id="
        + cls.getDefaultClusterId() + ")");
    out.println("Supported cluster ids: " + Arrays.toString(cls.getClusterIds()));

    if (cls.getBaseClasses() != null) {
      out.print("Base classes.........: ");
      int i = 0;
      for (Iterator<OClass> it = cls.getBaseClasses(); it.hasNext();) {
        if (i > 0)
          out.print(", ");
        out.print(it.next().getName());
        ++i;
      }
      out.println();
    }

    if (cls.properties().size() > 0) {
      out.println("Properties:");
      out.println("-------------------------------+----+-------------+-------------------------------+-----------+-----------+----------+------+------+");
      out.println(" NAME                          | ID | TYPE        | LINKED TYPE/CLASS             | INDEX     | MANDATORY | NOT NULL | MIN  | MAX  |");
      out.println("-------------------------------+----+-------------+-------------------------------+-----------+-----------+----------+------+------+");

      for (OProperty p : cls.properties()) {
        try {
          out.printf(" %-30s|%3d | %-12s| %-30s| %-10s| %-10s| %-9s| %-5s| %-5s|\n", p.getName(), p.getId(), p.getType(),
              p.getLinkedClass() != null ? p.getLinkedClass() : p.getLinkedType(), p.getIndex() != null ? p.getIndex() : "",
              p.isMandatory(), p.isNotNull(), p.getMin() != null ? p.getMin() : "", p.getMax() != null ? p.getMax() : "");
        } catch (Exception e) {
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.schema.OClass

    database.getStorage().addCluster("csv", OStorage.CLUSTER_TYPE.PHYSICAL);
    database.getStorage().addCluster("flat", OStorage.CLUSTER_TYPE.PHYSICAL);
    database.getStorage().addCluster("binary", OStorage.CLUSTER_TYPE.PHYSICAL);

    OClass account = database.getMetadata().getSchema()
        .createClass("Account", database.getStorage().addCluster("account", OStorage.CLUSTER_TYPE.PHYSICAL));
    account.createProperty("id", OType.INTEGER);
    account.createProperty("birthDate", OType.DATE);
    account.createProperty("binary", OType.BINARY);

    database.getMetadata().getSchema().createClass("Company").setSuperClass(account);

    OClass profile = database.getMetadata().getSchema()
        .createClass("Profile", database.getStorage().addCluster("profile", OStorage.CLUSTER_TYPE.PHYSICAL));
    profile.createProperty("nick", OType.STRING).setMin("3").setMax("30").createIndex(INDEX_TYPE.UNIQUE);
    profile.createProperty("name", OType.STRING).setMin("3").setMax("30").createIndex(INDEX_TYPE.NOTUNIQUE);
    profile.createProperty("surname", OType.STRING).setMin("3").setMax("30");
    profile.createProperty("registeredOn", OType.DATE).setMin("2010-01-01 00:00:00");
    profile.createProperty("lastAccessOn", OType.DATE).setMin("2010-01-01 00:00:00");

    OClass whiz = database.getMetadata().getSchema().createClass("Whiz");
    whiz.createProperty("id", OType.INTEGER);
    whiz.createProperty("account", OType.LINK, profile);
    whiz.createProperty("date", OType.DATE).setMin("2010-01-01 00:00:00");
    whiz.createProperty("text", OType.STRING).setMandatory(true).setMin("1").setMax("140").createIndex(INDEX_TYPE.FULLTEXT);
    whiz.createProperty("replyTo", OType.LINK, profile);

    database.getMetadata().getSchema().save();
    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.