Search in sources :

Example 21 with OProperty

use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.

the class OCommandExecutorSQLCreatePropertyTest method testLowerCase.

@Test
public void testLowerCase() throws Exception {
    final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
    db.create();
    db.command(new OCommandSQL("CREATE class division")).execute();
    db.command(new OCommandSQL("CREATE class company")).execute();
    db.command(new OCommandSQL("CREATE property company.division LINK division (mandatory, readonly, notnull, default 3, min 4, max 5, collate ci) unsafe")).execute();
    OClass companyClass = db.getMetadata().getSchema().getClass("company");
    OProperty property = companyClass.getProperty(PROP_DIVISION);
    assertEquals(property.getName(), PROP_DIVISION);
    assertEquals(property.getFullName(), PROP_FULL_DIVISION);
    assertEquals(property.getType(), OType.LINK);
    assertEquals(property.getLinkedClass().getName(), "division");
    assertTrue(property.isMandatory());
    assertTrue(property.isNotNull());
    assertTrue(property.isReadonly());
    assertEquals(property.getDefaultValue(), "3");
    assertEquals(property.getMin(), "4");
    assertEquals(property.getMax(), "5");
    assertEquals(property.getCollate().getName(), "ci");
    db.close();
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Example 22 with OProperty

use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.

the class OCommandExecutorSQLCreatePropertyTest method testCreateMandatoryPropertyWithEmbeddedType.

@Test
public void testCreateMandatoryPropertyWithEmbeddedType() throws Exception {
    final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
    db.create();
    db.command(new OCommandSQL("CREATE Class company")).execute();
    db.command(new OCommandSQL("CREATE Property company.officers EMBEDDEDLIST STRING (MANDATORY)")).execute();
    OClass companyClass = db.getMetadata().getSchema().getClass("company");
    OProperty property = companyClass.getProperty(PROP_OFFICERS);
    assertEquals(property.getName(), PROP_OFFICERS);
    assertEquals(property.getFullName(), PROP_FULL_OFFICERS);
    assertEquals(property.getType(), OType.EMBEDDEDLIST);
    assertEquals(property.getLinkedType(), OType.STRING);
    assertTrue(property.isMandatory());
    assertFalse(property.isNotNull());
    assertFalse(property.isReadonly());
    db.close();
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Example 23 with OProperty

use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.

the class OCommandExecutorSQLCreatePropertyTest method testBasicCreateProperty.

@Test
public void testBasicCreateProperty() throws Exception {
    final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
    db.create();
    db.command(new OCommandSQL("CREATE class company")).execute();
    db.command(new OCommandSQL("CREATE property company.name STRING")).execute();
    OClass companyClass = db.getMetadata().getSchema().getClass("company");
    OProperty property = companyClass.getProperty(PROP_NAME);
    assertEquals(property.getName(), PROP_NAME);
    assertEquals(property.getFullName(), PROP_FULL_NAME);
    assertEquals(property.getType(), OType.STRING);
    assertFalse(property.isMandatory());
    assertFalse(property.isNotNull());
    assertFalse(property.isReadonly());
    db.close();
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Example 24 with OProperty

use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.

the class OCommandExecutorSQLCreatePropertyTest method testMandatoryAsLinkedName.

@Test
public void testMandatoryAsLinkedName() throws Exception {
    final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
    db.create();
    db.command(new OCommandSQL("CREATE CLASS company")).execute();
    db.command(new OCommandSQL("CREATE CLASS Mandatory")).execute();
    db.command(new OCommandSQL("CREATE PROPERTY company.id EMBEDDEDLIST Mandatory UNSAFE")).execute();
    OClass companyClass = db.getMetadata().getSchema().getClass("company");
    OClass mandatoryClass = db.getMetadata().getSchema().getClass("Mandatory");
    OProperty idProperty = companyClass.getProperty(PROP_ID);
    assertEquals(idProperty.getName(), PROP_ID);
    assertEquals(idProperty.getFullName(), PROP_FULL_ID);
    assertEquals(idProperty.getType(), OType.EMBEDDEDLIST);
    assertEquals(idProperty.getLinkedClass(), mandatoryClass);
    assertFalse(idProperty.isMandatory());
    db.close();
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Example 25 with OProperty

use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.

the class OCommandExecutorSQLCreatePropertyTest method testDefaultAndMinMaxUnsafeProperty.

@Test
public void testDefaultAndMinMaxUnsafeProperty() throws Exception {
    final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
    db.create();
    db.command(new OCommandSQL("CREATE CLASS company")).execute();
    db.command(new OCommandSQL("CREATE PROPERTY company.id INTEGER (DEFAULT 5, MIN 1, MAX 10) UNSAFE")).execute();
    OClass companyClass = db.getMetadata().getSchema().getClass("company");
    OProperty idProperty = companyClass.getProperty(PROP_ID);
    assertEquals(idProperty.getName(), PROP_ID);
    assertEquals(idProperty.getFullName(), PROP_FULL_ID);
    assertEquals(idProperty.getType(), OType.INTEGER);
    assertEquals(idProperty.getLinkedType(), null);
    assertFalse(idProperty.isMandatory());
    assertFalse(idProperty.isNotNull());
    assertFalse(idProperty.isReadonly());
    assertEquals(idProperty.getDefaultValue(), "5");
    assertEquals(idProperty.getMin(), "1");
    assertEquals(idProperty.getMax(), "10");
    db.close();
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Aggregations

OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)121 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)84 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)41 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)32 Test (org.testng.annotations.Test)30 Test (org.junit.Test)28 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)25 OType (com.orientechnologies.orient.core.metadata.schema.OType)15 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)11 FilterCriteriaManager (ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager)10 IFilterCriteriaManager (ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager)10 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)8 OIndex (com.orientechnologies.orient.core.index.OIndex)8 Date (java.util.Date)8 Set (java.util.Set)8 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)7 Map (java.util.Map)7 ODatabaseObject (com.orientechnologies.orient.core.db.object.ODatabaseObject)6 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)6 Collection (java.util.Collection)6