Search in sources :

Example 1 with MapBasedQueryWalkerOrSupported

use of org.alfresco.rest.workflow.api.impl.MapBasedQueryWalkerOrSupported in project alfresco-remote-api by Alfresco.

the class SitesImpl method getFilterPropListOfSites.

private List<FilterProp> getFilterPropListOfSites(final Parameters parameters) {
    List<FilterProp> filterProps = new ArrayList<FilterProp>();
    Query q = parameters.getQuery();
    if (q != null) {
        MapBasedQueryWalkerOrSupported propertyWalker = new MapBasedQueryWalkerOrSupported(LIST_SITES_EQUALS_QUERY_PROPERTIES, null);
        QueryHelper.walk(q, propertyWalker);
        String siteVisibilityStr = propertyWalker.getProperty(PARAM_VISIBILITY, WhereClauseParser.EQUALS, String.class);
        if (siteVisibilityStr != null && !siteVisibilityStr.isEmpty()) {
            SiteVisibility siteVisibility = getSiteVisibilityFromParam(siteVisibilityStr);
            filterProps.add(new FilterPropString(SiteModel.PROP_SITE_VISIBILITY, siteVisibility.name(), FilterPropString.FilterTypeString.EQUALS));
        }
        String sitePreset = propertyWalker.getProperty(PARAM_PRESET, WhereClauseParser.EQUALS, String.class);
        if (sitePreset != null && !sitePreset.isEmpty()) {
            filterProps.add(new FilterPropString(SiteModel.PROP_SITE_PRESET, sitePreset, FilterPropString.FilterTypeString.EQUALS));
        }
    }
    // expected null or non-empty list
    return filterProps.isEmpty() ? null : filterProps;
}
Also used : Query(org.alfresco.rest.framework.resource.parameters.where.Query) FilterProp(org.alfresco.repo.node.getchildren.FilterProp) ArrayList(java.util.ArrayList) FilterPropString(org.alfresco.repo.node.getchildren.FilterPropString) MapBasedQueryWalkerOrSupported(org.alfresco.rest.workflow.api.impl.MapBasedQueryWalkerOrSupported) SiteVisibility(org.alfresco.service.cmr.site.SiteVisibility) FilterPropString(org.alfresco.repo.node.getchildren.FilterPropString)

Example 2 with MapBasedQueryWalkerOrSupported

use of org.alfresco.rest.workflow.api.impl.MapBasedQueryWalkerOrSupported in project alfresco-remote-api by Alfresco.

the class GroupsImpl method getGroupMembers.

public CollectionWithPagingInfo<GroupMember> getGroupMembers(String groupId, final Parameters parameters) {
    validateGroupId(groupId, false);
    // Not allowed to list all members.
    if (PermissionService.ALL_AUTHORITIES.equals(groupId)) {
        throw new UnsupportedResourceOperationException();
    }
    Paging paging = parameters.getPaging();
    // Retrieve sort column. This is limited for now to sort column due to
    // v0 api implementation. Should be improved in the future.
    Pair<String, Boolean> sortProp = getGroupsSortProp(parameters);
    AuthorityType authorityType = null;
    // Parse where clause properties.
    Query q = parameters.getQuery();
    if (q != null) {
        MapBasedQueryWalkerOrSupported propertyWalker = new MapBasedQueryWalkerOrSupported(LIST_GROUP_MEMBERS_QUERY_PROPERTIES, null);
        QueryHelper.walk(q, propertyWalker);
        String memberTypeStr = propertyWalker.getProperty(PARAM_MEMBER_TYPE, WhereClauseParser.EQUALS, String.class);
        authorityType = getAuthorityType(memberTypeStr);
    }
    PagingResults<AuthorityInfo> pagingResult = getAuthoritiesInfo(authorityType, groupId, sortProp, paging);
    // Create response.
    final List<AuthorityInfo> page = pagingResult.getPage();
    int totalItems = pagingResult.getTotalResultCount().getFirst();
    List<GroupMember> groupMembers = new AbstractList<GroupMember>() {

        @Override
        public GroupMember get(int index) {
            AuthorityInfo authorityInfo = page.get(index);
            return getGroupMember(authorityInfo);
        }

        @Override
        public int size() {
            return page.size();
        }
    };
    return CollectionWithPagingInfo.asPaged(paging, groupMembers, pagingResult.hasMoreItems(), totalItems);
}
Also used : AbstractList(java.util.AbstractList) GroupMember(org.alfresco.rest.api.model.GroupMember) Query(org.alfresco.rest.framework.resource.parameters.where.Query) UnsupportedResourceOperationException(org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException) Paging(org.alfresco.rest.framework.resource.parameters.Paging) AuthorityType(org.alfresco.service.cmr.security.AuthorityType) AuthorityInfo(org.alfresco.repo.security.authority.AuthorityInfo) MapBasedQueryWalkerOrSupported(org.alfresco.rest.workflow.api.impl.MapBasedQueryWalkerOrSupported)

Aggregations

Query (org.alfresco.rest.framework.resource.parameters.where.Query)2 MapBasedQueryWalkerOrSupported (org.alfresco.rest.workflow.api.impl.MapBasedQueryWalkerOrSupported)2 AbstractList (java.util.AbstractList)1 ArrayList (java.util.ArrayList)1 FilterProp (org.alfresco.repo.node.getchildren.FilterProp)1 FilterPropString (org.alfresco.repo.node.getchildren.FilterPropString)1 AuthorityInfo (org.alfresco.repo.security.authority.AuthorityInfo)1 GroupMember (org.alfresco.rest.api.model.GroupMember)1 UnsupportedResourceOperationException (org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException)1 Paging (org.alfresco.rest.framework.resource.parameters.Paging)1 AuthorityType (org.alfresco.service.cmr.security.AuthorityType)1 SiteVisibility (org.alfresco.service.cmr.site.SiteVisibility)1