private List<ResourceDto> createInputData(List<Content> contents) { List<ResourceDto> list = new ArrayList<>(contents.size()); for (final Content content : contents) { ResourceDto dto = (ResourceDto) CollectionUtils.find( list, new Predicate() { @Override public boolean evaluate(Object object) { return (object instanceof ResourceDto) && equalsContent( (ResourceDto) object, content.getName(), getContentType(content)); } }); if (dto == null) { list.add(new ResourceDto(content)); } else { dto.addLanguage(content.getLanguage()); } } return list; }
@RequestMapping(value = "/resource/available/{field}", method = RequestMethod.GET) @ResponseBody public Set<String> availableField(@PathVariable String field, @RequestParam String term) { Set<String> strings = new TreeSet<>(); switch (field) { case "name": List<Content> contents = cmsLiteService.getAllContents(); for (Content content : contents) { if (startsWith(content.getName(), term)) { strings.add(content.getName()); } } break; case "language": for (Locale locale : getAvailableLocales()) { if (startsWithIgnoreCase(locale.getDisplayLanguage(), term)) { strings.add(locale.getDisplayLanguage()); } } break; default: } return strings; }
@RequestMapping(value = "/resource/all/languages", method = RequestMethod.GET) @ResponseBody public Set<String> getAllLanguages() throws ContentNotFoundException { List<Content> contents = cmsLiteService.getAllContents(); Set<String> strings = new TreeSet<>(); for (Content content : contents) { strings.add(content.getLanguage()); } return strings; }