changes for remote fetcher
This commit is contained in:
parent
2a4e61f08f
commit
0b3178177a
|
@ -0,0 +1,37 @@
|
||||||
|
package eu.eudat.commons.enums;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public enum ExternalReferencesType {
|
||||||
|
Taxonomies((short) 0),
|
||||||
|
Licenses((short) 1),
|
||||||
|
Publications((short) 2),
|
||||||
|
Journals((short) 3),
|
||||||
|
PubRepositories((short) 4),
|
||||||
|
DataRepositories((short) 5),
|
||||||
|
Registries((short) 6),
|
||||||
|
Services((short) 7),
|
||||||
|
Project((short) 8),
|
||||||
|
Founder((short) 8),
|
||||||
|
Datasets((short) 9),
|
||||||
|
Organizations((short) 10),
|
||||||
|
Grants((short) 11),
|
||||||
|
Prefillings((short) 12),
|
||||||
|
Validators((short) 13),
|
||||||
|
Researcher((short) 14);
|
||||||
|
private final Short value;
|
||||||
|
|
||||||
|
ExternalReferencesType(Short value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Short getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Map<Short, IsActive> map = EnumUtils.getEnumValueMap(IsActive.class);
|
||||||
|
|
||||||
|
public static IsActive of(Short i) {
|
||||||
|
return map.get(i);
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,6 +38,8 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
@ -46,6 +48,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Service
|
||||||
public class EntityDoiServiceImpl implements EntityDoiService {
|
public class EntityDoiServiceImpl implements EntityDoiService {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(EntityDoiServiceImpl.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(EntityDoiServiceImpl.class));
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.controllers.v2;
|
package eu.eudat.controllers.v2;
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.commons.enums.ExternalReferencesType;
|
||||||
import eu.eudat.controllers.BaseController;
|
import eu.eudat.controllers.BaseController;
|
||||||
import eu.eudat.data.query.items.item.funder.FunderCriteriaRequest;
|
import eu.eudat.data.query.items.item.funder.FunderCriteriaRequest;
|
||||||
import eu.eudat.data.query.items.item.project.ProjectCriteriaRequest;
|
import eu.eudat.data.query.items.item.project.ProjectCriteriaRequest;
|
||||||
|
@ -50,27 +51,28 @@ public class ExternalReferencesController extends BaseController {
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(path = {"funders"}, consumes = "application/json", produces = "application/json")
|
// @PostMapping(path = {"funders"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody ResponseEntity<ResponseItem<List<Funder>>> getWithExternal(@RequestBody FunderCriteriaRequest funderCriteria) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
|
// public @ResponseBody ResponseEntity<ResponseItem<List<Funder>>> getWithExternal(@RequestBody FunderCriteriaRequest funderCriteria) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
//
|
||||||
List<Funder> dataTable = this.funderService.getCriteriaWithExternal(funderCriteria);
|
// List<Funder> dataTable = this.funderService.getCriteriaWithExternal(funderCriteria);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Funder>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Funder>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@PostMapping(path = {"projects"}, consumes = "application/json", produces = "application/json")
|
// @PostMapping(path = {"projects"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
// public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<List<Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
|
// ResponseEntity<ResponseItem<List<Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
//
|
||||||
List<Project> dataTable = this.projectService.getCriteriaWithExternal(projectCriteria);
|
// List<Project> dataTable = this.projectService.getCriteriaWithExternal(projectCriteria);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping(path = {"data-repo/{externalType}"}, produces = "application/json")
|
@GetMapping(path = {"data-repo/{externalType}"}, produces = "application/json")
|
||||||
public @ResponseBody ResponseEntity<ResponseItem<List<ExternalReference>>> listExternalReferecnes(@RequestParam(value = "externalType") String externalType, @RequestParam(value = "query", required = false) String query,
|
public @ResponseBody ResponseEntity<ResponseItem<List<ExternalReference>>> listExternalReferecnes(@RequestParam(value = "externalType") ExternalReferencesType externalType,
|
||||||
|
@RequestParam(value = "query", required = false) String query,
|
||||||
@RequestParam(value = "type", required = false) String type
|
@RequestParam(value = "type", required = false) String type
|
||||||
) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
@ -79,37 +81,37 @@ public class ExternalReferencesController extends BaseController {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalReference>>().status(ApiMessageCode.NO_MESSAGE).payload(externalReferences));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalReference>>().status(ApiMessageCode.NO_MESSAGE).payload(externalReferences));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
// @Transactional
|
||||||
@PostMapping(path = {"data-repo/persist"}, consumes = "application/json", produces = "application/json")
|
// @PostMapping(path = {"data-repo/persist"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
// public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<ExternalReference>> createExternalReferecnes(@RequestBody ExternalReference externalReference) throws Exception {
|
// ResponseEntity<ResponseItem<ExternalReference>> createExternalReferecnes(@RequestBody ExternalReference externalReference) throws Exception {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
//
|
||||||
ExternalReference newExternalReference = this.externalReferencesService.createDataRepo(externalReference);
|
// ExternalReference newExternalReference = this.externalReferencesService.createDataRepo(externalReference);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalReference>().payload(newExternalReference).status(ApiMessageCode.SUCCESS_MESSAGE));
|
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalReference>().payload(newExternalReference).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping(path = {"{externalType}"}, produces = "application/json")
|
// @GetMapping(path = {"{externalType}"}, produces = "application/json")
|
||||||
public @ResponseBody ResponseEntity<ResponseItem<List<ExternalReference2>>> listExternalReferecnes2(@RequestParam(value = "externalType") String externalType, @RequestParam(value = "query", required = false) String query,
|
// public @ResponseBody ResponseEntity<ResponseItem<List<ExternalReference2>>> listExternalReferecnes2(@RequestParam(value = "externalType") String externalType, @RequestParam(value = "query", required = false) String query,
|
||||||
@RequestParam(value = "type", required = false) String type
|
// @RequestParam(value = "type", required = false) String type
|
||||||
) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
// ) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
//
|
||||||
List<ExternalReference2> externalReferences = this.externalReferencesService.getExternalReference2(externalType, query, type);
|
// List<ExternalReference2> externalReferences = this.externalReferencesService.getExternalReference2(externalType, query, type);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalReference2>>().status(ApiMessageCode.NO_MESSAGE).payload(externalReferences));
|
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalReference2>>().status(ApiMessageCode.NO_MESSAGE).payload(externalReferences));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Transactional
|
// @Transactional
|
||||||
@PostMapping(value = {"{externalType}/persist"}, consumes = "application/json", produces = "application/json")
|
// @PostMapping(value = {"{externalType}/persist"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
// public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<ExternalReference2>> create(@RequestBody ExternalReference2 externalReference) throws Exception {
|
// ResponseEntity<ResponseItem<ExternalReference2>> create(@RequestBody ExternalReference2 externalReference) throws Exception {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
//
|
||||||
ExternalReference2 newExternalReference = this.externalReferencesService.create(externalReference);
|
// ExternalReference2 newExternalReference = this.externalReferencesService.create(externalReference);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalReference2>().payload(newExternalReference).status(ApiMessageCode.SUCCESS_MESSAGE));
|
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalReference2>().payload(newExternalReference).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.jayway.jsonpath.DocumentContext;
|
import com.jayway.jsonpath.DocumentContext;
|
||||||
import com.jayway.jsonpath.JsonPath;
|
import com.jayway.jsonpath.JsonPath;
|
||||||
|
import eu.eudat.commons.enums.ExternalReferencesType;
|
||||||
import eu.eudat.logic.proxy.config.*;
|
import eu.eudat.logic.proxy.config.*;
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
import eu.eudat.logic.proxy.config.entities.GenericUrls;
|
import eu.eudat.logic.proxy.config.entities.GenericUrls;
|
||||||
|
@ -50,55 +51,37 @@ public class RemoteFetcher {
|
||||||
).clientConnector(new ReactorClientHttpConnector(HttpClient.create().followRedirect(true))).build();
|
).clientConnector(new ReactorClientHttpConnector(HttpClient.create().followRedirect(true))).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Map<String, String>> get(String externalType, ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
public List<Map<String, String>> get(ExternalReferencesType externalType, ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
||||||
List<UrlConfiguration> urlConfigs = null;
|
|
||||||
FetchStrategy fetchStrategy = null;
|
FetchStrategy fetchStrategy = null;
|
||||||
switch (externalType){
|
GenericUrls exGenericUrls = this.getExternalUrls(externalType);
|
||||||
case "taxonomies":
|
List<UrlConfiguration> urlConfigs = key != null && !key.isEmpty() ? exGenericUrls.getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
||||||
urlConfigs = key != null && !key.isEmpty() ? configLoader.getExternalUrls().getTaxonomies().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
: exGenericUrls.getUrls();
|
||||||
: configLoader.getExternalUrls().getTaxonomies().getUrls();
|
|
||||||
fetchStrategy = configLoader.getExternalUrls().getTaxonomies().getFetchMode();
|
|
||||||
break;
|
|
||||||
case "licenses":
|
|
||||||
urlConfigs = key != null && !key.isEmpty() ? configLoader.getExternalUrls().getLicenses().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getLicenses().getUrls();
|
|
||||||
fetchStrategy = configLoader.getExternalUrls().getLicenses().getFetchMode();
|
|
||||||
break;
|
|
||||||
case "publications":
|
|
||||||
urlConfigs = key != null && !key.isEmpty() ? configLoader.getExternalUrls().getPublications().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getPublications().getUrls();
|
|
||||||
fetchStrategy = configLoader.getExternalUrls().getPublications().getFetchMode();
|
|
||||||
break;
|
|
||||||
case "journals":
|
|
||||||
urlConfigs = key != null && !key.isEmpty() ? configLoader.getExternalUrls().getJournals().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getJournals().getUrls();
|
|
||||||
fetchStrategy = configLoader.getExternalUrls().getJournals().getFetchMode();
|
|
||||||
break;
|
|
||||||
case "pubRepositories":
|
|
||||||
urlConfigs = key != null && !key.isEmpty() ? configLoader.getExternalUrls().getPubRepositories().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getPubRepositories().getUrls();
|
|
||||||
fetchStrategy = configLoader.getExternalUrls().getPubRepositories().getFetchMode();
|
|
||||||
break;
|
|
||||||
case "dataRepositories":
|
|
||||||
urlConfigs = key != null && !key.isEmpty() ? configLoader.getExternalUrls().getRepositories().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getRepositories().getUrls();
|
|
||||||
fetchStrategy = configLoader.getExternalUrls().getRepositories().getFetchMode();
|
|
||||||
break;
|
|
||||||
case "registries":
|
|
||||||
urlConfigs = key != null && !key.isEmpty() ? configLoader.getExternalUrls().getRegistries().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getRegistries().getUrls();
|
|
||||||
fetchStrategy = configLoader.getExternalUrls().getRegistries().getFetchMode();
|
|
||||||
break;
|
|
||||||
case "services":
|
|
||||||
urlConfigs = key != null && !key.isEmpty() ? configLoader.getExternalUrls().getServices().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
|
||||||
: configLoader.getExternalUrls().getServices().getUrls();
|
|
||||||
fetchStrategy = configLoader.getExternalUrls().getServices().getFetchMode();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GenericUrls getExternalUrls(ExternalReferencesType externalType) {
|
||||||
|
switch (externalType){
|
||||||
|
case Taxonomies: return configLoader.getExternalUrls().getTaxonomies();
|
||||||
|
case Licenses: return configLoader.getExternalUrls().getLicenses();
|
||||||
|
case Publications: return configLoader.getExternalUrls().getPublications();
|
||||||
|
case Journals: return configLoader.getExternalUrls().getJournals();
|
||||||
|
case PubRepositories: return configLoader.getExternalUrls().getPubRepositories();
|
||||||
|
case DataRepositories: return configLoader.getExternalUrls().getRepositories();
|
||||||
|
case Registries: return configLoader.getExternalUrls().getRegistries();
|
||||||
|
case Services: return configLoader.getExternalUrls().getServices();
|
||||||
|
case Grants: return configLoader.getExternalUrls().getGrants();
|
||||||
|
case Organizations: return configLoader.getExternalUrls().getOrganisations();
|
||||||
|
case Datasets: return configLoader.getExternalUrls().getDatasets();
|
||||||
|
case Founder: return configLoader.getExternalUrls().getFunders();
|
||||||
|
case Project: return configLoader.getExternalUrls().getProjects();
|
||||||
|
case Researcher: return configLoader.getExternalUrls().getResearchers();
|
||||||
|
case Validators: return configLoader.getExternalUrls().getValidations();
|
||||||
|
// case Prefillings: return configLoader.getExternalUrls().getPrefillings();
|
||||||
|
default: throw new IllegalArgumentException("Type not found" + externalType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Cacheable(value = "repositories", keyGenerator = "externalUrlsKeyGenerator")
|
@Cacheable(value = "repositories", keyGenerator = "externalUrlsKeyGenerator")
|
||||||
public List<Map<String, String>> getRepositories(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
public List<Map<String, String>> getRepositories(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
||||||
List<UrlConfiguration> urlConfigs =
|
List<UrlConfiguration> urlConfigs =
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.eudat.logic.services.externalreferences;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.commons.enums.ExternalReferencesType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
||||||
import eu.eudat.data.dao.criteria.RegistryCriteria;
|
import eu.eudat.data.dao.criteria.RegistryCriteria;
|
||||||
|
@ -15,9 +16,9 @@ import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.ExternalReference;
|
import eu.eudat.models.data.ExternalReference;
|
||||||
import eu.eudat.models.data.ExternalReference2;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -42,36 +43,36 @@ public class ExternalReferencesService {//implements ExternalReferencesService{
|
||||||
// pubRepositories,
|
// pubRepositories,
|
||||||
// dataRepositories
|
// dataRepositories
|
||||||
|
|
||||||
public ExternalReference createDataRepo(ExternalReference externalReference) throws Exception {
|
// public ExternalReference createDataRepo(ExternalReference externalReference) throws Exception {
|
||||||
// only dataRepositories, pubRepositories, journals
|
// // only dataRepositories, pubRepositories, journals
|
||||||
DataRepository dataRepository = externalReference.toDataModel();
|
// DataRepository dataRepository = externalReference.toDataModel();
|
||||||
dataRepository.getCreationUser().setId(this.userScope.getUserId());
|
// dataRepository.getCreationUser().setId(this.userScope.getUserId());
|
||||||
|
//
|
||||||
|
// dataRepository = apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao().createOrUpdate(dataRepository);
|
||||||
|
// return new ExternalReference().fromDataModel(dataRepository);
|
||||||
|
// }
|
||||||
|
|
||||||
dataRepository = apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao().createOrUpdate(dataRepository);
|
// public List<ExternalReference> getExternalReference(String externalType, String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
||||||
return new ExternalReference().fromDataModel(dataRepository);
|
// ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
||||||
}
|
// List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(externalType, externalUrlCriteria, type);
|
||||||
|
//
|
||||||
public List<ExternalReference> getExternalReference(String externalType, String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
// DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
// if (!query.isEmpty()) criteria.setLike(query);
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(externalType, externalUrlCriteria, type);
|
//
|
||||||
|
// List<ExternalReference> list = new LinkedList<>();
|
||||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
// if((externalType.equals("dataRepositories") || externalType.equals("pubRepositories") || externalType.equals("journals"))){
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
// criteria.setCreationUserId(this.userScope.getUserId());
|
||||||
|
// if (type.equals("")) {
|
||||||
List<ExternalReference> list = new LinkedList<>();
|
// List<DataRepository> dataRepositoryList = (this.apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao().getWithCriteria(criteria)).toList();
|
||||||
if((externalType.equals("dataRepositories") || externalType.equals("pubRepositories") || externalType.equals("journals"))){
|
// list = dataRepositoryList.stream().map(item -> new ExternalReference().fromDataModel(item)).collect(Collectors.toList());
|
||||||
criteria.setCreationUserId(this.userScope.getUserId());
|
// }
|
||||||
if (type.equals("")) {
|
// }
|
||||||
List<DataRepository> dataRepositoryList = (this.apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao().getWithCriteria(criteria)).toList();
|
//
|
||||||
list = dataRepositoryList.stream().map(item -> new ExternalReference().fromDataModel(item)).collect(Collectors.toList());
|
// ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
}
|
// list.addAll(remoteRepos.stream().map(item -> mapper.convertValue(item, ExternalReference.class)).collect(Collectors.toList()));
|
||||||
}
|
// list = list.stream().filter(x -> x.getName().toLowerCase().contains(query.toLowerCase())).collect(Collectors.toList());
|
||||||
|
// return list;
|
||||||
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
// }
|
||||||
list.addAll(remoteRepos.stream().map(item -> mapper.convertValue(item, ExternalReference.class)).collect(Collectors.toList()));
|
|
||||||
list = list.stream().filter(x -> x.getName().toLowerCase().contains(query.toLowerCase())).collect(Collectors.toList());
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,59 +80,115 @@ public class ExternalReferencesService {//implements ExternalReferencesService{
|
||||||
// registries,
|
// registries,
|
||||||
// services
|
// services
|
||||||
|
|
||||||
public ExternalReference2 create(ExternalReference2 externalReference) throws Exception {
|
// public ExternalReference2 create(ExternalReference2 externalReference) throws Exception {
|
||||||
if (externalReference.getLabel() == null || externalReference.getAbbreviation() == null || externalReference.getUri() == null) {
|
// if (externalReference.getLabel() == null || externalReference.getAbbreviation() == null || externalReference.getUri() == null) {
|
||||||
throw new Exception("Missing mandatory entity.");
|
// throw new Exception("Missing mandatory entity.");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// ExternalReference2 newExternalReference = null;
|
||||||
|
// if(externalReference.getExternalType().equals("registries")){
|
||||||
|
// Registry registry = externalReference.toDataModelRegistry();
|
||||||
|
// registry.getCreationUser().setId(this.userScope.getUserId());
|
||||||
|
// registry = apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao().createOrUpdate(registry);
|
||||||
|
// newExternalReference = new ExternalReference2().fromDataModel(registry);
|
||||||
|
// } else if (externalReference.getExternalType().equals("services")) {
|
||||||
|
// Service service = externalReference.toDataModelService();
|
||||||
|
// service.getCreationUser().setId(this.userScope.getUserId());
|
||||||
|
// service = apiContext.getOperationsContext().getDatabaseRepository().getServiceDao().createOrUpdate(service);
|
||||||
|
// newExternalReference = new ExternalReference2().fromDataModel(service);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return newExternalReference;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// public List<ExternalReference2> getExternalReference2(String externalType, String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
||||||
|
// ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
||||||
|
// List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(externalType,externalUrlCriteria, type);
|
||||||
|
//
|
||||||
|
// List<ExternalReference2> list = new LinkedList<>();
|
||||||
|
//
|
||||||
|
// if (externalType.equals("registries")){
|
||||||
|
// RegistryCriteria criteria = new RegistryCriteria();
|
||||||
|
//
|
||||||
|
// if (!query.isEmpty()) criteria.setLike(query);
|
||||||
|
// criteria.setCreationUserId(this.userScope.getUserId());
|
||||||
|
//
|
||||||
|
// if (type.equals("")) {
|
||||||
|
// List<Registry> registryList = (this.apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao().getWithCriteria(criteria)).toList();
|
||||||
|
// list = registryList.stream().map(item -> new ExternalReference2().fromDataModel(item)).collect(Collectors.toList());
|
||||||
|
// }
|
||||||
|
// } else if (externalType.equals("services")) {
|
||||||
|
// ServiceCriteria criteria = new ServiceCriteria();
|
||||||
|
//
|
||||||
|
// if (!query.isEmpty()) criteria.setLike(query);
|
||||||
|
// criteria.setCreationUserId(this.userScope.getUserId());
|
||||||
|
//
|
||||||
|
// if (type.equals("")) {
|
||||||
|
// List<Service> serviceList = (this.apiContext.getOperationsContext().getDatabaseRepository().getServiceDao().getWithCriteria(criteria)).toList();
|
||||||
|
// list = serviceList.stream().map(item -> new ExternalReference2().fromDataModel(item)).collect(Collectors.toList());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
// list.addAll(remoteRepos.stream().map(item -> mapper.convertValue(item, ExternalReference2.class)).collect(Collectors.toList()));
|
||||||
|
//
|
||||||
|
// return list;
|
||||||
|
// }
|
||||||
|
|
||||||
ExternalReference2 newExternalReference = null;
|
public List<ExternalReference> getExternalReference(ExternalReferencesType externalType, String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
||||||
if(externalReference.getExternalType().equals("registries")){
|
|
||||||
Registry registry = externalReference.toDataModelRegistry();
|
|
||||||
registry.getCreationUser().setId(this.userScope.getUserId());
|
|
||||||
registry = apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao().createOrUpdate(registry);
|
|
||||||
newExternalReference = new ExternalReference2().fromDataModel(registry);
|
|
||||||
} else if (externalReference.getExternalType().equals("services")) {
|
|
||||||
Service service = externalReference.toDataModelService();
|
|
||||||
service.getCreationUser().setId(this.userScope.getUserId());
|
|
||||||
service = apiContext.getOperationsContext().getDatabaseRepository().getServiceDao().createOrUpdate(service);
|
|
||||||
newExternalReference = new ExternalReference2().fromDataModel(service);
|
|
||||||
}
|
|
||||||
|
|
||||||
return newExternalReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<ExternalReference2> getExternalReference2(String externalType, String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
||||||
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(externalType,externalUrlCriteria, type);
|
List<Map<String, String>> remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(externalType, externalUrlCriteria, type);
|
||||||
|
|
||||||
List<ExternalReference2> list = new LinkedList<>();
|
List<ExternalReference> list = this.fetchFromDb(externalType, query, type);
|
||||||
|
|
||||||
if (externalType.equals("registries")){
|
list.addAll(remoteRepos.stream().map(ExternalReference::fromRemoteModel).toList());
|
||||||
RegistryCriteria criteria = new RegistryCriteria();
|
list = list.stream().filter(x -> x.getName().toLowerCase().contains(query.toLowerCase())).collect(Collectors.toList());
|
||||||
|
list.sort(Comparator.comparing(ExternalReference::getName));
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
return list;
|
||||||
criteria.setCreationUserId(this.userScope.getUserId());
|
}
|
||||||
|
|
||||||
if (type.equals("")) {
|
private List<ExternalReference> fetchFromDb(ExternalReferencesType externalType, String query, String type) throws InvalidApplicationException {
|
||||||
List<Registry> registryList = (this.apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao().getWithCriteria(criteria)).toList();
|
List<ExternalReference> list = new LinkedList<>();
|
||||||
list = registryList.stream().map(item -> new ExternalReference2().fromDataModel(item)).collect(Collectors.toList());
|
switch (externalType) {
|
||||||
|
case DataRepositories:
|
||||||
|
case PubRepositories:
|
||||||
|
case Journals: {
|
||||||
|
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||||
|
if (!query.isEmpty()) criteria.setLike(query);
|
||||||
|
criteria.setCreationUserId(this.userScope.getUserId());
|
||||||
|
if (type.equals("")) {
|
||||||
|
List<DataRepository> dataRepositoryList = (this.apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao().getWithCriteria(criteria)).toList();
|
||||||
|
list = dataRepositoryList.stream().map(item -> new ExternalReference().fromDataRepository(item)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (externalType.equals("services")) {
|
case Registries: {
|
||||||
ServiceCriteria criteria = new ServiceCriteria();
|
RegistryCriteria criteria = new RegistryCriteria();
|
||||||
|
if (!query.isEmpty()) criteria.setLike(query);
|
||||||
if (!query.isEmpty()) criteria.setLike(query);
|
criteria.setCreationUserId(this.userScope.getUserId());
|
||||||
criteria.setCreationUserId(this.userScope.getUserId());
|
if (type.equals("")) {
|
||||||
|
List<Registry> registryList = (this.apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao().getWithCriteria(criteria)).toList();
|
||||||
if (type.equals("")) {
|
list = registryList.stream().map(item -> new ExternalReference().fromRegistry(item)).collect(Collectors.toList());
|
||||||
List<Service> serviceList = (this.apiContext.getOperationsContext().getDatabaseRepository().getServiceDao().getWithCriteria(criteria)).toList();
|
}
|
||||||
list = serviceList.stream().map(item -> new ExternalReference2().fromDataModel(item)).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
case Services:
|
||||||
|
{
|
||||||
|
ServiceCriteria criteria = new ServiceCriteria();
|
||||||
|
|
||||||
|
if (!query.isEmpty()) criteria.setLike(query);
|
||||||
|
criteria.setCreationUserId(this.userScope.getUserId());
|
||||||
|
|
||||||
|
if (type.equals("")) {
|
||||||
|
List<Service> serviceList = (this.apiContext.getOperationsContext().getDatabaseRepository().getServiceDao().getWithCriteria(criteria)).toList();
|
||||||
|
list = serviceList.stream().map(item -> new ExternalReference().fromService(item)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case Taxonomies:
|
||||||
|
case Publications:
|
||||||
|
case Licenses:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
list.addAll(remoteRepos.stream().map(item -> mapper.convertValue(item, ExternalReference2.class)).collect(Collectors.toList()));
|
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,34 +1,64 @@
|
||||||
package eu.eudat.models.data;
|
package eu.eudat.models.data;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.data.old.DataRepository;
|
import eu.eudat.data.old.DataRepository;
|
||||||
|
import eu.eudat.data.old.Registry;
|
||||||
|
import eu.eudat.data.old.Service;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
|
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ExternalReference {
|
public class ExternalReference {
|
||||||
private UUID id;
|
|
||||||
private String name;
|
|
||||||
private String pid;
|
|
||||||
private String abbreviation;
|
|
||||||
private String uri;
|
|
||||||
private Date created;
|
|
||||||
private Date modified;
|
|
||||||
private String tag; // Api fetching the data
|
|
||||||
private String source; // Actual harvested source
|
|
||||||
|
|
||||||
public UUID getId() {
|
private String id;
|
||||||
|
private String name;
|
||||||
|
private String abbreviation;
|
||||||
|
private String pid;
|
||||||
|
private String originalId;
|
||||||
|
private String key;
|
||||||
|
private String pidTypeField;
|
||||||
|
private String uri;
|
||||||
|
private String description;
|
||||||
|
private String source;
|
||||||
|
private String count;
|
||||||
|
private String path;
|
||||||
|
private String host;
|
||||||
|
private String types;
|
||||||
|
private String firstName;
|
||||||
|
private String lastName;
|
||||||
|
private String tag;
|
||||||
|
|
||||||
|
public String getOriginalId() {
|
||||||
|
return originalId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOriginalId(String originalId) {
|
||||||
|
this.originalId = originalId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
public void setId(UUID id) {
|
|
||||||
|
public void setId(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
@ -36,58 +66,136 @@ public class ExternalReference {
|
||||||
public String getPid() {
|
public String getPid() {
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPid(String pid) {
|
public void setPid(String pid) {
|
||||||
this.pid = pid;
|
this.pid = pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAbbreviation() {
|
public String getPidTypeField() {
|
||||||
return abbreviation;
|
return pidTypeField;
|
||||||
}
|
}
|
||||||
public void setAbbreviation(String abbreviation) {
|
|
||||||
this.abbreviation = abbreviation;
|
public void setPidTypeField(String pidTypeField) {
|
||||||
|
this.pidTypeField = pidTypeField;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUri() {
|
public String getUri() {
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUri(String uri) {
|
public void setUri(String uri) {
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreated() {
|
public String getDescription() {
|
||||||
return created;
|
return description;
|
||||||
}
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getModified() {
|
public void setDescription(String description) {
|
||||||
return modified;
|
this.description = description;
|
||||||
}
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTag() {
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
public void setTag(String tag) {
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSource() {
|
public String getSource() {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSource(String source) {
|
public void setSource(String source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCount() {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
public ExternalReference fromDataModel(DataRepository entity) {
|
public void setCount(String count) {
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath(String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHost() {
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHost(String host) {
|
||||||
|
this.host = host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTypes() {
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypes(String types) {
|
||||||
|
this.types = types;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTag() {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTag(String tag) {
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAbbreviation() {
|
||||||
|
return abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbbreviation(String abbreviation) {
|
||||||
|
this.abbreviation = abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ExternalReference fromRemoteModel(Map<String, String> data) {
|
||||||
|
ExternalReference externalReference = new ExternalReference();
|
||||||
|
if (data == null) return externalReference;
|
||||||
|
|
||||||
|
externalReference.setId(data.getOrDefault("id", null));
|
||||||
|
externalReference.setName(data.getOrDefault("name", null));
|
||||||
|
externalReference.setAbbreviation(data.getOrDefault("abbreviation", null));
|
||||||
|
externalReference.setPid(data.getOrDefault("pid", null));
|
||||||
|
externalReference.setOriginalId(data.getOrDefault("originalId", null));
|
||||||
|
externalReference.setKey(data.getOrDefault("key", null));
|
||||||
|
externalReference.setPidTypeField(data.getOrDefault("pidTypeField", null));
|
||||||
|
externalReference.setUri(data.getOrDefault("uri", null));
|
||||||
|
externalReference.setDescription(data.getOrDefault("description", null));
|
||||||
|
externalReference.setSource(data.getOrDefault("source", null));
|
||||||
|
externalReference.setCount(data.getOrDefault("count", null));
|
||||||
|
externalReference.setPath(data.getOrDefault("path", null));
|
||||||
|
externalReference.setHost(data.getOrDefault("host", null));
|
||||||
|
externalReference.setTypes(data.getOrDefault("types", null));
|
||||||
|
externalReference.setFirstName(data.getOrDefault("firstName", null));
|
||||||
|
externalReference.setLastName(data.getOrDefault("lastName", null));
|
||||||
|
externalReference.setTag(data.getOrDefault("tag", null));
|
||||||
|
return externalReference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExternalReference fromDataRepository(DataRepository entity) {
|
||||||
this.setAbbreviation(entity.getAbbreviation());
|
this.setAbbreviation(entity.getAbbreviation());
|
||||||
this.setName(entity.getLabel());
|
this.setName(entity.getLabel());
|
||||||
this.setUri(entity.getUri());
|
this.setUri(entity.getUri());
|
||||||
this.setId(entity.getId());
|
this.setId(entity.getId().toString());
|
||||||
this.setPid(entity.getReference());
|
this.setPid(entity.getReference());
|
||||||
String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
||||||
if (source1.equals("dmp")) {
|
if (source1.equals("dmp")) {
|
||||||
|
@ -97,30 +205,38 @@ public class ExternalReference {
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataRepository toDataModel() throws Exception {
|
public ExternalReference fromRegistry(Registry entity){
|
||||||
DataRepository dataRepository = new DataRepository();
|
this.id = entity.getId().toString();
|
||||||
dataRepository.setId(this.id != null ? this.id : UUID.randomUUID());
|
this.abbreviation = entity.getAbbreviation();
|
||||||
dataRepository.setAbbreviation(this.abbreviation);
|
// this.created = entity.getCreated();
|
||||||
dataRepository.setCreated(this.created != null ? this.created : new Date());
|
// this.label = entity.getLabel();
|
||||||
dataRepository.setModified(new Date());
|
this.name = entity.getLabel();
|
||||||
dataRepository.setLabel(this.name);
|
// this.modified = entity.getModified();
|
||||||
if (this.source != null) {
|
this.uri = entity.getUri();
|
||||||
if (this.source.equals("Internal") || this.source.equals(this.id.toString().substring(0, this.source.length()))) {
|
String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
||||||
dataRepository.setReference(this.id.toString());
|
if (source1.equals("dmp")) {
|
||||||
} else {
|
this.source = "Internal";
|
||||||
dataRepository.setReference(this.source + ":" + dataRepository.getId());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
dataRepository.setReference("dmp:" + dataRepository.getId());
|
this.source = source1;
|
||||||
}
|
}
|
||||||
dataRepository.setUri(this.uri);
|
// this.reference = entity.getReference();
|
||||||
dataRepository.setStatus((short) 0);
|
return this;
|
||||||
dataRepository.setCreationUser(new UserInfo());
|
|
||||||
return dataRepository;
|
|
||||||
}
|
}
|
||||||
|
public ExternalReference fromService(Service entity) {
|
||||||
public String getHint() {
|
this.abbreviation = entity.getAbbreviation();
|
||||||
return null;
|
// this.created = entity.getCreated();
|
||||||
|
this.id = entity.getId().toString();
|
||||||
|
// this.label = entity.getLabel();
|
||||||
|
this.name = entity.getLabel();
|
||||||
|
// this.modified = entity.getModified();
|
||||||
|
this.uri = entity.getUri();
|
||||||
|
String source = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
||||||
|
if (source.equals("dmp")) {
|
||||||
|
this.source = "Internal";
|
||||||
|
} else {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue