mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1144, Added max suggestions config, custom properties inclusion and made ui tests more robust
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@63260 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -7,7 +7,7 @@ rm.notification.role=RecordsManager
|
||||
|
||||
#
|
||||
# Turn off imap server attachments if we are using RM.
|
||||
# TODO : Longer term needs to have a query based, dynamic
|
||||
# TODO : Longer term needs to have a query based, dynamic
|
||||
# exclusion for RM sites.
|
||||
#
|
||||
imap.server.attachments.extraction.enabled=false
|
||||
@@ -25,13 +25,25 @@ cache.writersSharedCache.maxItems=10000
|
||||
|
||||
#
|
||||
# Global RM admin default bootstrap details
|
||||
#
|
||||
#
|
||||
# Note: rmadmin is created with a randomly generated password. This can be changed by 'admin' if
|
||||
# required.
|
||||
#
|
||||
bootstrap.rmadmin.name=rmadmin
|
||||
|
||||
#
|
||||
#
|
||||
# Indicates whether RM rules will be run as RM Admin or not by default
|
||||
#
|
||||
rm.rule.runasrmadmin=true
|
||||
rm.rule.runasrmadmin=true
|
||||
|
||||
#
|
||||
# Auto-complete suggestion parameters
|
||||
#
|
||||
# The minimum size of fragment supplied that will trigger a search for suggestions for auto completion
|
||||
rm.autocompletesuggestion.minfragmentsize=2
|
||||
# The maximum number of path suggestions to supply
|
||||
rm.autocompletesuggestion.maxsuggestions.path=5
|
||||
# The maximum number of node suggestions to supply
|
||||
rm.autocompletesuggestion.maxsuggestions.node=5
|
||||
# The maximum number of date suggestions to supply
|
||||
rm.autocompletesuggestion.maxsuggestions.date=5
|
||||
|
@@ -24,7 +24,7 @@
|
||||
<ref bean="patch.migrateTenantsFromAttrsToTable" />
|
||||
<ref bean="patch.migrateAttrTenants" />
|
||||
</list>
|
||||
</property>
|
||||
</property>
|
||||
</bean> -->
|
||||
|
||||
<bean id="ExtendedPermissionService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
@@ -43,7 +43,7 @@
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="ExtendedPermissionService_security" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor">
|
||||
<property name="authenticationManager"><ref bean="authenticationManager"/></property>
|
||||
<property name="accessDecisionManager"><ref bean="accessDecisionManager"/></property>
|
||||
@@ -69,11 +69,11 @@
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean name="writersSharedCache" class="org.alfresco.repo.cache.DefaultSimpleCache">
|
||||
<property name="maxItems" value="${cache.writersSharedCache.maxItems}"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean name="writersCache" class="org.alfresco.repo.cache.TransactionalCache">
|
||||
<property name="sharedCache">
|
||||
<ref bean="writersSharedCache" />
|
||||
@@ -138,36 +138,36 @@
|
||||
</bean>
|
||||
|
||||
<bean id="extendedReaderDynamicAuthority" class="org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority" />
|
||||
|
||||
|
||||
<bean id="extendedWriterDynamicAuthority" class="org.alfresco.module.org_alfresco_module_rm.security.ExtendedWriterDynamicAuthority" />
|
||||
|
||||
|
||||
<!-- Action Service -->
|
||||
<bean id="actionService" class="org.alfresco.repo.action.ExtendedActionServiceImpl" init-method="init">
|
||||
|
||||
|
||||
<property name="filePlanService" ref="FilePlanService" />
|
||||
|
||||
|
||||
<property name="policyComponent">
|
||||
<ref bean="policyComponent" />
|
||||
</property>
|
||||
</property>
|
||||
<property name="nodeService">
|
||||
<ref bean="NodeService" />
|
||||
</property>
|
||||
</property>
|
||||
<property name="searchService">
|
||||
<ref bean="ADMSearchService" />
|
||||
</property>
|
||||
</property>
|
||||
<property name="authenticationContext">
|
||||
<ref bean="authenticationContext" />
|
||||
</property>
|
||||
</property>
|
||||
<property name="actionTrackingService">
|
||||
<ref bean="actionTrackingService" />
|
||||
</property>
|
||||
</property>
|
||||
<property name="dictionaryService">
|
||||
<ref bean="DictionaryService" />
|
||||
</property>
|
||||
<property name="monitor">
|
||||
<ref bean="actionServiceMonitor"/>
|
||||
</property>
|
||||
|
||||
|
||||
<property name="asynchronousActionExecutionQueues">
|
||||
<map>
|
||||
<!-- This is the default async queue -->
|
||||
@@ -177,33 +177,52 @@
|
||||
<entry key="deployment">
|
||||
<ref bean="deploymentAsynchronousActionExecutionQueue"/>
|
||||
</entry>
|
||||
</map>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="parameterProcessorComponent" class="org.alfresco.repo.action.parameter.ParameterProcessorComponent"/>
|
||||
|
||||
|
||||
<bean id="baseParamenterProcessor" abstract="true" init-method="init">
|
||||
<property name="parameterProcessorComponent" ref="parameterProcessorComponent"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="nodeParameterProcessor" parent="baseParamenterProcessor" class="org.alfresco.repo.action.parameter.NodeParameterProcessor" >
|
||||
<property name="name" value="node" />
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
<property name="dictionaryService" ref="DictionaryService" />
|
||||
<property name="namespaceService" ref="NamespaceService" />
|
||||
<property name="name" value="node" />
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
<property name="dictionaryService" ref="DictionaryService" />
|
||||
<property name="namespaceService" ref="NamespaceService" />
|
||||
<property name="recordsManagementAdminService" ref="recordsManagementAdminService" />
|
||||
<property name="maximumNumberSuggestions">
|
||||
<value>${rm.autocompletesuggestion.maxsuggestions.node}</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<!-- Bootstrap node parameter processor -->
|
||||
<bean id="nodeParameterSuggesterBootstrap" class="org.alfresco.repo.action.parameter.NodeParameterSuggesterBootstrap" init-method="init">
|
||||
<property name="namespaceService" ref="namespaceService"/>
|
||||
<property name="nodeParameterProcessor" ref="nodeParameterProcessor"/>
|
||||
<property name="nodeParameterProcessorAspects">
|
||||
<list>
|
||||
<value>rma:record</value>
|
||||
<value>cm:content</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="dateParameterProcessor" parent="baseParamenterProcessor" class="org.alfresco.repo.action.parameter.DateParameterProcessor">
|
||||
<property name="name" value="date" />
|
||||
<property name="name" value="date" />
|
||||
<property name="maximumNumberSuggestions">
|
||||
<value>${rm.autocompletesuggestion.maxsuggestions.date}</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="messageParameterProcessor" parent="baseParamenterProcessor" class="org.alfresco.repo.action.parameter.MessageParameterProcessor">
|
||||
<property name="name" value="message" />
|
||||
<property name="name" value="message" />
|
||||
</bean>
|
||||
|
||||
|
||||
<!-- Rule Service -->
|
||||
|
||||
|
||||
<bean id="ruleService" class="org.alfresco.repo.rule.ExtendedRuleServiceImpl" init-method="init">
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="nodeService2" ref="NodeService"/>
|
||||
@@ -218,16 +237,16 @@
|
||||
<property name="rulesDisabled">
|
||||
<value>false</value>
|
||||
</property>
|
||||
|
||||
|
||||
<!-- Since RM 2.1 -->
|
||||
<property name="filePlanAuthenticationService" ref="FilePlanAuthenticationService"/>
|
||||
<property name="filePlanService" ref="FilePlanService" />
|
||||
<property name="runAsRmAdmin">
|
||||
<value>${rm.rule.runasrmadmin}</value>
|
||||
</property>
|
||||
|
||||
</property>
|
||||
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="FormService_security" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor">
|
||||
<property name="authenticationManager"><ref bean="authenticationManager"/></property>
|
||||
<property name="accessDecisionManager"><ref bean="accessDecisionManager"/></property>
|
||||
@@ -240,14 +259,14 @@
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="searchScript" parent="baseJavaScriptExtension" class="org.alfresco.repo.jscript.ExtendedSearch">
|
||||
<property name="extensionName">
|
||||
<value>search</value>
|
||||
</property>
|
||||
<property name="searchSubsystemSwitchableApplicationContextFactory">
|
||||
<ref bean="Search" />
|
||||
</property>
|
||||
</property>
|
||||
<property name="serviceRegistry">
|
||||
<ref bean="ServiceRegistry"/>
|
||||
</property>
|
||||
@@ -258,11 +277,11 @@
|
||||
<value>${spaces.store}</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="on-delete-child-association-trigger" class="org.alfresco.repo.rule.ruletrigger.ExtendedBeforeDeleteChildAssociationRuleTrigger" parent="rule-trigger-base">
|
||||
<property name="executeRuleImmediately">
|
||||
<value>true</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
||||
</beans>
|
@@ -576,6 +576,12 @@
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="filePlanService" ref="FilePlanService" />
|
||||
<property name="capabilityService" ref="CapabilityService" />
|
||||
<property name="substitutionMinimumFragmentSize">
|
||||
<value>${rm.autocompletesuggestion.minfragmentsize}</value>
|
||||
</property>
|
||||
<property name="pathSubstitutionMaximumNumberSuggestions">
|
||||
<value>${rm.autocompletesuggestion.maxsuggestions.path}</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
@@ -61,6 +61,8 @@ public class DateParameterProcessor extends ParameterProcessor implements Parame
|
||||
YEAR + SEP + WEEK
|
||||
};
|
||||
|
||||
private int maximumNumberSuggestions = DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.parameter.ParameterProcessor#process(java.lang.String, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@@ -194,6 +196,19 @@ public class DateParameterProcessor extends ParameterProcessor implements Parame
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maxmimum number of suggestions returned from the global property
|
||||
*
|
||||
* @param maximumNumberSuggestions
|
||||
*/
|
||||
public void setMaximumNumberSuggestions(int maximumNumberSuggestions)
|
||||
{
|
||||
this.maximumNumberSuggestions = (maximumNumberSuggestions <= 0 ? DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS: maximumNumberSuggestions);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.action.parameter.ParameterSubstitutionSuggester#getSubstitutionSuggestions(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getSubstitutionSuggestions(String substitutionFragment)
|
||||
{
|
||||
@@ -203,6 +218,10 @@ public class DateParameterProcessor extends ParameterProcessor implements Parame
|
||||
{
|
||||
for(String field: ALL_FIELDS_FOR_SUBSTITUTION_QUERY) {
|
||||
suggestions.add(namePrefix + field);
|
||||
if(suggestions.size() >= maximumNumberSuggestions)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -212,6 +231,10 @@ public class DateParameterProcessor extends ParameterProcessor implements Parame
|
||||
if(prefixFieldName.toLowerCase().contains(substitutionFragment.toLowerCase()))
|
||||
{
|
||||
suggestions.add(namePrefix + field);
|
||||
if(suggestions.size() >= maximumNumberSuggestions)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,12 +20,15 @@ package org.alfresco.repo.action.parameter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
@@ -56,6 +59,8 @@ public class NodeParameterProcessor extends ParameterProcessor implements Parame
|
||||
DataTypeDefinition.MLTEXT
|
||||
};
|
||||
|
||||
private int maximumNumberSuggestions = DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS;
|
||||
|
||||
/** Node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
@@ -65,6 +70,12 @@ public class NodeParameterProcessor extends ParameterProcessor implements Parame
|
||||
/** Dictionary service */
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
/** Records management admin service */
|
||||
private RecordsManagementAdminService recordsManagementAdminService;
|
||||
|
||||
/** List of definitions (aspects and types) to use for substitution suggestions */
|
||||
private List<QName> suggestionDefinitions = null;
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
*/
|
||||
@@ -89,6 +100,14 @@ public class NodeParameterProcessor extends ParameterProcessor implements Parame
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param recordsManagementAdminService Records management admin service
|
||||
*/
|
||||
public void setRecordsManagementAdminService(RecordsManagementAdminService recordsManagementAdminService)
|
||||
{
|
||||
this.recordsManagementAdminService = recordsManagementAdminService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.parameter.ParameterProcessor#process(java.lang.String, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@@ -133,6 +152,30 @@ public class NodeParameterProcessor extends ParameterProcessor implements Parame
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maxmimum number of suggestions returned from the global property
|
||||
*
|
||||
* @param maximumNumberSuggestions
|
||||
*/
|
||||
public void setMaximumNumberSuggestions(int maximumNumberSuggestions)
|
||||
{
|
||||
this.maximumNumberSuggestions = (maximumNumberSuggestions <= 0 ? DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS: maximumNumberSuggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add suggestion definition to the list used to get properties suggestions from.
|
||||
*
|
||||
* @param definition Type or aspect
|
||||
*/
|
||||
public void addSuggestionDefinition(QName definition)
|
||||
{
|
||||
if(this.suggestionDefinitions == null)
|
||||
{
|
||||
this.suggestionDefinitions = Collections.synchronizedList(new ArrayList<QName>());
|
||||
}
|
||||
this.suggestionDefinitions.add(definition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of node substitution suggestions for the specified fragment.
|
||||
*
|
||||
@@ -144,39 +187,108 @@ public class NodeParameterProcessor extends ParameterProcessor implements Parame
|
||||
@Override
|
||||
public List<String> getSubstitutionSuggestions(String substitutionFragment)
|
||||
{
|
||||
Set<String> suggestionSet = Collections.synchronizedSet(new HashSet<String>());
|
||||
if(this.suggestionDefinitions != null)
|
||||
{
|
||||
for(QName definition : this.suggestionDefinitions)
|
||||
{
|
||||
if(getSubstitutionSuggestions(definition, substitutionFragment.toLowerCase(), suggestionSet))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> suggestions = new ArrayList<String>();
|
||||
getSubstitutionSuggestions(RecordsManagementModel.ASPECT_RECORD, substitutionFragment.toLowerCase(), suggestions);
|
||||
suggestions.addAll(suggestionSet);
|
||||
Collections.sort(suggestions);
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of node substitution suggestions for the given aspect specified fragment. Calls itself recursively for
|
||||
* associated aspects.
|
||||
* Get a list of node substitution suggestions for the given definition and specified fragment.
|
||||
*
|
||||
* @param aspect Aspect to get properties of and the call this method for associated aspects
|
||||
* @param definitionName Definition (aspect or type) to get properties of and the call this method for associated aspects
|
||||
* @param substitutionFragment Substitution fragment to search for
|
||||
* @param suggestions The current list of suggestions to which we will add newly found suggestions
|
||||
*/
|
||||
private void getSubstitutionSuggestions(QName aspect, String substitutionFragment, List<String> suggestions)
|
||||
private boolean getSubstitutionSuggestions(QName definitionName, String substitutionFragment, Set<String> suggestions)
|
||||
{
|
||||
AspectDefinition recordAspect = this.dictionaryService.getAspect(aspect);
|
||||
Map<QName, PropertyDefinition> properties = recordAspect.getProperties();
|
||||
for(QName key : properties.keySet())
|
||||
boolean gotMaximumSuggestions = false;
|
||||
ClassDefinition definition = this.dictionaryService.getAspect(definitionName);
|
||||
if(definition == null)
|
||||
{
|
||||
PropertyDefinition propertyDefinition = properties.get(key);
|
||||
QName type = propertyDefinition.getDataType().getName();
|
||||
if(ArrayUtils.contains(supportedDataTypes, type))
|
||||
definition = this.dictionaryService.getType(definitionName);
|
||||
}
|
||||
if(definition != null)
|
||||
{
|
||||
gotMaximumSuggestions = getSubstitutionSuggestionsForDefinition(definition, substitutionFragment, suggestions);
|
||||
}
|
||||
if(recordsManagementAdminService.isCustomisable(definitionName) && !gotMaximumSuggestions)
|
||||
{
|
||||
gotMaximumSuggestions = processPropertyDefinitions(recordsManagementAdminService.getCustomPropertyDefinitions(definitionName), substitutionFragment, suggestions);
|
||||
}
|
||||
return gotMaximumSuggestions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of node substitution suggestions for the given definition and specified fragment. Calls itself recursively for
|
||||
* associated aspects.
|
||||
*
|
||||
* @param definition Definition (aspect or type) to get properties of and the call this method for associated aspects
|
||||
* @param substitutionFragment Substitution fragment to search for
|
||||
* @param suggestions The current list of suggestions to which we will add newly found suggestions
|
||||
*/
|
||||
private boolean getSubstitutionSuggestionsForDefinition(ClassDefinition definition, String substitutionFragment, Set<String> suggestions)
|
||||
{
|
||||
boolean gotMaximumSuggestions = processPropertyDefinitions(definition.getProperties(), substitutionFragment, suggestions);
|
||||
if(!gotMaximumSuggestions)
|
||||
{
|
||||
for(QName defaultAspect : definition.getDefaultAspectNames())
|
||||
{
|
||||
String suggestion = "node." + key.getPrefixString();
|
||||
if(suggestion.toLowerCase().contains(substitutionFragment))
|
||||
gotMaximumSuggestions = getSubstitutionSuggestions(defaultAspect, substitutionFragment, suggestions);
|
||||
if(gotMaximumSuggestions)
|
||||
{
|
||||
suggestions.add(suggestion);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(QName defaultAspect : recordAspect.getDefaultAspectNames())
|
||||
return gotMaximumSuggestions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the supplied map of property definitions and add the ones that match the supplied fragment to the list of suggestions.
|
||||
*
|
||||
* @param definition Definition (aspect or type) to get properties of and the call this method for associated aspects
|
||||
* @param substitutionFragment Substitution fragment to search for
|
||||
* @param suggestions The current list of suggestions to which we will add newly found suggestions
|
||||
*/
|
||||
private boolean processPropertyDefinitions(Map<QName, PropertyDefinition> properties, String substitutionFragment, Set<String> suggestions)
|
||||
{
|
||||
boolean gotMaximumSuggestions = false;
|
||||
if(properties != null)
|
||||
{
|
||||
getSubstitutionSuggestions(defaultAspect, substitutionFragment, suggestions);
|
||||
for(QName key : properties.keySet())
|
||||
{
|
||||
PropertyDefinition propertyDefinition = properties.get(key);
|
||||
QName type = propertyDefinition.getDataType().getName();
|
||||
if(ArrayUtils.contains(supportedDataTypes, type))
|
||||
{
|
||||
String suggestion = getName() + "." + key.getPrefixString();
|
||||
if(suggestion.toLowerCase().contains(substitutionFragment))
|
||||
{
|
||||
if(suggestions.size() < this.maximumNumberSuggestions)
|
||||
{
|
||||
suggestions.add(suggestion);
|
||||
}
|
||||
else
|
||||
{
|
||||
gotMaximumSuggestions = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return gotMaximumSuggestions;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.action.parameter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* Record metadata bootstrap bean.
|
||||
* <p>
|
||||
* This method of bootstrapping record metadata aspects into the RecordService deprecates the
|
||||
* previous practice of extending rma:recordMetaData.
|
||||
*
|
||||
* @author Mark Hibbins
|
||||
* @since 2.2
|
||||
*/
|
||||
public class NodeParameterSuggesterBootstrap
|
||||
{
|
||||
/** namespace service */
|
||||
private NamespaceService namespaceService;
|
||||
|
||||
/** map of record metadata aspects against file plan type */
|
||||
private List<String> nodeParameterProcessorAspectsNames;
|
||||
|
||||
/** node parameter processor */
|
||||
private NodeParameterProcessor nodeParameterProcessor;
|
||||
|
||||
/**
|
||||
* @param recordMetadataAspects map of record metadata aspects against file plan types
|
||||
*/
|
||||
public void setNodeParameterProcessorAspects(List<String> nodeParameterProcessorAspectsNames)
|
||||
{
|
||||
this.nodeParameterProcessorAspectsNames = nodeParameterProcessorAspectsNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespaceService namespace service
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeParameterProcessor Node parameter processor
|
||||
*/
|
||||
public void setNodeParameterProcessor(NodeParameterProcessor nodeParameterProcessor)
|
||||
{
|
||||
this.nodeParameterProcessor = nodeParameterProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
ParameterCheck.mandatory("namespaceService", namespaceService);
|
||||
|
||||
if (nodeParameterProcessorAspectsNames != null)
|
||||
{
|
||||
for (String name : nodeParameterProcessorAspectsNames)
|
||||
{
|
||||
// convert to qname and save it
|
||||
QName aspect = QName.createQName(name, namespaceService);
|
||||
|
||||
// register with node parameter processor
|
||||
this.nodeParameterProcessor.addSuggestionDefinition(aspect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -22,5 +22,7 @@ import java.util.List;
|
||||
|
||||
public interface ParameterSubstitutionSuggester
|
||||
{
|
||||
final static int DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS = 10;
|
||||
|
||||
public List<String> getSubstitutionSuggestions(final String substitutionFragment);
|
||||
}
|
||||
|
@@ -60,8 +60,11 @@ public class RmSubstitutionSuggestionsGet extends DeclarativeWebScript
|
||||
private final static String CREATE_CAPABILITY = "Create";
|
||||
private final static String VIEW_CAPABILITY = "ViewRecords";
|
||||
|
||||
private final static int PATH_SUBSTITUTION_MINIMUM_FRAGMENT_LENGTH = 0;
|
||||
private final static int PATH_SUBSTITUTION_MAXIMUM_NUMBER_RESULTS = 10;
|
||||
private final static int DEFAULT_SUBSTITUTION_MINIMUM_FRAGMENT_LENGTH = 0;
|
||||
private final static int DEFAULT_MAXIMUM_NUMBER_PATH_SUGGESTIONS = 10;
|
||||
|
||||
private int pathSubstitutionMaximumNumberSuggestions = DEFAULT_MAXIMUM_NUMBER_PATH_SUGGESTIONS;
|
||||
private int substitutionMinimumFragmentSize = DEFAULT_SUBSTITUTION_MINIMUM_FRAGMENT_LENGTH;
|
||||
|
||||
private ParameterProcessorComponent parameterProcessorComponent;
|
||||
private NodeService nodeService;
|
||||
@@ -104,6 +107,26 @@ public class RmSubstitutionSuggestionsGet extends DeclarativeWebScript
|
||||
this.capabilityService = capabilityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the minimum fragment size to process for suggestion processing
|
||||
*
|
||||
* @param maximumNumberSuggestions
|
||||
*/
|
||||
public void setSubstitutionMinimumFragmentSize(int substitutionMinimumFragmentSize)
|
||||
{
|
||||
this.substitutionMinimumFragmentSize = Math.max(substitutionMinimumFragmentSize, DEFAULT_SUBSTITUTION_MINIMUM_FRAGMENT_LENGTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maxmimum number of suggestions returned from the global property
|
||||
*
|
||||
* @param maximumNumberSuggestions
|
||||
*/
|
||||
public void setPathSubstitutionMaximumNumberSuggestions(int pathSubstitutionMaximumNumberSuggestions)
|
||||
{
|
||||
this.pathSubstitutionMaximumNumberSuggestions = (pathSubstitutionMaximumNumberSuggestions <= 0 ? DEFAULT_MAXIMUM_NUMBER_PATH_SUGGESTIONS: pathSubstitutionMaximumNumberSuggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of substitutions for the given fragment.
|
||||
*
|
||||
@@ -119,8 +142,11 @@ public class RmSubstitutionSuggestionsGet extends DeclarativeWebScript
|
||||
|
||||
List<String> substitutionSuggestions = new ArrayList<String>();
|
||||
|
||||
substitutionSuggestions.addAll(getSubPathSuggestions(req, path, fragment));
|
||||
substitutionSuggestions.addAll(this.parameterProcessorComponent.getSubstitutionSuggestions(fragment));
|
||||
if((fragment != null) && (fragment.length() >= this.substitutionMinimumFragmentSize))
|
||||
{
|
||||
substitutionSuggestions.addAll(getSubPathSuggestions(req, path, fragment));
|
||||
substitutionSuggestions.addAll(this.parameterProcessorComponent.getSubstitutionSuggestions(fragment));
|
||||
}
|
||||
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put(SUBSTITUTIONS_MODEL_KEY, substitutionSuggestions);
|
||||
@@ -137,7 +163,7 @@ public class RmSubstitutionSuggestionsGet extends DeclarativeWebScript
|
||||
*/
|
||||
private List<String> getSubPathSuggestions(WebScriptRequest req, final String path, final String fragment) {
|
||||
List<String> pathSuggestions = new ArrayList<String>();
|
||||
if((path != null) && path.startsWith("/") && (fragment != null) && (fragment.length() >= PATH_SUBSTITUTION_MINIMUM_FRAGMENT_LENGTH))
|
||||
if((path != null) && path.startsWith("/") && (fragment != null))
|
||||
{
|
||||
String[] pathFragments = path.split("/");
|
||||
|
||||
@@ -177,7 +203,7 @@ public class RmSubstitutionSuggestionsGet extends DeclarativeWebScript
|
||||
if((fragment.isEmpty() || fileName.toLowerCase().startsWith(lowerCaseFragment)) && isNodeRefAppropriateForPathSuggestion(childNodeRef))
|
||||
{
|
||||
pathSuggestions.add("/" + fileName);
|
||||
if(pathSuggestions.size() >= PATH_SUBSTITUTION_MAXIMUM_NUMBER_RESULTS)
|
||||
if(pathSuggestions.size() >= pathSubstitutionMaximumNumberSuggestions)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ public class DateParameterProcessorTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubstitutionSuggestions_All_01()
|
||||
public void testGetSubstitutionSuggestions_01()
|
||||
{
|
||||
List<String> suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("date");
|
||||
assertTrue(suggestions.contains("date.day.short"));
|
||||
@@ -56,14 +56,11 @@ public class DateParameterProcessorTest
|
||||
assertTrue(suggestions.contains("date.month.long"));
|
||||
assertTrue(suggestions.contains("date.month.number"));
|
||||
assertTrue(suggestions.contains("date.year.short"));
|
||||
assertTrue(suggestions.contains("date.year"));
|
||||
assertTrue(suggestions.contains("date.year.long"));
|
||||
assertTrue(suggestions.contains("date.year.week"));
|
||||
assertEquals(13, suggestions.size());
|
||||
assertEquals(10, suggestions.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubstitutionSuggestions_All_02()
|
||||
public void testGetSubstitutionSuggestions_02()
|
||||
{
|
||||
List<String> suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("dat");
|
||||
assertTrue(suggestions.contains("date.day.short"));
|
||||
@@ -76,14 +73,11 @@ public class DateParameterProcessorTest
|
||||
assertTrue(suggestions.contains("date.month.long"));
|
||||
assertTrue(suggestions.contains("date.month.number"));
|
||||
assertTrue(suggestions.contains("date.year.short"));
|
||||
assertTrue(suggestions.contains("date.year"));
|
||||
assertTrue(suggestions.contains("date.year.long"));
|
||||
assertTrue(suggestions.contains("date.year.week"));
|
||||
assertEquals(13, suggestions.size());
|
||||
assertEquals(10, suggestions.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubstitutionSuggestions_All_03()
|
||||
public void testGetSubstitutionSuggestions_03()
|
||||
{
|
||||
List<String> suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("at");
|
||||
assertTrue(suggestions.contains("date.day.short"));
|
||||
@@ -96,14 +90,11 @@ public class DateParameterProcessorTest
|
||||
assertTrue(suggestions.contains("date.month.long"));
|
||||
assertTrue(suggestions.contains("date.month.number"));
|
||||
assertTrue(suggestions.contains("date.year.short"));
|
||||
assertTrue(suggestions.contains("date.year"));
|
||||
assertTrue(suggestions.contains("date.year.long"));
|
||||
assertTrue(suggestions.contains("date.year.week"));
|
||||
assertEquals(13, suggestions.size());
|
||||
assertEquals(10, suggestions.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubstitutionSuggestions_Partial_01()
|
||||
public void testGetSubstitutionSuggestions_05()
|
||||
{
|
||||
List<String> suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("ay");
|
||||
assertTrue(suggestions.contains("date.day.short"));
|
||||
@@ -115,7 +106,7 @@ public class DateParameterProcessorTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubstitutionSuggestions_Partial_02()
|
||||
public void testGetSubstitutionSuggestions_06()
|
||||
{
|
||||
List<String> suggestions = this.dateParameterProcessor.getSubstitutionSuggestions("on");
|
||||
assertTrue(suggestions.contains("date.day.long"));
|
||||
@@ -126,5 +117,4 @@ public class DateParameterProcessorTest
|
||||
assertTrue(suggestions.contains("date.year.long"));
|
||||
assertEquals(6, suggestions.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user