use of org.alfresco.service.cmr.repository.AssociationRef in project alfresco-remote-api by Alfresco.
the class AbstractNodeRelation method listNodePeerAssocs.
protected CollectionWithPagingInfo<Node> listNodePeerAssocs(List<AssociationRef> assocRefs, Parameters parameters, boolean returnTarget) {
Map<QName, String> qnameMap = new HashMap<>(3);
Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
List<String> includeParam = parameters.getInclude();
List<Node> collection = new ArrayList<Node>(assocRefs.size());
for (AssociationRef assocRef : assocRefs) {
// minimal info by default (unless "include"d otherwise)
NodeRef nodeRef = (returnTarget ? assocRef.getTargetRef() : assocRef.getSourceRef());
Node node = nodes.getFolderOrDocument(nodeRef, null, null, includeParam, mapUserInfo);
QName assocTypeQName = assocRef.getTypeQName();
if (!EXCLUDED_NS.contains(assocTypeQName.getNamespaceURI())) {
String assocType = qnameMap.get(assocTypeQName);
if (assocType == null) {
assocType = assocTypeQName.toPrefixString(namespaceService);
qnameMap.put(assocTypeQName, assocType);
}
node.setAssociation(new Assoc(assocType));
collection.add(node);
}
}
return listPage(collection, parameters.getPaging());
}
use of org.alfresco.service.cmr.repository.AssociationRef in project alfresco-remote-api by Alfresco.
the class NodeTargetsRelation method delete.
@Override
@WebApiDescription(title = "Remove node assoc(s)")
public void delete(String sourceNodeId, String targetNodeId, Parameters parameters) {
NodeRef srcNodeRef = nodes.validateNode(sourceNodeId);
NodeRef tgtNodeRef = nodes.validateNode(targetNodeId);
String assocTypeStr = parameters.getParameter(Nodes.PARAM_ASSOC_TYPE);
QNamePattern assocTypeQName = nodes.getAssocType(assocTypeStr, false);
if (assocTypeQName == null) {
assocTypeQName = RegexQNamePattern.MATCH_ALL;
}
// note: even if assocType is provided, we currently don't use nodeService.removeAssociation(srcNodeRef, tgtNodeRef, assocTypeQName);
// since silent it returns void even if nothing deleted, where as we return 404
boolean found = false;
List<AssociationRef> assocRefs = nodeAssocService.getTargetAssocs(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, sourceNodeId), assocTypeQName);
for (AssociationRef assocRef : assocRefs) {
if (assocRef.getTargetRef().equals(tgtNodeRef)) {
nodeAssocService.removeAssociation(srcNodeRef, tgtNodeRef, assocRef.getTypeQName());
found = true;
}
}
if (!found) {
throw new EntityNotFoundException(sourceNodeId + "," + assocTypeStr + "," + targetNodeId);
}
}
use of org.alfresco.service.cmr.repository.AssociationRef in project acs-community-packaging by Alfresco.
the class AdminNodeBrowseBean method selectToNode.
/**
* Action to select association To node
*
* @return next action
*/
public String selectToNode() {
AssociationRef assocRef = (AssociationRef) getAssocs().getRowData();
NodeRef targetRef = assocRef.getTargetRef();
setNodeRef(targetRef);
return "success";
}
use of org.alfresco.service.cmr.repository.AssociationRef in project acs-community-packaging by Alfresco.
the class AdminNodeBrowseBean method getSourceAssocs.
/**
* Gets the current source associations
*
* @return associations
*/
public DataModel getSourceAssocs() {
if (sourceAssocs == null) {
try {
List<AssociationRef> assocRefs = getNodeService().getSourceAssocs(getNodeRef(), RegexQNamePattern.MATCH_ALL);
sourceAssocs = new ListDataModel(assocRefs);
} catch (UnsupportedOperationException err) {
// some stores do not support associations
}
}
return sourceAssocs;
}
use of org.alfresco.service.cmr.repository.AssociationRef in project acs-community-packaging by Alfresco.
the class AdminNodeBrowseBean method getAssocs.
/**
* Gets the current node associations
*
* @return associations
*/
public DataModel getAssocs() {
if (assocs == null) {
try {
List<AssociationRef> assocRefs = getNodeService().getTargetAssocs(getNodeRef(), RegexQNamePattern.MATCH_ALL);
assocs = new ListDataModel(assocRefs);
} catch (UnsupportedOperationException err) {
// some stores do not support associations
}
}
return assocs;
}
Aggregations