Skip to content

Commit

Permalink
Sort projects by title in row expansion and popup dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
solth committed Oct 6, 2023
1 parent 08086bb commit 2e196a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import java.io.IOException;
import java.io.Serializable;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

import javax.faces.context.FacesContext;
import javax.faces.view.ViewScoped;
Expand Down Expand Up @@ -85,7 +87,8 @@ public void setSelectedProjectId(int projectId) {
public List<Project> getTemplateProjects() {
try {
Template template = ServiceManager.getTemplateService().getById(this.templateDTO.getId());
return template.getProjects();
return template.getProjects().stream().sorted(Comparator.comparing(Project::getTitle))
.collect(Collectors.toList());
} catch (DAOException e) {
Helper.setErrorMessage(ERROR_LOADING_ONE, new Object[] {ObjectType.TEMPLATE.getTranslationSingular(),
this.templateDTO.getId()}, logger, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -41,6 +43,7 @@
import org.kitodo.data.elasticsearch.search.Searcher;
import org.kitodo.data.exceptions.DataException;
import org.kitodo.exceptions.ProcessGenerationException;
import org.kitodo.production.dto.ProjectDTO;
import org.kitodo.production.dto.TaskDTO;
import org.kitodo.production.dto.TemplateDTO;
import org.kitodo.production.dto.WorkflowDTO;
Expand Down Expand Up @@ -204,7 +207,8 @@ public TemplateDTO convertJSONObjectToDTO(Map<String, Object> jsonObject, boolea
private void convertRelatedJSONObjects(Map<String, Object> jsonObject, TemplateDTO templateDTO)
throws DataException {
templateDTO.setProjects(convertRelatedJSONObjectToDTO(jsonObject, TemplateTypeField.PROJECTS.getKey(),
ServiceManager.getProjectService()));
ServiceManager.getProjectService()).stream().sorted(Comparator.comparing(ProjectDTO::getTitle))
.collect(Collectors.toList()));
}

/**
Expand Down

0 comments on commit 2e196a6

Please sign in to comment.