Polishes the Tag functionality by adding the mockup data into a json file (Ticket #76)

This commit is contained in:
gkolokythas 2019-05-16 14:16:24 +03:00
parent f71d02613a
commit f26b3200e3
2 changed files with 31 additions and 19 deletions

View File

@ -1,5 +1,7 @@
package eu.eudat.controllers;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.elastic.criteria.TagCriteria;
import eu.eudat.elastic.entities.Dataset;
import eu.eudat.elastic.repository.Repository;
@ -15,6 +17,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@ -40,27 +43,14 @@ public class TagController extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/external/tags"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<TagExternalSourcesModel>> listExternalTagModel(
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type) throws HugeResultSet, NoURLFound {
/*List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getTags(query, type);
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type) throws HugeResultSet, NoURLFound, IOException {
/* List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getTags(query, type);
TagExternalSourcesModel researchersExternalSourcesModel = new TagExternalSourcesModel().fromExternalItem(remoteRepos);*/
List<Map<String, String>> myListOfMaps = new ArrayList<>();
Map<String, String> map1 = new HashMap<>();
map1.put("pid", "1");
map1.put("name", "Tag1");
map1.put("label", "");
myListOfMaps.add(map1);
Map<String, String> map2 = new HashMap<>();
map2.put("pid", "2");
map2.put("name", "Tag2");
map2.put("label", "");
myListOfMaps.add(map2);
Map<String, String> map3 = new HashMap<>();
map3.put("pid", "3");
map3.put("name", "Tag3");
map3.put("label", "");
myListOfMaps.add(map3);
TagExternalSourcesModel researchersExternalSourcesModel = new TagExternalSourcesModel().fromExternalItem(myListOfMaps);
String path = "C:\\Users\\gkolokythas\\Documents\\openDmp\\dmp-backend\\web\\src\\main\\resources\\mockupTags.json";
ObjectMapper mapper = new ObjectMapper();
List<Map<String, String>> data = mapper.readValue(new File(path), new TypeReference<List<Map<String, String>>>(){});
TagExternalSourcesModel researchersExternalSourcesModel = new TagExternalSourcesModel().fromExternalItem(data);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<TagExternalSourcesModel>().payload(researchersExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
}

View File

@ -0,0 +1,22 @@
[
{
"pid": "1",
"name": "Tag1",
"label": ""
},
{
"pid": "2",
"name": "Tag2",
"label": ""
},
{
"pid": "3",
"name": "Tag3",
"label": ""
},
{
"pid": "4",
"name": "Tag4",
"label": ""
}
]