Adds remote fetching on "External Dataset" and fixes bug on "external references" not saving the correct "reference" property.
This commit is contained in:
parent
1ef0782989
commit
2b62cdbe4e
|
@ -1,7 +1,15 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.data.entities.ExternalDataset;
|
import eu.eudat.data.entities.ExternalDataset;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ExternalDatasetCriteria extends Criteria<ExternalDataset> {
|
public class ExternalDatasetCriteria extends Criteria<ExternalDataset> {
|
||||||
|
private UUID creationUserId;
|
||||||
|
|
||||||
|
public UUID getCreationUserId() {
|
||||||
|
return creationUserId;
|
||||||
|
}
|
||||||
|
public void setCreationUserId(UUID creationUserId) {
|
||||||
|
this.creationUserId = creationUserId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ public class ExternalDatasetDaoImpl extends DatabaseAccess<ExternalDataset> impl
|
||||||
query.where((builder, root) -> builder.or(
|
query.where((builder, root) -> builder.or(
|
||||||
builder.like(builder.upper(root.get("reference")), "%" + criteria.getLike().toUpperCase() + "%"),
|
builder.like(builder.upper(root.get("reference")), "%" + criteria.getLike().toUpperCase() + "%"),
|
||||||
builder.equal(builder.upper(root.get("label")), criteria.getLike().toUpperCase())));
|
builder.equal(builder.upper(root.get("label")), criteria.getLike().toUpperCase())));
|
||||||
|
if (criteria.getCreationUserId() != null)
|
||||||
|
query.where((builder, root) -> builder.equal(root.join("creationUser").get("id"), criteria.getCreationUserId()));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class ResponsesCache {
|
||||||
caches.add(new GuavaCache("services", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("services", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
caches.add(new GuavaCache("tags", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("tags", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
caches.add(new GuavaCache("researchers", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("researchers", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
|
caches.add(new GuavaCache("externalDatasets", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
simpleCacheManager.setCaches(caches);
|
simpleCacheManager.setCaches(caches);
|
||||||
System.out.println("OK");
|
System.out.println("OK");
|
||||||
return simpleCacheManager;
|
return simpleCacheManager;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class ExternalDatasets extends BaseController {
|
||||||
ResponseEntity<ResponseItem<List<ExternalDatasetListingModel>>> getWithExternal(
|
ResponseEntity<ResponseItem<List<ExternalDatasetListingModel>>> getWithExternal(
|
||||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type, Principal principal
|
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type, Principal principal
|
||||||
) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException {
|
) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException {
|
||||||
List<ExternalDatasetListingModel> dataTable = externalDatasetManager.getWithExternal(query);
|
List<ExternalDatasetListingModel> dataTable = externalDatasetManager.getWithExternal(query, type, principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalDatasetListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalDatasetListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -515,13 +515,15 @@ public class DatasetManager {
|
||||||
if (dataset.getDatasetExternalDatasets() != null && !dataset.getDatasetExternalDatasets().isEmpty()) {
|
if (dataset.getDatasetExternalDatasets() != null && !dataset.getDatasetExternalDatasets().isEmpty()) {
|
||||||
for (eu.eudat.data.entities.DatasetExternalDataset datasetExternalDataset : dataset.getDatasetExternalDatasets()) {
|
for (eu.eudat.data.entities.DatasetExternalDataset datasetExternalDataset : dataset.getDatasetExternalDatasets()) {
|
||||||
ExternalDatasetCriteria criteria = new ExternalDatasetCriteria();
|
ExternalDatasetCriteria criteria = new ExternalDatasetCriteria();
|
||||||
criteria.setLike(datasetExternalDataset.getExternalDataset().getLabel());
|
criteria.setLike(datasetExternalDataset.getExternalDataset().getReference());
|
||||||
List<eu.eudat.data.entities.ExternalDataset> entries = databaseRepository.getExternalDatasetDao().getWithCriteria(criteria).toList();
|
List<eu.eudat.data.entities.ExternalDataset> entries = databaseRepository.getExternalDatasetDao().getWithCriteria(criteria).toList();
|
||||||
if (entries != null && !entries.isEmpty()) {
|
if (entries != null && !entries.isEmpty()) {
|
||||||
datasetExternalDataset.getExternalDataset().setId(entries.get(0).getId());
|
datasetExternalDataset.getExternalDataset().setId(entries.get(0).getId());
|
||||||
datasetExternalDataset.setDataset(dataset);
|
datasetExternalDataset.setDataset(dataset);
|
||||||
dataset.getDatasetExternalDatasets().add(datasetExternalDataset);
|
dataset.getDatasetExternalDatasets().add(datasetExternalDataset);
|
||||||
} else {
|
} else {
|
||||||
|
datasetExternalDataset.getExternalDataset().setId(UUID.randomUUID());
|
||||||
|
datasetExternalDataset.setDataset(dataset);
|
||||||
ExternalDataset externalDataset = databaseRepository.getExternalDatasetDao().createOrUpdate(datasetExternalDataset.getExternalDataset());
|
ExternalDataset externalDataset = databaseRepository.getExternalDatasetDao().createOrUpdate(datasetExternalDataset.getExternalDataset());
|
||||||
datasetExternalDataset.setExternalDataset(externalDataset);
|
datasetExternalDataset.setExternalDataset(externalDataset);
|
||||||
dataset.getDatasetExternalDatasets().add(datasetExternalDataset);
|
dataset.getDatasetExternalDatasets().add(datasetExternalDataset);
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.logic.builders.model.criteria.ExternalDatasetCriteriaBuilder;
|
import eu.eudat.logic.builders.model.criteria.ExternalDatasetCriteriaBuilder;
|
||||||
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
||||||
import eu.eudat.data.entities.ExternalDataset;
|
import eu.eudat.data.entities.ExternalDataset;
|
||||||
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
||||||
|
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
|
import eu.eudat.models.data.external.ExternalDatasetSourcesModel;
|
||||||
|
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
||||||
import eu.eudat.models.data.externaldataset.ExternalDatasetListingModel;
|
import eu.eudat.models.data.externaldataset.ExternalDatasetListingModel;
|
||||||
import eu.eudat.data.query.items.table.externaldataset.ExternalDatasetTableRequest;
|
import eu.eudat.data.query.items.table.externaldataset.ExternalDatasetTableRequest;
|
||||||
|
import eu.eudat.models.data.externaldataset.ExternalDatasetModel;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||||
|
@ -17,8 +23,11 @@ import eu.eudat.logic.services.ApiContext;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ExternalDatasetManager {
|
public class ExternalDatasetManager {
|
||||||
|
@ -40,10 +49,26 @@ public class ExternalDatasetManager {
|
||||||
return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(externalDatasetListingmodels).totalCount(items.count()).build();
|
return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(externalDatasetListingmodels).totalCount(items.count()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ExternalDatasetListingModel> getWithExternal(String query) throws HugeResultSet, NoURLFound, InstantiationException, IllegalAccessException {
|
public List<ExternalDatasetListingModel> getWithExternal(String query, String type, Principal principal) throws HugeResultSet, NoURLFound {
|
||||||
|
// Fetch the local saved external Datasets that belong to the user.
|
||||||
ExternalDatasetCriteria criteria = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ExternalDatasetCriteriaBuilder.class).like(query).build();
|
ExternalDatasetCriteria criteria = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ExternalDatasetCriteriaBuilder.class).like(query).build();
|
||||||
|
criteria.setCreationUserId(principal.getId());
|
||||||
QueryableList<eu.eudat.data.entities.ExternalDataset> items = apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao().getWithCriteria(criteria);
|
QueryableList<eu.eudat.data.entities.ExternalDataset> items = apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao().getWithCriteria(criteria);
|
||||||
|
|
||||||
|
// Fetch external Datasets from external sources.
|
||||||
|
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
||||||
|
List<Map<String, String>> remoteRepos = remoteFetcher.getDatasets(externalUrlCriteria, type);
|
||||||
|
|
||||||
|
// Parse items from external sources to listing models.
|
||||||
|
ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
List<ExternalDatasetListingModel> externalDatasetModels = remoteRepos.stream()
|
||||||
|
.map(item -> mapper.convertValue(item, ExternalDatasetListingModel.class))
|
||||||
|
.collect(Collectors.toCollection(LinkedList::new));
|
||||||
|
|
||||||
|
// Merge fetched and local.
|
||||||
List<ExternalDatasetListingModel> externalDatasets = items.select(item -> new ExternalDatasetListingModel().fromDataModel(item));
|
List<ExternalDatasetListingModel> externalDatasets = items.select(item -> new ExternalDatasetListingModel().fromDataModel(item));
|
||||||
|
externalDatasets.addAll(externalDatasetModels);
|
||||||
|
|
||||||
return externalDatasets;
|
return externalDatasets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class RemoteFetcher {
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable("datasets")
|
@Cacheable("externalDatasets")
|
||||||
public List<Map<String, String>> getDatasets(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
public List<Map<String, String>> getDatasets(ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
||||||
List<UrlConfiguration> urlConfigs =
|
List<UrlConfiguration> urlConfigs =
|
||||||
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getDatasets().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
key != null && !key.isEmpty() ? configLoader.getExternalUrls().getDatasets().getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
||||||
|
|
|
@ -85,11 +85,17 @@ public class DataRepository implements DataModel<eu.eudat.data.entities.DataRepo
|
||||||
entity.setCreated(new Date());
|
entity.setCreated(new Date());
|
||||||
entity.setModified(new Date());
|
entity.setModified(new Date());
|
||||||
entity.setStatus((short) 0);
|
entity.setStatus((short) 0);
|
||||||
if (this.source == null) this.source = "dmp";
|
if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
|
||||||
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
if (this.reference != null && !this.reference.trim().isEmpty()
|
||||||
entity.setReference(this.reference);
|
&& this.source != null && !this.source.trim().isEmpty()) {
|
||||||
} else {
|
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
||||||
entity.setReference(this.source + ":" + this.reference);
|
entity.setReference(this.reference);
|
||||||
|
} else {
|
||||||
|
entity.setReference(this.source + ":" + this.reference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.reference == null) {
|
||||||
|
entity.setReference(this.source + ":" + this.label);
|
||||||
}
|
}
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,11 +89,17 @@ public class Registry implements DataModel<eu.eudat.data.entities.Registry, Regi
|
||||||
entity.setId(this.id != null ? this.id : UUID.randomUUID());
|
entity.setId(this.id != null ? this.id : UUID.randomUUID());
|
||||||
entity.setLabel(this.label);
|
entity.setLabel(this.label);
|
||||||
entity.setAbbreviation(this.abbreviation);
|
entity.setAbbreviation(this.abbreviation);
|
||||||
if (this.source == null) this.source = "dmp";
|
if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
|
||||||
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
if (this.reference != null && !this.reference.trim().isEmpty()
|
||||||
entity.setReference(this.reference);
|
&& this.source != null && !this.source.trim().isEmpty()) {
|
||||||
} else {
|
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
||||||
entity.setReference(this.source + ":" + this.reference);
|
entity.setReference(this.reference);
|
||||||
|
} else {
|
||||||
|
entity.setReference(this.source + ":" + this.reference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.reference == null) {
|
||||||
|
entity.setReference(this.source + ":" + this.label);
|
||||||
}
|
}
|
||||||
entity.setUri(this.uri);
|
entity.setUri(this.uri);
|
||||||
entity.setModified(new Date());
|
entity.setModified(new Date());
|
||||||
|
|
|
@ -86,12 +86,17 @@ public class Service implements DataModel<eu.eudat.data.entities.Service, Servic
|
||||||
entity.setId(this.id != null ? this.id : UUID.randomUUID());
|
entity.setId(this.id != null ? this.id : UUID.randomUUID());
|
||||||
entity.setLabel(this.label);
|
entity.setLabel(this.label);
|
||||||
entity.setAbbreviation(this.abbreviation);
|
entity.setAbbreviation(this.abbreviation);
|
||||||
if (this.source == null) this.source = "dmp";
|
if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
|
||||||
if (this.reference == null) this.reference = entity.getId().toString();
|
if (this.reference != null && !this.reference.trim().isEmpty()
|
||||||
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
&& this.source != null && !this.source.trim().isEmpty()) {
|
||||||
entity.setReference(this.reference);
|
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
||||||
} else {
|
entity.setReference(this.reference);
|
||||||
entity.setReference(this.source + ":" + this.reference);
|
} else {
|
||||||
|
entity.setReference(this.source + ":" + this.reference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.reference == null) {
|
||||||
|
entity.setReference(this.source + ":" + this.label);
|
||||||
}
|
}
|
||||||
entity.setUri(this.uri);
|
entity.setUri(this.uri);
|
||||||
entity.setModified(new Date());
|
entity.setModified(new Date());
|
||||||
|
|
|
@ -4,14 +4,15 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class ExternalDatasetModel extends ExternalListingItem<ExternalDatasetModel> {
|
public class ExternalDatasetSourcesModel extends ExternalListingItem<ExternalDatasetSourcesModel> {
|
||||||
@Override
|
@Override
|
||||||
public ExternalDatasetModel fromExternalItem(List<Map<String, String>> values) {
|
public ExternalDatasetSourcesModel fromExternalItem(List<Map<String, String>> values) {
|
||||||
for (Map<String, String> item : values) {
|
for (Map<String, String> item : values) {
|
||||||
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
|
ExternalSourcesItemModel model = new ExternalSourcesItemModel();
|
||||||
model.setId(item.get("pid"));
|
model.setId(item.get("pid"));
|
||||||
model.setUri(item.get("uri"));
|
model.setUri(item.get("uri"));
|
||||||
model.setName(item.get("name"));
|
model.setName(item.get("name"));
|
||||||
|
model.setSource(item.get("source"));
|
||||||
this.add(model);
|
this.add(model);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.data.external;
|
||||||
|
|
||||||
public class ExternalSourcesItemModel {
|
public class ExternalSourcesItemModel {
|
||||||
private String id;
|
private String id;
|
||||||
|
private String pid;
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
private String uri;
|
private String uri;
|
||||||
|
@ -14,15 +15,20 @@ public class ExternalSourcesItemModel {
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPid() {
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
public void setPid(String pid) {
|
||||||
|
this.pid = pid;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +36,6 @@ public class ExternalSourcesItemModel {
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +43,6 @@ public class ExternalSourcesItemModel {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +50,6 @@ public class ExternalSourcesItemModel {
|
||||||
public String getRemoteId() {
|
public String getRemoteId() {
|
||||||
return remoteId;
|
return remoteId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRemoteId(String remoteId) {
|
public void setRemoteId(String remoteId) {
|
||||||
this.remoteId = remoteId;
|
this.remoteId = remoteId;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +57,6 @@ public class ExternalSourcesItemModel {
|
||||||
public String getAbbreviation() {
|
public String getAbbreviation() {
|
||||||
return abbreviation;
|
return abbreviation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAbbreviation(String abbreviation) {
|
public void setAbbreviation(String abbreviation) {
|
||||||
this.abbreviation = abbreviation;
|
this.abbreviation = abbreviation;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +64,6 @@ public class ExternalSourcesItemModel {
|
||||||
public String getTag() {
|
public String getTag() {
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTag(String tag) {
|
public void setTag(String tag) {
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +71,6 @@ public class ExternalSourcesItemModel {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,34 +10,35 @@ import java.util.UUID;
|
||||||
public class ExternalDatasetListingModel implements DataModel<ExternalDataset, ExternalDatasetListingModel> {
|
public class ExternalDatasetListingModel implements DataModel<ExternalDataset, ExternalDatasetListingModel> {
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String label;
|
private String name;
|
||||||
private String abbreviation;
|
private String abbreviation;
|
||||||
private String reference;
|
private String reference;
|
||||||
private Date created;
|
private Date created;
|
||||||
private Date modified;
|
private Date modified;
|
||||||
private String info;
|
private String info;
|
||||||
private ExternalDatasetType type;
|
private ExternalDatasetType type;
|
||||||
|
private String pid;
|
||||||
|
private String uri;
|
||||||
|
private String tag; // Api fetching the data
|
||||||
|
private String source; // Actual harvested source
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(UUID id) {
|
public void setId(UUID id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabel() {
|
public String getName() {
|
||||||
return label;
|
return name;
|
||||||
}
|
}
|
||||||
|
public void setName(String name) {
|
||||||
public void setLabel(String label) {
|
this.name = name;
|
||||||
this.label = label;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAbbreviation() {
|
public String getAbbreviation() {
|
||||||
return abbreviation;
|
return abbreviation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAbbreviation(String abbreviation) {
|
public void setAbbreviation(String abbreviation) {
|
||||||
this.abbreviation = abbreviation;
|
this.abbreviation = abbreviation;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +46,6 @@ public class ExternalDatasetListingModel implements DataModel<ExternalDataset, E
|
||||||
public String getReference() {
|
public String getReference() {
|
||||||
return reference;
|
return reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReference(String reference) {
|
public void setReference(String reference) {
|
||||||
this.reference = reference;
|
this.reference = reference;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,6 @@ public class ExternalDatasetListingModel implements DataModel<ExternalDataset, E
|
||||||
public Date getCreated() {
|
public Date getCreated() {
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreated(Date created) {
|
public void setCreated(Date created) {
|
||||||
this.created = created;
|
this.created = created;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +60,6 @@ public class ExternalDatasetListingModel implements DataModel<ExternalDataset, E
|
||||||
public Date getModified() {
|
public Date getModified() {
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModified(Date modified) {
|
public void setModified(Date modified) {
|
||||||
this.modified = modified;
|
this.modified = modified;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +67,6 @@ public class ExternalDatasetListingModel implements DataModel<ExternalDataset, E
|
||||||
public Integer getType() {
|
public Integer getType() {
|
||||||
return type != null ? type.getValue() : null;
|
return type != null ? type.getValue() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(Integer type) {
|
public void setType(Integer type) {
|
||||||
this.type = ExternalDatasetType.fromInteger(type);
|
this.type = ExternalDatasetType.fromInteger(type);
|
||||||
}
|
}
|
||||||
|
@ -77,19 +74,52 @@ public class ExternalDatasetListingModel implements DataModel<ExternalDataset, E
|
||||||
public String getInfo() {
|
public String getInfo() {
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInfo(String info) {
|
public void setInfo(String info) {
|
||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPid() {
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
public void setPid(String pid) {
|
||||||
|
this.pid = pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUri() {
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
public void setUri(String uri) {
|
||||||
|
this.uri = uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTag() {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
public void setTag(String tag) {
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
public void setSource(String source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExternalDatasetListingModel fromDataModel(ExternalDataset entity) {
|
public ExternalDatasetListingModel fromDataModel(ExternalDataset entity) {
|
||||||
this.id = entity.getId();
|
this.id = entity.getId();
|
||||||
this.abbreviation = entity.getAbbreviation();
|
this.abbreviation = entity.getAbbreviation();
|
||||||
this.label = entity.getLabel();
|
this.name = entity.getLabel();
|
||||||
this.modified = entity.getModified();
|
this.modified = entity.getModified();
|
||||||
this.created = entity.getCreated();
|
this.created = entity.getCreated();
|
||||||
this.reference = entity.getReference();
|
this.reference = entity.getReference();
|
||||||
|
String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
||||||
|
if (source1.equals("dmp")) {
|
||||||
|
this.source = "Internal";
|
||||||
|
} else {
|
||||||
|
this.source = source1;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,10 +128,22 @@ public class ExternalDatasetListingModel implements DataModel<ExternalDataset, E
|
||||||
ExternalDataset externalDataset = new ExternalDataset();
|
ExternalDataset externalDataset = new ExternalDataset();
|
||||||
externalDataset.setAbbreviation(this.abbreviation);
|
externalDataset.setAbbreviation(this.abbreviation);
|
||||||
externalDataset.setCreated(this.created != null ? this.created : new Date());
|
externalDataset.setCreated(this.created != null ? this.created : new Date());
|
||||||
externalDataset.setLabel(this.label);
|
externalDataset.setLabel(this.name);
|
||||||
externalDataset.setId(this.id);
|
externalDataset.setId(this.id);
|
||||||
externalDataset.setModified(this.modified);
|
externalDataset.setModified(this.modified);
|
||||||
externalDataset.setReference(this.reference);
|
if (this.source != null && this.source.equals("Internal")) this.source = "dmp";
|
||||||
|
if (this.reference != null && !this.reference.trim().isEmpty()
|
||||||
|
&& this.source != null && !this.source.trim().isEmpty()) {
|
||||||
|
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
||||||
|
externalDataset.setReference(this.reference);
|
||||||
|
} else {
|
||||||
|
externalDataset.setReference(this.source + ":" + this.reference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.reference == null) {
|
||||||
|
externalDataset.setReference(this.source + ":" + this.name);
|
||||||
|
}
|
||||||
|
externalDataset.setModified(new Date());
|
||||||
return externalDataset;
|
return externalDataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { ExternalDatasetType } from '../../common/enum/external-dataset-type';
|
||||||
export interface ExternalDatasetModel {
|
export interface ExternalDatasetModel {
|
||||||
abbreviation: String;
|
abbreviation: String;
|
||||||
id: String;
|
id: String;
|
||||||
label: String;
|
name: String;
|
||||||
reference: String;
|
reference: String;
|
||||||
type: ExternalDatasetType;
|
type: ExternalDatasetType;
|
||||||
info: String;
|
info: String;
|
||||||
|
|
|
@ -260,16 +260,16 @@ export class ExternalDatasetEditorModel {
|
||||||
|
|
||||||
public abbreviation: String;
|
public abbreviation: String;
|
||||||
public id: String;
|
public id: String;
|
||||||
public label: String;
|
public name: String;
|
||||||
public reference: String;
|
public reference: String;
|
||||||
public type: ExternalDatasetType;
|
public type: ExternalDatasetType;
|
||||||
public info: String;
|
public info: String;
|
||||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
||||||
public source: String;
|
public source: String;
|
||||||
|
|
||||||
constructor(id?: string, abbreviation?: string, label?: string, reference?: string, info?: string, type?: ExternalDatasetType, source?: String) {
|
constructor(id?: string, abbreviation?: string, name?: string, reference?: string, source?: String, info?: string, type?: ExternalDatasetType) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.label = label;
|
this.name = name;
|
||||||
this.abbreviation = abbreviation;
|
this.abbreviation = abbreviation;
|
||||||
this.reference = reference;
|
this.reference = reference;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
|
@ -280,7 +280,7 @@ export class ExternalDatasetEditorModel {
|
||||||
fromModel(item: ExternalDatasetModel): ExternalDatasetEditorModel {
|
fromModel(item: ExternalDatasetModel): ExternalDatasetEditorModel {
|
||||||
this.abbreviation = item.abbreviation;
|
this.abbreviation = item.abbreviation;
|
||||||
this.id = item.id;
|
this.id = item.id;
|
||||||
this.label = item.label;
|
this.name = item.name;
|
||||||
this.reference = item.reference;
|
this.reference = item.reference;
|
||||||
this.type = item.type;
|
this.type = item.type;
|
||||||
this.info = item.info;
|
this.info = item.info;
|
||||||
|
@ -292,7 +292,7 @@ export class ExternalDatasetEditorModel {
|
||||||
return new FormBuilder().group({
|
return new FormBuilder().group({
|
||||||
id: [this.id],
|
id: [this.id],
|
||||||
abbreviation: [this.abbreviation],
|
abbreviation: [this.abbreviation],
|
||||||
label: [this.label],
|
name: [this.name],
|
||||||
reference: [this.reference],
|
reference: [this.reference],
|
||||||
type: [this.type, Validators.required],
|
type: [this.type, Validators.required],
|
||||||
info: [this.info],
|
info: [this.info],
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
<div class="col-12 row align-items-center">
|
<div class="col-12 row align-items-center">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<p>
|
<p>
|
||||||
{{i+1}}) {{suggestion.get('label').value}}
|
{{i+1}}) {{suggestion.get('name').value}}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
|
|
|
@ -77,9 +77,9 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
|
||||||
filterFn: this.searchDatasetExternalDatasets.bind(this),
|
filterFn: this.searchDatasetExternalDatasets.bind(this),
|
||||||
removeAfterSelection: true,
|
removeAfterSelection: true,
|
||||||
initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1),
|
initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1),
|
||||||
displayFn: (item) => item ? item.label : null,
|
displayFn: (item) => item ? item.name : null,
|
||||||
titleFn: (item) => item ? item.label : null,
|
titleFn: (item) => item ? item.name : null,
|
||||||
subtitleFn: (item) => item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
||||||
};
|
};
|
||||||
|
|
||||||
this.registriesAutoCompleteConfiguration = {
|
this.registriesAutoCompleteConfiguration = {
|
||||||
|
@ -97,7 +97,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
|
||||||
initialItems: (type) => this.searchDatasetExternalServices('', type),
|
initialItems: (type) => this.searchDatasetExternalServices('', type),
|
||||||
displayFn: (item) => item ? item.label : null,
|
displayFn: (item) => item ? item.label : null,
|
||||||
titleFn: (item) => item ? item.label : null,
|
titleFn: (item) => item ? item.label : null,
|
||||||
subtitleFn: (item) => item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
||||||
};
|
};
|
||||||
|
|
||||||
this.tagsAutoCompleteConfiguration = {
|
this.tagsAutoCompleteConfiguration = {
|
||||||
|
@ -115,7 +115,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl
|
||||||
}
|
}
|
||||||
|
|
||||||
externalDatasetsOnItemChange(event) {
|
externalDatasetsOnItemChange(event) {
|
||||||
const externalDatasetModel = new ExternalDatasetEditorModel(event.id, event.abbreviation, event.label, event.reference, event.source);
|
const externalDatasetModel = new ExternalDatasetEditorModel(event.id, event.abbreviation, event.name, event.pid ? event.pid : event.reference, event.source);
|
||||||
(<FormArray>this.formGroup.get('externalDatasets')).push(externalDatasetModel.buildForm());
|
(<FormArray>this.formGroup.get('externalDatasets')).push(externalDatasetModel.buildForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div mat-dialog-content class="row">
|
<div mat-dialog-content class="row">
|
||||||
<mat-form-field class="col-auto">
|
<mat-form-field class="col-auto">
|
||||||
<input matInput formControlName="label" placeholder="{{'DATASET-REFERENCED-MODELS.EXTERNAL-DATASET.LABEL' | translate}}" required>
|
<input matInput formControlName="name" placeholder="{{'DATASET-REFERENCED-MODELS.EXTERNAL-DATASET.LABEL' | translate}}" required>
|
||||||
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="formGroup.get('name').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field class="col-auto">
|
<mat-form-field class="col-auto">
|
||||||
<input matInput formControlName="abbreviation" placeholder="{{'DATASET-REFERENCED-MODELS.EXTERNAL-DATASET.ABBREVIATION' | translate}}" required>
|
<input matInput formControlName="abbreviation" placeholder="{{'DATASET-REFERENCED-MODELS.EXTERNAL-DATASET.ABBREVIATION' | translate}}" required>
|
||||||
|
|
Loading…
Reference in New Issue