Search in sources :

Example 6 with OProperty

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

the class TestFilters method testEqualsToDateFilterCriteria.

@Test
public void testEqualsToDateFilterCriteria() throws ParseException {
    IModel<OProperty> property = wicket.getProperty(DATE_FIELD);
    IFilterCriteriaManager manager = new FilterCriteriaManager(property);
    IModel<String> model = Model.of(DATE_VALUE_1);
    manager.addFilterCriteria(manager.createEqualsFilterCriteria(model, Model.of(true)));
    queryModel.addFilterCriteriaManager(property.getObject().getName(), manager);
    assertTrue(queryModel.size() == 1);
    queryModel.clearFilterCriteriaManagers();
    queryModel.detach();
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    IModel<Date> dateModel = Model.of(dateFormat.parse(DATE_VALUE_1));
    manager.addFilterCriteria(manager.createEqualsFilterCriteria(dateModel, Model.of(true)));
    queryModel.addFilterCriteriaManager(property.getObject().getName(), manager);
    assertTrue(queryModel.size() == 1);
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) FilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 7 with OProperty

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

the class TestFilters method testLinkMapKey.

@Test
public void testLinkMapKey() {
    String key = MAP_KEYS.get(0);
    IModel<OProperty> property = wicket.getProperty(LINK_MAP_FIELD);
    IFilterCriteriaManager manager = new FilterCriteriaManager(property);
    manager.addFilterCriteria(manager.createMapContainsKeyCriteria(Model.of(key), Model.<Boolean>of(true)));
    queryModel.addFilterCriteriaManager(LINK_MAP_FIELD, manager);
    assertTrue("size must be 1 but it is - " + queryModel.getObject().size(), queryModel.getObject().size() == 1);
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) FilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager) Test(org.junit.Test)

Example 8 with OProperty

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

the class TestFilters method testContainsTextFilterCriteria.

@Test
public void testContainsTextFilterCriteria() {
    IModel<OProperty> property = wicket.getProperty(STRING_FIELD);
    IFilterCriteriaManager manager = new FilterCriteriaManager(property);
    IModel<String> model = Model.of("summer");
    manager.addFilterCriteria(manager.createContainsStringFilterCriteria(model, Model.of(true)));
    queryModel.addFilterCriteriaManager(property.getObject().getName(), manager);
    assertTrue(queryModel.size() == 1);
    assertTrue(queryModel.getObject().get(0).field(STRING_FIELD).equals(STR_VALUE_2));
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) FilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager) Test(org.junit.Test)

Example 9 with OProperty

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

the class TestInAppOrientDBCompatibility method testPropertyRenaming.

@Test
public void testPropertyRenaming() {
    ODatabaseDocument db = wicket.getTester().getDatabase();
    OSchema schema = db.getMetadata().getSchema();
    OClass classA = schema.createClass("TestPropertyRenaming");
    OProperty property = classA.createProperty("propertyOld", OType.STRING);
    assertEquals(property, classA.getProperty("propertyOld"));
    assertNull(classA.getProperty("propertyNew"));
    property.setName("propertyNew");
    schema.reload();
    classA = schema.getClass("TestPropertyRenaming");
    assertNull(classA.getProperty("propertyOld"));
    assertEquals(property, classA.getProperty("propertyNew"));
}
Also used : OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) Test(org.junit.Test)

Example 10 with OProperty

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

the class TestPrototypers method testOClassPrototyper.

@Test
public void testOClassPrototyper() throws Exception {
    OClass newClass = OClassPrototyper.newPrototype();
    assertNull(wicket.getTester().getSchema().getClass("NewClass"));
    newClass.setName("NewClass");
    assertEquals("NewClass", newClass.getName());
    newClass.setClusterSelection(ORoundRobinClusterSelectionStrategy.NAME);
    assertEquals(ORoundRobinClusterSelectionStrategy.NAME, newClass.getClusterSelection().getName());
    Collection<OProperty> properties = newClass.properties();
    assertNotNull(properties);
    assertTrue(properties.size() == 0);
    properties = newClass.declaredProperties();
    assertNotNull(properties);
    assertTrue(properties.size() == 0);
    assertFalse(newClass.hasSuperClasses());
    OClass oRoleClass = wicket.getTester().getSchema().getClass("ORole");
    newClass.addSuperClass(oRoleClass);
    assertTrue(newClass.hasSuperClasses());
    assertTrue(newClass.getSuperClassesNames().contains("ORole"));
    assertTrue(newClass.getSuperClasses().contains(oRoleClass));
    assertTrue(newClass.isSubClassOf(oRoleClass));
    newClass.removeSuperClass(oRoleClass);
    assertFalse(newClass.hasSuperClasses());
    assertFalse(newClass.isSubClassOf(oRoleClass));
    // Realization
    assertTrue(newClass instanceof IPrototype);
    OClass realizedNewClass = ((IPrototype<OClass>) newClass).realizePrototype();
    assertEquals(wicket.getTester().getSchema().getClass("NewClass"), realizedNewClass);
    assertFalse(realizedNewClass instanceof IPrototype);
    assertEquals("NewClass", realizedNewClass.getName());
    assertEquals(ORoundRobinClusterSelectionStrategy.NAME, realizedNewClass.getClusterSelection().getName());
    wicket.getTester().getSchema().dropClass(realizedNewClass.getName());
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) Test(org.junit.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