Skip to content
Snippets Groups Projects
Commit 069c1f4f authored by srosse's avatar srosse
Browse files

OO-980: sort the catalog list in controller

parent a99e63c3
No related branches found
No related tags found
No related merge requests found
......@@ -183,8 +183,7 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
StringBuilder sb = new StringBuilder();
sb.append("select cei from ").append(CatalogEntryImpl.class.getName()).append(" as cei ")
.append(" inner join fetch cei.ownerGroup as ownerGroup")
.append(" where cei.type=").append(CatalogEntry.TYPE_NODE)
.append(" order by cei.name");
.append(" where cei.type=").append(CatalogEntry.TYPE_NODE);
return dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), CatalogEntry.class)
......
......@@ -19,6 +19,7 @@
*/
package org.olat.catalog.ui;
import java.util.Collections;
import java.util.List;
import org.olat.basesecurity.BaseSecurityManager;
......@@ -74,6 +75,7 @@ public class CatalogEntryAddController extends BasicController {
catalogManager = CatalogManager.getInstance();
List<CatalogEntry> catEntryList = CatalogManager.getInstance().getAllCatalogNodes();
Collections.sort(catEntryList, new CatalogEntryNodeComparator(getLocale()));
mainVC = createVelocityContainer("catMove");
mainVC.contextPut("withTitle", new Boolean(title));
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.catalog.ui;
import java.text.Collator;
import java.util.Comparator;
import java.util.Locale;
import org.olat.catalog.CatalogEntry;
/**
*
* Initial date: 18.02.2014<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class CatalogEntryNodeComparator implements Comparator<CatalogEntry> {
private final Collator myCollator;
public CatalogEntryNodeComparator(Locale locale) {
myCollator = Collator.getInstance(locale);
}
@Override
public int compare(final CatalogEntry c1, final CatalogEntry c2) {
if(c1 == null) {
if(c2 == null) return 0;
return -1;
}
if(c2 == null) return 1;
String t1 = c1.getName();
String t2 = c2.getName();
if(t1 == null) {
if(t2 == null) return 0;
return -1;
}
if(t2 == null) return 1;
return myCollator.compare(t1, t2);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment