Search in sources :

Example 1 with FilterPropString

use of org.alfresco.repo.node.getchildren.FilterPropString 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 FilterPropString

use of org.alfresco.repo.node.getchildren.FilterPropString 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;
}
Also used : Serializable(java.io.Serializable) FilterProp(org.alfresco.repo.node.getchildren.FilterProp) FilterPropBoolean(org.alfresco.repo.node.getchildren.FilterPropBoolean) FilterPropString(org.alfresco.repo.node.getchildren.FilterPropString) FilterPropBoolean(org.alfresco.repo.node.getchildren.FilterPropBoolean) FilterPropString(org.alfresco.repo.node.getchildren.FilterPropString)

Example 3 with FilterPropString

use of org.alfresco.repo.node.getchildren.FilterPropString in project alfresco-remote-api by Alfresco.

the class SiteAdminSitesGet method getFilterProperties.

private List<FilterProp> getFilterProperties(String filter) {
    if (filter == null || filter.isEmpty() || filter.equals("*")) {
        return null;
    }
    List<FilterProp> filterProps = new ArrayList<FilterProp>();
    filterProps.add(new FilterPropString(ContentModel.PROP_NAME, filter, FilterTypeString.STARTSWITH_IGNORECASE));
    filterProps.add(new FilterPropString(ContentModel.PROP_TITLE, filter, FilterTypeString.STARTSWITH_IGNORECASE));
    return filterProps;
}
Also used : FilterProp(org.alfresco.repo.node.getchildren.FilterProp) ArrayList(java.util.ArrayList) FilterPropString(org.alfresco.repo.node.getchildren.FilterPropString)

Aggregations

FilterProp (org.alfresco.repo.node.getchildren.FilterProp)3 FilterPropString (org.alfresco.repo.node.getchildren.FilterPropString)3 ArrayList (java.util.ArrayList)2 Serializable (java.io.Serializable)1 FilterPropBoolean (org.alfresco.repo.node.getchildren.FilterPropBoolean)1 Query (org.alfresco.rest.framework.resource.parameters.where.Query)1 MapBasedQueryWalkerOrSupported (org.alfresco.rest.workflow.api.impl.MapBasedQueryWalkerOrSupported)1 SiteVisibility (org.alfresco.service.cmr.site.SiteVisibility)1