Index: site-manage-tool/tool/src/java/org/sakaiproject/site/tool/SiteAction.java =================================================================== --- site-manage-tool/tool/src/java/org/sakaiproject/site/tool/SiteAction.java (revision 103599) +++ site-manage-tool/tool/src/java/org/sakaiproject/site/tool/SiteAction.java (working copy) @@ -36,6 +36,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.StringTokenizer; import java.util.Vector; import java.util.Map.Entry; @@ -662,6 +663,18 @@ private String SAKAI_LOCALES_MORE = "locales.more"; private LocaleComparator localeComparator = new LocaleComparator(); + /** + * by bbailla2: the following are sakai.properties to sort dropdowns in worksite setup + */ + final String sessionSortKeyProperty="worksitesetup.sort.key.session"; + final String sessionSortOrderProperty="worksitesetup.sort.order.session"; + final String courseSetSortKeyProperty="worksitesetup.sort.key.courseSet"; + final String courseSetSortOrderProperty="worksitesetup.sort.order.courseSet"; + final String courseOfferingSortKeyProperty="worksitesetup.sort.key.courseOffering"; + final String courseOfferingSortOrderProperty="worksitesetup.sort.order.courseOffering"; + final String sectionSortKeyProperty="worksitesetup.sort.key.section"; + final String sectionSortOrderProperty="worksitesetup.sort.order.section"; + /** * what are the tool ids within Home page? * If this is for a newly added Home tool, get the tool ids from template site or system set default @@ -2944,23 +2957,33 @@ if (numSelections != 0) { + //give levelOpts sorted lists // execution will fall through these statements based on number of selections already made if (numSelections == cmLevelSize - 1) { - levelOpts[numSelections] = getCMSections((String) selections.get(numSelections-1)); + //by bbailla2 + //this is the section level + List sections = getCMSections((String) selections.get(numSelections-1)); + levelOpts[numSelections] = sortCollectionBySakaiProperties(sections, sectionSortKeyProperty, sectionSortOrderProperty); } else if (numSelections == cmLevelSize - 2) { - levelOpts[numSelections] = getCMCourseOfferings(getSelectionString(selections, numSelections), t.getEid()); + //by bbailla2 + //this is the course offering level + List courseOfferings = getCMCourseOfferings(getSelectionString(selections, numSelections), t.getEid()); + levelOpts[numSelections] = sortCollectionBySakaiProperties(courseOfferings, courseOfferingSortKeyProperty, courseOfferingSortOrderProperty); } else if (numSelections < cmLevelSize) { - levelOpts[numSelections] = sortCmObject(cms.findCourseSets(getSelectionString(selections, numSelections))); + //by bbailla2 + //this is the course set level + List courseSets = cms.findCourseSets(getSelectionString(selections, numSelections)); + levelOpts[numSelections] = sortCollectionBySakaiProperties(courseSets, courseSetSortKeyProperty, courseSetSortOrderProperty); } } // always set the top level Set courseSets = filterCourseSetList(getCourseSet(state)); - levelOpts[0] = sortCmObject(courseSets); + levelOpts[0] = levelOpts[0] = sortCollectionBySakaiProperties(courseSets,courseSetSortKeyProperty,courseSetSortOrderProperty); // clean further element inside the array for (int i = numSelections + 1; i 0) { - context.put("termList", terms); + //by bbailla2 + Collection sortedTerms=sortCollectionBySakaiProperties(terms,sessionSortKeyProperty,sessionSortOrderProperty); + context.put("termList", sortedTerms); } return terms; } // setTermListForContext @@ -11472,7 +11497,73 @@ } } // sortCmObject + + /** + * by bbailla2 + * Converts a sakai.properties property into an ArrayList + * @param property a sakai.properties property in the form of a comma or space separated list + * @return an ArrayList representation of the list + */ + private ArrayList getListFromProperty( String property ) + { + ArrayList result=new ArrayList(); + + String list = ServerConfigurationService.getString( property ); + + StringTokenizer tokens=new StringTokenizer( list, ", " ); + while( tokens.hasMoreTokens() ) + { + result.add( tokens.nextToken() ); + } + + return result; + } + /** + * by bbailla2 + * Sorts a collection by the sort keys and orders specified in a sakai.properties property + * @param c the collection to sort + * @param keyProp the sakai.properties property that specifies a list of keys + * @param orderProp the sakai.properties property that specifies a list of orders + * @return the sorted collection + */ + private Collection sortCollectionBySakaiProperties(Collection c, String keyProp, String orderProp) + { + //Get the keys from sakai.properties + ArrayList keys=getListFromProperty(keyProp); + ArrayList orders=getListFromProperty(orderProp); + + if (c!=null) + { + //Add them to a list for the SortTool (they must have the form "" in this implementation) + List propsList=new ArrayList(); + if (keys.isEmpty()) + { + //No keys are specified, so use the default sort order + propsList.add("eid"); + propsList.add("title"); + } + else + { + //Populate propsList + for (int i=0;i