本文整理汇总了Java中com.orientechnologies.orient.core.metadata.schema.OProperty类的典型用法代码示例。如果您正苦于以下问题:Java OProperty类的具体用法?Java OProperty怎么用?Java OProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OProperty类属于com.orientechnologies.orient.core.metadata.schema包,在下文中一共展示了OProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToCatalogLinkIfAble
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
private Object convertToCatalogLinkIfAble(Object value,OProperty fieldProperty,ODocument mainDoc){
String catalogsLinkNameAttribute = getOrientDBEndpoint().getCatalogsLinkAttr();//
String catalogsLinkName = getOrientDBEndpoint().getCatalogsLinkName();//
String catalogNameField = fieldProperty.getLinkedClass().getCustom(catalogsLinkNameAttribute);
if (catalogNameField==null){
catalogNameField = catalogsLinkName;
}
List<OIdentifiable> catalogLinks = curDb.query(new OSQLSynchQuery<OIdentifiable>(
"select from "+fieldProperty.getLinkedClass().getName()+" where "+catalogNameField+"=?"), value);
if (catalogLinks.size()>0){
value = catalogLinks.get(0).getIdentity();
}else{
boolean updateCatalogs = getOrientDBEndpoint().isCatalogsUpdate();//
if (updateCatalogs){
ODocument catalogRecord = new ODocument(fieldProperty.getLinkedClass());
catalogRecord.field(catalogNameField,value);
catalogRecord.save(true);
value = catalogRecord.getIdentity();
}
}
return value;
}
示例2: testUpgradeSchema_TypeDoesNotYetExist
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
@Test
public void testUpgradeSchema_TypeDoesNotYetExist() throws Exception {
service.upgradeSchema();
try (ODatabaseDocumentTx db = database.getInstance().connect()) {
OSchema schema = db.getMetadata().getSchema();
OClass type = schema.getClass("key_store");
assertThat(type, is(notNullValue()));
OProperty prop = type.getProperty("name");
assertThat(prop, is(notNullValue()));
assertThat(prop.isMandatory(), is(true));
assertThat(prop.isNotNull(), is(true));
assertThat(prop.getType(), is(OType.STRING));
prop = type.getProperty("bytes");
assertThat(prop, is(notNullValue()));
assertThat(prop.isMandatory(), is(true));
assertThat(prop.isNotNull(), is(true));
assertThat(prop.getType(), is(OType.BINARY));
assertThat(type.getInvolvedIndexes("name"), hasSize(1));
assertThat(type.getInvolvedIndexes("name").iterator().next().getType(), is("UNIQUE"));
}
}
示例3: getData
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
@Override
public Collection<OProperty> getData() {
OClass oClass = oClassModel.getObject();
if(oClass==null)
{
return null;
}
else if(allPropertiesModel==null||Boolean.TRUE.equals(allPropertiesModel.getObject()))
{
return oClass.properties();
}
else
{
return oClass.declaredProperties();
}
}
示例4: load
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected T load() {
ODocument doc = docModel.getObject();
OProperty prop = propertyModel!=null?propertyModel.getObject():null;
if(doc==null) return null;
if(prop==null) return (T) doc;
if(valueType==null) {
return (T) doc.field(prop.getName());
} else
{
Object ret = doc.field(prop.getName(), valueType);
if(ORecord.class.isAssignableFrom(valueType) && ret instanceof ORID) {
ret = ((ORID)ret).getRecord();
}
return (T) ret;
}
}
示例5: testOPropertiesDataProvider
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
@Test
public void testOPropertiesDataProvider()
{
OSchema schema = wicket.getTester().getSchema();
OClass oClass = schema.getClass("ClassA");
OPropertiesDataProvider provider = new OPropertiesDataProvider(oClass, true);
provider.setSort("name", SortOrder.ASCENDING);
Iterator<? extends OProperty> it = provider.iterator(0, -1);
List<OProperty> allProperties = new ArrayList<OProperty>(oClass.properties());
while(it.hasNext())
{
OProperty oProperty = it.next();
assertTrue(allProperties.remove(provider.model(oProperty).getObject()));
}
assertTrue(allProperties.size()==0);
provider.detach();
}
示例6: testListModels
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
@Test
public void testListModels()
{
IModel<String> classNameModel = Model.of();
IModel<OClass> classModel = new OClassModel(classNameModel);
IModel<List<OProperty>> propertiesModel = new ListOPropertiesModel(classModel, null);
IModel<List<OIndex<?>>> indexesModel = new ListOIndexesModel(classModel, null);
List<OProperty> properties = propertiesModel.getObject();
List<OIndex<?>> indexes = indexesModel.getObject();
assertNotNull(properties);
assertNotNull(indexes);
assertTrue(properties.isEmpty());
assertTrue(indexes.isEmpty());
classModel.detach();
propertiesModel.detach();
indexesModel.detach();
classNameModel.setObject("OUser");
properties = propertiesModel.getObject();
indexes = indexesModel.getObject();
assertNotNull(properties);
assertNotNull(indexes);
assertFalse(properties.isEmpty());
assertFalse(indexes.isEmpty());
}
示例7: testOPropertyModel
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
@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);
}
示例8: testRemovingReadonlyField
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
@Test
public void testRemovingReadonlyField()
{
ODatabaseDocument db = wicket.getTester().getDatabase();
OSchema schema = db.getMetadata().getSchema();
OClass classA = schema.createClass("TestRemovingField");
classA.createProperty("name", OType.STRING);
OProperty property = classA.createProperty("property", OType.STRING);
property.setReadonly(true);
ODocument doc = new ODocument(classA);
doc.field("name", "My Name");
doc.field("property", "value1");
doc.save();
doc.field("name", "My Name 2");
doc.field("property", "value2");
doc.undo("property");
doc.save();
}
示例9: testRemovingReadonlyField2
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
@Test
public void testRemovingReadonlyField2()
{
ODatabaseDocument db = wicket.getTester().getDatabase();
OSchema schema = db.getMetadata().getSchema();
OClass classA = schema.createClass("TestRemovingField2");
classA.createProperty("name", OType.STRING);
OProperty property = classA.createProperty("property", OType.STRING);
property.setReadonly(true);
ODocument doc = new ODocument(classA);
doc.field("name", "My Name");
doc.field("property", "value1");
doc.save();
doc.field("name", "My Name 2");
doc.field("property", "value2");
doc.undo();
doc.field("name", "My Name 3");
doc.save();
}
示例10: testEqualsToDateTimeFilterCriteria
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
@Test
public void testEqualsToDateTimeFilterCriteria() throws ParseException {
IModel<OProperty> property = wicket.getProperty(DATETIME_FIELD);
IFilterCriteriaManager manager = new FilterCriteriaManager(property);
IModel<String> model = Model.of(DATETIME_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 HH:mm:ss");
IModel<Date> dateModel = Model.of(dateFormat.parse(DATETIME_VALUE_1));
manager.addFilterCriteria(manager.createEqualsFilterCriteria(dateModel, Model.of(true)));
queryModel.addFilterCriteriaManager(property.getObject().getName(), manager);
assertTrue(queryModel.size() == 1);
}
示例11: testEqualsToDateFilterCriteria
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
@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);
}
示例12: testLinkFilter
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
@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));
}
示例13: testODocumentLinkQueryProvider
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
@Test
public void testODocumentLinkQueryProvider() {
IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(NUMBER_FIELD));
IFilterCriteria equalsFilterCriteria = manager.createEqualsFilterCriteria(Model.of(NUM_VALUE_1), Model.of(true));
manager.addFilterCriteria(equalsFilterCriteria);
String numField = wicket.getProperty(NUMBER_FIELD).getObject().getName();
queryModel.addFilterCriteriaManager(numField, manager);
ODocument doc = queryModel.getObject().get(0);
IModel<OProperty> property = wicket.getProperty(LINK_LIST_FIELD);
ODocumentLinksQueryDataProvider provider = new ODocumentLinksQueryDataProvider(new ODocumentModel(doc), property);
OQueryModel<ODocument> state = provider.getFilterState();
state.addFilterCriteriaManager(numField, manager);
state.detach();
assertTrue("size must be 1, but it is " + provider.size(), provider.size() == 1);
assertTrue(state.getObject().get(0) != null);
}
示例14: configureProperty
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void configureProperty(OClass oClass, RProperty rProperty) {
PropertyMapping mapping = PropertyMapping.forPropertyType(rProperty.getType());
if (mapping == null) {
throw new IllegalArgumentException(String.format("No mapping found for property type '%s'.",
rProperty.getType()));
}
String oPropertyName = schemaMapping.getRFeatureMapping(rProperty).getOPropertyName();
OProperty oProperty = oClass.getProperty(oPropertyName);
OType oType = mapping.getSchemaType();
if (oProperty == null) {
logger.info("Creating property '{}.{}' of type {}.", oClass.getName(), oPropertyName, oType);
oProperty = oClass.createProperty(oPropertyName, oType);
}
if (oProperty.getType() != oType) {
logger.error("Property '{}.{}' is not of type {}. Errors might occur when modifying this property.",
oClass.getName(), oPropertyName, oType);
}
oProperty.setMandatory(rProperty.isMandatory());
oProperty.setNotNull(rProperty.isMandatory());
if (rProperty.isUnique() && !oProperty.isIndexed()) {
logger.info("Creating index for property '{}.{}'.", oClass.getName(), oPropertyName);
oProperty.createIndex(OClass.INDEX_TYPE.UNIQUE);
}
}
示例15: configureLink
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入依赖的package包/类
private void configureLink(OSchema oSchema, RClass rClass) {
final OClass oClass = oSchema.getClass(schemaMapping.getRTypeMapping(rClass).getOClassName());
rClass.getFeatures().stream().
filter(rFeature -> rFeature instanceof RLink)
.map(it -> (RLink) it)
.forEach(rLink -> {
String oPropertyName = schemaMapping.getRFeatureMapping(rLink).getOPropertyName();
OProperty oProperty = oClass.getProperty(oPropertyName);
OType oType = schemaMapping.getRFeatureMapping(rLink).getOPropertyType();
RClass targetRClass = rLink.getTargetClass();
OClass oTargetClass = oSchema.getClass(schemaMapping.getRTypeMapping(targetRClass).getOClassName());
if (oProperty == null) {
logger.info("Creating link '{}.{}' of type {} to class '{}'.", oClass.getName(), oPropertyName, oType,
oTargetClass.getName());
oProperty = oClass.createProperty(oPropertyName, oType, oTargetClass);
}
if (oProperty.getType() != oType || !oProperty.getLinkedClass().equals(oTargetClass)) {
logger.error("Property '{}.{}' is not of type {} or does not reference class '{}'. " +
"Errors might occur when modifying this property; consider migrating this property manually.",
oClass.getName(), oPropertyName, oType, oTargetClass.getName());
}
oProperty.setMandatory(rLink.isMandatory());
oProperty.setNotNull(rLink.isMandatory());
});
}