Search in sources :

Example 6 with NodeServiceTrait

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

the class VirtualNodeServiceExtension method getParentAssocs.

@Override
public List<ChildAssociationRef> getParentAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) {
    NodeServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference != null) {
        Reference parent = reference.execute(new GetParentReferenceMethod());
        if (parent == null) {
            return theTrait.getParentAssocs(reference.execute(new GetActualNodeRefMethod(environment)), typeQNamePattern, qnamePattern);
        } else {
            if (typeQNamePattern.isMatch(ContentModel.ASSOC_CONTAINS)) {
                Reference parentsParent = parent.execute(new GetParentReferenceMethod());
                NodeRef parentNodeRef = parent.toNodeRef();
                if (parentsParent == null) {
                    parentNodeRef = parent.execute(new GetActualNodeRefMethod(environment));
                }
                NodeRef referenceNodeRef = reference.toNodeRef();
                Map<QName, Serializable> properties = smartStore.getProperties(reference);
                Serializable name = properties.get(ContentModel.PROP_NAME);
                QName assocChildName = QName.createQNameWithValidLocalName(VirtualContentModel.VIRTUAL_CONTENT_MODEL_1_0_URI, name.toString());
                if (qnamePattern.isMatch(assocChildName)) {
                    ChildAssociationRef assoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, parentNodeRef, assocChildName, referenceNodeRef);
                    return Arrays.asList(assoc);
                } else {
                    return Collections.emptyList();
                }
            } else {
                return Collections.emptyList();
            }
        }
    } else {
        return theTrait.getParentAssocs(nodeRef, typeQNamePattern, qnamePattern);
    }
}
Also used : GetParentReferenceMethod(org.alfresco.repo.virtual.ref.GetParentReferenceMethod) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) NodeServiceTrait(org.alfresco.repo.node.db.traitextender.NodeServiceTrait) Reference(org.alfresco.repo.virtual.ref.Reference) QName(org.alfresco.service.namespace.QName) GetActualNodeRefMethod(org.alfresco.repo.virtual.ref.GetActualNodeRefMethod) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 7 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, Set<QName> childNodeTypeQNames) {
    NodeServiceTrait theTrait = getTrait();
    boolean canVirtualize = canVirtualizeAssocNodeRef(nodeRef);
    if (canVirtualize) {
        Reference reference = smartStore.virtualize(nodeRef);
        List<ChildAssociationRef> virtualAssociations = smartStore.getChildAssocs(reference, childNodeTypeQNames);
        List<ChildAssociationRef> associations = new LinkedList<>(virtualAssociations);
        if (smartStore.canMaterialize(reference)) {
            NodeRef materialReference = smartStore.materialize(reference);
            List<ChildAssociationRef> actualAssociations = theTrait.getChildAssocs(materialReference, childNodeTypeQNames);
            associations.addAll(actualAssociations);
        }
        return associations;
    } else {
        return theTrait.getChildAssocs(nodeRef, childNodeTypeQNames);
    }
}
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 8 with NodeServiceTrait

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

the class VirtualNodeServiceExtension method getAspects.

@Override
public Set<QName> getAspects(NodeRef nodeRef) {
    NodeServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference != null) {
        GetAspectsMethod method = new GetAspectsMethod(theTrait, environment);
        return reference.execute(method);
    } else {
        return theTrait.getAspects(nodeRef);
    }
}
Also used : GetAspectsMethod(org.alfresco.repo.virtual.ref.GetAspectsMethod) NodeServiceTrait(org.alfresco.repo.node.db.traitextender.NodeServiceTrait) Reference(org.alfresco.repo.virtual.ref.Reference)

Example 9 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, boolean preload) {
    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, preload);
        List<ChildAssociationRef> associations = new LinkedList<>(virtualAssociations);
        if (smartStore.canMaterialize(reference)) {
            NodeRef materialReference = smartStore.materialize(reference);
            List<ChildAssociationRef> actualAssociations = theTrait.getChildAssocs(materialReference, typeQNamePattern, qnamePattern, preload);
            associations.addAll(actualAssociations);
        }
        return associations;
    } else {
        return theTrait.getChildAssocs(nodeRef, typeQNamePattern, qnamePattern, 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 10 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) {
    NodeServiceTrait theTrait = getTrait();
    boolean canVirtualize = canVirtualizeAssocNodeRef(nodeRef);
    if (canVirtualize) {
        Reference reference = smartStore.virtualize(nodeRef);
        List<ChildAssociationRef> virtualAssociations = smartStore.getChildAssocs(reference, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, 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, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, Integer.MAX_VALUE, false);
            associations.addAll(actualAssociations);
        }
        return associations;
    } else {
        return theTrait.getChildAssocs(nodeRef);
    }
}
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