use of org.alfresco.repo.virtual.ref.Reference in project alfresco-repository by Alfresco.
the class VirtualNodeServiceExtension method getSourceAssocs.
@Override
public List<AssociationRef> getSourceAssocs(NodeRef targetRef, QNamePattern qnamePattern) {
NodeServiceTrait theTrait = getTrait();
Reference reference = Reference.fromNodeRef(targetRef);
if (reference != null) {
List<AssociationRef> materialAssocs = new ArrayList<AssociationRef>();
if (smartStore.canMaterialize(reference)) {
List<AssociationRef> sourceAssocs = theTrait.getSourceAssocs(smartStore.materialize(reference), qnamePattern);
for (AssociationRef associationRef : sourceAssocs) {
NodeRef sourceRef = associationRef.getSourceRef();
Reference sourceReference = NodeProtocol.newReference(sourceRef, reference.execute(new GetParentReferenceMethod()));
AssociationRef virtualAssocRef = new AssociationRef(associationRef.getId(), sourceReference.toNodeRef(), associationRef.getTypeQName(), targetRef);
materialAssocs.add(virtualAssocRef);
}
}
return materialAssocs;
} else {
return theTrait.getSourceAssocs(targetRef, qnamePattern);
}
}
use of org.alfresco.repo.virtual.ref.Reference 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);
}
}
use of org.alfresco.repo.virtual.ref.Reference 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);
}
}
use of org.alfresco.repo.virtual.ref.Reference 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);
}
}
use of org.alfresco.repo.virtual.ref.Reference 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);
}
}
Aggregations