Skip to content

Commit

Permalink
SAK-45025 fix up AlphaNumeric sorting one more place in LEssons (saka…
Browse files Browse the repository at this point in the history
  • Loading branch information
ottenhoff authored Mar 10, 2021
1 parent 8485df8 commit 04c7980
Showing 1 changed file with 21 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3542,44 +3542,29 @@ public String addBlti() {
// code twice, we take that list and translate to titles, rather than calling
// getItemGroups again
public String getItemGroupTitles(String itemGroups, SimplePageItem item) {
String ret = "";
if (StringUtils.isNotBlank(itemGroups)) {

List<String> groupNames = new ArrayList<>();
Site site = getCurrentSite();
String[] groupIds = split(itemGroups, ",");
for (int i = 0; i < groupIds.length; i++) {
Group group=site.getGroup(groupIds[i]);
if (group != null) {
String title = group.getTitle();
if (title != null && !title.equals(""))
groupNames.add(title);
else
groupNames.add(messageLocator.getMessage("simplepage.deleted-group"));
} else
groupNames.add(messageLocator.getMessage("simplepage.deleted-group"));
}
Collections.sort(groupNames);
for (String name: groupNames) {
if (StringUtils.isBlank(ret))
ret = name;
else
ret = ret + "," + name;
}

}

if (item.isPrerequisite()) {
if (StringUtils.isBlank(ret))
ret = messageLocator.getMessage("simplepage.prerequisites_tag");
else
ret = messageLocator.getMessage("simplepage.prerequisites_tag") + "; " + ret;
}
String ret = null;
if (StringUtils.isNotBlank(itemGroups)) {

List<String> groupNames = new ArrayList<>();
for (String groupId : split(itemGroups, ",")) {
Group group = getCurrentSite().getGroup(groupId);
if (group != null && StringUtils.isNotBlank(group.getTitle())) {
groupNames.add(group.getTitle());
} else {
groupNames.add(messageLocator.getMessage("simplepage.deleted-group"));
}
}
groupNames.sort(new AlphaNumericComparator());
ret = StringUtils.join(groupNames, ", ");
}

if (StringUtils.isBlank(ret))
return null;
if (StringUtils.isBlank(ret) && item.isPrerequisite()) {
return messageLocator.getMessage("simplepage.prerequisites_tag");
} else if (item.isPrerequisite()) {
return messageLocator.getMessage("simplepage.prerequisites_tag") + "; " + ret;
}

return ret;
return ret;
}

private String getParentTitle(SimplePageItem item, boolean continuation, Set<Long> seen) {
Expand Down

0 comments on commit 04c7980

Please sign in to comment.