本文整理汇总了Java中org.alfresco.repo.dictionary.M2Model.createConstraint方法的典型用法代码示例。如果您正苦于以下问题:Java M2Model.createConstraint方法的具体用法?Java M2Model.createConstraint怎么用?Java M2Model.createConstraint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.repo.dictionary.M2Model
的用法示例。
在下文中一共展示了M2Model.createConstraint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCustomConstraintDefinition
import org.alfresco.repo.dictionary.M2Model; //导入方法依赖的package包/类
/**
* @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#addCustomConstraintDefinition(org.alfresco.service.namespace.QName, java.lang.String, boolean, java.util.List, org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic)
*/
public void addCustomConstraintDefinition(QName constraintName, String title, boolean caseSensitive, List<String> allowedValues, MatchLogic matchLogic)
{
mandatory("constraintName", constraintName);
mandatoryString("title", title);
mandatory("allowedValues", allowedValues);
mandatory("matchLogic", matchLogic);
NodeRef modelRef = getCustomModelRef(constraintName.getNamespaceURI());
M2Model deserializedModel = readCustomContentModel(modelRef);
String constraintNameAsPrefixString = constraintName.toPrefixString(getNamespaceService());
M2Constraint customConstraint = deserializedModel.getConstraint(constraintNameAsPrefixString);
if (customConstraint != null)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONSTRAINT_EXISTS, constraintNameAsPrefixString));
}
M2Constraint newCon = deserializedModel.createConstraint(constraintNameAsPrefixString, CUSTOM_CONSTRAINT_TYPE);
newCon.setTitle(title);
newCon.createParameter(PARAM_ALLOWED_VALUES, allowedValues);
newCon.createParameter(PARAM_CASE_SENSITIVE, caseSensitive ? "true" : "false");
newCon.createParameter(PARAM_MATCH_LOGIC, matchLogic.toString());
writeCustomContentModel(modelRef, deserializedModel);
if (logger.isInfoEnabled())
{
logger.info("addCustomConstraintDefinition: "+constraintNameAsPrefixString+" (valueCnt: "+allowedValues.size()+")");
}
}