Search in sources :

Example 31 with ChildAssociationRef

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

the class UIChildAssociationEditor method renderExistingAssociations.

/**
 * @see org.alfresco.web.ui.repo.component.property.BaseAssociationEditor#renderExistingAssociations(javax.faces.context.FacesContext, javax.faces.context.ResponseWriter, org.alfresco.service.cmr.repository.NodeService, boolean)
 */
protected void renderExistingAssociations(FacesContext context, ResponseWriter out, NodeService nodeService, boolean allowMany) throws IOException {
    boolean itemsRendered = false;
    // show the associations from the original list if they are not in the removed list
    Iterator iter = this.originalAssocs.values().iterator();
    while (iter.hasNext()) {
        ChildAssociationRef assoc = (ChildAssociationRef) iter.next();
        if (removed.containsKey(assoc.getChildRef().toString()) == false) {
            renderExistingAssociation(context, out, nodeService, assoc.getChildRef(), allowMany);
            itemsRendered = true;
        }
    }
    // also show any associations added in this session
    iter = this.added.values().iterator();
    while (iter.hasNext()) {
        ChildAssociationRef assoc = (ChildAssociationRef) iter.next();
        renderExistingAssociation(context, out, nodeService, assoc.getChildRef(), allowMany);
        itemsRendered = true;
    }
    // show the none selected message if no items were rendered
    if (itemsRendered == false && allowMany == true) {
        renderNone(context, out);
    }
}
Also used : Iterator(java.util.Iterator) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 32 with ChildAssociationRef

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

the class UIChildAssociationEditor 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>");
            ChildAssociationRef assoc = (ChildAssociationRef) iter.next();
            NodeRef targetNode = assoc.getChildRef();
            // if the node represents a person, show the username instead of the name
            if (ContentModel.TYPE_PERSON.equals(nodeService.getType(targetNode))) {
                out.write(Utils.encode(User.getFullName(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 {
                out.write(Repository.getDisplayPath(nodeService.getPath(targetNode)));
                out.write("/");
                out.write(Repository.getNameForNode(nodeService, targetNode));
            }
            out.write("</td></tr>");
        }
        out.write("</table>");
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Iterator(java.util.Iterator) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 33 with ChildAssociationRef

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

the class UISpaceSelector method getChildrenForNode.

public Collection<NodeRef> getChildrenForNode(FacesContext context) {
    NodeRef nodeRef = new NodeRef(Repository.getStoreRef(), this.navigationId);
    List<ChildAssociationRef> allKids = getNodeService(context).getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
    DictionaryService dd = getDictionaryService(context);
    NodeService service = getFastNodeService(context);
    // filter out those children that are not spaces
    List<NodeRef> spaceKids = new ArrayList<NodeRef>();
    for (ChildAssociationRef ref : allKids) {
        if (dd.isSubClass(service.getType(ref.getChildRef()), ContentModel.TYPE_FOLDER) && dd.isSubClass(service.getType(ref.getChildRef()), ContentModel.TYPE_SYSTEM_FOLDER) == false) {
            spaceKids.add(ref.getChildRef());
        }
    }
    return spaceKids;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) DictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService) NodeService(org.alfresco.service.cmr.repository.NodeService) ArrayList(java.util.ArrayList) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 34 with ChildAssociationRef

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

the class UISpaceSelector method getParentNodeId.

public String getParentNodeId(FacesContext context) {
    String id = null;
    if (this.navigationId != null && this.navigationId.equals(Application.getCompanyRootId(context)) == false) {
        try {
            ChildAssociationRef parentRef = getFastNodeService(context).getPrimaryParent(new NodeRef(Repository.getStoreRef(), this.navigationId));
            id = parentRef.getParentRef().getId();
        } catch (AccessDeniedException accessErr) {
        // cannot navigate to parent id will be null
        }
    }
    return id;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) AccessDeniedException(org.alfresco.repo.security.permissions.AccessDeniedException) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 35 with ChildAssociationRef

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

the class UICategorySelector method getChildrenForNode.

public Collection<NodeRef> getChildrenForNode(FacesContext context) {
    NodeRef nodeRef = new NodeRef(Repository.getStoreRef(), this.navigationId);
    Collection<ChildAssociationRef> childRefs = getCategoryService(context).getChildren(nodeRef, CategoryService.Mode.SUB_CATEGORIES, CategoryService.Depth.IMMEDIATE);
    Collection<NodeRef> refs = new ArrayList<NodeRef>(childRefs.size());
    for (ChildAssociationRef childRef : childRefs) {
        refs.add(childRef.getChildRef());
    }
    return refs;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ArrayList(java.util.ArrayList) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Aggregations

ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)258 NodeRef (org.alfresco.service.cmr.repository.NodeRef)202 QName (org.alfresco.service.namespace.QName)109 Test (org.junit.Test)56 HashMap (java.util.HashMap)54 BaseUnitTest (org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)53 ArrayList (java.util.ArrayList)52 Serializable (java.io.Serializable)42 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)25 FacesContext (javax.faces.context.FacesContext)22 Map (java.util.Map)19 UserTransaction (javax.transaction.UserTransaction)18 Node (org.alfresco.web.bean.repository.Node)17 Date (java.util.Date)15 StoreRef (org.alfresco.service.cmr.repository.StoreRef)13 NodeService (org.alfresco.service.cmr.repository.NodeService)12 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)12 List (java.util.List)11 StringPropertyValue (org.alfresco.solr.client.StringPropertyValue)11 IOException (java.io.IOException)10