当前位置: 首页>>代码示例>>Java>>正文


Java M2Constraint类代码示例

本文整理汇总了Java中org.alfresco.repo.dictionary.M2Constraint的典型用法代码示例。如果您正苦于以下问题:Java M2Constraint类的具体用法?Java M2Constraint怎么用?Java M2Constraint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


M2Constraint类属于org.alfresco.repo.dictionary包,在下文中一共展示了M2Constraint类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeCustomConstraintDefinition

import org.alfresco.repo.dictionary.M2Constraint; //导入依赖的package包/类
/**
 * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#removeCustomConstraintDefinition(org.alfresco.service.namespace.QName)
 */
public void removeCustomConstraintDefinition(QName constraintName)
{
    mandatory("constraintName", constraintName);

    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_CANNOT_FIND_CONSTRAINT, constraintNameAsPrefixString));
    }

    deserializedModel.removeConstraint(constraintNameAsPrefixString);

    writeCustomContentModel(modelRef, deserializedModel);

    if (logger.isInfoEnabled())
    {
        logger.info("deleteCustomConstraintDefinition: "+constraintNameAsPrefixString);
    }
}
 
开发者ID:Alfresco,项目名称:records-management-old,代码行数:29,代码来源:RecordsManagementAdminServiceImpl.java

示例2: setConstraintOtherData

import org.alfresco.repo.dictionary.M2Constraint; //导入依赖的package包/类
private void setConstraintOtherData(CustomModelConstraint constraint, M2Constraint m2Constraint, String propDataType)
{
    if (m2Constraint.getType() == null)
    {
        throw new InvalidArgumentException("cmm.rest_api.constraint_type_null");
    }

    ConstraintValidator constraintValidator = ConstraintValidator.findByType(m2Constraint.getType());
    if (propDataType != null)
    {
        // Check if the constraint can be used with given data type
        constraintValidator.validateUsage(prefixedStringToQname(propDataType));
    }

    m2Constraint.setTitle(constraint.getTitle());
    m2Constraint.setDescription(constraint.getDescription());
    for (CustomModelNamedValue parameter : constraint.getParameters())
    {
        validateName(parameter.getName(), "cmm.rest_api.constraint_parameter_name_null");
        if (parameter.getListValue() != null)
        {
            if (propDataType != null && "allowedValues".equals(parameter.getName()))
            {
                validateListConstraint(parameter.getListValue(), propDataType);
            }
            m2Constraint.createParameter(parameter.getName(), parameter.getListValue());
        }
        else
        {
            constraintValidator.validate(parameter.getName(), parameter.getSimpleValue());
            m2Constraint.createParameter(parameter.getName(), parameter.getSimpleValue());
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:35,代码来源:CustomModelsImpl.java

示例3: addCustomConstraintDefinition

import org.alfresco.repo.dictionary.M2Constraint; //导入依赖的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()+")");
    }
}
 
开发者ID:Alfresco,项目名称:records-management-old,代码行数:36,代码来源:RecordsManagementAdminServiceImpl.java

示例4: changeCustomConstraintValues

import org.alfresco.repo.dictionary.M2Constraint; //导入依赖的package包/类
/**
 * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#changeCustomConstraintValues(org.alfresco.service.namespace.QName, java.util.List)
 */
public void changeCustomConstraintValues(QName constraintName, List<String> newAllowedValues)
{
    mandatory("constraintName", constraintName);
    mandatory("newAllowedValues", newAllowedValues);

    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_CANNOT_FIND_CONSTRAINT, constraintNameAsPrefixString));
    }

    String type = customConstraint.getType();
    if (type == null ||
        (!type.equals(CUSTOM_CONSTRAINT_TYPE) &&
         !type.equals(CAPATIBILITY_CUSTOM_CONTRAINT_TYPE)))
    {
        throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNEXPECTED_TYPE_CONSTRAINT, type, constraintNameAsPrefixString, CUSTOM_CONSTRAINT_TYPE));
    }

    customConstraint.removeParameter(PARAM_ALLOWED_VALUES);
    customConstraint.createParameter(PARAM_ALLOWED_VALUES, newAllowedValues);

    writeCustomContentModel(modelRef, deserializedModel);

    if (logger.isInfoEnabled())
    {
        logger.info("changeCustomConstraintValues: "+constraintNameAsPrefixString+" (valueCnt: "+newAllowedValues.size()+")");
    }
}
 
