2018-07-11 15:47:36 +02:00
|
|
|
package eu.eudat.controllers;
|
|
|
|
|
|
|
|
import eu.eudat.elastic.criteria.TagCriteria;
|
|
|
|
import eu.eudat.elastic.entities.Dataset;
|
|
|
|
import eu.eudat.elastic.repository.Repository;
|
|
|
|
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
|
|
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
|
|
import eu.eudat.logic.services.ApiContext;
|
|
|
|
import eu.eudat.models.data.external.TagExternalSourcesModel;
|
|
|
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
|
|
import eu.eudat.types.ApiMessageCode;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
2018-08-31 16:12:31 +02:00
|
|
|
import java.io.IOException;
|
2019-05-16 12:54:29 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
2018-07-11 15:47:36 +02:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by ikalyvas on 7/5/2018.
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@CrossOrigin
|
|
|
|
@RequestMapping(value = {"/api"})
|
2018-08-31 16:12:31 +02:00
|
|
|
public class TagController extends BaseController {
|
2018-07-11 15:47:36 +02:00
|
|
|
|
2018-08-31 16:12:31 +02:00
|
|
|
private Repository<Dataset, TagCriteria> datasetRepository;
|
2018-07-11 15:47:36 +02:00
|
|
|
|
|
|
|
@Autowired
|
|
|
|
public TagController(ApiContext apiContext, Repository tagRepository) {
|
|
|
|
super(apiContext);
|
|
|
|
this.datasetRepository = tagRepository;
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET, value = {"/external/tags"}, produces = "application/json")
|
|
|
|
public @ResponseBody
|
|
|
|
ResponseEntity<ResponseItem<TagExternalSourcesModel>> listExternalTagModel(
|
2018-08-31 16:12:31 +02:00
|
|
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type) throws HugeResultSet, NoURLFound {
|
2019-05-16 12:54:29 +02:00
|
|
|
/*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);
|
|
|
|
|
2018-08-31 16:12:31 +02:00
|
|
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<TagExternalSourcesModel>().payload(researchersExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
|
2018-07-11 15:47:36 +02:00
|
|
|
}
|
|
|
|
}
|