Search in sources :

Example 1 with OProperty

use of com.orientechnologies.orient.core.metadata.schema.OProperty in project guice-persist-orient by xvik.

the class MandatoryPropertyExtension method afterRegistration.

@Override
public void afterRegistration(final OObjectDatabaseTx db, final SchemeDescriptor descriptor, final Field field, final Mandatory annotation) {
    final String name = field.getName();
    final boolean mandatory = annotation.value();
    final OProperty property = db.getMetadata().getSchema().getClass(descriptor.schemeClass).getProperty(name);
    if (property.isMandatory() != mandatory) {
        property.setMandatory(mandatory);
        logger.debug("Set {}.{} property mandatory={}", descriptor.schemeClass, name, mandatory);
    }
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty)

Example 2 with OProperty

use of com.orientechnologies.orient.core.metadata.schema.OProperty in project guice-persist-orient by xvik.

the class NotNullFieldExtension method afterRegistration.

@Override
public void afterRegistration(final OObjectDatabaseTx db, final SchemeDescriptor descriptor, final Field field, final ONotNull annotation) {
    final String name = field.getName();
    final boolean notnull = annotation.value();
    final OProperty property = db.getMetadata().getSchema().getClass(descriptor.schemeClass).getProperty(name);
    if (property.isNotNull() != notnull) {
        property.setNotNull(notnull);
        logger.debug("Set {}.{} property notnull={}", descriptor.schemeClass, name, notnull);
    }
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty)

Example 3 with OProperty

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

the class TestModels method testOPropertyModel.

@Test
public void testOPropertyModel() {
    OProperty userNameProperty = wicket.getTester().getSchema().getClass("OUser").getProperty("name");
    OPropertyModel propertyModel = new OPropertyModel("OUser", "name");
    assertModelObjectEquals(userNameProperty, propertyModel);
    // Test for null
    propertyModel.setObject(null);
    assertModelObjectEquals(null, propertyModel);
    // Test for classRename
    OClass newClass = wicket.getTester().getSchema().createClass("TestRenameOProperty");
    OProperty property = newClass.createProperty("newProperty", OType.STRING);
    propertyModel.setObject(property);
    assertModelObjectEquals(property, propertyModel);
    property.setName("newProperty2");
    assertModelObjectEquals(property, propertyModel);
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OPropertyModel(ru.ydn.wicket.wicketorientdb.model.OPropertyModel) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) Test(org.junit.Test)

Example 4 with OProperty

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

the class TestModels method testOPropertyNamingModel.

@Test
public void testOPropertyNamingModel() {
    IModel<String> classNameModel = Model.of("OUser");
    IModel<OClass> oClassModel = new OClassModel(classNameModel);
    IModel<OProperty> propertyModel = new OPropertyModel(oClassModel, "name");
    OPropertyNamingModel model = new OPropertyNamingModel(propertyModel);
    assertModelObjectEquals("Name", model);
    model.detach();
    classNameModel.setObject("ORole");
    assertModelObjectEquals("Role Name", model);
}
Also used : OPropertyNamingModel(ru.ydn.wicket.wicketorientdb.model.OPropertyNamingModel) OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OClassModel(ru.ydn.wicket.wicketorientdb.model.OClassModel) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) OPropertyModel(ru.ydn.wicket.wicketorientdb.model.OPropertyModel) Test(org.junit.Test)

Example 5 with OProperty

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

the class TestFilters method testLinkFilter.

@Test
public void testLinkFilter() {
    IModel<OProperty> property = wicket.getProperty(NUMBER_FIELD);
    IFilterCriteriaManager manager = new FilterCriteriaManager(property);
    IFilterCriteria equalsFilterCriteria = manager.createEqualsFilterCriteria(Model.of(NUM_VALUE_1), Model.of(true));
    manager.addFilterCriteria(equalsFilterCriteria);
    queryModel.addFilterCriteriaManager(property.getObject().getName(), manager);
    ODocument document = queryModel.getObject().get(0).field(LINK_FIELD);
    queryModel.clearFilterCriteriaManagers();
    queryModel.detach();
    property = wicket.getProperty(LINK_FIELD);
    manager = new FilterCriteriaManager(property);
    equalsFilterCriteria = manager.createEqualsFilterCriteria(new ODocumentModel(document), Model.of(true));
    manager.addFilterCriteria(equalsFilterCriteria);
    queryModel.addFilterCriteriaManager(property.getObject().getName(), manager);
    assertTrue(queryModel.size() == 1);
    assertTrue(queryModel.getObject().get(0).field(STRING_FIELD).equals(STR_VALUE_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) ODocumentModel(ru.ydn.wicket.wicketorientdb.model.ODocumentModel) IFilterCriteria(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) 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