本文整理汇总了Java中com.orientechnologies.orient.core.metadata.schema.OProperty.setMandatory方法的典型用法代码示例。如果您正苦于以下问题:Java OProperty.setMandatory方法的具体用法?Java OProperty.setMandatory怎么用?Java OProperty.setMandatory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orientechnologies.orient.core.metadata.schema.OProperty
的用法示例。
在下文中一共展示了OProperty.setMandatory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: modifyCaseInsensitiveNameField
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入方法依赖的package包/类
private void modifyCaseInsensitiveNameField(final OClass type) {
log.info("Modifying case-insensitive name field on component");
OProperty ciNameProperty = type.getProperty(P_CI_NAME);
if (!ciNameProperty.isMandatory()) {
ciNameProperty.setMandatory(true);
}
if (!ciNameProperty.isNotNull()) {
ciNameProperty.setNotNull(true);
}
}
示例3: afterRegistration
import com.orientechnologies.orient.core.metadata.schema.OProperty; //导入方法依赖的package包/类
@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);
}
}