use of org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker in project alfresco-remote-api by Alfresco.
the class AbstractNodeRelation method getAssocTypeFromWhereElseAll.
protected QNamePattern getAssocTypeFromWhereElseAll(Parameters parameters) {
QNamePattern assocTypeQNamePattern = RegexQNamePattern.MATCH_ALL;
Query q = parameters.getQuery();
if (q != null) {
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(WHERE_PARAMS_ASSOC_TYPE, null);
QueryHelper.walk(q, propertyWalker);
String assocTypeQNameStr = propertyWalker.getProperty(Nodes.PARAM_ASSOC_TYPE, WhereClauseParser.EQUALS, String.class);
if (assocTypeQNameStr != null) {
assocTypeQNamePattern = nodes.getAssocType(assocTypeQNameStr);
}
}
return assocTypeQNamePattern;
}
use of org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker in project alfresco-remote-api by Alfresco.
the class NodeParentsRelation method readAll.
/**
* List child node's parent(s) based on (parent ->) child associations.
* Returns primary parent & also secondary parents, if any.
*
* @param childNodeId String id of child node
*/
@Override
@WebApiDescription(title = "Return a list of parent nodes based on child assocs")
public CollectionWithPagingInfo<Node> readAll(String childNodeId, Parameters parameters) {
NodeRef childNodeRef = nodes.validateOrLookupNode(childNodeId, null);
QNamePattern assocTypeQNameParam = RegexQNamePattern.MATCH_ALL;
Boolean isPrimary = null;
Query q = parameters.getQuery();
if (q != null) {
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(WHERE_PARAMS_PARENTS, null);
QueryHelper.walk(q, propertyWalker);
isPrimary = propertyWalker.getProperty(Nodes.PARAM_ISPRIMARY, WhereClauseParser.EQUALS, Boolean.class);
String assocTypeQNameStr = propertyWalker.getProperty(Nodes.PARAM_ASSOC_TYPE, WhereClauseParser.EQUALS, String.class);
if (assocTypeQNameStr != null) {
assocTypeQNameParam = nodes.getAssocType(assocTypeQNameStr);
}
}
List<ChildAssociationRef> childAssocRefs = null;
if (assocTypeQNameParam.equals(RegexQNamePattern.MATCH_ALL)) {
childAssocRefs = nodeService.getParentAssocs(childNodeRef);
} else {
childAssocRefs = nodeService.getParentAssocs(childNodeRef, assocTypeQNameParam, RegexQNamePattern.MATCH_ALL);
}
return listNodeChildAssocs(childAssocRefs, parameters, isPrimary, false);
}
use of org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker in project records-management by Alfresco.
the class SearchTypesFactory method buildSearchTypesCategoriesEndpoint.
/**
* Helper method to build search types for categories endpoint
* @param parameters
* @param listRecordCategoryChildrenEqualsQueryProperties
* @return
*/
public Set<QName> buildSearchTypesCategoriesEndpoint(Parameters parameters, Set<String> listRecordCategoryChildrenEqualsQueryProperties) {
Set<QName> searchTypeQNames = new HashSet<>();
Query q = parameters.getQuery();
boolean includeRecordFolders = false;
boolean includeRecordCategories = false;
if (q != null) {
// filtering via "where" clause
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(listRecordCategoryChildrenEqualsQueryProperties, null);
QueryHelper.walk(q, propertyWalker);
Boolean isRecordFolder = propertyWalker.getProperty(RecordCategoryChild.PARAM_IS_RECORD_FOLDER, WhereClauseParser.EQUALS, Boolean.class);
Boolean isRecordCategory = propertyWalker.getProperty(RecordCategoryChild.PARAM_IS_RECORD_CATEGORY, WhereClauseParser.EQUALS, Boolean.class);
if ((isRecordFolder != null && isRecordFolder.booleanValue()) || (isRecordCategory != null && !isRecordCategory.booleanValue())) {
includeRecordFolders = true;
} else if ((isRecordFolder != null && !isRecordFolder.booleanValue()) || (isRecordCategory != null && isRecordCategory.booleanValue())) {
includeRecordCategories = true;
}
String nodeTypeQNameStr = propertyWalker.getProperty(RecordCategoryChild.PARAM_NODE_TYPE, WhereClauseParser.EQUALS, String.class);
QName filterNodeTypeQName;
if (nodeTypeQNameStr != null) {
if ((isRecordFolder != null) || (isRecordCategory != null)) {
throw new InvalidArgumentException("Invalid filter - nodeType and isRecordFolder/isRecordCategory are mutually exclusive");
}
Pair<QName, Boolean> pair = parseNodeTypeFilter(nodeTypeQNameStr);
filterNodeTypeQName = pair.getFirst();
if (nodeTypeQNameStr.equals(RecordsManagementModel.TYPE_RECORD_FOLDER)) {
includeRecordFolders = true;
} else if (filterNodeTypeQName.equals(RecordsManagementModel.TYPE_RECORD_CATEGORY)) {
includeRecordCategories = true;
} else {
throw new InvalidParameterException("Filter nodeType: " + nodeTypeQNameStr + " is invalid for this endpoint");
}
}
} else {
includeRecordCategories = true;
includeRecordFolders = true;
}
if (includeRecordFolders) {
searchTypeQNames.add(RecordsManagementModel.TYPE_RECORD_FOLDER);
}
if (includeRecordCategories) {
searchTypeQNames.add(RecordsManagementModel.TYPE_RECORD_CATEGORY);
}
return searchTypeQNames;
}
use of org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker in project records-management by Alfresco.
the class SearchTypesFactory method buildSearchTypesForUnfiledEndpoint.
/**
* Helper method to build search types for unfiled container and unfiled record folders endpoints
* @param parameters
* @param listFolderChildrenEqualsQueryProperties
* @return
*/
public Set<QName> buildSearchTypesForUnfiledEndpoint(Parameters parameters, Set<String> listFolderChildrenEqualsQueryProperties) {
Set<QName> searchTypeQNames = new HashSet<>();
Query q = parameters.getQuery();
boolean includeUnfiledRecordFolders = false;
boolean includeRecords = false;
boolean includeSubTypes = false;
if (q != null) {
// filtering via "where" clause
MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(listFolderChildrenEqualsQueryProperties, null);
QueryHelper.walk(q, propertyWalker);
Boolean isUnfiledRecordFolder = propertyWalker.getProperty(UnfiledChild.PARAM_IS_UNFILED_RECORD_FOLDER, WhereClauseParser.EQUALS, Boolean.class);
Boolean isRecord = propertyWalker.getProperty(UnfiledChild.PARAM_IS_RECORD, WhereClauseParser.EQUALS, Boolean.class);
if ((isUnfiledRecordFolder != null && isUnfiledRecordFolder.booleanValue()) || (isRecord != null && !isRecord.booleanValue())) {
includeUnfiledRecordFolders = true;
} else if ((isUnfiledRecordFolder != null && !isUnfiledRecordFolder.booleanValue()) || (isRecord != null && isRecord.booleanValue())) {
includeRecords = true;
}
String nodeTypeQNameStr = propertyWalker.getProperty(UnfiledChild.PARAM_NODE_TYPE, WhereClauseParser.EQUALS, String.class);
QName filterNodeTypeQName;
if (nodeTypeQNameStr != null) {
if ((isUnfiledRecordFolder != null) || (isRecord != null)) {
throw new InvalidArgumentException("Invalid filter - nodeType and isUnfiledRecordFolder/isRecord are mutually exclusive");
}
Pair<QName, Boolean> pair = parseNodeTypeFilter(nodeTypeQNameStr);
filterNodeTypeQName = pair.getFirst();
includeSubTypes = pair.getSecond();
if (nodeTypeQNameStr.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER)) {
includeUnfiledRecordFolders = true;
} else if (filterNodeTypeQName.equals(ContentModel.TYPE_CONTENT)) {
includeRecords = true;
} else if (dictionaryService.isSubClass(filterNodeTypeQName, ContentModel.TYPE_CONTENT)) {
searchTypeQNames.add(filterNodeTypeQName);
if (includeSubTypes) {
Collection<QName> qnames = dictionaryService.getSubTypes(filterNodeTypeQName, true);
searchTypeQNames.addAll(qnames);
}
} else {
throw new InvalidParameterException("Filter nodeType: " + nodeTypeQNameStr + " is invalid for this endpoint");
}
}
} else {
includeRecords = true;
includeUnfiledRecordFolders = true;
includeSubTypes = true;
}
if (includeUnfiledRecordFolders) {
searchTypeQNames.add(RecordsManagementModel.TYPE_UNFILED_RECORD_FOLDER);
}
if (includeRecords) {
if (includeSubTypes) {
Collection<QName> qnames = dictionaryService.getSubTypes(ContentModel.TYPE_CONTENT, true);
searchTypeQNames.addAll(qnames);
} else {
searchTypeQNames.add(ContentModel.TYPE_CONTENT);
searchTypeQNames.add(RecordsManagementModel.TYPE_NON_ELECTRONIC_DOCUMENT);
}
}
return searchTypeQNames;
}
use of org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker 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;
}
Aggregations