+/*\r
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
package org.argeo.slc.web.mvc.execution;\r
\r
+import java.util.Comparator;\r
import java.util.List;\r
+import java.util.SortedSet;\r
+import java.util.TreeSet;\r
\r
import javax.servlet.http.HttpServletRequest;\r
import javax.servlet.http.HttpServletResponse;\r
\r
// TODO: use centralized agentId property (from MsgConstants)?\r
String agentId = request.getParameter("agentId");\r
- \r
+\r
SlcAgent slcAgent = agentFactory.getAgent(agentId);\r
\r
- List<ExecutionModuleDescriptor> descriptors = slcAgent.listExecutionModuleDescriptors();\r
+ List<ExecutionModuleDescriptor> descriptors = slcAgent\r
+ .listExecutionModuleDescriptors();\r
+ SortedSet<ExecutionModuleDescriptor> set = new TreeSet<ExecutionModuleDescriptor>(\r
+ new Comparator<ExecutionModuleDescriptor>() {\r
+\r
+ public int compare(ExecutionModuleDescriptor md1,\r
+ ExecutionModuleDescriptor md2) {\r
+ String str1 = md1.getLabel() != null ? md1.getLabel()\r
+ : md1.getName();\r
+ String str2 = md2.getLabel() != null ? md2.getLabel()\r
+ : md2.getName();\r
+ return str1.compareTo(str2);\r
+ }\r
+ });\r
+ set.addAll(descriptors);\r
\r
- modelAndView.addObject(new ObjectList(descriptors));\r
+ modelAndView.addObject(new ObjectList(set));\r
}\r
\r
public void setAgentFactory(SlcAgentFactory agentFactory) {\r