use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class PropertyIndexTest method testGetIndexes.
@Test(dependsOnMethods = "createAdditionalSchemas")
public void testGetIndexes() {
final OSchema schema = database.getMetadata().getSchema();
final OClass oClass = schema.getClass("PropertyIndexTestClass");
final OProperty propOne = oClass.getProperty("prop1");
final Collection<OIndex<?>> indexes = propOne.getIndexes();
Assert.assertEquals(indexes.size(), 1);
Assert.assertNotNull(containsIndex(indexes, "PropertyIndexTestClass.prop1"));
}
use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class PropertyIndexTest method testCreateUniqueIndex.
@Test
public void testCreateUniqueIndex() {
final OSchema schema = database.getMetadata().getSchema();
final OClass oClass = schema.getClass("PropertyIndexTestClass");
final OProperty propOne = oClass.getProperty("prop1");
propOne.createIndex(OClass.INDEX_TYPE.UNIQUE, new ODocument().field("ignoreNullValues", true));
final Collection<OIndex<?>> indexes = propOne.getIndexes();
OIndexDefinition indexDefinition = null;
for (final OIndex<?> index : indexes) {
if (index.getName().equals("PropertyIndexTestClass.prop1")) {
indexDefinition = index.getDefinition();
break;
}
}
Assert.assertNotNull(indexDefinition);
Assert.assertEquals(indexDefinition.getParamCount(), 1);
Assert.assertEquals(indexDefinition.getFields().size(), 1);
Assert.assertTrue(indexDefinition.getFields().contains("prop1"));
Assert.assertEquals(indexDefinition.getTypes().length, 1);
Assert.assertEquals(indexDefinition.getTypes()[0], OType.STRING);
schema.save();
}
use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class ClassIndexManagerTest method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
super.beforeClass();
final OSchema schema = database.getMetadata().getSchema();
if (schema.existsClass("classIndexManagerTestClass"))
schema.dropClass("classIndexManagerTestClass");
if (schema.existsClass("classIndexManagerTestClassTwo"))
schema.dropClass("classIndexManagerTestClassTwo");
if (schema.existsClass("classIndexManagerTestSuperClass"))
schema.dropClass("classIndexManagerTestSuperClass");
if (schema.existsClass("classIndexManagerTestCompositeCollectionClass"))
schema.dropClass("classIndexManagerTestCompositeCollectionClass");
final OClass superClass = schema.createClass("classIndexManagerTestSuperClass");
final OProperty propertyZero = superClass.createProperty("prop0", OType.STRING);
superClass.createIndex("classIndexManagerTestSuperClass.prop0", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "prop0" });
final OClass oClass = schema.createClass("classIndexManagerTestClass", superClass);
final OProperty propOne = oClass.createProperty("prop1", OType.STRING);
oClass.createIndex("classIndexManagerTestClass.prop1", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "prop1" });
final OProperty propTwo = oClass.createProperty("prop2", OType.INTEGER);
propTwo.createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
oClass.createProperty("prop3", OType.BOOLEAN);
final OProperty propFour = oClass.createProperty("prop4", OType.EMBEDDEDLIST, OType.STRING);
propFour.createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
oClass.createProperty("prop5", OType.EMBEDDEDMAP, OType.STRING);
oClass.createIndex("classIndexManagerTestIndexByKey", OClass.INDEX_TYPE.NOTUNIQUE, "prop5");
oClass.createIndex("classIndexManagerTestIndexByValue", OClass.INDEX_TYPE.NOTUNIQUE, "prop5 by value");
final OProperty propSix = oClass.createProperty("prop6", OType.EMBEDDEDSET, OType.STRING);
propSix.createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
oClass.createIndex("classIndexManagerComposite", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "prop1", "prop2" });
final OClass oClassTwo = schema.createClass("classIndexManagerTestClassTwo");
oClassTwo.createProperty("prop1", OType.STRING);
oClassTwo.createProperty("prop2", OType.INTEGER);
final OClass compositeCollectionClass = schema.createClass("classIndexManagerTestCompositeCollectionClass");
compositeCollectionClass.createProperty("prop1", OType.STRING);
compositeCollectionClass.createProperty("prop2", OType.EMBEDDEDLIST, OType.INTEGER);
compositeCollectionClass.createIndex("classIndexManagerTestIndexValueAndCollection", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "prop1", "prop2" });
oClass.createIndex("classIndexManagerTestIndexOnPropertiesFromClassAndSuperclass", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "prop0", "prop1" });
schema.reload();
database.close();
}
use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class CRUDObjectInheritanceTestSchemaFull method checkProperty.
protected void checkProperty(OClass iClass, String iPropertyName, OType iType) {
OProperty prop = iClass.getProperty(iPropertyName);
Assert.assertNotNull(prop);
Assert.assertEquals(prop.getType(), iType);
}
use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class CRUDObjectInheritanceTestSchemaFull method checkNoLinkedProperty.
protected void checkNoLinkedProperty(OClass iClass, String iPropertyName, OType iType) {
OProperty prop = iClass.getProperty(iPropertyName);
Assert.assertNotNull(prop);
Assert.assertNull(prop.getLinkedType());
Assert.assertNull(prop.getLinkedClass());
}
Aggregations