Polishes the Tag functionality by adding the mockup data into a json file (Ticket #76)
This commit is contained in:
parent
f71d02613a
commit
f26b3200e3
|
@ -1,5 +1,7 @@
|
||||||
package eu.eudat.controllers;
|
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.criteria.TagCriteria;
|
||||||
import eu.eudat.elastic.entities.Dataset;
|
import eu.eudat.elastic.entities.Dataset;
|
||||||
import eu.eudat.elastic.repository.Repository;
|
import eu.eudat.elastic.repository.Repository;
|
||||||
|
@ -15,6 +17,7 @@ import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -40,27 +43,14 @@ public class TagController extends BaseController {
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/tags"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = {"/external/tags"}, produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<TagExternalSourcesModel>> listExternalTagModel(
|
ResponseEntity<ResponseItem<TagExternalSourcesModel>> listExternalTagModel(
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type) throws HugeResultSet, NoURLFound {
|
@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);
|
/* List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getTags(query, type);
|
||||||
TagExternalSourcesModel researchersExternalSourcesModel = new TagExternalSourcesModel().fromExternalItem(remoteRepos);*/
|
TagExternalSourcesModel researchersExternalSourcesModel = new TagExternalSourcesModel().fromExternalItem(remoteRepos);*/
|
||||||
|
|
||||||
List<Map<String, String>> myListOfMaps = new ArrayList<>();
|
String path = "C:\\Users\\gkolokythas\\Documents\\openDmp\\dmp-backend\\web\\src\\main\\resources\\mockupTags.json";
|
||||||
Map<String, String> map1 = new HashMap<>();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
map1.put("pid", "1");
|
List<Map<String, String>> data = mapper.readValue(new File(path), new TypeReference<List<Map<String, String>>>(){});
|
||||||
map1.put("name", "Tag1");
|
TagExternalSourcesModel researchersExternalSourcesModel = new TagExternalSourcesModel().fromExternalItem(data);
|
||||||
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);
|
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<TagExternalSourcesModel>().payload(researchersExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<TagExternalSourcesModel>().payload(researchersExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"pid": "1",
|
||||||
|
"name": "Tag1",
|
||||||
|
"label": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "2",
|
||||||
|
"name": "Tag2",
|
||||||
|
"label": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "3",
|
||||||
|
"name": "Tag3",
|
||||||
|
"label": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": "4",
|
||||||
|
"name": "Tag4",
|
||||||
|
"label": ""
|
||||||
|
}
|
||||||
|
]
|
Loading…
Reference in New Issue