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;
}
}
diff --git a/rm-server/source/java/org/alfresco/repo/action/parameter/NodeParameterSuggesterBootstrap.java b/rm-server/source/java/org/alfresco/repo/action/parameter/NodeParameterSuggesterBootstrap.java
new file mode 100755
index 0000000000..a04106f041
--- /dev/null
+++ b/rm-server/source/java/org/alfresco/repo/action/parameter/NodeParameterSuggesterBootstrap.java
@@ -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 .
+ */
+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.
+ *
+ * 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 nodeParameterProcessorAspectsNames;
+
+ /** node parameter processor */
+ private NodeParameterProcessor nodeParameterProcessor;
+
+ /**
+ * @param recordMetadataAspects map of record metadata aspects against file plan types
+ */
+ public void setNodeParameterProcessorAspects(List 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);
+ }
+ }
+ }
+}
diff --git a/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterSubstitutionSuggester.java b/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterSubstitutionSuggester.java
index 2445273c20..3d3fb0fbd3 100644
--- a/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterSubstitutionSuggester.java
+++ b/rm-server/source/java/org/alfresco/repo/action/parameter/ParameterSubstitutionSuggester.java
@@ -22,5 +22,7 @@ import java.util.List;
public interface ParameterSubstitutionSuggester
{
+ final static int DEFAULT_MAXIMUM_NUMBER_SUGGESTIONS = 10;
+
public List getSubstitutionSuggestions(final String substitutionFragment);
}
diff --git a/rm-server/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java b/rm-server/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java
index 6eaac4db2a..0c41818a2f 100644
--- a/rm-server/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java
+++ b/rm-server/source/java/org/alfresco/repo/web/scripts/substitutionsuggestions/RmSubstitutionSuggestionsGet.java
@@ -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 substitutionSuggestions = new ArrayList();
- 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 model = new HashMap();
model.put(SUBSTITUTIONS_MODEL_KEY, substitutionSuggestions);
@@ -137,7 +163,7 @@ public class RmSubstitutionSuggestionsGet extends DeclarativeWebScript
*/
private List getSubPathSuggestions(WebScriptRequest req, final String path, final String fragment) {
List pathSuggestions = new ArrayList();
- 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;
}
diff --git a/rm-server/test/java/org/alfresco/repo/action/parameter/DateParameterProcessorTest.java b/rm-server/test/java/org/alfresco/repo/action/parameter/DateParameterProcessorTest.java
index af9626bc65..4b43513d67 100644
--- a/rm-server/test/java/org/alfresco/repo/action/parameter/DateParameterProcessorTest.java
+++ b/rm-server/test/java/org/alfresco/repo/action/parameter/DateParameterProcessorTest.java
@@ -43,7 +43,7 @@ public class DateParameterProcessorTest
}
@Test
- public void testGetSubstitutionSuggestions_All_01()
+ public void testGetSubstitutionSuggestions_01()
{
List 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 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 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 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 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());
}
-
}