Search in sources :

Example 1 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 2 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 3 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)

Example 4 with AssociationRef

use of org.alfresco.service.cmr.repository.AssociationRef in project acs-community-packaging by Alfresco.

the class UIAssociationEditor method renderReadOnlyAssociations.

/**
 * @see org.alfresco.web.ui.repo.component.property.BaseAssociationEditor#renderReadOnlyAssociations(javax.faces.context.FacesContext, javax.faces.context.ResponseWriter, org.alfresco.service.cmr.repository.NodeService)
 */
protected void renderReadOnlyAssociations(FacesContext context, ResponseWriter out, NodeService nodeService) throws IOException {
    if (this.originalAssocs.size() > 0) {
        out.write("<table cellspacing='0' cellpadding='2' border='0'>");
        Iterator iter = this.originalAssocs.values().iterator();
        while (iter.hasNext()) {
            out.write("<tr><td>");
            AssociationRef assoc = (AssociationRef) iter.next();
            NodeRef targetNode = assoc.getTargetRef();
            if (nodeService.exists(targetNode)) {
                if (ContentModel.TYPE_PERSON.equals(nodeService.getType(targetNode))) {
                    // if the node represents a person, show the username instead of the name
                    out.write(Utils.encode(User.getFullNameAndUserId(nodeService, targetNode)));
                } else if (ContentModel.TYPE_AUTHORITY_CONTAINER.equals(nodeService.getType(targetNode))) {
                    // if the node represents a group, show the group display name instead of the name
                    String groupDisplayName = (String) nodeService.getProperty(targetNode, ContentModel.PROP_AUTHORITY_DISPLAY_NAME);
                    if (groupDisplayName == null || groupDisplayName.length() == 0) {
                        String group = (String) nodeService.getProperty(targetNode, ContentModel.PROP_AUTHORITY_NAME);
                        groupDisplayName = group.substring(PermissionService.GROUP_PREFIX.length());
                    }
                    out.write(Utils.encode(groupDisplayName));
                } else {
                    // use the standard cm:name property
                    // Fix AWC-1301
                    String displayString = null;
                    try {
                        displayString = Repository.getDisplayPath(nodeService.getPath(targetNode)) + "/" + Repository.getNameForNode(nodeService, targetNode);
                    } catch (AccessDeniedException ade) {
                        displayString = Application.getMessage(context, MSG_WARN_CANNOT_VIEW_TARGET_DETAILS);
                    }
                    out.write(Utils.encode(displayString));
                }
            } else {
                String message = Application.getMessage(context, MSG_WARN_USER_WAS_DELETED);
                out.write(message);
            }
            out.write("</td></tr>");
        }
        out.write("</table>");
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) AccessDeniedException(org.alfresco.repo.security.permissions.AccessDeniedException) Iterator(java.util.Iterator) AssociationRef(org.alfresco.service.cmr.repository.AssociationRef)

Example 5 with AssociationRef

use of org.alfresco.service.cmr.repository.AssociationRef in project acs-community-packaging by Alfresco.

the class UIAssociationEditor method addTarget.

/**
 * Updates the component and node state to reflect an association being added
 *
 * @param node The node we are dealing with
 * @param toAdd The noderefs of the children to add
 */
protected void addTarget(Node node, String[] toAdd) {
    if (node != null && toAdd != null && toAdd.length > 0) {
        for (int x = 0; x < toAdd.length; x++) {
            String targetRef = toAdd[x];
            // update the node so it knows to add the association (if it wasn't there originally)
            if (this.originalAssocs.containsKey(targetRef) == false) {
                QName assocQName = Repository.resolveToQName(this.associationName);
                AssociationRef newAssoc = new AssociationRef(null, node.getNodeRef(), assocQName, new NodeRef(targetRef));
                Map<String, AssociationRef> added = node.getAddedAssociations().get(this.associationName);
                added.put(targetRef, newAssoc);
                if (logger.isDebugEnabled())
                    logger.debug("Added association to " + targetRef + " to the added list");
            }
            // if the association was previously removed and has now been re-added it
            // will still be in the "to be removed" list so remove it if it is
            Map<String, AssociationRef> removed = node.getRemovedAssociations().get(this.associationName);
            if (removed.containsKey(targetRef)) {
                removed.remove(targetRef);
                if (logger.isDebugEnabled())
                    logger.debug("Removed association to " + targetRef + " from the removed list");
            }
        }
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) QName(org.alfresco.service.namespace.QName) AssociationRef(org.alfresco.service.cmr.repository.AssociationRef)

Aggregations

AssociationRef (org.alfresco.service.cmr.repository.AssociationRef)138 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)112 NodeRef (org.alfresco.service.cmr.repository.NodeRef)102 QName (org.alfresco.service.namespace.QName)56 ArrayList (java.util.ArrayList)44 Serializable (java.io.Serializable)30 Test (org.junit.Test)26 HashMap (java.util.HashMap)24 List (java.util.List)15 Pair (org.alfresco.util.Pair)14 HashSet (java.util.HashSet)13 Map (java.util.Map)13 StoreRef (org.alfresco.service.cmr.repository.StoreRef)12 BaseSpringTest (org.alfresco.util.BaseSpringTest)10 Extend (org.alfresco.traitextender.Extend)8 Iterator (java.util.Iterator)7 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)7 PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)7 Path (org.alfresco.service.cmr.repository.Path)6 Version (org.alfresco.service.cmr.version.Version)6