Package com.orientechnologies.orient.core.metadata.schema

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


  @Test(dependsOnMethods = "checkSchema")
  public void checkSchemaApi() {
    database = new ODatabaseDocumentTx(url);
    database.open("admin", "admin");

    OSchema schema = database.getMetadata().getSchema();

    try {
      Assert.assertNull(schema.getClass("Animal33"));
    } catch (OSchemaException e) {
    }

    database.close();
  }
View Full Code Here


    Assert.assertEquals(doc.getVersion(), oldVersion);
    Assert.assertEquals(doc.field("name"), "modified");
  }

  public void testCreateEmbddedClassDocument() {
    final OSchema schema = database.getMetadata().getSchema();
    final String SUFFIX = "TESTCLUSTER1";

    OClass testClass1 = schema.createClass("testCreateEmbddedClass1");
    OClass testClass2 = schema.createClass("testCreateEmbddedClass2");
    testClass2.createProperty("testClass1Property", OType.EMBEDDED, testClass1);

    int clusterId = database.addCluster("testCreateEmbddedClass2" + SUFFIX);
    schema.getClass("testCreateEmbddedClass2").addClusterId(clusterId);

    testClass1 = schema.getClass("testCreateEmbddedClass1");
    testClass2 = schema.getClass("testCreateEmbddedClass2");

    ODocument testClass2Document = new ODocument(testClass2);
    testClass2Document.field("testClass1Property", new ODocument(testClass1));
    testClass2Document.save("testCreateEmbddedClass2" + SUFFIX);
View Full Code Here

  public void beforeClass() throws Exception {
    super.beforeClass();
    if (database.isClosed())
      database.open("admin", "admin");

    final OSchema schema = database.getMetadata().getSchema();
    final OClass oClass = schema.createClass("sqlSelectHashIndexReuseTestClass");

    oClass.createProperty("prop1", OType.INTEGER);
    oClass.createProperty("prop2", OType.INTEGER);
    oClass.createProperty("prop3", OType.INTEGER);
    oClass.createProperty("prop4", OType.INTEGER);
    oClass.createProperty("prop5", OType.INTEGER);
    oClass.createProperty("prop6", OType.INTEGER);
    oClass.createProperty("prop7", OType.STRING);
    oClass.createProperty("prop8", OType.INTEGER);
    oClass.createProperty("prop9", OType.INTEGER);

    oClass.createProperty("fEmbeddedMap", OType.EMBEDDEDMAP, OType.INTEGER);
    oClass.createProperty("fEmbeddedMapTwo", OType.EMBEDDEDMAP, OType.INTEGER);

    oClass.createProperty("fLinkMap", OType.LINKMAP);

    oClass.createProperty("fEmbeddedList", OType.EMBEDDEDLIST, OType.INTEGER);
    oClass.createProperty("fEmbeddedListTwo", OType.EMBEDDEDLIST, OType.INTEGER);

    oClass.createProperty("fLinkList", OType.LINKLIST);

    oClass.createProperty("fEmbeddedSet", OType.EMBEDDEDSET, OType.INTEGER);
    oClass.createProperty("fEmbeddedSetTwo", OType.EMBEDDEDSET, OType.INTEGER);

    oClass.createIndex("indexone", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "prop1", "prop2");
    oClass.createIndex("indextwo", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "prop3");
    oClass.createIndex("indexthree", OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, "prop1", "prop2", "prop4");
    oClass.createIndex("indexfour", OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, "prop4", "prop1", "prop3");
    oClass.createIndex("indexfive", OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, "prop6", "prop1", "prop3");
    oClass.createIndex("indexsix", OClass.INDEX_TYPE.FULLTEXT_HASH_INDEX, "prop7");

    oClass.createIndex("sqlSelectHashIndexReuseTestEmbeddedMapByKey", OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, "fEmbeddedMap");
    oClass.createIndex("sqlSelectHashIndexReuseTestEmbeddedMapByValue", OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX,
        "fEmbeddedMap by value");
    oClass.createIndex("sqlSelectHashIndexReuseTestEmbeddedList", OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, "fEmbeddedList");

    oClass.createIndex("sqlSelectHashIndexReuseTestEmbeddedMapByKeyProp8", OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX,
        "fEmbeddedMapTwo", "prop8");
    oClass.createIndex("sqlSelectHashIndexReuseTestEmbeddedMapByValueProp8", OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX,
        "fEmbeddedMapTwo by value", "prop8");

    oClass.createIndex("sqlSelectHashIndexReuseTestEmbeddedSetProp8", OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, "fEmbeddedSetTwo",
        "prop8");
    oClass.createIndex("sqlSelectHashIndexReuseTestProp9EmbeddedSetProp8", OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX, "prop9",
        "fEmbeddedSetTwo", "prop8");

    oClass.createIndex("sqlSelectHashIndexReuseTestEmbeddedListTwoProp8", OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX,
        "fEmbeddedListTwo", "prop8");

    schema.save();

    final String fullTextIndexStrings[] = { "Alice : What is the use of a book, without pictures or conversations?",
        "Rabbit : Oh my ears and whiskers, how late it's getting!",
        "Alice : If it had grown up, it would have made a dreadfully ugly child; but it makes rather a handsome pig, I think",
        "The Cat : We're all mad here.", "The Hatter : Why is a raven like a writing desk?",
View Full Code Here

    Assert.assertEquals(profiler.getCounter("db.demo.query.compositeIndexUsed.2"), oldcompositeIndexUsed2 + 1);
  }

  @Test
  public void testReuseOfIndexOnSeveralClassesFields() {
    final OSchema schema = database.getMetadata().getSchema();
    final OClass superClass = schema.createClass("sqlSelectHashIndexReuseTestSuperClass");
    superClass.createProperty("prop0", OType.INTEGER);
    final OClass oClass = schema.createClass("sqlSelectHashIndexReuseTestChildClass", superClass);
    oClass.createProperty("prop1", OType.INTEGER);

    oClass.createIndex("sqlSelectHashIndexReuseTestOnPropertiesFromClassAndSuperclass", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX,
        "prop0", "prop1");

    schema.save();

    long oldIndexUsage = profiler.getCounter("db.demo.query.indexUsed");
    long oldcompositeIndexUsed = profiler.getCounter("db.demo.query.compositeIndexUsed");
    long oldcompositeIndexUsed2 = profiler.getCounter("db.demo.query.compositeIndexUsed.2");
View Full Code Here

  @BeforeClass
  public void beforeClass() {
    if (database.isClosed())
      database.open("admin", "admin");

    final OSchema schema = database.getMetadata().getSchema();
    final OClass oClass = schema.createClass("SQLDropClassTestClass");
    oClass.createProperty("prop1", EXPECTED_PROP1_TYPE);
    oClass.createProperty("prop2", EXPECTED_PROP2_TYPE);

    schema.save();
    database.close();
  }
View Full Code Here

    super.beforeClass();

    if (database.isClosed())
      database.open("admin", "admin");

    final OSchema schema = database.getMetadata().getSchema();
    schema.createClass(TEST_CLASS);
    schema.save();

    database.close();
  }
View Full Code Here

  @BeforeClass
  public void beforeClass() throws Exception {
    super.beforeClass();

    final OSchema schema = database.getMetadata().getSchema();

    final OClass testClass = schema.createClass("SQLSelectCompositeIndexDirectSearchTestClass");
    testClass.createProperty("prop1", OType.INTEGER);
    testClass.createProperty("prop2", OType.INTEGER);
    schema.save();

    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        final ODocument document = new ODocument("SQLSelectCompositeIndexDirectSearchTestClass");
        document.field("prop1", i);
View Full Code Here

  @BeforeMethod
  public void beforeMethod() throws Exception {
    super.beforeMethod();

    final OSchema schema = database.getMetadata().getSchema();
    schema.reload();
    database.getStorage().reload();

    schema.getClass("IndexTxTestClass").truncate();
  }
View Full Code Here

  public <T extends Asset> void registerAssetAdapter(final AssetAdapter<T> adapter) {
    Class<T> entityClass = checkNotNull(adapter).getEntityClass();
    checkState(assetAdapters.putIfAbsent(entityClass, adapter) == null,
        "Asset adapter already registered for class %s", adapter.getEntityClass());
    try (ODatabaseDocumentTx db = databaseInstance.get().acquire()) {
      OSchema schema = db.getMetadata().getSchema();
      adapter.createStorageClass(schema);
    }
  }
View Full Code Here

  public <T extends Component> void registerComponentAdapter(final ComponentAdapter<T> adapter) {
    Class<T> entityClass = checkNotNull(adapter).getEntityClass();
    checkState(componentAdapters.putIfAbsent(entityClass, adapter) == null,
        "Component adapter already registered for class %s", adapter.getEntityClass());
    try (ODatabaseDocumentTx db = databaseInstance.get().acquire()) {
      OSchema schema = db.getMetadata().getSchema();
      adapter.createStorageClass(schema);
    }
  }
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.metadata.schema.OSchema

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.