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;
}
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;
}
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;
}
Aggregations