mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-2130 (Post method invocation processor for QueryEngineResults)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/ENFORCE@107252 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -98,30 +98,6 @@ public class PostMethodInvocationProcessor
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the processor from the available processors.
|
||||
*
|
||||
* @param clazz The class of the post invocation object.
|
||||
* @return The suitable processor for the given class.
|
||||
*/
|
||||
protected BasePostMethodInvocationProcessor getProcessorForClass(Class<? extends Object> clazz)
|
||||
{
|
||||
mandatory("clazz", clazz);
|
||||
BasePostMethodInvocationProcessor result = null;
|
||||
|
||||
Set<Entry<Class<?>, BasePostMethodInvocationProcessor>> processorsEntrySet = getProcessors().entrySet();
|
||||
for (Map.Entry<Class<?>, BasePostMethodInvocationProcessor> processorEntry : processorsEntrySet)
|
||||
{
|
||||
if (processorEntry.getKey().isAssignableFrom(clazz))
|
||||
{
|
||||
result = processorEntry.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the given object
|
||||
*
|
||||
|
@@ -20,6 +20,7 @@ package org.alfresco.module.org_alfresco_module_rm.classification.interceptor.pr
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.search.impl.querymodel.QueryEngineResults;
|
||||
@@ -33,35 +34,42 @@ import org.alfresco.service.cmr.search.ResultSet;
|
||||
*/
|
||||
public class QueryEngineResultsPostMethodInvocationProcessor extends BasePostMethodInvocationProcessor
|
||||
{
|
||||
/** The post method invocation processor for {@link ResultSet ResultSets}. */
|
||||
private BasePostMethodInvocationProcessor resultSetProcessor;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#getClassName()
|
||||
*/
|
||||
@Override
|
||||
protected Class<QueryEngineResults> getClassName()
|
||||
{
|
||||
return QueryEngineResults.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.BasePostMethodInvocationProcessor#process(java.lang.Object)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T process(T object)
|
||||
{
|
||||
if (resultSetProcessor == null)
|
||||
{
|
||||
resultSetProcessor = getPostMethodInvocationProcessor().getProcessorForClass(ResultSet.class);
|
||||
}
|
||||
|
||||
QueryEngineResults queryEngineResults = getClassName().cast(object);
|
||||
Map<Set<String>, ResultSet> resultsMap = queryEngineResults.getResults();
|
||||
Map<Set<String>, ResultSet> returnMap = new HashMap<>();
|
||||
for (Set<String> key : resultsMap.keySet())
|
||||
BasePostMethodInvocationProcessor processor = null;
|
||||
|
||||
for (Entry<Set<String>, ResultSet> entry : resultsMap.entrySet())
|
||||
{
|
||||
ResultSet newResultSet = resultSetProcessor.process(resultsMap.get(key));
|
||||
ResultSet value = entry.getValue();
|
||||
if (processor == null)
|
||||
{
|
||||
processor = getPostMethodInvocationProcessor().getProcessor(value);
|
||||
}
|
||||
|
||||
ResultSet newResultSet = processor.process(value);
|
||||
if (newResultSet != null)
|
||||
{
|
||||
returnMap.put(key, newResultSet);
|
||||
returnMap.put(entry.getKey(), newResultSet);
|
||||
}
|
||||
}
|
||||
|
||||
return (T) new QueryEngineResults(returnMap);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user