Search in sources :

Example 6 with AssociationRef

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());
}
Also used : HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) Node(org.alfresco.rest.api.model.Node) ArrayList(java.util.ArrayList) UserInfo(org.alfresco.rest.api.model.UserInfo) AssociationRef(org.alfresco.service.cmr.repository.AssociationRef) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Assoc(org.alfresco.rest.api.model.Assoc)

Example 7 with AssociationRef

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);
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) RegexQNamePattern(org.alfresco.service.namespace.RegexQNamePattern) QNamePattern(org.alfresco.service.namespace.QNamePattern) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) AssociationRef(org.alfresco.service.cmr.repository.AssociationRef) WebApiDescription(org.alfresco.rest.framework.WebApiDescription)

Example 8 with AssociationRef

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";
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) AssociationRef(org.alfresco.service.cmr.repository.AssociationRef) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 9 with AssociationRef

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;
}
Also used : AssociationRef(org.alfresco.service.cmr.repository.AssociationRef) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) ListDataModel(javax.faces.model.ListDataModel)

Example 10 with AssociationRef

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;
}
Also used : AssociationRef(org.alfresco.service.cmr.repository.AssociationRef) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) ListDataModel(javax.faces.model.ListDataModel)

Aggregations

AssociationRef (org.alfresco.service.cmr.repository.AssociationRef)35 NodeRef (org.alfresco.service.cmr.repository.NodeRef)26 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)22 QName (org.alfresco.service.namespace.QName)13 ArrayList (java.util.ArrayList)9 Serializable (java.io.Serializable)8 HashMap (java.util.HashMap)7 List (java.util.List)6 Map (java.util.Map)6 Iterator (java.util.Iterator)4 PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)4 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)3 QNamePattern (org.alfresco.service.namespace.QNamePattern)3 IOException (java.io.IOException)2 Date (java.util.Date)2 ListDataModel (javax.faces.model.ListDataModel)2 MimeMessage (javax.mail.internet.MimeMessage)2 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)2 DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)2 ContentData (org.alfresco.service.cmr.repository.ContentData)2