Java Code Examples for org.alfresco.service.cmr.dictionary.DictionaryService#getAssociation()

The following examples show how to use org.alfresco.service.cmr.dictionary.DictionaryService#getAssociation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChildAssociatedNodeFinder.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: RelationshipTypeDefintionWrapper.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void updateDefinition(DictionaryService dictionaryService)
{
    AssociationDefinition assocDef = dictionaryService.getAssociation(alfrescoName);

    if (assocDef != null)
    {
        setTypeDefDisplayName(assocDef.getTitle(dictionaryService));
        setTypeDefDescription(assocDef.getDescription(dictionaryService));
    }
    else
    {
        super.updateDefinition(dictionaryService);
    }
    
    updateTypeDefInclProperties();
}
 
Example 3
Source File: PeerAssociatedNodeFinder.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 4
Source File: ChildAssocEntity.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * 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);
}