开发者ID:Alfresco,项目名称:records-management-old,代码行数:38,代码来源:RecordsManagementAdminServiceImpl.java

示例5: changeCustomConstraintTitle

import org.alfresco.repo.dictionary.M2Constraint; //导入依赖的package包/类
/**
 * @see org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService#changeCustomConstraintTitle(org.alfresco.service.namespace.QName, java.lang.String)
 */
public void changeCustomConstraintTitle(QName constraintName, String title)
{
    mandatory("constraintName", constraintName);
    mandatoryString("title", title);

    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_CANNOT_FIND_CONSTRAINT, constraintNameAsPrefixString));
    }

    String type = customConstraint.getType();
    if ((type == null) || (! type.equals(CUSTOM_CONSTRAINT_TYPE)))
    {

        throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNEXPECTED_TYPE_CONSTRAINT, type, constraintNameAsPrefixString, CUSTOM_CONSTRAINT_TYPE));
    }

    customConstraint.setTitle(title);

    writeCustomContentModel(modelRef, deserializedModel);

    if (logger.isInfoEnabled())
    {
        logger.info("changeCustomConstraintTitle: "+constraintNameAsPrefixString+" (title: "+title+")");
    }
}
 
开发者ID:Alfresco,项目名称:records-management-old,代码行数:36,代码来源:RecordsManagementAdminServiceImpl.java

示例6: setCustomPropertyDefinitionConstraint

import org.alfresco.repo.dictionary.M2Constraint; //导入依赖的package包/类
/**
 * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#setCustomPropertyDefinitionConstraint(org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName)
 */
public QName setCustomPropertyDefinitionConstraint(QName propQName, QName newLovConstraint)
{
    mandatory("propQName", propQName);
    mandatory("newLovConstraint", newLovConstraint);

    PropertyDefinition propDefn = getDictionaryService().getProperty(propQName);
    if (propDefn == null)
    {
        throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName));
    }

    NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI());
    M2Model deserializedModel = readCustomContentModel(modelRef);

    M2Property targetProp = findProperty(propQName, deserializedModel);
    String dataType = targetProp.getType();

    if (! dataType.equals(DataTypeDefinition.TEXT.toPrefixString(getNamespaceService())))
    {

        throw new AlfrescoRuntimeException(I18NUtil.getMessage(CannotApplyConstraintMetadataException.MSG_CANNOT_APPLY_CONSTRAINT, newLovConstraint, targetProp.getName(), dataType));
    }
    String lovConstraintQNameAsString = newLovConstraint.toPrefixString(getNamespaceService());

    // Add the constraint - if it isn't already there.
    String refOfExistingConstraint = null;

    for (M2Constraint c : targetProp.getConstraints())
    {
        // There should only be one constraint.
        refOfExistingConstraint = c.getRef();
        break;
    }
    if (refOfExistingConstraint != null)
    {
        targetProp.removeConstraintRef(refOfExistingConstraint);
    }
    targetProp.addConstraintRef(lovConstraintQNameAsString);

    writeCustomContentModel(modelRef, deserializedModel);

    if (logger.isInfoEnabled())
    {
        logger.info("addCustomPropertyDefinitionConstraint: "+lovConstraintQNameAsString);
    }

    return propQName;
}
 
开发者ID:Alfresco,项目名称:records-management-old,代码行数:52,代码来源:RecordsManagementAdminServiceImpl.java


注:本文中的org.alfresco.repo.dictionary.M2Constraint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。