use of org.alfresco.service.cmr.repository.AssociationRef in project alfresco-repository by Alfresco.
the class ImapServiceImpl method getUnsubscribedFolders.
private Set<NodeRef> getUnsubscribedFolders(String userName) {
Set<NodeRef> result = new HashSet<NodeRef>();
PersonService personService = serviceRegistry.getPersonService();
NodeRef userRef = null;
if (personService.personExists(userName)) {
userRef = personService.getPerson(userName);
}
if (userRef != null) {
List<AssociationRef> unsubscribedFodlers = nodeService.getTargetAssocs(userRef, ImapModel.ASSOC_IMAP_UNSUBSCRIBED);
for (AssociationRef asocRef : unsubscribedFodlers) {
result.add(asocRef.getTargetRef());
}
}
return result;
}
use of org.alfresco.service.cmr.repository.AssociationRef in project alfresco-repository by Alfresco.
the class VirtualNodeServiceExtension method getTargetAssocs.
@Override
public List<AssociationRef> getTargetAssocs(NodeRef sourceRef, QNamePattern qnamePattern) {
NodeServiceTrait theTrait = getTrait();
List<AssociationRef> targetAssocs = null;
Reference reference = Reference.fromNodeRef(sourceRef);
if (reference != null) {
if (smartStore.canMaterialize(reference)) {
NodeRef materializedReferece = smartStore.materialize(reference);
targetAssocs = theTrait.getTargetAssocs(materializedReferece, qnamePattern);
} else {
targetAssocs = new LinkedList<>();
}
} else {
targetAssocs = theTrait.getTargetAssocs(sourceRef, qnamePattern);
}
List<AssociationRef> virtualizedIfNeededTargetAssocs = null;
Reference sourceReference = Reference.fromNodeRef(sourceRef);
if (sourceReference != null) {
virtualizedIfNeededTargetAssocs = new LinkedList<>();
for (AssociationRef associationRef : targetAssocs) {
NodeRef targetNodeRef = associationRef.getTargetRef();
Reference targetReference = NodeProtocol.newReference(targetNodeRef, sourceReference.execute(new GetParentReferenceMethod()));
AssociationRef virtualAssocRef = new AssociationRef(associationRef.getId(), sourceRef, associationRef.getTypeQName(), targetReference.toNodeRef(targetNodeRef.getStoreRef()));
virtualizedIfNeededTargetAssocs.add(virtualAssocRef);
}
} else {
virtualizedIfNeededTargetAssocs = targetAssocs;
if (DownloadModel.TYPE_DOWNLOAD.equals(environment.getType(sourceRef))) {
if (qnamePattern.isMatch(DownloadModel.ASSOC_REQUESTED_NODES)) {
List<AssociationRef> virtualTargetAssocs = getDownloadTargetAssocs(sourceRef);
virtualizedIfNeededTargetAssocs.addAll(virtualTargetAssocs);
}
}
}
return virtualizedIfNeededTargetAssocs;
}
use of org.alfresco.service.cmr.repository.AssociationRef 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.service.cmr.repository.AssociationRef in project alfresco-repository by Alfresco.
the class VirtualNodeServiceExtension method createAssociation.
@Override
public AssociationRef createAssociation(NodeRef sourceRef, NodeRef targetRef, QName assocTypeQName) {
Reference targetReference = Reference.fromNodeRef(targetRef);
if (targetReference != null && getTrait().getType(materializeIfPossible(sourceRef)).equals(DownloadModel.TYPE_DOWNLOAD)) {
// NOTE : this is enables downloads of virtual structures
createDownloadAssociation(sourceRef, targetRef);
AssociationRef assocRef = new AssociationRef(sourceRef, assocTypeQName, targetRef);
return assocRef;
} else {
return getTrait().createAssociation(materializeIfPossible(sourceRef), materializeIfPossible(targetRef), assocTypeQName);
}
}
use of org.alfresco.service.cmr.repository.AssociationRef in project alfresco-repository by Alfresco.
the class AbstractNodeDAOImpl method getSourceNodeAssocs.
@Override
public Collection<Pair<Long, AssociationRef>> getSourceNodeAssocs(Long targetNodeId, QName typeQName) {
Long typeQNameId = null;
if (typeQName != null) {
Pair<Long, QName> typeQNamePair = qnameDAO.getQName(typeQName);
if (typeQNamePair == null) {
// No such QName
return Collections.emptyList();
}
typeQNameId = typeQNamePair.getFirst();
}
List<NodeAssocEntity> nodeAssocEntities = selectNodeAssocsByTarget(targetNodeId, typeQNameId);
List<Pair<Long, AssociationRef>> results = new ArrayList<Pair<Long, AssociationRef>>(nodeAssocEntities.size());
for (NodeAssocEntity nodeAssocEntity : nodeAssocEntities) {
Long assocId = nodeAssocEntity.getId();
AssociationRef assocRef = nodeAssocEntity.getAssociationRef(qnameDAO);
results.add(new Pair<Long, AssociationRef>(assocId, assocRef));
}
return results;
}
Aggregations