Search in sources :

Example 16 with NodeServiceTrait

use of org.alfresco.repo.node.db.traitextender.NodeServiceTrait in project alfresco-repository by Alfresco.

the class VirtualNodeServiceExtension method getChildAssocs.

@Override
public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern, int maxResults, boolean preload) {
    NodeServiceTrait theTrait = getTrait();
    boolean canVirtualize = canVirtualizeAssocNodeRef(nodeRef);
    if (canVirtualize) {
        Reference reference = smartStore.virtualize(nodeRef);
        List<ChildAssociationRef> virtualAssociations = smartStore.getChildAssocs(reference, typeQNamePattern, qnamePattern, maxResults, preload);
        List<ChildAssociationRef> associations = new LinkedList<>(virtualAssociations);
        if (associations.size() < maxResults) {
            if (smartStore.canMaterialize(reference)) {
                NodeRef materialReference = smartStore.materialize(reference);
                List<ChildAssociationRef> actualAssociations = theTrait.getChildAssocs(materialReference, typeQNamePattern, qnamePattern, maxResults - associations.size(), preload);
                associations.addAll(actualAssociations);
            }
        }
        return associations;
    } else {
        return theTrait.getChildAssocs(nodeRef, typeQNamePattern, qnamePattern, maxResults, preload);
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) NodeServiceTrait(org.alfresco.repo.node.db.traitextender.NodeServiceTrait) Reference(org.alfresco.repo.virtual.ref.Reference) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) LinkedList(java.util.LinkedList)

Example 17 with NodeServiceTrait

use of org.alfresco.repo.node.db.traitextender.NodeServiceTrait in project alfresco-repository by Alfresco.

the class VirtualNodeServiceExtension method getChildAssocs.

@Override
public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) {
    NodeServiceTrait theTrait = getTrait();
    boolean canVirtualize = canVirtualizeAssocNodeRef(nodeRef);
    if (canVirtualize) {
        Reference reference = smartStore.virtualize(nodeRef);
        List<ChildAssociationRef> virtualAssociations = smartStore.getChildAssocs(reference, typeQNamePattern, qnamePattern, Integer.MAX_VALUE, false);
        List<ChildAssociationRef> associations = new LinkedList<>(virtualAssociations);
        if (smartStore.canMaterialize(reference)) {
            NodeRef materialReference = smartStore.materialize(reference);
            List<ChildAssociationRef> actualAssociations = theTrait.getChildAssocs(materialReference, typeQNamePattern, qnamePattern);
            associations.addAll(actualAssociations);
        }
        return associations;
    } else {
        return theTrait.getChildAssocs(nodeRef, typeQNamePattern, qnamePattern);
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) NodeServiceTrait(org.alfresco.repo.node.db.traitextender.NodeServiceTrait) Reference(org.alfresco.repo.virtual.ref.Reference) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) LinkedList(java.util.LinkedList)

Aggregations

NodeServiceTrait (org.alfresco.repo.node.db.traitextender.NodeServiceTrait)17 NodeRef (org.alfresco.service.cmr.repository.NodeRef)16 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)14 Reference (org.alfresco.repo.virtual.ref.Reference)12 LinkedList (java.util.LinkedList)7 GetParentReferenceMethod (org.alfresco.repo.virtual.ref.GetParentReferenceMethod)3 Serializable (java.io.Serializable)2 AssociationRef (org.alfresco.service.cmr.repository.AssociationRef)2 QName (org.alfresco.service.namespace.QName)2 ArrayList (java.util.ArrayList)1 VirtualizationException (org.alfresco.repo.virtual.VirtualizationException)1 GetActualNodeRefMethod (org.alfresco.repo.virtual.ref.GetActualNodeRefMethod)1 GetAspectsMethod (org.alfresco.repo.virtual.ref.GetAspectsMethod)1 FilingData (org.alfresco.repo.virtual.template.FilingData)1 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)1