diff --git a/src/main/java/org/genesys2/server/service/impl/FullTextSearchServiceImpl.java b/src/main/java/org/genesys2/server/service/impl/FullTextSearchServiceImpl.java index 494c2a1070d623badc52b131545a5af4db02bcb7..8d3dde6d4905104f21d80f5d1695ad2cae35b17d 100644 --- a/src/main/java/org/genesys2/server/service/impl/FullTextSearchServiceImpl.java +++ b/src/main/java/org/genesys2/server/service/impl/FullTextSearchServiceImpl.java @@ -193,6 +193,10 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial return instituteRepository.findOne(id); } else if (Country.class.getName().equals(className)) { return countryRepository.findOne(id); + } else if (ActivityPost.class.getName().equals(className)) { + return postRepository.findOne(id); + } else if (Article.class.getName().equals(className)) { + return articleRepository.findOne(id); } else { throw new UnsupportedOperationException("Missing toEntity implementation for class=" + className); } @@ -460,7 +464,6 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial // FIXME Should not include articles that belong to institutes or // countries final Article article = (Article) model; - document.setClassPK(article.getClassPk()); document.setBody(article.getBody()); document.setSummary(article.getSummary()); document.setLanguage(article.getLang()); @@ -469,19 +472,19 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial document.setUrlToContent("/content/" + article.getSlug()); } else if (model instanceof ActivityPost) { - updateDocumentForCountry((ActivityPost) model, document); + updateDocument((ActivityPost) model, document); } else if (model instanceof Country) { - updateDocumentForCountry((Country) model, document); + updateDocument((Country) model, document); } else if (model instanceof FaoInstitute) { - updateDocumentForFaoInstitute((FaoInstitute) model, document); + updateDocument((FaoInstitute) model, document); } return document; } - private void updateDocumentForCountry(ActivityPost activityPost, FullTextDocument document) { + private void updateDocument(ActivityPost activityPost, FullTextDocument document) { document.setBody(activityPost.getBody()); document.setSummary(activityPost.getTitle()); document.setCreatedDate(activityPost.getCreatedDate()); @@ -489,7 +492,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial document.setUrlToContent("/content/news/" + activityPost.getId() + "/" + this.jspHelper.suggestUrlForText(activityPost.getTitle())); } - private void updateDocumentForCountry(Country country, FullTextDocument document) { + private void updateDocument(Country country, FullTextDocument document) { document.setUrlToContent("/geo/" + country.getCode3()); document.setLanguage(contentService.getDefaultLocale().getLanguage()); document.setSummary(country.getCode3() + " " + country.getNameL()); @@ -500,7 +503,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial } } - private void updateDocumentForFaoInstitute(FaoInstitute institute, FullTextDocument document) { + private void updateDocument(FaoInstitute institute, FullTextDocument document) { document.setUrlToContent("/wiews/" + institute.getCode()); document.setLanguage(contentService.getDefaultLocale().getLanguage()); document.setSummary(institute.getCode() + " " + institute.getAcronym() + " " + institute.getFullName()); diff --git a/src/main/java/org/genesys2/server/servlet/controller/SearchController.java b/src/main/java/org/genesys2/server/servlet/controller/SearchController.java index 2445941d7e48f3c1af602f119035ae593f50aaee..2cc3a229c5d832bf508ad2bd7881c2fc8f9461f6 100644 --- a/src/main/java/org/genesys2/server/servlet/controller/SearchController.java +++ b/src/main/java/org/genesys2/server/servlet/controller/SearchController.java @@ -24,6 +24,8 @@ import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.genesys2.server.model.impl.ActivityPost; +import org.genesys2.server.model.impl.Article; import org.genesys2.server.model.impl.ClassPK; import org.genesys2.server.model.impl.Country; import org.genesys2.server.model.impl.FaoInstitute; @@ -142,10 +144,14 @@ public class SearchController { @RequestMapping("/acn/search2") public String findFullTextDocument(ModelMap model, @RequestParam(required = false, value = "q") String searchQuery, @RequestParam(value = "page", required = true, defaultValue = "1") int page, - @RequestParam(value = "section", required = true, defaultValue = "accession") String section) throws SearchException { + @RequestParam(value = "section", required = false, defaultValue = "accession") String section) throws SearchException { + + if (StringUtils.isBlank(section)) { + section = "accession"; + } ClassPK classPK = contentService.getClassPk(section); - if (classPK == null) { + if (classPK == null && ! "accession".equals(section)) { LOG.warn("No search section " + section); throw new SearchException("No such search section"); } @@ -160,8 +166,13 @@ public class SearchController { model.addAttribute("pagedData", fullTextSearchService.search(searchQuery, new PageRequest(page - 1, 50), FaoInstitute.class)); } else if ("country".equals(section)) { model.addAttribute("pagedData", fullTextSearchService.search(searchQuery, new PageRequest(page - 1, 50), Country.class)); + } else if ("article".equals(section)) { + model.addAttribute("pagedData", fullTextSearchService.search(searchQuery, new PageRequest(page - 1, 50), Article.class)); + } else if ("activitypost".equals(section)) { + model.addAttribute("pagedData", fullTextSearchService.search(searchQuery, new PageRequest(page - 1, 50), ActivityPost.class)); } else { - model.addAttribute("pagedData", fullTextSearchService.search(searchQuery, new PageRequest(page - 1, 50), section)); + LOG.error("Unsupported full-text searchfor section: " + section); + throw new UnsupportedOperationException("No such search section"); } } catch (SearchException e) { LOG.info("Searching for: " + searchQuery + " failed with error " + e.getMessage()); diff --git a/src/main/sourceapp/0/styles/genesys.scss b/src/main/sourceapp/0/styles/genesys.scss index 62121276b0a6b4275b59a7188b22b049bf329ec3..008096639d6a3969fbd38d59175e1ac6fe6b2772 100644 --- a/src/main/sourceapp/0/styles/genesys.scss +++ b/src/main/sourceapp/0/styles/genesys.scss @@ -2487,3 +2487,20 @@ div[x-href] { .dropdown-menu.view-columns li { padding: 0 10px; } + +.genesys-mini { + .title { + margin: 0.5em 0; + font-size: 130%; + } + + .summary { + margin: 0.5em 0; + margin-left: 3em; + } + + .url { + margin: 0.5em 0; + color: Gray; + } +} diff --git a/src/main/sourceapp/1/styles/genesys.scss b/src/main/sourceapp/1/styles/genesys.scss index 2f38d8b5db294ff73a76ed6975ef6b8dd40ade96..8b2a8630734f96fc0e81be74eaa347b344375453 100644 --- a/src/main/sourceapp/1/styles/genesys.scss +++ b/src/main/sourceapp/1/styles/genesys.scss @@ -653,4 +653,26 @@ span.idx-col { img { width: 100%; } -} \ No newline at end of file +} + +.genesys-mini { + .title { + margin: 0.5em 0; + font-size: 130%; + } + + .summary { + margin: 0.5em 0; + margin-left: 3em; + } + + .url { + margin: 0.5em 0; + color: Gray; + } + + .not-current { + font-style: italic; + opacity: 0.5; + } +} diff --git a/src/main/webapp/WEB-INF/jsp/search2/index.jsp b/src/main/webapp/WEB-INF/jsp/search2/index.jsp index db345c359a5a6929228010b60448330165efb20c..ea443eb2a09ced38aeaa4a055717b11a88d4d92d 100644 --- a/src/main/webapp/WEB-INF/jsp/search2/index.jsp +++ b/src/main/webapp/WEB-INF/jsp/search2/index.jsp @@ -71,12 +71,8 @@