mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1169, File-to path substitution to include node parameter
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@63051 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -19,8 +19,13 @@
|
|||||||
package org.alfresco.repo.action.parameter;
|
package org.alfresco.repo.action.parameter;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
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.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
@@ -36,7 +41,7 @@ import org.apache.commons.lang.ArrayUtils;
|
|||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public class NodeParameterProcessor extends ParameterProcessor
|
public class NodeParameterProcessor extends ParameterProcessor implements ParameterSubstitutionSuggester
|
||||||
{
|
{
|
||||||
/** Supported data types */
|
/** Supported data types */
|
||||||
private QName[] supportedDataTypes =
|
private QName[] supportedDataTypes =
|
||||||
@@ -127,4 +132,51 @@ public class NodeParameterProcessor extends ParameterProcessor
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of node substitution suggestions for the specified fragment.
|
||||||
|
*
|
||||||
|
* @param substitutionFragment The fragment to search for
|
||||||
|
* @returns A list of node substitution suggestions, for example 'node.cm:title'
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.action.parameter.ParameterSubstitutionSuggester#getSubstitutionSuggestions(java.lang.String)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<String> getSubstitutionSuggestions(String substitutionFragment)
|
||||||
|
{
|
||||||
|
List<String> suggestions = new ArrayList<String>();
|
||||||
|
getSubstitutionSuggestions(RecordsManagementModel.ASPECT_RECORD, substitutionFragment.toLowerCase(), suggestions);
|
||||||
|
return suggestions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of node substitution suggestions for the given aspect specified fragment. Calls itself recursively for
|
||||||
|
* associated aspects.
|
||||||
|
*
|
||||||
|
* @param aspect Aspect 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)
|
||||||
|
{
|
||||||
|
AspectDefinition recordAspect = this.dictionaryService.getAspect(aspect);
|
||||||
|
Map<QName, PropertyDefinition> properties = recordAspect.getProperties();
|
||||||
|
for(QName key : properties.keySet())
|
||||||
|
{
|
||||||
|
PropertyDefinition propertyDefinition = properties.get(key);
|
||||||
|
QName type = propertyDefinition.getDataType().getName();
|
||||||
|
if(ArrayUtils.contains(supportedDataTypes, type))
|
||||||
|
{
|
||||||
|
String suggestion = "node." + key.getPrefixString();
|
||||||
|
if(suggestion.toLowerCase().contains(substitutionFragment))
|
||||||
|
{
|
||||||
|
suggestions.add(suggestion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(QName defaultAspect : recordAspect.getDefaultAspectNames())
|
||||||
|
{
|
||||||
|
getSubstitutionSuggestions(defaultAspect, substitutionFragment, suggestions);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user