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


Java AssociationDefinition.getTargetClass方法代码示例

本文整理汇总了Java中org.alfresco.service.cmr.dictionary.AssociationDefinition.getTargetClass方法的典型用法代码示例。如果您正苦于以下问题:Java AssociationDefinition.getTargetClass方法的具体用法?Java AssociationDefinition.getTargetClass怎么用?Java AssociationDefinition.getTargetClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.service.cmr.dictionary.AssociationDefinition的用法示例。


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

示例1: checkSourceMultiplicity

import org.alfresco.service.cmr.dictionary.AssociationDefinition; //导入方法依赖的package包/类
/**
 * Checks that the source multiplicity has not been violated for the
 * target of the association.
 */
protected void checkSourceMultiplicity(
        List<IntegrityRecord> eventResults,
        AssociationDefinition assocDef,
        QName assocTypeQName,
        NodeRef targetNodeRef)
{
    // get the source multiplicity
    boolean mandatory = assocDef.isSourceMandatory();
    boolean allowMany = assocDef.isSourceMany();
    // do we need to check
    if (!mandatory && allowMany)
    {
        // it is not mandatory and it allows many on both sides of the assoc
        return;
    }
    
    // check the target of the association if this is a delete
    if (isDelete)
    {
        // get the class the association is defined for and see if it is an aspect
        ClassDefinition classDef = assocDef.getTargetClass(); 
        if (classDef.isAspect())
        {
            // see if the target node has the aspect applied, if it does not
            // there's no need to check multiplicity
            if (!this.nodeService.hasAspect(targetNodeRef, classDef.getName()))
            {
                return;
            }
        }
    }
    
    int actualSize = 0;
    if (assocDef.isChild())
    {
        // check the parent assocs present
        List<ChildAssociationRef> parentAssocRefs = nodeService.getParentAssocs(
                targetNodeRef,
                assocTypeQName,
                RegexQNamePattern.MATCH_ALL);
        actualSize = parentAssocRefs.size();
    }
    else
    {
        // check the source assocs present
        List<AssociationRef> sourceAssocRefs = nodeService.getSourceAssocs(targetNodeRef, assocTypeQName);
        actualSize = sourceAssocRefs.size();
    }
    
    if ((mandatory && actualSize == 0) || (!allowMany && actualSize > 1))
    {
        if (actualSize == 0)
        {
            // ALF-9591: Integrity check: Association source multiplicity checking is incorrect
            //           At this point, there is no point worrying.  There are no more associations
            //           pointing *to* this node and therefore the checking of the source
            //           multiplicity (a feature of the source type/aspect) is not relevant
            return;
        }
        
        String parentOrSourceStr = (assocDef.isChild() ? "parent" : "source");
        IntegrityRecord result = new IntegrityRecord(
                "The association " + parentOrSourceStr + " multiplicity has been violated: \n" +
                "   Target Node: " + targetNodeRef + "\n" +
                "   Association: " + assocDef + "\n" +
                "   Required " + parentOrSourceStr + " Multiplicity: " + getMultiplicityString(mandatory, allowMany) + "\n" +
                "   Actual " + parentOrSourceStr + " Multiplicity: " + actualSize);
        eventResults.add(result);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:75,代码来源:AssocSourceMultiplicityIntegrityEvent.java


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