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


Java AssociationDefinition.isChild方法代码示例

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


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

示例1: init

import org.alfresco.service.cmr.dictionary.AssociationDefinition; //导入方法依赖的package包/类
public void init()
{
    super.init();
    // Quickly scan the supplied association types and remove any that either
    // do not exist or are not child association types.
    DictionaryService dictionaryService = serviceRegistry.getDictionaryService();
    childAssociationTypes.clear();
    for (QName associationType : suppliedAssociationTypes)
    {
        AssociationDefinition assocDef = dictionaryService.getAssociation(associationType);
        if (assocDef != null && assocDef.isChild())
        {
            childAssociationTypes.add(associationType);
        }
    }
    initialised = true;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:ChildAssociatedNodeFinder.java

示例2: init

import org.alfresco.service.cmr.dictionary.AssociationDefinition; //导入方法依赖的package包/类
public void init()
{
    super.init();
    DictionaryService dictionaryService = serviceRegistry.getDictionaryService();
    peerAssociationTypes.clear();
    for (QName associationType : suppliedAssociationTypes)
    {
        AssociationDefinition assocDef = dictionaryService.getAssociation(associationType);
        if (assocDef != null && !assocDef.isChild())
        {
            peerAssociationTypes.add(associationType);
        }
    }
    initialised = true;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:PeerAssociatedNodeFinder.java

示例3: checkIntegrity

import org.alfresco.service.cmr.dictionary.AssociationDefinition; //导入方法依赖的package包/类
public void checkIntegrity(List<IntegrityRecord> eventResults)
{
    QName assocTypeQName = getTypeQName();
    QName assocQName = getQName();
    NodeRef sourceNodeRef = getNodeRef();
    
    // get the association def
    AssociationDefinition assocDef = getAssocDef(eventResults, assocTypeQName);
    // the association definition must exist
    if (assocDef == null)
    {
        IntegrityRecord result = new IntegrityRecord(
                "Association type does not exist: \n" +
                "   Association Type: " + assocTypeQName);
        eventResults.add(result);
        return;
    }
    
    // check that we are dealing with child associations
    if (assocQName == null)
    {
        throw new IllegalArgumentException("The association qualified name must be supplied");
    }
    if (!assocDef.isChild())
    {
        throw new UnsupportedOperationException("This operation is only relevant to child associations");
    }
    ChildAssociationDefinition childAssocDef = (ChildAssociationDefinition) assocDef;
    
    // perform required checks
    checkAssocQNameRegex(eventResults, childAssocDef, assocQName, sourceNodeRef);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:33,代码来源:AssocTargetRoleIntegrityEvent.java

示例4: checkAssociation

import org.alfresco.service.cmr.dictionary.AssociationDefinition; //导入方法依赖的package包/类
/**
 * @param nodeRef NodeRef
 * @param assocDef AssociationDefinition
 * @return boolean
 */
private boolean checkAssociation(NodeRef nodeRef, AssociationDefinition assocDef)
{
    boolean complete = true;
    
    if (assocDef.isTargetMandatory() && !assocDef.isTargetMandatoryEnforced())
    {
        int actualSize = 0;
        if (assocDef.isChild())
        {
            // check the child assocs present
            List<ChildAssociationRef> childAssocRefs = nodeService.getChildAssocs(
                    nodeRef,
                    assocDef.getName(),
                    RegexQNamePattern.MATCH_ALL);
            actualSize = childAssocRefs.size();
        }
        else
        {
            // check the target assocs present
            List<AssociationRef> targetAssocRefs = nodeService.getTargetAssocs(nodeRef, assocDef.getName());
            actualSize = targetAssocRefs.size();
        }
        if (assocDef.isTargetMandatory() && actualSize == 0)
        {
            complete = false;
        }
    }
    return complete;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:35,代码来源:IncompleteNodeTagger.java

示例5: isValidCmisRelationship

import org.alfresco.service.cmr.dictionary.AssociationDefinition; //导入方法依赖的package包/类
/**
 * Is an association valid in CMIS? It must be a non-child relationship and
 * the source and target must both be valid CMIS types.
 * 
 * @param associationQName QName
 * @return boolean
 */
public boolean isValidCmisRelationship(QName associationQName)
{
    if (associationQName == null)
    {
        return false;
    }
    if (associationQName.equals(RELATIONSHIP_QNAME))
    {
        return true;
    }
    AssociationDefinition associationDefinition = dictionaryService.getAssociation(
            associationQName);
    if (associationDefinition == null)
    {
        return false;
    }
    if (associationDefinition.isChild())
    {
        return false;
    }
    if(!isValidCmisRelationshipEndPoint(associationDefinition.getTargetClass().getName()))
    {
        return false;
    }
    if(!isValidCmisRelationshipEndPoint(associationDefinition.getSourceClass().getName()))
    {
        return false;
    }
    return true;
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:38,代码来源:CMISMapping.java

示例6: associationExists

import org.alfresco.service.cmr.dictionary.AssociationDefinition; //导入方法依赖的package包/类
/**
 * Check if an instance of the association already exists from the given
 * source node reference to the given target node reference
 *
 * @param associationDefinition The association definition
 * @param source The source node reference
 * @param target The target node reference
 * @return <code>true</code> if an association already exists, <code>false</code> otherwise
 */
private boolean associationExists(AssociationDefinition associationDefinition, NodeRef source, NodeRef target)
{
    boolean associationAlreadyExists = false;

    QName associationDefinitionName = associationDefinition.getName();
    if (associationDefinition.isChild())
    {
        List<ChildAssociationRef> childAssocs = getNodeService().getChildAssocs(source, associationDefinitionName, associationDefinitionName);
        for (ChildAssociationRef chAssRef : childAssocs)
        {
            if (chAssRef.getChildRef().equals(target))
            {
                associationAlreadyExists = true;
            }
        }
    }
    else
    {
        List<AssociationRef> assocs = getNodeService().getTargetAssocs(source, associationDefinitionName);
        for (AssociationRef assRef : assocs)
        {
            if (assRef.getTargetRef().equals(target))
            {
                associationAlreadyExists = true;
            }
        }
    }

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

示例7: linkNode

import org.alfresco.service.cmr.dictionary.AssociationDefinition; //导入方法依赖的package包/类
/**
 * Link an existing Node
 * 
 * @param context  node to link in
 * @return  node reference of child linked in
 */
private NodeRef linkNode(ImportNode context)
{
    ImportParent parentContext = context.getParentContext();
    NodeRef parentRef = parentContext.getParentRef();
    
    // determine the node reference to link to
    String uuid = context.getUUID();
    if (uuid == null || uuid.length() == 0)
    {
        throw new ImporterException("Node reference does not specify a reference to follow.");
    }
    NodeRef referencedRef = new NodeRef(rootRef.getStoreRef(), uuid);

    // Note: do not link references that are defined in the root of the import
    if (!parentRef.equals(getRootRef()))
    {
        // determine child assoc type
        QName assocType = getAssocType(context);
        AssociationDefinition assocDef = dictionaryService.getAssociation(assocType);
        if (assocDef.isChild())
        {
            // determine child name
            QName childQName = getChildName(context);
            if (childQName == null)
            {
                String name = (String)nodeService.getProperty(referencedRef, ContentModel.PROP_NAME);
                if (name == null || name.length() == 0)
                {
                    throw new ImporterException("Cannot determine node reference child name");
                }
                String localName = QName.createValidLocalName(name);
                childQName = QName.createQName(assocType.getNamespaceURI(), localName);
            }
        
            // create the secondary link
            nodeService.addChild(parentRef, referencedRef, assocType, childQName);
            reportNodeLinked(referencedRef, parentRef, assocType, childQName);
        }
        else
        {
            nodeService.createAssociation(parentRef, referencedRef, assocType);
            reportNodeLinked(parentRef, referencedRef, assocType, null);
        }
    }
    
    // second, perform any specified udpates to the node
    updateStrategy.importNode(context);
    return referencedRef; 
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:56,代码来源:ImporterComponent.java

示例8: 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

示例9: getChildNameUnique

import org.alfresco.service.cmr.dictionary.AssociationDefinition; //导入方法依赖的package包/类
/**
 * Apply the <b>cm:name</b> to the child association. If the child name is <tt>null</tt> then a GUID is generated as
 * a substitute.
 * <p>
 * Unknown associations or associations that do not require unique name checking will use a GUID for the child
 * name and the CRC value used <b>will be negative</b>.
 * 
 * @param childName the <b>cm:name</b> applying to the association.
 */
public static Pair<String, Long> getChildNameUnique(
        DictionaryService dictionaryService,
        QName assocTypeQName,
        String childName)
{
    if (childName == null)
    {
        throw new IllegalArgumentException("Child name may not be null.  Use the Node ID ...");
    }
    
    String childNameNewShort; // 
    long childNameNewCrc = -1L; // By default, they don't compete

    AssociationDefinition assocDef = dictionaryService.getAssociation(assocTypeQName);
    if (assocDef == null || !assocDef.isChild())
    {
        if (logger.isWarnEnabled())
        {
            logger.warn("No child association of this type could be found: " + assocTypeQName);
        }
        childNameNewShort = GUID.generate();
        childNameNewCrc = -1L * getChildNodeNameCrc(childNameNewShort);
    }
    else
    {
        ChildAssociationDefinition childAssocDef = (ChildAssociationDefinition) assocDef;
        if (childAssocDef.getDuplicateChildNamesAllowed())
        {
            childNameNewShort = GUID.generate();
            childNameNewCrc = -1L * getChildNodeNameCrc(childNameNewShort);
        }
        else
        {
            String childNameNewLower = childName.toLowerCase();
            childNameNewShort = getChildNodeNameShort(childNameNewLower);
            childNameNewCrc = getChildNodeNameCrc(childNameNewLower);
        }
    }
    return new Pair<String, Long>(childNameNewShort, childNameNewCrc);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:50,代码来源:ChildAssocEntity.java

示例10: executeImpl

import org.alfresco.service.cmr.dictionary.AssociationDefinition; //导入方法依赖的package包/类
/**
 * Override  method from DeclarativeWebScript
 */
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    String associationFilter = req.getParameter(REQ_URL_TEMPL_VAR_ASSOCIATION_FILTER);
    String namespacePrefix = req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX);
    String name = req.getParameter(REQ_URL_TEMPL_VAR_NAME);
	
    Map<String, Object> model = new HashMap<String, Object>();
    Map<QName, AssociationDefinition> assocdef = new HashMap<QName, AssociationDefinition>();
    QName associationQname = null;
    QName classQname = getClassQname(req);
   
    if(associationFilter == null)
    {
    	associationFilter = "all";
    }
    
    //validate association filter
    if(isValidAssociationFilter(associationFilter) == false)
    {
    	throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the associationFilter - " + associationFilter + " - parameter in the URL");
    }
    
    // validate  for the presence of both name and namespaceprefix 
    if((name == null && namespacePrefix != null) || 
       (name != null && namespacePrefix == null))
    {
    	throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing either name or namespaceprefix parameter in the URL - both combination of name and namespaceprefix is needed");
    }
    
    // check for association filters
    if(associationFilter.equals("child"))
	{
		model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.dictionaryservice.getClass(classQname).getChildAssociations().values());
	}
    else if(associationFilter.equals("general"))
	{
		for(AssociationDefinition assocname:this.dictionaryservice.getClass(classQname).getAssociations().values())
     {
			if(assocname.isChild() == false)
			{
				assocdef.put(assocname.getName(), assocname);
			}
     }
		model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, assocdef.values());
	}
    else if(associationFilter.equals("all"))
	{
		model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, this.dictionaryservice.getClass(classQname).getAssociations().values());
    }

    // if both namespaceprefix and name parameters are given then, the combination namespaceprefix_name is used as the index to create the qname
    if(name != null && namespacePrefix != null)
    {        	
    	// validate the class combination namespaceprefix_name
    	associationQname = getAssociationQname(namespacePrefix, name);
    	
    	if(this.dictionaryservice.getClass(classQname).getAssociations().get(associationQname)== null)
    	{
    		throw new WebScriptException(Status.STATUS_NOT_FOUND, "not a Valid - namespaceprefix_name combination");
    	}
    	
    	model.put(MODEL_PROP_KEY_INDIVIDUAL_PROPERTY_DEFS, this.dictionaryservice.getClass(classQname).getAssociations().get(associationQname));
    }

    model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, this.dictionaryservice);
    
    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:72,代码来源:AbstractAssociationsGet.java

示例11: generateItem

import org.alfresco.service.cmr.dictionary.AssociationDefinition; //导入方法依赖的package包/类
protected void generateItem(FacesContext context, UIPropertySheet propSheet) throws IOException
{
   String associationName = (String)getName();

   // get details of the association
   DataDictionary dd = (DataDictionary)FacesContextUtils.getRequiredWebApplicationContext(
         context).getBean(Application.BEAN_DATA_DICTIONARY);
   AssociationDefinition assocDef = dd.getAssociationDefinition(propSheet.getNode(), associationName);
   
   if (assocDef == null)
   {
      logger.warn("Failed to find child association definition for association '" + associationName + "'");
   }
   else
   {
      // we've found the association definition but we also need to check
      // that the association is a parent child one
      if (assocDef.isChild() == false)
      {
         logger.warn("The association named '" + associationName + "' is not a child association");
      }
      else
      {
         String displayLabel = (String)getDisplayLabel();
         if (displayLabel == null)
         {
            // try and get the repository assigned label
            displayLabel = assocDef.getTitle(dd.getDictionaryService());
            
            // if the label is still null default to the local name of the property
            if (displayLabel == null)
            {
               displayLabel = assocDef.getName().getLocalName();
            }
         }
         
         // generate the label and type specific control
         generateLabel(context, propSheet, displayLabel);
         generateControl(context, propSheet, assocDef);
      }
   }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:43,代码来源:UIChildAssociation.java

示例12: generateItem

import org.alfresco.service.cmr.dictionary.AssociationDefinition; //导入方法依赖的package包/类
protected void generateItem(FacesContext context, UIPropertySheet propSheet) throws IOException
{
   String associationName = (String)getName();

   // get details of the association
   DataDictionary dd = (DataDictionary)FacesContextUtils.getRequiredWebApplicationContext(
         context).getBean(Application.BEAN_DATA_DICTIONARY);
   AssociationDefinition assocDef = dd.getAssociationDefinition(propSheet.getNode(), associationName);
   
   if (assocDef == null)
   {
      logger.warn("Failed to find association definition for association '" + associationName + "'");
   }
   else
   {
      // we've found the association definition but we also need to check
      // that the association is not a parent child one
      if (assocDef.isChild())
      {
         logger.warn("The association named '" + associationName + "' is not an association");
      }
      else
      {
         String displayLabel = (String)getDisplayLabel();
         if (displayLabel == null)
         {
            // try and get the repository assigned label
            displayLabel = assocDef.getTitle(dd.getDictionaryService());
            
            // if the label is still null default to the local name of the property
            if (displayLabel == null)
            {
               displayLabel = assocDef.getName().getLocalName();
            }
         }
         
         // generate the label and type specific control
         generateLabel(context, propSheet, displayLabel);
         generateControl(context, propSheet, assocDef);
      }
   }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:43,代码来源:UIAssociation.java

示例13: removeRelationship

import org.alfresco.service.cmr.dictionary.AssociationDefinition; //导入方法依赖的package包/类
/**
 * @see org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService#removeRelationship(java.lang.String, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
 */
@Override
public void removeRelationship(String uniqueName, NodeRef source, NodeRef target)
{
    mandatoryString("uniqueName", uniqueName);
    mandatory("source", source);
    mandatory("target", target);

    // Check that the association definition for the given unique name exists.
    AssociationDefinition associationDefinition = getAssociationDefinition(uniqueName);
    if (associationDefinition == null)
    {
        StringBuilder sb = new StringBuilder();
        sb.append("No association definition found for '").
            append(uniqueName).
            append("'.");
        throw new IllegalArgumentException(sb.toString());
    }

    // Get the association definition name
    final QName associationDefinitionName = associationDefinition.getName();
    final NodeRef targetNode = target;
    final NodeRef sourceNode = source;

    invokeBeforeRemoveReference(sourceNode, targetNode, associationDefinitionName);

    if (associationDefinition.isChild())
    {
        AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
        {
            @Override
            public Void doWork()
            {
                List<ChildAssociationRef> children = getNodeService().getChildAssocs(sourceNode);
                for (ChildAssociationRef chRef : children)
                {
                    if (associationDefinitionName.equals(chRef.getTypeQName()) && chRef.getChildRef().equals(targetNode))
                    {
                        getNodeService().removeChildAssociation(chRef);
                    }
                }

                return null;
            }
        });
    }
    else
    {
        getNodeService().removeAssociation(source, targetNode, associationDefinitionName);
    }

    invokeOnRemoveReference(source, targetNode, associationDefinitionName);
}
 
开发者ID:Alfresco,项目名称:records-management-old,代码行数:56,代码来源:RelationshipServiceImpl.java


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