From 51a3eda4c22fcaaf5bbdef3939d0e478fa7bcd2c Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Mon, 21 Nov 2022 14:26:22 +0100 Subject: [PATCH] ui --- .../java/eu/dnetlib/is/MainController.java | 47 +++++++++---------- .../templates/fragments/mainParts.html | 22 ++++++--- .../resources/templates/simpleResources.html | 4 +- ...pleResourceType.java => ResourceType.java} | 18 +++++-- .../repository/ResourceTypeRepository.java | 8 ++++ .../SimpleResourceTypeRepository.java | 8 ---- .../src/main/resources/sql/schema.sql | 33 +++++++++---- 7 files changed, 88 insertions(+), 52 deletions(-) rename libs/dnet-is-common/src/main/java/eu/dnetlib/is/resource/model/{SimpleResourceType.java => ResourceType.java} (70%) create mode 100644 libs/dnet-is-common/src/main/java/eu/dnetlib/is/resource/repository/ResourceTypeRepository.java delete mode 100644 libs/dnet-is-common/src/main/java/eu/dnetlib/is/resource/repository/SimpleResourceTypeRepository.java diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/MainController.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/MainController.java index ac4ff9e1..9ecc1cc8 100644 --- a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/MainController.java +++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/MainController.java @@ -11,8 +11,8 @@ import org.springframework.web.bind.annotation.RequestParam; import eu.dnetlib.is.context.model.Context; import eu.dnetlib.is.context.model.repository.ContextRepository; -import eu.dnetlib.is.resource.model.SimpleResourceType; -import eu.dnetlib.is.resource.repository.SimpleResourceTypeRepository; +import eu.dnetlib.is.resource.model.ResourceType; +import eu.dnetlib.is.resource.repository.ResourceTypeRepository; import eu.dnetlib.is.vocabulary.model.Vocabulary; import eu.dnetlib.is.vocabulary.repository.VocabularyRepository; import eu.dnetlib.is.wfs.WfHistoryRestController; @@ -27,11 +27,29 @@ public class MainController { private VocabularyRepository vocabularyRepository; @Autowired - private SimpleResourceTypeRepository simpleResourceTypeRepository; + private ResourceTypeRepository resourceTypeRepository; @GetMapping("/main") public void mainPage() {} + @GetMapping("/resources") + public String listResources(@RequestParam final String type, final ModelMap map) { + + if (type.equalsIgnoreCase("vocabulary")) { + return "vocabularies"; + } else if (type.equalsIgnoreCase("context")) { + return "contexts"; + } else { + final Optional restype = resourceTypeRepository.findById(type); + if (restype.isPresent() && restype.get().isSimple()) { + map.addAttribute("type", restype.get()); + } else { + map.addAttribute("type", new ResourceType("not_present", "???", 0)); + } + return "simpleResources"; + } + } + @GetMapping("/contextEditor") public void contextEditor(@RequestParam final String id, final ModelMap map) { final Context ctx = contextRepository.getById(id); @@ -41,9 +59,6 @@ public class MainController { map.put("ctxParams", ctx.getParameters()); } - @GetMapping("/contexts") - public void contexts() {} - @GetMapping("/vocabularyEditor") public void vocabularyEditor(@RequestParam final String id, final ModelMap map) { final Vocabulary voc = vocabularyRepository.getById(id); @@ -52,22 +67,6 @@ public class MainController { map.put("vocDesc", voc.getDescription()); } - @GetMapping("/vocabularies") - public void vocabularies() {} - - @GetMapping("/simpleResources") - public void simpleResources(@RequestParam final String type, final ModelMap map) { - - final Optional restype = simpleResourceTypeRepository.findById(type); - - if (restype.isPresent()) { - map.addAttribute("type", restype.get()); - } else { - map.addAttribute("type", new SimpleResourceType("not_present", "???", 0)); - } - - } - @GetMapping("/wf_history") public void wfHistory(final ModelMap map, @RequestParam(required = false, defaultValue = "-1") final Long from, @@ -78,7 +77,7 @@ public class MainController { } @ModelAttribute("resTypes") - public Iterable resourceTypes() { - return simpleResourceTypeRepository.findAll(); + public Iterable resourceTypes() { + return resourceTypeRepository.findAll(); } } diff --git a/apps/dnet-is-application/src/main/resources/templates/fragments/mainParts.html b/apps/dnet-is-application/src/main/resources/templates/fragments/mainParts.html index b35293d4..bd10295b 100644 --- a/apps/dnet-is-application/src/main/resources/templates/fragments/mainParts.html +++ b/apps/dnet-is-application/src/main/resources/templates/fragments/mainParts.html @@ -31,15 +31,23 @@