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);
}
}
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);
}
}
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);
}
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);
}
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));
}
Aggregations