Skip to content

Commit

Permalink
Filter templates in service class instead of DTO getter method
Browse files Browse the repository at this point in the history
  • Loading branch information
solth committed Apr 17, 2023
1 parent 35181c8 commit ae834af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void setClient(ClientDTO client) {
* @return list of active templates as TemplateDTO
*/
public List<TemplateDTO> getTemplates() {
return templates.stream().filter(TemplateDTO::isActive).collect(Collectors.toList());
return templates;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public Long countDatabaseRows() throws DAOException {
public Long countNotIndexedDatabaseRows() throws DAOException {
return countDatabaseRows("SELECT COUNT(*) FROM Project WHERE indexAction = 'INDEX' OR indexAction IS NULL");
}

@Override
public Long countResults(Map filters) throws DataException {
return countDocuments(getProjectsForCurrentUserQuery());
Expand Down Expand Up @@ -224,14 +224,14 @@ private List<TemplateDTO> getTemplatesForProjectDTO(Map<String, Object> jsonObje
templateDTO.setTitle(TemplateTypeField.TITLE.getStringValue(singleObject));
templateDTOS.add(templateDTO);
}
return templateDTOS;
return templateDTOS.stream().filter(TemplateDTO::isActive).collect(Collectors.toList());
}

private void convertRelatedJSONObjects(Map<String, Object> jsonObject, ProjectDTO projectDTO) throws DataException {
// TODO: not clear if project lists will need it
projectDTO.setUsers(new ArrayList<>());
projectDTO.setTemplates(convertRelatedJSONObjectToDTO(jsonObject, ProjectTypeField.TEMPLATES.getKey(),
ServiceManager.getTemplateService()));
ServiceManager.getTemplateService()).stream().filter(TemplateDTO::isActive).collect(Collectors.toList()));
}

/**
Expand Down

0 comments on commit ae834af

Please sign in to comment.