diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/MainAjaxController.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/MainAjaxController.java new file mode 100644 index 00000000..aea360e2 --- /dev/null +++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/MainAjaxController.java @@ -0,0 +1,30 @@ +package eu.dnetlib.is; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import eu.dnetlib.data.is.resource.model.ResourceType; +import eu.dnetlib.data.is.resource.repository.ResourceTypeRepository; + +@RestController +public class MainAjaxController { + + @Autowired + private ResourceTypeRepository resourceTypeRepository; + + @GetMapping("/ajax/resourceTypes") + public Iterable resourceTypes() { + return resourceTypeRepository.findAll(); + } + + @GetMapping("/ajax/resourceTypes/{id}") + public ResourceType resourceTypes(@PathVariable final String id) { + return resourceTypeRepository + .findById(id) + .orElse(new ResourceType("not_present", "???", MediaType.TEXT_PLAIN_VALUE, 0)); + } + +} 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 deleted file mode 100644 index 92e4aebe..00000000 --- a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/MainController.java +++ /dev/null @@ -1,98 +0,0 @@ -package eu.dnetlib.is; - -import java.util.Arrays; -import java.util.Optional; -import java.util.stream.Collectors; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestParam; - -import eu.dnetlib.data.is.context.repository.ContextRepository; -import eu.dnetlib.data.is.resource.model.ResourceType; -import eu.dnetlib.data.is.resource.repository.ResourceTypeRepository; -import eu.dnetlib.data.is.vocabulary.repository.VocabularyRepository; -import eu.dnetlib.data.is.vocabulary.repository.VocabularyTermRepository; -import eu.dnetlib.is.info.KeyValue; -import eu.dnetlib.is.wfs.WfHistoryAjaxController; -import eu.dnetlib.openaire.dsm.utils.DsmBrowsableFields; - -@Controller -public class MainController { - - @Autowired - private ContextRepository contextRepository; - - @Autowired - private VocabularyRepository vocabularyRepository; - - @Autowired - private VocabularyTermRepository vocabularyTermRepository; - - @Autowired - private ResourceTypeRepository resourceTypeRepository; - - @GetMapping("/main") - public void mainPage() {} - - @GetMapping("/dsm") - public void searchDsApi(final ModelMap map) { - map.addAttribute("pageSize", 100); - map.addAttribute("browsableFields", Arrays.stream(DsmBrowsableFields.values()) - .map(f -> new KeyValue(f.name(), f.desc)) - .collect(Collectors.toList())); - map.addAttribute("protocols", vocabularyTermRepository.findTermsByVocabulary("dnet:protocols")); - map.addAttribute("compatibilityLevels", vocabularyTermRepository.findTermsByVocabulary("dnet:compatibilityLevel")); - map.addAttribute("contentDescTypes", vocabularyTermRepository.findTermsByVocabulary("dnet:content_description_typologies")); - } - - @GetMapping("/resources") - public String listResources(@RequestParam final String type, final ModelMap map) { - - if (type.equalsIgnoreCase("vocabulary")) { - return "redirect:vocs"; - } else if (type.equalsIgnoreCase("context")) { - return "redirect:contexts"; - } else if (type.equalsIgnoreCase("protocol")) { - return "redirect:protocols"; - } 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", "???", MediaType.TEXT_PLAIN_VALUE, 0)); - } - return "simpleResources"; - } - } - - @GetMapping("/vocs") - public void vocabularies() {} - - @GetMapping("/contexts") - public void contexts() {} - - @GetMapping("/protocols") - public void protocols() {} - - @GetMapping("/wf_history") - public void wfHistory(final ModelMap map, - @RequestParam(required = false, defaultValue = "-1") final Long from, - @RequestParam(required = false, defaultValue = "-1") final Long to) { - map.put("maxNumberOfRecentWfs", WfHistoryAjaxController.MAX_NUMBER_OF_RECENT_WFS); - map.put("fromDate", from); - map.put("toDate", to); - } - - @GetMapping("/info") - public void wfHistory() throws Exception {} - - @ModelAttribute("resTypes") - public Iterable resourceTypes() { - return resourceTypeRepository.findAll(); - } -} diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/wfs/WfHistoryAjaxController.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/wfs/WfHistoryAjaxController.java index c42c12d2..2ff88462 100644 --- a/apps/dnet-is-application/src/main/java/eu/dnetlib/is/wfs/WfHistoryAjaxController.java +++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/is/wfs/WfHistoryAjaxController.java @@ -22,12 +22,16 @@ public class WfHistoryAjaxController { @Autowired private WfProcessExecutionRepository wfProcessExecutionRepository; + @Deprecated public static final int MAX_NUMBER_OF_RECENT_WFS = 100; @GetMapping("/") - public List history(@RequestParam(required = false) final Long from, @RequestParam(required = false) final Long to) { + public List history( + @RequestParam(required = true) final int total, + @RequestParam(required = false) final Long from, + @RequestParam(required = false) final Long to) { if (from == null && to == null) { - return wfProcessExecutionRepository.findAll(PageRequest.of(0, MAX_NUMBER_OF_RECENT_WFS, Sort.by("endDate").descending())).toList(); + return wfProcessExecutionRepository.findAll(PageRequest.of(0, total, Sort.by("endDate").descending())).toList(); } else if (from == null) { return wfProcessExecutionRepository.findByEndDateBetweenOrderByEndDateDesc(new Date(0), new Date(to)); } else if (to == null) { diff --git a/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmAjaxController.java b/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmAjaxController.java index 444e5370..9e9cdcef 100644 --- a/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmAjaxController.java +++ b/apps/dnet-is-application/src/main/java/eu/dnetlib/openaire/dsm/DsmAjaxController.java @@ -1,6 +1,10 @@ package eu.dnetlib.openaire.dsm; +import java.util.Arrays; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; @@ -13,10 +17,12 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import eu.dnetlib.common.controller.AbstractDnetController; +import eu.dnetlib.data.is.vocabulary.repository.VocabularyTermRepository; import eu.dnetlib.data.openaire.dsm.model.Api; import eu.dnetlib.data.openaire.dsm.model.BrowseTerm; import eu.dnetlib.data.openaire.dsm.model.view.SimpleDsWithApis; import eu.dnetlib.is.errors.DsmException; +import eu.dnetlib.is.info.KeyValue; import eu.dnetlib.openaire.dsm.utils.DsmBrowsableFields; @RestController @@ -26,6 +32,25 @@ public class DsmAjaxController extends AbstractDnetController { @Autowired private DsmService dsmService; + @Autowired + private VocabularyTermRepository vocabularyTermRepository; + + @GetMapping("/browsableFields") + public List browsableFields() { + return Arrays.stream(DsmBrowsableFields.values()) + .map(f -> new KeyValue(f.name(), f.desc)) + .collect(Collectors.toList()); + } + + @GetMapping("/validTerms") + public Map> validTerms() { + final Map> map = new LinkedHashMap<>(); + map.put("protocols", vocabularyTermRepository.findTermsByVocabulary("dnet:protocols")); + map.put("compatibilityLevels", vocabularyTermRepository.findTermsByVocabulary("dnet:compatibilityLevel")); + map.put("contentDescTypes", vocabularyTermRepository.findTermsByVocabulary("dnet:content_description_typologies")); + return map; + } + @GetMapping("/browse/{field}") public List browse(@PathVariable final String field) { return dsmService.browseTerm(DsmBrowsableFields.valueOf(field)); diff --git a/apps/dnet-is-application/src/main/resources/static/contexts/editor.html b/apps/dnet-is-application/src/main/resources/static/html/context_viewer.html similarity index 92% rename from apps/dnet-is-application/src/main/resources/static/contexts/editor.html rename to apps/dnet-is-application/src/main/resources/static/html/context_viewer.html index ac36dc61..a1c73d73 100644 --- a/apps/dnet-is-application/src/main/resources/static/contexts/editor.html +++ b/apps/dnet-is-application/src/main/resources/static/html/context_viewer.html @@ -1,3 +1,5 @@ +

Context Editor

+
@@ -6,7 +8,7 @@ data-target="#showParametersModal" ng-click="loadContextParameters()">[show]

- Return to contexts list Download + Return to contexts list Download

    diff --git a/apps/dnet-is-application/src/main/resources/static/contexts/list.html b/apps/dnet-is-application/src/main/resources/static/html/contexts.html similarity index 97% rename from apps/dnet-is-application/src/main/resources/static/contexts/list.html rename to apps/dnet-is-application/src/main/resources/static/html/contexts.html index 4dd1df6b..5a309327 100644 --- a/apps/dnet-is-application/src/main/resources/static/contexts/list.html +++ b/apps/dnet-is-application/src/main/resources/static/html/contexts.html @@ -1,3 +1,4 @@ +

    Contexts

    @@ -26,7 +27,7 @@ no contexts - {{ctx.id}} + {{ctx.id}} {{ctx.label}} {{ctx.type}} diff --git a/apps/dnet-is-application/src/main/resources/static/dsm/addApi.html b/apps/dnet-is-application/src/main/resources/static/html/dsm_add_api.html similarity index 97% rename from apps/dnet-is-application/src/main/resources/static/dsm/addApi.html rename to apps/dnet-is-application/src/main/resources/static/html/dsm_add_api.html index 0b4e0147..7e8af135 100644 --- a/apps/dnet-is-application/src/main/resources/static/dsm/addApi.html +++ b/apps/dnet-is-application/src/main/resources/static/html/dsm_add_api.html @@ -1,3 +1,5 @@ +

    Datasource Manager: Add API

    +
    diff --git a/apps/dnet-is-application/src/main/resources/static/dsm/api.html b/apps/dnet-is-application/src/main/resources/static/html/dsm_api.html similarity index 66% rename from apps/dnet-is-application/src/main/resources/static/dsm/api.html rename to apps/dnet-is-application/src/main/resources/static/html/dsm_api.html index 04185ca0..bef68f7c 100644 --- a/apps/dnet-is-application/src/main/resources/static/dsm/api.html +++ b/apps/dnet-is-application/src/main/resources/static/html/dsm_api.html @@ -1,3 +1,5 @@ +

    Datasource Manager: API

    +
    diff --git a/apps/dnet-is-application/src/main/resources/static/dsm/results.html b/apps/dnet-is-application/src/main/resources/static/html/dsm_results.html similarity index 92% rename from apps/dnet-is-application/src/main/resources/static/dsm/results.html rename to apps/dnet-is-application/src/main/resources/static/html/dsm_results.html index adf9fbf0..a0092ff4 100644 --- a/apps/dnet-is-application/src/main/resources/static/dsm/results.html +++ b/apps/dnet-is-application/src/main/resources/static/html/dsm_results.html @@ -1,3 +1,5 @@ +

    Datasource Manager: Results

    +
    @@ -5,7 +7,7 @@ Number of results: {{nResults}}
    Page: {{currPage + 1}} / {{nPages}}- / -

    - +