use of org.alfresco.repo.node.getchildren.FilterProp in project records-management by Alfresco.
the class FilePlanComponentsApiUtils method getListChildrenFilterProps.
/**
* Returns a List of filter properties specified by request parameters.
* @param parameters The {@link Parameters} object to get the parameters passed into the request
* including:
* - filter, sort & paging params (where, orderBy, skipCount, maxItems)
* @return The list of {@link FilterProp}. Can be null.
*/
public List<FilterProp> getListChildrenFilterProps(Parameters parameters, Set<String> listFolderChildrenEqualsQueryProperties) {
List<FilterProp> filterProps = null;
Query q = parameters.getQuery();
if (q != null) {
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(listFolderChildrenEqualsQueryProperties, null);
QueryHelper.walk(q, propertyWalker);
Boolean isPrimary = propertyWalker.getProperty(RMNode.PARAM_ISPRIMARY, WhereClauseParser.EQUALS, Boolean.class);
if (isPrimary != null) {
filterProps = new ArrayList<>(1);
filterProps.add(new FilterPropBoolean(GetChildrenCannedQuery.FILTER_QNAME_NODE_IS_PRIMARY, isPrimary));
}
Boolean isClosed = propertyWalker.getProperty(RMNode.PARAM_IS_CLOSED, WhereClauseParser.EQUALS, Boolean.class);
if (isClosed != null) {
filterProps = new ArrayList<>(1);
filterProps.add(new FilterPropBoolean(RecordsManagementModel.PROP_IS_CLOSED, isClosed));
}
// TODO see how we can filter for categories that have retention schedule
// Boolean hasRetentionSchedule = propertyWalker.getProperty(RMNode.PARAM_HAS_RETENTION_SCHEDULE, WhereClauseParser.EQUALS, Boolean.class);
// if (hasRetentionSchedule != null)
// {
// filterProps = new ArrayList<>(1);
// }
}
return filterProps;
}
use of org.alfresco.repo.node.getchildren.FilterProp in project alfresco-remote-api by Alfresco.
the class NodesImpl method getListChildrenFilterProps.
/**
* <p>Returns a List of filter properties specified by request parameters.</p>
*
* @param parameters The {@link Parameters} object to get the parameters passed into the request
* including:
* - filter, sort & paging params (where, orderBy, skipCount, maxItems)
* - incFiles, incFolders (both true by default)
* @return The list of {@link FilterProp}. Can be null.
*/
protected List<FilterProp> getListChildrenFilterProps(final Parameters parameters) {
List<FilterProp> filterProps = null;
Query q = parameters.getQuery();
if (q != null) {
MapBasedQueryWalker propertyWalker = createListChildrenQueryWalker();
QueryHelper.walk(q, propertyWalker);
Boolean isPrimary = propertyWalker.getProperty(PARAM_ISPRIMARY, WhereClauseParser.EQUALS, Boolean.class);
if (isPrimary != null) {
filterProps = new ArrayList<>(1);
filterProps.add(new FilterPropBoolean(GetChildrenCannedQuery.FILTER_QNAME_NODE_IS_PRIMARY, isPrimary));
}
}
return filterProps;
}
use of org.alfresco.repo.node.getchildren.FilterProp in project alfresco-remote-api by Alfresco.
the class SitesImpl method getSites.
public CollectionWithPagingInfo<Site> getSites(final Parameters parameters) {
final BeanPropertiesFilter filter = parameters.getFilter();
Paging paging = parameters.getPaging();
PagingRequest pagingRequest = Util.getPagingRequest(paging);
// pagingRequest.setRequestTotalCountMax(requestTotalCountMax)
List<Pair<QName, Boolean>> sortProps = new ArrayList<Pair<QName, Boolean>>();
List<SortColumn> sortCols = parameters.getSorting();
if ((sortCols != null) && (sortCols.size() > 0)) {
for (SortColumn sortCol : sortCols) {
QName sortPropQName = SORT_PARAMS_TO_QNAMES.get(sortCol.column);
if (sortPropQName == null) {
throw new InvalidArgumentException("Invalid sort field: " + sortCol.column);
}
sortProps.add(new Pair<>(sortPropQName, (sortCol.asc ? Boolean.TRUE : Boolean.FALSE)));
}
} else {
// default sort order
sortProps.add(new Pair<>(ContentModel.PROP_TITLE, Boolean.TRUE));
}
List<FilterProp> filterProps = getFilterPropListOfSites(parameters);
final PagingResults<SiteInfo> pagingResult = siteService.listSites(filterProps, sortProps, pagingRequest);
final List<SiteInfo> sites = pagingResult.getPage();
int totalItems = pagingResult.getTotalResultCount().getFirst();
final String personId = AuthenticationUtil.getFullyAuthenticatedUser();
List<Site> page = new AbstractList<Site>() {
@Override
public Site get(int index) {
SiteInfo siteInfo = sites.get(index);
String role = null;
if (filter.isAllowed(Site.ROLE)) {
role = siteService.getMembersRole(siteInfo.getShortName(), personId);
}
return new Site(siteInfo, role);
}
@Override
public int size() {
return sites.size();
}
};
return CollectionWithPagingInfo.asPaged(paging, page, pagingResult.hasMoreItems(), totalItems);
}
use of org.alfresco.repo.node.getchildren.FilterProp in project alfresco-remote-api by Alfresco.
the class SitesImpl method includeFilter.
// note: currently inclusive and OR-based
private boolean includeFilter(Map<QName, Serializable> propVals, List<FilterProp> filterProps) {
for (FilterProp filterProp : filterProps) {
Serializable propVal = propVals.get(filterProp.getPropName());
if (propVal != null) {
if ((filterProp instanceof FilterPropString) && (propVal instanceof String)) {
String val = (String) propVal;
String filter = (String) filterProp.getPropVal();
switch((FilterPropString.FilterTypeString) filterProp.getFilterType()) {
case STARTSWITH:
if (val.startsWith(filter)) {
return true;
}
break;
case STARTSWITH_IGNORECASE:
if (val.toLowerCase().startsWith(filter.toLowerCase())) {
return true;
}
break;
case EQUALS:
if (val.equals(filter)) {
return true;
}
break;
case EQUALS_IGNORECASE:
if (val.equalsIgnoreCase(filter)) {
return true;
}
break;
case ENDSWITH:
if (val.endsWith(filter)) {
return true;
}
break;
case ENDSWITH_IGNORECASE:
if (val.toLowerCase().endsWith(filter.toLowerCase())) {
return true;
}
break;
case MATCHES:
if (val.matches(filter)) {
return true;
}
break;
case MATCHES_IGNORECASE:
if (val.toLowerCase().matches(filter.toLowerCase())) {
return true;
}
break;
default:
}
}
}
if ((filterProp instanceof FilterPropBoolean) && (propVal instanceof Boolean)) {
Boolean val = (Boolean) propVal;
Boolean filter = (Boolean) filterProp.getPropVal();
return (val == filter);
}
}
return false;
}
use of org.alfresco.repo.node.getchildren.FilterProp in project alfresco-remote-api by Alfresco.
the class SiteAdminSitesGet method executeImpl.
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
// check the current user access rights
if (!siteService.isSiteAdmin(currentUser)) {
// Note: security, no message to indicate why
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Resource not found.");
}
// Create paging
final ScriptPagingDetails paging = new ScriptPagingDetails(getIntParameter(req, MAX_ITEMS, DEFAULT_MAX_ITEMS_PER_PAGE), getIntParameter(req, SKIP_COUNT, 0));
// request a total count of found items
paging.setRequestTotalCountMax(Integer.MAX_VALUE);
final List<FilterProp> filterProp = getFilterProperties(req.getParameter(NAME_FILTER));
final List<Pair<QName, Boolean>> sortProps = new ArrayList<Pair<QName, Boolean>>();
sortProps.add(new Pair<QName, Boolean>(ContentModel.PROP_NAME, true));
PagingResults<SiteInfo> pagingResults = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<PagingResults<SiteInfo>>() {
public PagingResults<SiteInfo> doWork() throws Exception {
return siteService.listSites(filterProp, sortProps, paging);
}
}, AuthenticationUtil.getAdminUserName());
List<SiteInfo> result = pagingResults.getPage();
List<SiteState> sites = new ArrayList<SiteState>(result.size());
for (SiteInfo info : result) {
sites.add(SiteState.create(info, siteService.listMembers(info.getShortName(), null, SiteModel.SITE_MANAGER, 0), currentUser, nodeService, personService));
}
Map<String, Object> sitesData = new HashMap<String, Object>(6);
// Site data
sitesData.put("items", sites);
// Paging data
sitesData.put("count", result.size());
sitesData.put("hasMoreItems", pagingResults.hasMoreItems());
sitesData.put("totalItems", (pagingResults.getTotalResultCount() == null ? -1 : pagingResults.getTotalResultCount().getFirst()));
sitesData.put("skipCount", paging.getSkipCount());
sitesData.put("maxItems", paging.getMaxItems());
// Create the model from the site and pagination data
Map<String, Object> model = new HashMap<String, Object>(1);
model.put("data", sitesData);
return model;
}
Aggregations