Merge branch 'dmp-refactoring' of code-repo.d4science.org:MaDgiK-CITE/argos into dmp-refactoring
# Conflicts: # dmp-backend/core/src/main/java/eu/eudat/audit/AuditableAction.java # dmp-backend/web/src/main/resources/config/permissions.yml
This commit is contained in:
commit
bdcaee004d
|
@ -31,9 +31,19 @@ public class AuditableAction {
|
||||||
public static final EventId Dmp_Persist = new EventId(5002, "Dmp_Persist");
|
public static final EventId Dmp_Persist = new EventId(5002, "Dmp_Persist");
|
||||||
public static final EventId Dmp_Delete = new EventId(5003, "Dmp_Delete");
|
public static final EventId Dmp_Delete = new EventId(5003, "Dmp_Delete");
|
||||||
|
|
||||||
public static final EventId DescriptionTemplate_Query = new EventId(6000, "DescriptionTemplate_Query");
|
public static final EventId Description_Query = new EventId(6000, "Description_Query");
|
||||||
public static final EventId DescriptionTemplate_Lookup = new EventId(6001, "DescriptionTemplate_Lookup");
|
public static final EventId Description_Lookup = new EventId(6001, "Description_Lookup");
|
||||||
public static final EventId DescriptionTemplate_Persist = new EventId(6002, "DescriptionTemplate_Persist");
|
public static final EventId Description_Persist = new EventId(6002, "Description_Persist");
|
||||||
public static final EventId DescriptionTemplate_Delete = new EventId(6003, "DescriptionTemplate_Delete");
|
public static final EventId Description_Delete = new EventId(6003, "Description_Delete");
|
||||||
|
|
||||||
|
public static final EventId Reference_Query = new EventId(7000, "Reference_Query");
|
||||||
|
public static final EventId Reference_Lookup = new EventId(7001, "Reference_Lookup");
|
||||||
|
public static final EventId Reference_Persist = new EventId(7002, "Reference_Persist");
|
||||||
|
public static final EventId Reference_Delete = new EventId(7003, "Reference_Delete");
|
||||||
|
|
||||||
|
public static final EventId DescriptionTemplate_Query = new EventId(8000, "DescriptionTemplate_Query");
|
||||||
|
public static final EventId DescriptionTemplate_Lookup = new EventId(8001, "DescriptionTemplate_Lookup");
|
||||||
|
public static final EventId DescriptionTemplate_Persist = new EventId(8002, "DescriptionTemplate_Persist");
|
||||||
|
public static final EventId DescriptionTemplate_Delete = new EventId(8003, "DescriptionTemplate_Delete");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,4 +67,19 @@ public final class Permission {
|
||||||
public static String ViewDescriptionTemplateTypePage = "ViewDescriptionTemplateTypePage";
|
public static String ViewDescriptionTemplateTypePage = "ViewDescriptionTemplateTypePage";
|
||||||
public static String ViewDmpBlueprintPage = "ViewDmpBlueprintPage";
|
public static String ViewDmpBlueprintPage = "ViewDmpBlueprintPage";
|
||||||
|
|
||||||
|
//Reference
|
||||||
|
public static String BrowseReference = "BrowseReference";
|
||||||
|
public static String EditReference = "EditReference";
|
||||||
|
public static String DeleteReference = "DeleteReference";
|
||||||
|
|
||||||
|
//DmpReference
|
||||||
|
public static String BrowseDmpReference = "BrowseDmpReference";
|
||||||
|
public static String EditDmpReference = "EditDmpReference";
|
||||||
|
public static String DeleteDmpReference = "DeleteDmpReference";
|
||||||
|
|
||||||
|
public static String BrowseDescriptionReference = "BrowseDescriptionReference";
|
||||||
|
public static String EditDescriptionReference = "EditDescriptionReference";
|
||||||
|
public static String DeleteDescriptionReference = "DeleteDescriptionReference";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package eu.eudat.commons.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
import eu.eudat.data.converters.enums.DatabaseEnum;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public enum ReferenceFieldDataType implements DatabaseEnum<Short> {
|
||||||
|
Text((short) 0),
|
||||||
|
Date((short) 1);
|
||||||
|
private final Short value;
|
||||||
|
|
||||||
|
ReferenceFieldDataType(Short value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public Short getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Map<Short, ReferenceFieldDataType> map = EnumUtils.getEnumValueMap(ReferenceFieldDataType.class);
|
||||||
|
|
||||||
|
public static ReferenceFieldDataType of(Short i) {
|
||||||
|
return map.get(i);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package eu.eudat.commons.enums;
|
||||||
|
|
||||||
|
import eu.eudat.data.converters.enums.DatabaseEnum;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public enum ReferenceSourceType implements DatabaseEnum<Short> {
|
||||||
|
|
||||||
|
Internal((short) 0),
|
||||||
|
External((short) 1);
|
||||||
|
|
||||||
|
private final Short value;
|
||||||
|
|
||||||
|
ReferenceSourceType(Short value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Short getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Map<Short, ReferenceSourceType> map = EnumUtils.getEnumValueMap(ReferenceSourceType.class);
|
||||||
|
|
||||||
|
public static ReferenceSourceType of(Short i) {
|
||||||
|
return map.get(i);
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import eu.eudat.data.converters.enums.DatabaseEnum;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public enum ExternalReferencesType implements DatabaseEnum<Short> {
|
public enum ReferenceType implements DatabaseEnum<Short> {
|
||||||
Taxonomies((short) 0),
|
Taxonomies((short) 0),
|
||||||
Licenses((short) 1),
|
Licenses((short) 1),
|
||||||
Publications((short) 2),
|
Publications((short) 2),
|
||||||
|
@ -22,7 +22,7 @@ public enum ExternalReferencesType implements DatabaseEnum<Short> {
|
||||||
Researcher((short) 13);
|
Researcher((short) 13);
|
||||||
private final Short value;
|
private final Short value;
|
||||||
|
|
||||||
ExternalReferencesType(Short value) {
|
ReferenceType(Short value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,9 +31,9 @@ public enum ExternalReferencesType implements DatabaseEnum<Short> {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<Short, ExternalReferencesType> map = EnumUtils.getEnumValueMap(ExternalReferencesType.class);
|
private static final Map<Short, ReferenceType> map = EnumUtils.getEnumValueMap(ReferenceType.class);
|
||||||
|
|
||||||
public static ExternalReferencesType of(Short i) {
|
public static ReferenceType of(Short i) {
|
||||||
return map.get(i);
|
return map.get(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -103,11 +103,13 @@ public class SectionEntity implements XmlSerializable<SectionEntity> {
|
||||||
systemFields.appendChild(systemField.toXml(doc));
|
systemFields.appendChild(systemField.toXml(doc));
|
||||||
}
|
}
|
||||||
rootElement.appendChild(systemFields);
|
rootElement.appendChild(systemFields);
|
||||||
|
if (this.descriptionTemplates != null) {
|
||||||
Element descriptionTemplates = doc.createElement("descriptionTemplates");
|
Element descriptionTemplates = doc.createElement("descriptionTemplates");
|
||||||
for (DescriptionTemplateEntity descriptionTemplate : this.descriptionTemplates) {
|
for (DescriptionTemplateEntity descriptionTemplate : this.descriptionTemplates) {
|
||||||
descriptionTemplates.appendChild(descriptionTemplate.toXml(doc));
|
descriptionTemplates.appendChild(descriptionTemplate.toXml(doc));
|
||||||
}
|
}
|
||||||
rootElement.appendChild(descriptionTemplates);
|
rootElement.appendChild(descriptionTemplates);
|
||||||
|
}
|
||||||
temp = this.fields.stream().filter(f -> f.getCategory().equals(DmpBlueprintFieldCategory.Extra)).collect(Collectors.toList());
|
temp = this.fields.stream().filter(f -> f.getCategory().equals(DmpBlueprintFieldCategory.Extra)).collect(Collectors.toList());
|
||||||
List<ExtraFieldEntity> extraFieldList = temp.stream().map(x-> (ExtraFieldEntity)x).collect(Collectors.toList());
|
List<ExtraFieldEntity> extraFieldList = temp.stream().map(x-> (ExtraFieldEntity)x).collect(Collectors.toList());
|
||||||
Element extraFields = doc.createElement("extraFields");
|
Element extraFields = doc.createElement("extraFields");
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package eu.eudat.commons.types.reference;
|
||||||
|
|
||||||
|
import jakarta.xml.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "definition")
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class DefinitionEntity {
|
||||||
|
@XmlElementWrapper(name = "fields")
|
||||||
|
@XmlElement(name = "field")
|
||||||
|
private List<FieldEntity> fields;
|
||||||
|
|
||||||
|
public List<FieldEntity> getFields() {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFields(List<FieldEntity> fields) {
|
||||||
|
this.fields = fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package eu.eudat.commons.types.reference;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
|
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "field")
|
||||||
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
public class FieldEntity {
|
||||||
|
|
||||||
|
@XmlAttribute(name = "code")
|
||||||
|
private String code;
|
||||||
|
@XmlAttribute(name = "dataType")
|
||||||
|
private ReferenceFieldDataType dataType;
|
||||||
|
@XmlAttribute(name = "value")
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ReferenceFieldDataType getDataType() {
|
||||||
|
return dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataType(ReferenceFieldDataType dataType) {
|
||||||
|
this.dataType = dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -7,6 +7,14 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.oauth2.client.AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager;
|
||||||
|
import org.springframework.security.oauth2.client.InMemoryReactiveOAuth2AuthorizedClientService;
|
||||||
|
import org.springframework.security.oauth2.client.ReactiveOAuth2AuthorizedClientService;
|
||||||
|
import org.springframework.security.oauth2.client.registration.ClientRegistration;
|
||||||
|
import org.springframework.security.oauth2.client.registration.InMemoryReactiveClientRegistrationRepository;
|
||||||
|
import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository;
|
||||||
|
import org.springframework.security.oauth2.client.web.reactive.function.client.ServerOAuth2AuthorizedClientExchangeFilterFunction;
|
||||||
|
import org.springframework.security.oauth2.core.AuthorizationGrantType;
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -27,8 +35,20 @@ public class DepositConfiguration {
|
||||||
@Qualifier("depositClients")
|
@Qualifier("depositClients")
|
||||||
public List<RepositoryDeposit> depositClients() {
|
public List<RepositoryDeposit> depositClients() {
|
||||||
List<RepositoryDeposit> clients = new ArrayList<>();
|
List<RepositoryDeposit> clients = new ArrayList<>();
|
||||||
for (String url: properties.getUrls()) {
|
for (DepositProperties.DepositSource source: properties.getSources()) {
|
||||||
clients.add(new DepositRepository(WebClient.builder().baseUrl(url + "/api/deposit").build()));
|
// ClientRegistration clientRegistration = ClientRegistration
|
||||||
|
// .withRegistrationId(source.getClientId())
|
||||||
|
// .clientId(source.getClientId())
|
||||||
|
// .clientSecret(source.getClientSecret())
|
||||||
|
// .scope(source.getScope())
|
||||||
|
// .issuerUri(source.getIssuerUrl())
|
||||||
|
// .authorizationGrantType(AuthorizationGrantType.JWT_BEARER)
|
||||||
|
// .build();
|
||||||
|
// ReactiveClientRegistrationRepository clientRegistrationRepository = new InMemoryReactiveClientRegistrationRepository(clientRegistration);
|
||||||
|
// ReactiveOAuth2AuthorizedClientService clientService = new InMemoryReactiveOAuth2AuthorizedClientService(clientRegistrationRepository);
|
||||||
|
// AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager authorizedClientManager = new AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager(clientRegistrationRepository, clientService);
|
||||||
|
// ServerOAuth2AuthorizedClientExchangeFilterFunction oauth = new ServerOAuth2AuthorizedClientExchangeFilterFunction(authorizedClientManager);
|
||||||
|
// clients.add(new DepositRepository(WebClient.builder().baseUrl(source.getUrl() + "/api/deposit").filters(exchangeFilterFunctions -> exchangeFilterFunctions.add(oauth)).build()));
|
||||||
}
|
}
|
||||||
return clients;
|
return clients;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,18 +8,52 @@ import java.util.List;
|
||||||
@ConfigurationProperties(prefix = "deposit")
|
@ConfigurationProperties(prefix = "deposit")
|
||||||
public class DepositProperties {
|
public class DepositProperties {
|
||||||
|
|
||||||
private List<String> urls;
|
private final List<DepositSource> sources;
|
||||||
|
|
||||||
@ConstructorBinding
|
@ConstructorBinding
|
||||||
public DepositProperties(List<String> urls) {
|
public DepositProperties(List<DepositSource> sources) {
|
||||||
this.urls = urls;
|
this.sources = sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getUrls() {
|
public List<DepositSource> getSources() {
|
||||||
return urls;
|
return sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUrls(List<String> urls) {
|
public static class DepositSource {
|
||||||
this.urls = urls;
|
|
||||||
|
private final String url;
|
||||||
|
private final String issuerUrl;
|
||||||
|
private final String clientId;
|
||||||
|
private final String clientSecret;
|
||||||
|
private final String scope;
|
||||||
|
|
||||||
|
@ConstructorBinding
|
||||||
|
public DepositSource(String url, String issuerUrl, String clientId, String clientSecret, String scope) {
|
||||||
|
this.url = url;
|
||||||
|
this.issuerUrl = issuerUrl;
|
||||||
|
this.clientId = clientId;
|
||||||
|
this.clientSecret = clientSecret;
|
||||||
|
this.scope = scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIssuerUrl() {
|
||||||
|
return issuerUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClientId() {
|
||||||
|
return clientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClientSecret() {
|
||||||
|
return clientSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getScope() {
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package eu.eudat.configurations.referencetype;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties({ReferenceTypeProperties.class})
|
||||||
|
public class ReferenceTypeConfiguration {
|
||||||
|
|
||||||
|
private final ReferenceTypeProperties referenceTypeProperties;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ReferenceTypeConfiguration(ReferenceTypeProperties referenceTypeProperties) {
|
||||||
|
this.referenceTypeProperties = referenceTypeProperties;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package eu.eudat.configurations.referencetype;
|
||||||
|
|
||||||
|
public class ReferenceTypeField {
|
||||||
|
|
||||||
|
String code;
|
||||||
|
|
||||||
|
String dataType;
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDataType() {
|
||||||
|
return dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataType(String dataType) {
|
||||||
|
this.dataType = dataType;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,164 @@
|
||||||
|
package eu.eudat.configurations.referencetype;
|
||||||
|
|
||||||
|
import eu.eudat.model.persist.referencedefinition.DefinitionPersist;
|
||||||
|
import eu.eudat.model.referencedefinition.Field;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.boot.context.properties.bind.ConstructorBinding;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ConfigurationProperties(prefix = "reference-type")
|
||||||
|
public class ReferenceTypeProperties {
|
||||||
|
|
||||||
|
private Map<String, List<ReferenceTypeField>> grant;
|
||||||
|
private Map<String, List<ReferenceTypeField>> funder;
|
||||||
|
private Map<String, List<ReferenceTypeField>> researcher;
|
||||||
|
private Map<String, List<ReferenceTypeField>> service;
|
||||||
|
private Map<String, List<ReferenceTypeField>> registry;
|
||||||
|
private Map<String, List<ReferenceTypeField>> project;
|
||||||
|
private Map<String, List<ReferenceTypeField>> organisation;
|
||||||
|
private Map<String, List<ReferenceTypeField>> dataset;
|
||||||
|
private Map<String, List<Field>> dataRepository;
|
||||||
|
private Map<String, List<ReferenceTypeField>> pubRepository;
|
||||||
|
private Map<String, List<ReferenceTypeField>> journal;
|
||||||
|
private Map<String, List<ReferenceTypeField>> publication;
|
||||||
|
private Map<String, List<ReferenceTypeField>> licence;
|
||||||
|
private Map<String, List<ReferenceTypeField>> taxonomy;
|
||||||
|
|
||||||
|
@ConstructorBinding
|
||||||
|
public ReferenceTypeProperties(Map<String, List<ReferenceTypeField>> grant, Map<String, List<ReferenceTypeField>> funder,
|
||||||
|
Map<String, List<ReferenceTypeField>> researcher, Map<String, List<ReferenceTypeField>> service,
|
||||||
|
Map<String, List<ReferenceTypeField>> registry, Map<String, List<ReferenceTypeField>> project,
|
||||||
|
Map<String, List<ReferenceTypeField>> organisation, Map<String, List<ReferenceTypeField>> dataset,
|
||||||
|
Map<String, List<Field>> dataRepository, Map<String, List<ReferenceTypeField>> pubRepository,
|
||||||
|
Map<String, List<ReferenceTypeField>> journal, Map<String, List<ReferenceTypeField>> publication,
|
||||||
|
Map<String, List<ReferenceTypeField>> licence, Map<String, List<ReferenceTypeField>> taxonomy) {
|
||||||
|
this.grant = grant;
|
||||||
|
this.funder = funder;
|
||||||
|
this.researcher = researcher;
|
||||||
|
this.service = service;
|
||||||
|
this.registry = registry;
|
||||||
|
this.project = project;
|
||||||
|
this.organisation = organisation;
|
||||||
|
this.dataset = dataset;
|
||||||
|
this.dataRepository = dataRepository;
|
||||||
|
this.pubRepository = pubRepository;
|
||||||
|
this.journal = journal;
|
||||||
|
this.publication = publication;
|
||||||
|
this.licence = licence;
|
||||||
|
this.taxonomy = taxonomy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<ReferenceTypeField>> getGrant() {
|
||||||
|
return grant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGrant(Map<String, List<ReferenceTypeField>> grant) {
|
||||||
|
this.grant = grant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<ReferenceTypeField>> getFunder() {
|
||||||
|
return funder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFunder(Map<String, List<ReferenceTypeField>> funder) {
|
||||||
|
this.funder = funder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<ReferenceTypeField>> getResearcher() {
|
||||||
|
return researcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResearcher(Map<String, List<ReferenceTypeField>> researcher) {
|
||||||
|
this.researcher = researcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<ReferenceTypeField>> getService() {
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setService(Map<String, List<ReferenceTypeField>> service) {
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<ReferenceTypeField>> getRegistry() {
|
||||||
|
return registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegistry(Map<String, List<ReferenceTypeField>> registry) {
|
||||||
|
this.registry = registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<ReferenceTypeField>> getProject() {
|
||||||
|
return project;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProject(Map<String, List<ReferenceTypeField>> project) {
|
||||||
|
this.project = project;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<ReferenceTypeField>> getOrganisation() {
|
||||||
|
return organisation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrganisation(Map<String, List<ReferenceTypeField>> organisation) {
|
||||||
|
this.organisation = organisation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<ReferenceTypeField>> getDataset() {
|
||||||
|
return dataset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataset(Map<String, List<ReferenceTypeField>> dataset) {
|
||||||
|
this.dataset = dataset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<Field>> getDataRepository() {
|
||||||
|
return dataRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataRepository(Map<String, List<Field>> dataRepository) {
|
||||||
|
this.dataRepository = dataRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<ReferenceTypeField>> getPubRepository() {
|
||||||
|
return pubRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPubRepository(Map<String, List<ReferenceTypeField>> pubRepository) {
|
||||||
|
this.pubRepository = pubRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<ReferenceTypeField>> getJournal() {
|
||||||
|
return journal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJournal(Map<String, List<ReferenceTypeField>> journal) {
|
||||||
|
this.journal = journal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<ReferenceTypeField>> getPublication() {
|
||||||
|
return publication;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublication(Map<String, List<ReferenceTypeField>> publication) {
|
||||||
|
this.publication = publication;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<ReferenceTypeField>> getLicence() {
|
||||||
|
return licence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLicence(Map<String, List<ReferenceTypeField>> licence) {
|
||||||
|
this.licence = licence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<ReferenceTypeField>> getTaxonomy() {
|
||||||
|
return taxonomy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaxonomy(Map<String, List<ReferenceTypeField>> taxonomy) {
|
||||||
|
this.taxonomy = taxonomy;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,15 +5,13 @@ import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
import eu.eudat.data.converters.DateToUTCConverter;
|
||||||
import eu.eudat.data.converters.enums.DescriptionStatusConverter;
|
import eu.eudat.data.converters.enums.DescriptionStatusConverter;
|
||||||
import eu.eudat.data.converters.enums.IsActiveConverter;
|
import eu.eudat.data.converters.enums.IsActiveConverter;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.*;
|
||||||
import jakarta.persistence.Convert;
|
|
||||||
import jakarta.persistence.Id;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
//@Entity
|
@Entity
|
||||||
//@Table(name = "\"Description\"")
|
@Table(name = "\"Description\"")
|
||||||
public class DescriptionEntity {
|
public class DescriptionEntity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
|
|
@ -0,0 +1,110 @@
|
||||||
|
package eu.eudat.data;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.converters.DateToUTCConverter;
|
||||||
|
import eu.eudat.data.converters.enums.IsActiveConverter;
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "\"DescriptionReference\"")
|
||||||
|
public class DescriptionReferenceEntity {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
|
public static final String _id = "id";
|
||||||
|
|
||||||
|
@Column(name = "data")
|
||||||
|
private String data;
|
||||||
|
|
||||||
|
public static final String _data = "data";
|
||||||
|
|
||||||
|
@Column(name = "description_id", columnDefinition = "uuid", nullable = false)
|
||||||
|
private UUID descriptionId;
|
||||||
|
|
||||||
|
public static final String _descriptionId = "descriptionId";
|
||||||
|
|
||||||
|
@Column(name = "reference_id", columnDefinition = "uuid", nullable = false)
|
||||||
|
private UUID referenceId;
|
||||||
|
|
||||||
|
public static final String _referenceId = "referenceId";
|
||||||
|
|
||||||
|
@Column(name = "created_at")
|
||||||
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
|
private Instant createdAt;
|
||||||
|
|
||||||
|
public static final String _createdAt = "createdAt";
|
||||||
|
|
||||||
|
@Column(name = "updated_at")
|
||||||
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
|
private Instant updatedAt;
|
||||||
|
|
||||||
|
public static final String _updatedAt = "updatedAt";
|
||||||
|
|
||||||
|
@Column(name = "is_active", nullable = false)
|
||||||
|
@Convert(converter = IsActiveConverter.class)
|
||||||
|
private IsActive isActive;
|
||||||
|
|
||||||
|
public static final String _isActive = "isActive";
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(String data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getDescriptionId() {
|
||||||
|
return descriptionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescriptionId(UUID descriptionId) {
|
||||||
|
this.descriptionId = descriptionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getReferenceId() {
|
||||||
|
return referenceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReferenceId(UUID referenceId) {
|
||||||
|
this.referenceId = referenceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Instant createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getUpdatedAt() {
|
||||||
|
return updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatedAt(Instant updatedAt) {
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IsActive getIsActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsActive(IsActive isActive) {
|
||||||
|
this.isActive = isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,9 +10,8 @@ import org.hibernate.annotations.GenericGenerator;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
//TODO: (thgiannos) Wire up when all other dependent entities are refactored
|
@Entity
|
||||||
//@Entity
|
@Table(name = "\"Dmp\"")
|
||||||
//@Table(name = "\"DMP\"")
|
|
||||||
public class DmpEntity {
|
public class DmpEntity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@ -85,77 +84,23 @@ public class DmpEntity {
|
||||||
|
|
||||||
public static final String _isActive = "isActive";
|
public static final String _isActive = "isActive";
|
||||||
|
|
||||||
@Column(name = "\"finalized_at\"")
|
@Column(name = "finalized_at")
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
private Instant finalizedAt;
|
private Instant finalizedAt;
|
||||||
|
|
||||||
public static final String _finalizedAt = "finalizedAt";
|
public static final String _finalizedAt = "finalizedAt";
|
||||||
|
|
||||||
@Column(name = "\"published_at\"")
|
@Column(name = "published_at")
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
private Instant publishedAt;
|
private Instant publishedAt;
|
||||||
|
|
||||||
public static final String _publishedAt = "publishedAt";
|
public static final String _publishedAt = "publishedAt";
|
||||||
|
|
||||||
//TODO: (thgiannos) Handle using the DMPEntity builder
|
@Column(name = "creator")
|
||||||
// @OneToMany(mappedBy = "dmp", fetch = FetchType.LAZY)
|
|
||||||
// private Set<Dataset> dataset;
|
|
||||||
|
|
||||||
// @ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
// @JoinColumn(name = "\"Grant\"")
|
|
||||||
//TODO: (thgiannos) Previously 'Grant'
|
|
||||||
private UUID grant;
|
|
||||||
|
|
||||||
public static final String _grant = "grant";
|
|
||||||
|
|
||||||
//TODO: (thgiannos) Handle using the DMPEntity builder
|
|
||||||
// @OneToMany(fetch = FetchType.LAZY, mappedBy = "dmp")
|
|
||||||
// private Set<DMPDatasetProfile> associatedDmps;
|
|
||||||
|
|
||||||
// @ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
// @JoinColumn(name = "\"Profile\"")
|
|
||||||
//TODO: (thgiannos) Previously 'DMPProfile'
|
|
||||||
private UUID profile;
|
|
||||||
|
|
||||||
public static final String _profile = "profile";
|
|
||||||
|
|
||||||
// @ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
// @JoinColumn(name = "\"Creator\"")
|
|
||||||
//TODO: (thgiannos) Previously 'UserInfo'
|
|
||||||
private UUID creator;
|
private UUID creator;
|
||||||
|
|
||||||
public static final String _creator = "creator";
|
public static final String _creator = "creator";
|
||||||
|
|
||||||
//TODO: (thgiannos) Handle using the DMPEntity builder
|
|
||||||
// @OneToMany(mappedBy = "entityId", fetch = FetchType.LAZY)
|
|
||||||
// private Set<EntityDoiEntity> dois;
|
|
||||||
|
|
||||||
// @ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
// @JoinColumn(name = "\"Project\"")
|
|
||||||
//TODO: (thgiannos) Previously 'Project'
|
|
||||||
private UUID project;
|
|
||||||
|
|
||||||
public static final String _project = "project";
|
|
||||||
|
|
||||||
// TODO: (thgiannos) Implement join entity
|
|
||||||
// @OneToMany(fetch = FetchType.LAZY)
|
|
||||||
// @JoinTable(name = "\"DMPOrganisation\"",
|
|
||||||
// joinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")},
|
|
||||||
// inverseJoinColumns = {@JoinColumn(name = "\"Organisation\"", referencedColumnName = "\"ID\"")}
|
|
||||||
// )
|
|
||||||
// private Set<Organisation> organisations;
|
|
||||||
|
|
||||||
// TODO: (thgiannos) Implement join entity
|
|
||||||
// @OneToMany(fetch = FetchType.LAZY)
|
|
||||||
// @JoinTable(name = "\"DMPResearcher\"",
|
|
||||||
// joinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")},
|
|
||||||
// inverseJoinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")}
|
|
||||||
// )
|
|
||||||
// private Set<Researcher> researchers;
|
|
||||||
|
|
||||||
//TODO: (thgiannos) Handle using the DMPEntity builder
|
|
||||||
// private Set<UserDMP> users;
|
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -276,22 +221,6 @@ public class DmpEntity {
|
||||||
this.publishedAt = publishedAt;
|
this.publishedAt = publishedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getGrant() {
|
|
||||||
return grant;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGrant(UUID grant) {
|
|
||||||
this.grant = grant;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getProfile() {
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProfile(UUID profile) {
|
|
||||||
this.profile = profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getCreator() {
|
public UUID getCreator() {
|
||||||
return creator;
|
return creator;
|
||||||
}
|
}
|
||||||
|
@ -300,12 +229,4 @@ public class DmpEntity {
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getProject() {
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProject(UUID project) {
|
|
||||||
this.project = project;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
package eu.eudat.data;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "\"DmpReference\"")
|
||||||
|
public class DmpReferenceEntity {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
||||||
|
private UUID id;
|
||||||
|
public static final String _id = "id";
|
||||||
|
|
||||||
|
@Column(name = "dmp_id", columnDefinition = "uuid", nullable = false)
|
||||||
|
private UUID dmpId;
|
||||||
|
public static final String _dmpId = "dmpId";
|
||||||
|
|
||||||
|
@Column(name = "reference_id", columnDefinition = "uuid", nullable = false)
|
||||||
|
private UUID referenceId;
|
||||||
|
public static final String _referenceId = "referenceId";
|
||||||
|
|
||||||
|
@Column(name = "data")
|
||||||
|
private String data;
|
||||||
|
|
||||||
|
@Column(name = "created_at", nullable = false)
|
||||||
|
private Instant createdAt;
|
||||||
|
public static final String _createdAt = "createdAt";
|
||||||
|
|
||||||
|
@Column(name = "updated_at", nullable = false)
|
||||||
|
private Instant updatedAt;
|
||||||
|
public static final String _updatedAt = "updatedAt";
|
||||||
|
|
||||||
|
public static final String _data = "data";
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getDmpId() {
|
||||||
|
return dmpId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDmpId(UUID dmpId) {
|
||||||
|
this.dmpId = dmpId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getReferenceId() {
|
||||||
|
return referenceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReferenceId(UUID referenceId) {
|
||||||
|
this.referenceId = referenceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(String data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Instant createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getUpdatedAt() {
|
||||||
|
return updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatedAt(Instant updatedAt) {
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,179 @@
|
||||||
|
package eu.eudat.data;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||||
|
import eu.eudat.data.converters.enums.ReferenceSourceTypeConverter;
|
||||||
|
import eu.eudat.data.converters.enums.ReferenceTypeConverter;
|
||||||
|
import eu.eudat.data.converters.enums.IsActiveConverter;
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "\"Reference\"")
|
||||||
|
public class ReferenceEntity {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
||||||
|
private UUID id;
|
||||||
|
public static final String _id = "id";
|
||||||
|
|
||||||
|
@Column(name = "label", length = 500, nullable = false)
|
||||||
|
private String label;
|
||||||
|
public static final String _label = "label";
|
||||||
|
|
||||||
|
@Column(name = "type", nullable = false)
|
||||||
|
@Convert(converter = ReferenceTypeConverter.class)
|
||||||
|
private ReferenceType type;
|
||||||
|
public static final String _type = "type";
|
||||||
|
|
||||||
|
@Column(name = "description")
|
||||||
|
private String description;
|
||||||
|
public static final String _description = "description";
|
||||||
|
|
||||||
|
@Type(eu.eudat.configurations.typedefinition.XMLType.class)
|
||||||
|
@Column(name = "definition", columnDefinition = "xml")
|
||||||
|
private String definition;
|
||||||
|
public static final String _definition = "definition";
|
||||||
|
|
||||||
|
@Column(name = "reference", length = 1024, nullable = false)
|
||||||
|
private String reference;
|
||||||
|
public static final String _reference = "reference";
|
||||||
|
|
||||||
|
@Column(name = "abbreviation", length = 50)
|
||||||
|
private String abbreviation;
|
||||||
|
public static final String _abbreviation = "abbreviation";
|
||||||
|
|
||||||
|
@Column(name = "source", length = 1024)
|
||||||
|
private String source;
|
||||||
|
public static final String _source = "source";
|
||||||
|
|
||||||
|
@Column(name = "source_type", nullable = false)
|
||||||
|
@Convert(converter = ReferenceSourceTypeConverter.class)
|
||||||
|
private ReferenceSourceType referenceSourceType;
|
||||||
|
public static final String _sourceType = "sourceType";
|
||||||
|
|
||||||
|
@Column(name = "is_active", nullable = false)
|
||||||
|
@Convert(converter = IsActiveConverter.class)
|
||||||
|
private IsActive isActive;
|
||||||
|
public static final String _isActive = "isActive";
|
||||||
|
|
||||||
|
@Column(name = "created_at", nullable = false)
|
||||||
|
private Instant createdAt;
|
||||||
|
public static final String _createdAt = "createdAt";
|
||||||
|
|
||||||
|
@Column(name = "updated_at", nullable = false)
|
||||||
|
private Instant updatedAt;
|
||||||
|
public static final String _updatedAt = "updatedAt";
|
||||||
|
|
||||||
|
@Column(name = "created_by", columnDefinition = "uuid")
|
||||||
|
private UUID createdBy;
|
||||||
|
public static final String _createdBy = "createdBy";
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(ReferenceType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefinition() {
|
||||||
|
return definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefinition(String definition) {
|
||||||
|
this.definition = definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReference() {
|
||||||
|
return reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReference(String reference) {
|
||||||
|
this.reference = reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAbbreviation() {
|
||||||
|
return abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbbreviation(String abbreviation) {
|
||||||
|
this.abbreviation = abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSource(String source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceSourceType getReferenceSourceType() {
|
||||||
|
return referenceSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReferenceSourceType(ReferenceSourceType referenceSourceType) {
|
||||||
|
this.referenceSourceType = referenceSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IsActive getIsActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsActive(IsActive isActive) {
|
||||||
|
this.isActive = isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Instant createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getUpdatedAt() {
|
||||||
|
return updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatedAt(Instant updatedAt) {
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getCreatedBy() {
|
||||||
|
return createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedBy(UUID createdBy) {
|
||||||
|
this.createdBy = createdBy;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package eu.eudat.data.converters.enums;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||||
|
import jakarta.persistence.Converter;
|
||||||
|
|
||||||
|
@Converter
|
||||||
|
public class ReferenceSourceTypeConverter extends DatabaseEnumConverter<ReferenceSourceType, Short>{
|
||||||
|
public ReferenceSourceType of(Short i) {
|
||||||
|
return ReferenceSourceType.of(i);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package eu.eudat.data.converters.enums;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
|
import jakarta.persistence.Converter;
|
||||||
|
|
||||||
|
@Converter
|
||||||
|
public class ReferenceTypeConverter extends DatabaseEnumConverter<ReferenceType, Short> {
|
||||||
|
public ReferenceType of(Short i) {
|
||||||
|
return ReferenceType.of(i);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,57 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
|
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
|
||||||
import org.hibernate.annotations.Type;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"DatasetProfileRuleset\"")
|
|
||||||
public class DatasetProfileRuleset {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "\"Label\"")
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
@Type(eu.eudat.configurations.typedefinition.XMLType.class)
|
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
|
|
||||||
private String definition;
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefinition() {
|
|
||||||
// return XML.toJSONObject(definition).toString(); //return definition as json
|
|
||||||
return definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefinition(String definition) {
|
|
||||||
// this.definition = XML.toString(definition); //if definition is in json
|
|
||||||
this.definition = definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
|
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
|
||||||
import org.hibernate.annotations.Type;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"DatasetProfileViewstyle\"")
|
|
||||||
public class DatasetProfileViewstyle {
|
|
||||||
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "\"Label\"")
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
@Type(eu.eudat.configurations.typedefinition.XMLType.class)
|
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
|
|
||||||
private String definition;
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefinition() {
|
|
||||||
// return XML.toJSONObject(definition).toString(); //return definition as json
|
|
||||||
return definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefinition(String definition) {
|
|
||||||
// this.definition = XML.toString(definition); //if definition is in json
|
|
||||||
this.definition = definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Description {
|
public class Description {
|
||||||
|
@ -72,6 +73,10 @@ public class Description {
|
||||||
|
|
||||||
public static final String _hash = "hash";
|
public static final String _hash = "hash";
|
||||||
|
|
||||||
|
private List<DescriptionReference> descriptionReferences;
|
||||||
|
|
||||||
|
public static final String _descriptionReferences = "descriptionReferences";
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -199,4 +204,13 @@ public class Description {
|
||||||
public void setHash(String hash) {
|
public void setHash(String hash) {
|
||||||
this.hash = hash;
|
this.hash = hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<DescriptionReference> getDescriptionReferences() {
|
||||||
|
return descriptionReferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescriptionReferences(List<DescriptionReference> descriptionReferences) {
|
||||||
|
this.descriptionReferences = descriptionReferences;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
package eu.eudat.model;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class DescriptionReference {
|
||||||
|
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
|
public static final String _id = "id";
|
||||||
|
|
||||||
|
private String data;
|
||||||
|
|
||||||
|
public static final String _data = "data";
|
||||||
|
|
||||||
|
private Description description;
|
||||||
|
|
||||||
|
public static final String _description = "description";
|
||||||
|
|
||||||
|
private Reference reference;
|
||||||
|
|
||||||
|
public static final String _reference = "reference";
|
||||||
|
|
||||||
|
private Instant createdAt;
|
||||||
|
|
||||||
|
public static final String _createdAt = "createdAt";
|
||||||
|
|
||||||
|
private Instant updatedAt;
|
||||||
|
|
||||||
|
public static final String _updatedAt = "updatedAt";
|
||||||
|
|
||||||
|
private IsActive isActive;
|
||||||
|
|
||||||
|
public static final String _isActive = "isActive";
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(String data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Description getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(Description description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Reference getReference() {
|
||||||
|
return reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReference(Reference reference) {
|
||||||
|
this.reference = reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Instant createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getUpdatedAt() {
|
||||||
|
return updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatedAt(Instant updatedAt) {
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IsActive getIsActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsActive(IsActive isActive) {
|
||||||
|
this.isActive = isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import eu.eudat.commons.enums.DmpStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Dmp {
|
public class Dmp {
|
||||||
|
@ -68,26 +69,21 @@ public class Dmp {
|
||||||
|
|
||||||
public static final String _publishedAt = "publishedAt";
|
public static final String _publishedAt = "publishedAt";
|
||||||
|
|
||||||
private UUID grant;
|
|
||||||
|
|
||||||
public static final String _grant = "grant";
|
|
||||||
|
|
||||||
private UUID profile;
|
|
||||||
|
|
||||||
public static final String _profile = "profile";
|
|
||||||
|
|
||||||
private UUID creator;
|
private UUID creator;
|
||||||
|
|
||||||
public static final String _creator = "creator";
|
public static final String _creator = "creator";
|
||||||
|
|
||||||
private UUID project;
|
|
||||||
|
|
||||||
public static final String _project = "project";
|
|
||||||
|
|
||||||
private String hash;
|
private String hash;
|
||||||
|
|
||||||
public static final String _hash = "hash";
|
public static final String _hash = "hash";
|
||||||
|
|
||||||
|
private List<Description> dmpDescriptions;
|
||||||
|
|
||||||
|
public static final String _dmpDescriptions = "dmpDescriptions";
|
||||||
|
|
||||||
|
public static final String _dmpReferences = "dmpReferences";
|
||||||
|
private List<DmpReference> dmpReferences;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -208,22 +204,6 @@ public class Dmp {
|
||||||
this.publishedAt = publishedAt;
|
this.publishedAt = publishedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getGrant() {
|
|
||||||
return grant;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGrant(UUID grant) {
|
|
||||||
this.grant = grant;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getProfile() {
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProfile(UUID profile) {
|
|
||||||
this.profile = profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getCreator() {
|
public UUID getCreator() {
|
||||||
return creator;
|
return creator;
|
||||||
}
|
}
|
||||||
|
@ -232,14 +212,6 @@ public class Dmp {
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getProject() {
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProject(UUID project) {
|
|
||||||
this.project = project;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHash() {
|
public String getHash() {
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
@ -248,4 +220,19 @@ public class Dmp {
|
||||||
this.hash = hash;
|
this.hash = hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Description> getDmpDescriptions() {
|
||||||
|
return dmpDescriptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDmpDescriptions(List<Description> dmpDescriptions) {
|
||||||
|
this.dmpDescriptions = dmpDescriptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DmpReference> getDmpReferences() {
|
||||||
|
return dmpReferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDmpReferences(List<DmpReference> dmpReferences) {
|
||||||
|
this.dmpReferences = dmpReferences;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.model.dmpblueprintdefinition.Definition;
|
import eu.eudat.model.dmpblueprintdefinition.Definition;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DmpBlueprint {
|
public class DmpBlueprint {
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
package eu.eudat.model;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class DmpReference {
|
||||||
|
|
||||||
|
private UUID id;
|
||||||
|
public static final String _id = "id";
|
||||||
|
|
||||||
|
private Dmp dmp;
|
||||||
|
public static final String _dmp = "dmp";
|
||||||
|
|
||||||
|
private Reference reference;
|
||||||
|
public static final String _reference = "reference";
|
||||||
|
|
||||||
|
private String data;
|
||||||
|
public static final String _data = "data";
|
||||||
|
|
||||||
|
private Instant createdAt;
|
||||||
|
|
||||||
|
public static final String _createdAt = "createdAt";
|
||||||
|
private Instant updatedAt;
|
||||||
|
|
||||||
|
public static final String _updatedAt = "updatedAt";
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dmp getDmp() {
|
||||||
|
return dmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDmp(Dmp dmp) {
|
||||||
|
this.dmp = dmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Reference getReference() {
|
||||||
|
return reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReference(Reference reference) {
|
||||||
|
this.reference = reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(String data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCreatedAt() { return createdAt;}
|
||||||
|
|
||||||
|
public void setCreatedAt(Instant createdAt) {this.createdAt = createdAt;}
|
||||||
|
|
||||||
|
public Instant getUpdatedAt() {return updatedAt;}
|
||||||
|
|
||||||
|
public void setUpdatedAt(Instant updatedAt) {this.updatedAt = updatedAt;}
|
||||||
|
}
|
|
@ -0,0 +1,159 @@
|
||||||
|
package eu.eudat.model;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||||
|
import eu.eudat.model.referencedefinition.Definition;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class Reference {
|
||||||
|
|
||||||
|
private UUID id;
|
||||||
|
public static final String _id = "id";
|
||||||
|
|
||||||
|
private String label;
|
||||||
|
public static final String _label = "label";
|
||||||
|
|
||||||
|
private ReferenceType type;
|
||||||
|
public static final String _type = "type";
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
public static final String _description = "description";
|
||||||
|
|
||||||
|
private Definition definition;
|
||||||
|
public static final String _definition = "definition";
|
||||||
|
|
||||||
|
private String reference;
|
||||||
|
public static final String _reference = "reference";
|
||||||
|
|
||||||
|
private String abbreviation;
|
||||||
|
public static final String _abbreviation = "abbreviation";
|
||||||
|
|
||||||
|
private String source;
|
||||||
|
public static final String _source = "source";
|
||||||
|
|
||||||
|
private ReferenceSourceType referenceSourceType;
|
||||||
|
public static final String _sourceType = "sourceType";
|
||||||
|
|
||||||
|
private IsActive isActive;
|
||||||
|
public static final String _isActive = "isActive";
|
||||||
|
|
||||||
|
private Instant createdAt;
|
||||||
|
public static final String _createdAt = "createdAt";
|
||||||
|
|
||||||
|
private Instant updatedAt;
|
||||||
|
public static final String _updatedAt = "updatedAt";
|
||||||
|
|
||||||
|
//private UserInfo createdBy; ToDo
|
||||||
|
//public static final String _createdBy = "createdBy";
|
||||||
|
|
||||||
|
private List<DmpReference> dmpReferences;
|
||||||
|
public static final String _dmpReferences = "dmpReferences";
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(ReferenceType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Definition getDefinition() {
|
||||||
|
return definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefinition(Definition definition) {
|
||||||
|
this.definition = definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReference() {
|
||||||
|
return reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReference(String reference) {
|
||||||
|
this.reference = reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAbbreviation() {
|
||||||
|
return abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbbreviation(String abbreviation) {
|
||||||
|
this.abbreviation = abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSource(String source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceSourceType getReferenceSourceType() {
|
||||||
|
return referenceSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReferenceSourceType(ReferenceSourceType referenceSourceType) {
|
||||||
|
this.referenceSourceType = referenceSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IsActive getIsActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsActive(IsActive isActive) {
|
||||||
|
this.isActive = isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Instant createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getUpdatedAt() {
|
||||||
|
return updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatedAt(Instant updatedAt) {
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DmpReference> getDmpReferences() {
|
||||||
|
return dmpReferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDmpReferences(List<DmpReference> dmpReferences) {
|
||||||
|
this.dmpReferences = dmpReferences;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,9 +3,14 @@ package eu.eudat.model.builder;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.model.Description;
|
import eu.eudat.model.Description;
|
||||||
|
import eu.eudat.model.DescriptionReference;
|
||||||
import eu.eudat.model.Dmp;
|
import eu.eudat.model.Dmp;
|
||||||
|
import eu.eudat.model.DmpReference;
|
||||||
|
import eu.eudat.query.DescriptionReferenceQuery;
|
||||||
import eu.eudat.query.DmpQuery;
|
import eu.eudat.query.DmpQuery;
|
||||||
|
import eu.eudat.query.DmpReferenceQuery;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
@ -57,6 +62,9 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
||||||
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(Description._dmp));
|
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(Description._dmp));
|
||||||
Map<UUID, Dmp> dmpItemsMap = this.collectDmps(dmpFields, data);
|
Map<UUID, Dmp> dmpItemsMap = this.collectDmps(dmpFields, data);
|
||||||
|
|
||||||
|
FieldSet descriptionReferencesFields = fields.extractPrefixed(this.asPrefix(Description._descriptionReferences));
|
||||||
|
Map<UUID, List<DescriptionReference>> descriptionReferencesMap = this.collectDescriptionReferences(descriptionReferencesFields, data);
|
||||||
|
|
||||||
List<Description> models = new ArrayList<>();
|
List<Description> models = new ArrayList<>();
|
||||||
for (DescriptionEntity d : data) {
|
for (DescriptionEntity d : data) {
|
||||||
Description m = new Description();
|
Description m = new Description();
|
||||||
|
@ -94,9 +102,14 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
||||||
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmp()))
|
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmp()))
|
||||||
m.setDmp(dmpItemsMap.get(d.getDmp()));
|
m.setDmp(dmpItemsMap.get(d.getDmp()));
|
||||||
|
|
||||||
|
if (!descriptionReferencesFields.isEmpty() && descriptionReferencesMap != null && descriptionReferencesMap.containsKey(d.getId()))
|
||||||
|
m.setDescriptionReferences(descriptionReferencesMap.get(d.getId()));
|
||||||
|
|
||||||
models.add(m);
|
models.add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,4 +143,22 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
||||||
return itemMap;
|
return itemMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<UUID, List<DescriptionReference>> collectDescriptionReferences(FieldSet fields, List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || data.isEmpty()) return null;
|
||||||
|
this.logger.debug("checking related - {}", DescriptionReference.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, List<DescriptionReference>> itemMap;
|
||||||
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DescriptionReference._description, Description._id));
|
||||||
|
DescriptionReferenceQuery query = this.queryFactory.query(DescriptionReferenceQuery.class).authorize(this.authorize).descriptionIds(data.stream().map(DescriptionEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(DescriptionReferenceBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDescription().getId());
|
||||||
|
|
||||||
|
if (!fields.hasField(this.asIndexer(DmpReference._dmp, Dmp._id))) {
|
||||||
|
itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDescription() != null).peek(x -> {
|
||||||
|
x.getDescription().setId(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,155 @@
|
||||||
|
package eu.eudat.model.builder;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.DescriptionReferenceEntity;
|
||||||
|
import eu.eudat.model.Description;
|
||||||
|
import eu.eudat.model.DescriptionReference;
|
||||||
|
import eu.eudat.model.Reference;
|
||||||
|
import eu.eudat.query.DescriptionQuery;
|
||||||
|
import eu.eudat.query.ReferenceQuery;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DescriptionReferenceBuilder extends BaseBuilder<DescriptionReference, DescriptionReferenceEntity> {
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DescriptionReferenceBuilder(
|
||||||
|
ConventionService conventionService,
|
||||||
|
BuilderFactory builderFactory, QueryFactory queryFactory) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpReferenceBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DescriptionReference> build(FieldSet fields, List<DescriptionReferenceEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||||
|
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||||
|
if (fields == null || data == null || fields.isEmpty())
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
FieldSet referenceFields = fields.extractPrefixed(this.asPrefix(DescriptionReference._reference));
|
||||||
|
Map<UUID, Reference> referenceItemsMap = this.collectReferences(referenceFields, data);
|
||||||
|
|
||||||
|
FieldSet descriptionFields = fields.extractPrefixed(this.asPrefix(DescriptionReference._description));
|
||||||
|
Map<UUID, Description> descriptionItemsMap = this.collectDescriptions(descriptionFields, data);
|
||||||
|
|
||||||
|
List<DescriptionReference> models = new ArrayList<>();
|
||||||
|
|
||||||
|
for (DescriptionReferenceEntity d : data) {
|
||||||
|
DescriptionReference m = new DescriptionReference();
|
||||||
|
if (fields.hasField(this.asIndexer(DescriptionReference._id)))
|
||||||
|
m.setId(d.getId());
|
||||||
|
if (fields.hasField(this.asIndexer(DescriptionReference._data)))
|
||||||
|
m.setData(d.getData());
|
||||||
|
if (fields.hasField(this.asIndexer(DescriptionReference._createdAt)))
|
||||||
|
m.setCreatedAt(d.getCreatedAt());
|
||||||
|
if (fields.hasField(this.asIndexer(DescriptionReference._updatedAt)))
|
||||||
|
m.setUpdatedAt(d.getUpdatedAt());
|
||||||
|
if (fields.hasField(this.asIndexer(DescriptionReference._isActive)))
|
||||||
|
m.setIsActive(d.getIsActive());
|
||||||
|
|
||||||
|
if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getReferenceId())) {
|
||||||
|
m.setReference(referenceItemsMap.get(d.getReferenceId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!descriptionFields.isEmpty() && descriptionItemsMap != null && descriptionItemsMap.containsKey(d.getDescriptionId())) {
|
||||||
|
m.setDescription(descriptionItemsMap.get(d.getDescriptionId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
models.add(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, Description> collectDescriptions(FieldSet fields, List<DescriptionReferenceEntity> data) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || data.isEmpty())
|
||||||
|
return null;
|
||||||
|
this.logger.debug("checking related - {}", Description.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, Description> itemMap;
|
||||||
|
if (!fields.hasOtherField(this.asIndexer(Reference._id))) {
|
||||||
|
itemMap = this.asEmpty(
|
||||||
|
data.stream().map(DescriptionReferenceEntity::getDescriptionId).distinct().collect(Collectors.toList()),
|
||||||
|
x -> {
|
||||||
|
Description item = new Description();
|
||||||
|
item.setId(x);
|
||||||
|
return item;
|
||||||
|
},
|
||||||
|
Description::getId);
|
||||||
|
} else {
|
||||||
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Reference._id);
|
||||||
|
DescriptionQuery q = this.queryFactory.query(DescriptionQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionReferenceEntity::getDescriptionId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(DescriptionBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Description::getId);
|
||||||
|
}
|
||||||
|
if (!fields.hasField(Description._id)) {
|
||||||
|
itemMap.forEach((id, item) -> {
|
||||||
|
if (item != null)
|
||||||
|
item.setId(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, Reference> collectReferences(FieldSet fields, List<DescriptionReferenceEntity> data) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || data.isEmpty())
|
||||||
|
return null;
|
||||||
|
this.logger.debug("checking related - {}", Reference.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, Reference> itemMap;
|
||||||
|
if (!fields.hasOtherField(this.asIndexer(Reference._id))) {
|
||||||
|
itemMap = this.asEmpty(
|
||||||
|
data.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()),
|
||||||
|
x -> {
|
||||||
|
Reference item = new Reference();
|
||||||
|
item.setId(x);
|
||||||
|
return item;
|
||||||
|
},
|
||||||
|
Reference::getId);
|
||||||
|
} else {
|
||||||
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Reference._id);
|
||||||
|
ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionReferenceEntity::getReferenceId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(ReferenceBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Reference::getId);
|
||||||
|
}
|
||||||
|
if (!fields.hasField(Reference._id)) {
|
||||||
|
itemMap.forEach((id, item) -> {
|
||||||
|
if (item != null)
|
||||||
|
item.setId(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,8 +3,13 @@ package eu.eudat.model.builder;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.model.Dmp;
|
import eu.eudat.model.*;
|
||||||
|
import eu.eudat.query.DescriptionQuery;
|
||||||
|
import eu.eudat.query.DmpReferenceQuery;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.DataLogEntry;
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
@ -15,16 +20,25 @@ import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
|
public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
|
||||||
|
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DmpBuilder(ConventionService conventionService) {
|
public DmpBuilder(ConventionService conventionService,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
BuilderFactory builderFactory) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBuilder.class)));
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBuilder.class)));
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DmpBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
public DmpBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
@ -38,29 +52,99 @@ public class DmpBuilder extends BaseBuilder<Dmp, DmpEntity> {
|
||||||
this.logger.trace(new DataLogEntry("requested fields", fields));
|
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||||
if (fields == null || data == null || fields.isEmpty())
|
if (fields == null || data == null || fields.isEmpty())
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
||||||
List<Dmp> models = new ArrayList<>();
|
List<Dmp> models = new ArrayList<>();
|
||||||
|
|
||||||
|
FieldSet dmpDescriptionsFields = fields.extractPrefixed(this.asPrefix(Dmp._dmpDescriptions));
|
||||||
|
Map<UUID, List<Description>> dmpDescriptionsMap = this.collectDmpDescriptions(dmpDescriptionsFields, data);
|
||||||
|
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asPrefix(Reference._dmpReferences));
|
||||||
|
Map<UUID, List<DmpReference>> dmpReferenceMap = this.collectDmpReferences(dmpReferencesFields, data);
|
||||||
|
|
||||||
for (DmpEntity d : data) {
|
for (DmpEntity d : data) {
|
||||||
Dmp m = new Dmp();
|
Dmp m = new Dmp();
|
||||||
if (fields.hasField(this.asIndexer(Dmp._id))) m.setId(d.getId());
|
if (fields.hasField(this.asIndexer(Dmp._id)))
|
||||||
if (fields.hasField(this.asIndexer(Dmp._label))) m.setLabel(d.getLabel());
|
m.setId(d.getId());
|
||||||
if (fields.hasField(this.asIndexer(Dmp._version))) m.setVersion(d.getVersion());
|
if (fields.hasField(this.asIndexer(Dmp._label)))
|
||||||
if (fields.hasField(this.asIndexer(Dmp._status))) m.setStatus(d.getStatus());
|
m.setLabel(d.getLabel());
|
||||||
if (fields.hasField(this.asIndexer(Dmp._properties))) m.setProperties(d.getProperties());
|
if (fields.hasField(this.asIndexer(Dmp._version)))
|
||||||
if (fields.hasField(this.asIndexer(Dmp._dmpProperties))) m.setDmpProperties(d.getDmpProperties());
|
m.setVersion(d.getVersion());
|
||||||
if (fields.hasField(this.asIndexer(Dmp._groupId))) m.setGroupId(d.getGroupId());
|
if (fields.hasField(this.asIndexer(Dmp._status)))
|
||||||
if (fields.hasField(this.asIndexer(Dmp._description))) m.setDescription(d.getDescription());
|
m.setStatus(d.getStatus());
|
||||||
if (fields.hasField(this.asIndexer(Dmp._isPublic))) m.setIsPublic(d.getIsPublic());
|
if (fields.hasField(this.asIndexer(Dmp._properties)))
|
||||||
if (fields.hasField(this.asIndexer(Dmp._extraProperties))) m.setExtraProperties(d.getExtraProperties());
|
m.setProperties(d.getProperties());
|
||||||
if (fields.hasField(this.asIndexer(Dmp._createdAt))) m.setCreatedAt(d.getCreatedAt());
|
if (fields.hasField(this.asIndexer(Dmp._dmpProperties)))
|
||||||
if (fields.hasField(this.asIndexer(Dmp._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
m.setDmpProperties(d.getDmpProperties());
|
||||||
if (fields.hasField(this.asIndexer(Dmp._isActive))) m.setIsActive(d.getIsActive());
|
if (fields.hasField(this.asIndexer(Dmp._groupId)))
|
||||||
if (fields.hasField(this.asIndexer(Dmp._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
|
m.setGroupId(d.getGroupId());
|
||||||
if (fields.hasField(this.asIndexer(Dmp._publishedAt))) m.setPublishedAt(d.getPublishedAt());
|
if (fields.hasField(this.asIndexer(Dmp._description)))
|
||||||
if (fields.hasField(this.asIndexer(Dmp._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
|
m.setDescription(d.getDescription());
|
||||||
|
if (fields.hasField(this.asIndexer(Dmp._isPublic)))
|
||||||
|
m.setIsPublic(d.getIsPublic());
|
||||||
|
if (fields.hasField(this.asIndexer(Dmp._extraProperties)))
|
||||||
|
m.setExtraProperties(d.getExtraProperties());
|
||||||
|
if (fields.hasField(this.asIndexer(Dmp._createdAt)))
|
||||||
|
m.setCreatedAt(d.getCreatedAt());
|
||||||
|
if (fields.hasField(this.asIndexer(Dmp._updatedAt)))
|
||||||
|
m.setUpdatedAt(d.getUpdatedAt());
|
||||||
|
if (fields.hasField(this.asIndexer(Dmp._isActive)))
|
||||||
|
m.setIsActive(d.getIsActive());
|
||||||
|
if (fields.hasField(this.asIndexer(Dmp._finalizedAt)))
|
||||||
|
m.setFinalizedAt(d.getFinalizedAt());
|
||||||
|
if (fields.hasField(this.asIndexer(Dmp._publishedAt)))
|
||||||
|
m.setPublishedAt(d.getPublishedAt());
|
||||||
|
if (fields.hasField(this.asIndexer(Dmp._hash)))
|
||||||
|
m.setHash(this.hashValue(d.getUpdatedAt()));
|
||||||
|
|
||||||
|
if (!dmpDescriptionsFields.isEmpty() && dmpDescriptionsMap != null && dmpDescriptionsMap.containsKey(d.getId()))
|
||||||
|
m.setDmpDescriptions(dmpDescriptionsMap.get(d.getId()));
|
||||||
|
|
||||||
|
if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId()))
|
||||||
|
m.setDmpReferences(dmpReferenceMap.get(d.getId()));
|
||||||
|
|
||||||
models.add(m);
|
models.add(m);
|
||||||
}
|
}
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<UUID, List<Description>> collectDmpDescriptions(FieldSet fields, List<DmpEntity> data) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || data.isEmpty())
|
||||||
|
return null;
|
||||||
|
this.logger.debug("checking related - {}", Description.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, List<Description>> itemMap;
|
||||||
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(Description._dmp, Dmp._id));
|
||||||
|
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(DescriptionBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId());
|
||||||
|
|
||||||
|
if (!fields.hasField(this.asIndexer(Description._dmp, Dmp._id))) {
|
||||||
|
itemMap.forEach((id, dmps) -> {
|
||||||
|
dmps.forEach(description -> {
|
||||||
|
if (description != null && description.getDmp() != null)
|
||||||
|
description.getDmp().setId(null);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, List<DmpReference>> collectDmpReferences(FieldSet fields, List<DmpEntity> datas) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || datas.isEmpty()) return null;
|
||||||
|
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, List<DmpReference>> itemMap = null;
|
||||||
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpReference._dmp, Dmp._id));
|
||||||
|
DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).authorize(this.authorize).dmpIds(datas.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(DmpReferenceBuilder.class).authorize(this.authorize).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId());
|
||||||
|
|
||||||
|
if (!fields.hasField(this.asIndexer(DmpReference._dmp, Dmp._id))) {
|
||||||
|
itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getDmp() != null).peek(x -> {
|
||||||
|
x.getDmp().setId(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,132 @@
|
||||||
|
package eu.eudat.model.builder;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.DmpReferenceEntity;
|
||||||
|
import eu.eudat.model.Dmp;
|
||||||
|
import eu.eudat.model.DmpReference;
|
||||||
|
import eu.eudat.model.Reference;
|
||||||
|
import eu.eudat.query.DmpQuery;
|
||||||
|
import eu.eudat.query.ReferenceQuery;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DmpReferenceBuilder extends BaseBuilder<DmpReference, DmpReferenceEntity>{
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DmpReferenceBuilder(
|
||||||
|
ConventionService conventionService,
|
||||||
|
BuilderFactory builderFactory, QueryFactory queryFactory) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpReferenceBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpReferenceBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DmpReference> build(FieldSet fields, List<DmpReferenceEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||||
|
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||||
|
if (fields == null || data == null || fields.isEmpty())
|
||||||
|
return new ArrayList<>();
|
||||||
|
FieldSet referenceFields = fields.extractPrefixed(this.asPrefix(DmpReference._reference));
|
||||||
|
Map<UUID, Reference> referenceItemsMap = this.collectReferences(referenceFields, data);
|
||||||
|
|
||||||
|
FieldSet dmpFields = fields.extractPrefixed(this.asPrefix(DmpReference._dmp));
|
||||||
|
Map<UUID, Dmp> dmpItemsMap = this.collectDmps(dmpFields, data);
|
||||||
|
|
||||||
|
List<DmpReference> models = new ArrayList<>();
|
||||||
|
for (DmpReferenceEntity d : data) {
|
||||||
|
DmpReference m = new DmpReference();
|
||||||
|
if (fields.hasField(this.asIndexer(DmpReference._id))) m.setId(d.getId());
|
||||||
|
if (fields.hasField(this.asIndexer(DmpReference._data))) m.setData(d.getData());
|
||||||
|
if (fields.hasField(this.asIndexer(DmpReference._createdAt))) m.setCreatedAt(d.getCreatedAt());
|
||||||
|
if (fields.hasField(this.asIndexer(DmpReference._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
||||||
|
if(!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getReferenceId())){
|
||||||
|
m.setReference(referenceItemsMap.get(d.getReferenceId()));
|
||||||
|
}
|
||||||
|
if(!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())){
|
||||||
|
m.setDmp(dmpItemsMap.get(d.getDmpId()));
|
||||||
|
}
|
||||||
|
models.add(m);
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, Reference> collectReferences(FieldSet fields, List<DmpReferenceEntity> data) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || data.isEmpty()) return null;
|
||||||
|
this.logger.debug("checking related - {}", Reference.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, Reference> itemMap;
|
||||||
|
if (!fields.hasOtherField(this.asIndexer(Reference._id))) {
|
||||||
|
itemMap = this.asEmpty(
|
||||||
|
data.stream().map(x -> x.getReferenceId()).distinct().collect(Collectors.toList()),
|
||||||
|
x -> {
|
||||||
|
Reference item = new Reference();
|
||||||
|
item.setId(x);
|
||||||
|
return item;
|
||||||
|
},
|
||||||
|
Reference::getId);
|
||||||
|
} else {
|
||||||
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Reference._id);
|
||||||
|
ReferenceQuery q = this.queryFactory.query(ReferenceQuery.class).authorize(this.authorize).ids(data.stream().map(x -> x.getReferenceId()).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(ReferenceBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Reference::getId);
|
||||||
|
}
|
||||||
|
if (!fields.hasField(Reference._id)) {
|
||||||
|
itemMap.values().stream().filter(Objects::nonNull).peek(x -> x.setId(null)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, Dmp> collectDmps(FieldSet fields, List<DmpReferenceEntity> data) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || data.isEmpty()) return null;
|
||||||
|
this.logger.debug("checking related - {}", Dmp.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, Dmp> itemMap;
|
||||||
|
if (!fields.hasOtherField(this.asIndexer(Dmp._id))) {
|
||||||
|
itemMap = this.asEmpty(
|
||||||
|
data.stream().map(x -> x.getDmpId()).distinct().collect(Collectors.toList()),
|
||||||
|
x -> {
|
||||||
|
Dmp item = new Dmp();
|
||||||
|
item.setId(x);
|
||||||
|
return item;
|
||||||
|
},
|
||||||
|
Dmp::getId);
|
||||||
|
} else {
|
||||||
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(Dmp._id);
|
||||||
|
DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).ids(data.stream().map(x -> x.getDmpId()).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(DmpBuilder.class).authorize(this.authorize).asForeignKey(q, clone, Dmp::getId);
|
||||||
|
}
|
||||||
|
if (!fields.hasField(Dmp._id)) {
|
||||||
|
itemMap.values().stream().filter(Objects::nonNull).peek(x -> x.setId(null)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,110 @@
|
||||||
|
package eu.eudat.model.builder;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
|
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
import eu.eudat.model.DmpReference;
|
||||||
|
import eu.eudat.model.Reference;
|
||||||
|
import eu.eudat.model.builder.referencedefinition.DefinitionBuilder;
|
||||||
|
import eu.eudat.query.DmpReferenceQuery;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class ReferenceBuilder extends BaseBuilder<Reference, ReferenceEntity>{
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
private final XmlHandlingService xmlHandlingService;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ReferenceBuilder(
|
||||||
|
ConventionService conventionService,
|
||||||
|
BuilderFactory builderFactory, QueryFactory queryFactory, XmlHandlingService xmlHandlingService) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(ReferenceBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Reference> build(FieldSet fields, List<ReferenceEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||||
|
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||||
|
if (fields == null || data == null || fields.isEmpty())
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
//ToDo FieldSet userInfoFields = fields.extractPrefixed(this.asPrefix(Reference._createdBy));
|
||||||
|
FieldSet definitionFields = fields.extractPrefixed(this.asPrefix(Reference._definition));
|
||||||
|
|
||||||
|
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asPrefix(Reference._dmpReferences));
|
||||||
|
Map<UUID, List<DmpReference>> dmpReferenceMap = this.collectDmpReferences(dmpReferencesFields, data);
|
||||||
|
|
||||||
|
List<Reference> models = new ArrayList<>();
|
||||||
|
for (ReferenceEntity d : data) {
|
||||||
|
Reference m = new Reference();
|
||||||
|
if (fields.hasField(this.asIndexer(Reference._id))) m.setId(d.getId());
|
||||||
|
if (fields.hasField(this.asIndexer(Reference._label))) m.setLabel(d.getLabel());
|
||||||
|
if (fields.hasField(this.asIndexer(Reference._createdAt))) m.setCreatedAt(d.getCreatedAt());
|
||||||
|
if (fields.hasField(this.asIndexer(Reference._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
||||||
|
if (fields.hasField(this.asIndexer(Reference._isActive))) m.setIsActive(d.getIsActive());
|
||||||
|
if (!definitionFields.isEmpty() && d.getDefinition() != null){
|
||||||
|
DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DefinitionEntity.class, d.getDefinition());
|
||||||
|
m.setDefinition(this.builderFactory.builder(DefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));
|
||||||
|
}
|
||||||
|
if (fields.hasField(this.asIndexer(Reference._reference))) m.setReference(d.getReference());
|
||||||
|
if (fields.hasField(this.asIndexer(Reference._abbreviation))) m.setAbbreviation(d.getAbbreviation());
|
||||||
|
if (fields.hasField(this.asIndexer(Reference._description))) m.setDescription(d.getDescription());
|
||||||
|
if (fields.hasField(this.asIndexer(Reference._source))) m.setSource(d.getSource());
|
||||||
|
if (fields.hasField(this.asIndexer(Reference._sourceType))) m.setReferenceSourceType(d.getReferenceSourceType());
|
||||||
|
if (fields.hasField(this.asIndexer(Reference._type))) m.setType(d.getType());
|
||||||
|
// if (!userInfoFields.isEmpty() && d.getCreatedBy() != null){
|
||||||
|
// //ToDo
|
||||||
|
// }
|
||||||
|
if (!dmpReferenceMap.isEmpty() && dmpReferenceMap != null && dmpReferenceMap.containsKey(d.getId())) m.setDmpReferences(dmpReferenceMap.get(d.getId()));
|
||||||
|
models.add(m);
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, List<DmpReference>> collectDmpReferences(FieldSet fields, List<ReferenceEntity> datas) throws MyApplicationException {
|
||||||
|
if (fields.isEmpty() || datas.isEmpty()) return null;
|
||||||
|
this.logger.debug("checking related - {}", DmpReference.class.getSimpleName());
|
||||||
|
|
||||||
|
Map<UUID, List<DmpReference>> itemMap = null;
|
||||||
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(DmpReference._reference, Reference._id));
|
||||||
|
DmpReferenceQuery query = this.queryFactory.query(DmpReferenceQuery.class).authorize(this.authorize).referenceIds(datas.stream().map(x -> x.getId()).distinct().collect(Collectors.toList()));
|
||||||
|
itemMap = this.builderFactory.builder(DmpReferenceBuilder.class).authorize(this.authorize).authorize(this.authorize).asMasterKey(query, clone, x -> x.getReference().getId());
|
||||||
|
|
||||||
|
if (!fields.hasField(this.asIndexer(DmpReference._reference, Reference._id))) {
|
||||||
|
itemMap.values().stream().flatMap(List::stream).filter(x -> x != null && x.getReference() != null).map(x -> {
|
||||||
|
x.getReference().setId(null);
|
||||||
|
return x;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return itemMap;
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,7 +26,7 @@ public class ExtraFieldBuilder extends FieldBuilder<ExtraField, ExtraFieldEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ExtraField buildChild(FieldSet fields, ExtraFieldEntity data, ExtraField model) {
|
protected ExtraField buildChild(FieldSet fields, ExtraFieldEntity data, ExtraField model) {
|
||||||
if (fields.hasField(this.asIndexer(ExtraField._type))) model.setType(data.getType());
|
if (fields.hasField(this.asIndexer(ExtraField._dataType))) model.setDataType(data.getType());
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ public abstract class FieldBuilder<Model extends Field, Entity extends FieldEnti
|
||||||
if (fields.hasField(this.asIndexer(Model._placeholder))) m.setPlaceholder(d.getPlaceholder());
|
if (fields.hasField(this.asIndexer(Model._placeholder))) m.setPlaceholder(d.getPlaceholder());
|
||||||
if (fields.hasField(this.asIndexer(Model._ordinal))) m.setOrdinal(d.getOrdinal());
|
if (fields.hasField(this.asIndexer(Model._ordinal))) m.setOrdinal(d.getOrdinal());
|
||||||
if (fields.hasField(this.asIndexer(Model._required))) m.setRequired(d.isRequired());
|
if (fields.hasField(this.asIndexer(Model._required))) m.setRequired(d.isRequired());
|
||||||
|
this.buildChild(fields, d, m);
|
||||||
models.add(m);
|
models.add(m);
|
||||||
}
|
}
|
||||||
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package eu.eudat.model.builder.dmpblueprintdefinition;
|
package eu.eudat.model.builder.dmpblueprintdefinition;
|
||||||
|
|
||||||
import eu.eudat.commons.types.dmpblueprint.ExtraFieldEntity;
|
import eu.eudat.commons.types.dmpblueprint.SystemFieldEntity;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.model.dmpblueprintdefinition.ExtraField;
|
import eu.eudat.model.dmpblueprintdefinition.SystemField;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class SystemFieldBuilder extends FieldBuilder<ExtraField, ExtraFieldEntity> {
|
public class SystemFieldBuilder extends FieldBuilder<SystemField, SystemFieldEntity> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public SystemFieldBuilder(
|
public SystemFieldBuilder(
|
||||||
|
@ -21,12 +21,12 @@ public class SystemFieldBuilder extends FieldBuilder<ExtraField, ExtraFieldEntit
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(SystemFieldBuilder.class)));
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(SystemFieldBuilder.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ExtraField getInstance() {
|
protected SystemField getInstance() {
|
||||||
return new ExtraField();
|
return new SystemField();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ExtraField buildChild(FieldSet fields, ExtraFieldEntity data, ExtraField model) {
|
protected SystemField buildChild(FieldSet fields, SystemFieldEntity data, SystemField model) {
|
||||||
if (fields.hasField(this.asIndexer(ExtraField._type))) model.setType(data.getType());
|
if (fields.hasField(this.asIndexer(SystemField._systemFieldType))) model.setSystemFieldType(data.getType());
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
package eu.eudat.model.builder.referencedefinition;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.BaseBuilder;
|
||||||
|
import eu.eudat.model.referencedefinition.Definition;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DefinitionBuilder extends BaseBuilder<Definition, DefinitionEntity> {
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DefinitionBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(DefinitionBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefinitionBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Definition> build(FieldSet fields, List<DefinitionEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||||
|
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||||
|
if (fields == null || data == null || fields.isEmpty())
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
//Not Bulk Build because is XML no interaction with db
|
||||||
|
FieldSet definitionFields = fields.extractPrefixed(this.asPrefix(Definition._fields));
|
||||||
|
|
||||||
|
List<Definition> models = new ArrayList<>();
|
||||||
|
for (DefinitionEntity d : data) {
|
||||||
|
Definition m = new Definition();
|
||||||
|
if (!definitionFields.isEmpty() && d.getFields() != null) m.setFields(this.builderFactory.builder(FieldBuilder.class).authorize(this.authorize).build(definitionFields, d.getFields()));
|
||||||
|
models.add(m);
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package eu.eudat.model.builder.referencedefinition;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.types.reference.FieldEntity;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.builder.BaseBuilder;
|
||||||
|
import eu.eudat.model.referencedefinition.Field;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class FieldBuilder extends BaseBuilder<Field, FieldEntity> {
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public FieldBuilder(
|
||||||
|
ConventionService conventionService, BuilderFactory builderFactory) {
|
||||||
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(FieldBuilder.class)));
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Field> build(FieldSet fields, List<FieldEntity> data) throws MyApplicationException {
|
||||||
|
this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0));
|
||||||
|
this.logger.trace(new DataLogEntry("requested fields", fields));
|
||||||
|
if (fields == null || data == null || fields.isEmpty())
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
List<Field> models = new ArrayList<>();
|
||||||
|
for (FieldEntity d : data) {
|
||||||
|
Field m = new Field();
|
||||||
|
if (fields.hasField(this.asIndexer(Field._code))) m.setCode(d.getCode());
|
||||||
|
if (fields.hasField(this.asIndexer(Field._dataType))) m.setDataType(d.getDataType());
|
||||||
|
if (fields.hasField(this.asIndexer(Field._value))) m.setValue(d.getValue());
|
||||||
|
|
||||||
|
models.add(m);
|
||||||
|
}
|
||||||
|
this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0));
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,9 @@ package eu.eudat.model.censorship;
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.Description;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.DataLogEntry;
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
@ -21,9 +23,12 @@ public class DescriptionCensor extends BaseCensor {
|
||||||
|
|
||||||
protected final AuthorizationService authService;
|
protected final AuthorizationService authService;
|
||||||
|
|
||||||
public DescriptionCensor(ConventionService conventionService, AuthorizationService authService) {
|
protected final CensorFactory censorFactory;
|
||||||
|
|
||||||
|
public DescriptionCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
|
||||||
super(conventionService);
|
super(conventionService);
|
||||||
this.authService = authService;
|
this.authService = authService;
|
||||||
|
this.censorFactory = censorFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void censor(FieldSet fields, UUID userId) {
|
public void censor(FieldSet fields, UUID userId) {
|
||||||
|
@ -32,6 +37,9 @@ public class DescriptionCensor extends BaseCensor {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.authService.authorizeForce(Permission.BrowseDescription);
|
this.authService.authorizeForce(Permission.BrowseDescription);
|
||||||
|
|
||||||
|
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(Description._dmp));
|
||||||
|
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
package eu.eudat.model.censorship;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.DescriptionReference;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DescriptionReferenceCensor extends BaseCensor {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionReferenceCensor.class));
|
||||||
|
|
||||||
|
protected final AuthorizationService authService;
|
||||||
|
|
||||||
|
protected final CensorFactory censorFactory;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DescriptionReferenceCensor(ConventionService conventionService,
|
||||||
|
AuthorizationService authService,
|
||||||
|
CensorFactory censorFactory) {
|
||||||
|
super(conventionService);
|
||||||
|
this.authService = authService;
|
||||||
|
this.censorFactory = censorFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void censor(FieldSet fields, UUID userId) {
|
||||||
|
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||||
|
if (fields == null || fields.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.authService.authorizeForce(Permission.BrowseDescriptionReference);
|
||||||
|
FieldSet descriptionFields = fields.extractPrefixed(this.asIndexerPrefix(DescriptionReference._description));
|
||||||
|
this.censorFactory.censor(DescriptionCensor.class).censor(descriptionFields, userId);
|
||||||
|
FieldSet referenceFields = fields.extractPrefixed(this.asIndexerPrefix(DescriptionReference._reference));
|
||||||
|
this.censorFactory.censor(ReferenceCensor.class).censor(referenceFields, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package eu.eudat.model.censorship;
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.Dmp;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.censor.CensorFactory;
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
@ -21,6 +22,7 @@ public class DmpCensor extends BaseCensor {
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpCensor.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpCensor.class));
|
||||||
|
|
||||||
protected final AuthorizationService authService;
|
protected final AuthorizationService authService;
|
||||||
|
|
||||||
protected final CensorFactory censorFactory;
|
protected final CensorFactory censorFactory;
|
||||||
|
|
||||||
public DmpCensor(ConventionService conventionService,
|
public DmpCensor(ConventionService conventionService,
|
||||||
|
@ -37,6 +39,11 @@ public class DmpCensor extends BaseCensor {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.authService.authorizeForce(Permission.BrowseDmp);
|
this.authService.authorizeForce(Permission.BrowseDmp);
|
||||||
|
|
||||||
|
FieldSet dmpDescriptionsFields = fields.extractPrefixed(this.asIndexerPrefix(Dmp._dmpDescriptions));
|
||||||
|
this.censorFactory.censor(DescriptionCensor.class).censor(dmpDescriptionsFields, userId);
|
||||||
|
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asIndexerPrefix(Dmp._dmpReferences));
|
||||||
|
this.censorFactory.censor(DmpReferenceCensor.class).censor(dmpReferencesFields, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package eu.eudat.model.censorship;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.DmpReference;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DmpReferenceCensor extends BaseCensor {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpReferenceCensor.class));
|
||||||
|
|
||||||
|
protected final AuthorizationService authService;
|
||||||
|
protected final CensorFactory censorFactory;
|
||||||
|
|
||||||
|
public DmpReferenceCensor(ConventionService conventionService,
|
||||||
|
AuthorizationService authService,
|
||||||
|
CensorFactory censorFactory) {
|
||||||
|
super(conventionService);
|
||||||
|
this.authService = authService;
|
||||||
|
this.censorFactory = censorFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void censor(FieldSet fields, UUID userId) {
|
||||||
|
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||||
|
if (fields == null || fields.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.authService.authorizeForce(Permission.BrowseDmpReference);
|
||||||
|
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._dmp));
|
||||||
|
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
||||||
|
FieldSet referenceFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._reference));
|
||||||
|
this.censorFactory.censor(ReferenceCensor.class).censor(referenceFields, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package eu.eudat.model.censorship;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.model.Reference;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.DataLogEntry;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class ReferenceCensor extends BaseCensor {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceCensor.class));
|
||||||
|
|
||||||
|
protected final AuthorizationService authService;
|
||||||
|
protected final CensorFactory censorFactory;
|
||||||
|
|
||||||
|
public ReferenceCensor(ConventionService conventionService,
|
||||||
|
AuthorizationService authService,
|
||||||
|
CensorFactory censorFactory) {
|
||||||
|
super(conventionService);
|
||||||
|
this.authService = authService;
|
||||||
|
this.censorFactory = censorFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void censor(FieldSet fields, UUID userId) {
|
||||||
|
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||||
|
if (fields == null || fields.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.authService.authorizeForce(Permission.BrowseReference);
|
||||||
|
FieldSet dmpReferencesFields = fields.extractPrefixed(this.asIndexerPrefix(Reference._dmpReferences));
|
||||||
|
this.censorFactory.censor(DmpReferenceCensor.class).censor(dmpReferencesFields, userId);
|
||||||
|
//ToDo
|
||||||
|
//FieldSet definitionFields = fields.extractPrefixed(this.asIndexerPrefix(Reference._createdBy));
|
||||||
|
//this.censorFactory.censor(UserInfo.class).censor(definitionFields, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
package eu.eudat.model.deleter;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DescriptionReferenceEntity;
|
||||||
|
import eu.eudat.query.DescriptionReferenceQuery;
|
||||||
|
import gr.cite.tools.data.deleter.Deleter;
|
||||||
|
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.management.InvalidApplicationException;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DescriptionReferenceDeleter implements Deleter {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionReferenceDeleter.class));
|
||||||
|
|
||||||
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
|
protected final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
protected final DeleterFactory deleterFactory;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DescriptionReferenceDeleter(
|
||||||
|
EntityManager entityManager,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
DeleterFactory deleterFactory
|
||||||
|
) {
|
||||||
|
this.entityManager = entityManager;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.deleterFactory = deleterFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAndSaveByIds(List<UUID> ids) throws InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids));
|
||||||
|
List<DescriptionReferenceEntity> data = this.queryFactory.query(DescriptionReferenceQuery.class).ids(ids).collect();
|
||||||
|
logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
this.deleteAndSave(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAndSave(List<DescriptionReferenceEntity> data) throws InvalidApplicationException {
|
||||||
|
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
this.delete(data);
|
||||||
|
logger.trace("saving changes");
|
||||||
|
this.entityManager.flush();
|
||||||
|
logger.trace("changes saved");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(List<DescriptionReferenceEntity> data) throws InvalidApplicationException {
|
||||||
|
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Instant now = Instant.now();
|
||||||
|
|
||||||
|
for (DescriptionReferenceEntity item : data) {
|
||||||
|
logger.trace("deleting item {}", item.getId());
|
||||||
|
item.setIsActive(IsActive.Inactive);
|
||||||
|
item.setUpdatedAt(now);
|
||||||
|
logger.trace("updating item");
|
||||||
|
this.entityManager.merge(item);
|
||||||
|
logger.trace("updated item");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
package eu.eudat.model.deleter;
|
||||||
|
|
||||||
|
import eu.eudat.data.DmpReferenceEntity;
|
||||||
|
import eu.eudat.query.DmpReferenceQuery;
|
||||||
|
import gr.cite.tools.data.deleter.Deleter;
|
||||||
|
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.management.InvalidApplicationException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DmpReferenceDeleter implements Deleter {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpReferenceDeleter.class));
|
||||||
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
|
protected final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
protected final DeleterFactory deleterFactory;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DmpReferenceDeleter(
|
||||||
|
EntityManager entityManager,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
DeleterFactory deleterFactory
|
||||||
|
) {
|
||||||
|
this.entityManager = entityManager;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.deleterFactory = deleterFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAndSaveByIds(List<UUID> ids) throws InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids));
|
||||||
|
List<DmpReferenceEntity> data = this.queryFactory.query(DmpReferenceQuery.class).ids(ids).collect();
|
||||||
|
logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
this.deleteAndSave(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAndSave(List<DmpReferenceEntity> data) throws InvalidApplicationException {
|
||||||
|
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
this.delete(data);
|
||||||
|
logger.trace("saving changes");
|
||||||
|
this.entityManager.flush();
|
||||||
|
logger.trace("changes saved");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(List<DmpReferenceEntity> data) throws InvalidApplicationException {
|
||||||
|
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (DmpReferenceEntity item : data) {
|
||||||
|
logger.trace("deleting item {}", item.getId());
|
||||||
|
logger.trace("updating item");
|
||||||
|
this.entityManager.merge(item);
|
||||||
|
logger.trace("updated item");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
package eu.eudat.model.deleter;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
import eu.eudat.query.ReferenceQuery;
|
||||||
|
import gr.cite.tools.data.deleter.Deleter;
|
||||||
|
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.management.InvalidApplicationException;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class ReferenceDeleter implements Deleter {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceDeleter.class));
|
||||||
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
|
protected final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
protected final DeleterFactory deleterFactory;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ReferenceDeleter(
|
||||||
|
EntityManager entityManager,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
DeleterFactory deleterFactory
|
||||||
|
) {
|
||||||
|
this.entityManager = entityManager;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.deleterFactory = deleterFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAndSaveByIds(List<UUID> ids) throws InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids));
|
||||||
|
List<ReferenceEntity> data = this.queryFactory.query(ReferenceQuery.class).ids(ids).collect();
|
||||||
|
logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
this.deleteAndSave(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAndSave(List<ReferenceEntity> data) throws InvalidApplicationException {
|
||||||
|
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
this.delete(data);
|
||||||
|
logger.trace("saving changes");
|
||||||
|
this.entityManager.flush();
|
||||||
|
logger.trace("changes saved");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(List<ReferenceEntity> data) throws InvalidApplicationException {
|
||||||
|
logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
if (data == null || data.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Instant now = Instant.now();
|
||||||
|
|
||||||
|
for (ReferenceEntity item : data) {
|
||||||
|
logger.trace("deleting item {}", item.getId());
|
||||||
|
item.setIsActive(IsActive.Inactive);
|
||||||
|
item.setUpdatedAt(now);
|
||||||
|
logger.trace("updating item");
|
||||||
|
this.entityManager.merge(item);
|
||||||
|
logger.trace("updated item");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,14 +4,14 @@ import eu.eudat.commons.enums.DmpBlueprintExtraFieldDataType;
|
||||||
|
|
||||||
public class ExtraField extends Field {
|
public class ExtraField extends Field {
|
||||||
|
|
||||||
public final static String _type = "type";
|
public final static String _dataType = "dataType";
|
||||||
private DmpBlueprintExtraFieldDataType type;
|
private DmpBlueprintExtraFieldDataType dataType;
|
||||||
|
|
||||||
public DmpBlueprintExtraFieldDataType getType() {
|
public DmpBlueprintExtraFieldDataType getDataType() {
|
||||||
return type;
|
return dataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(DmpBlueprintExtraFieldDataType type) {
|
public void setDataType(DmpBlueprintExtraFieldDataType dataType) {
|
||||||
this.type = type;
|
this.dataType = dataType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,14 @@ import eu.eudat.commons.enums.DmpBlueprintSystemFieldType;
|
||||||
|
|
||||||
public class SystemField extends Field {
|
public class SystemField extends Field {
|
||||||
|
|
||||||
public final static String _type = "type";
|
public final static String _systemFieldType = "systemFieldType";
|
||||||
private DmpBlueprintSystemFieldType type;
|
private DmpBlueprintSystemFieldType systemFieldType;
|
||||||
|
|
||||||
public DmpBlueprintSystemFieldType getType() {
|
public DmpBlueprintSystemFieldType getSystemFieldType() {
|
||||||
return type;
|
return systemFieldType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(DmpBlueprintSystemFieldType type) {
|
public void setSystemFieldType(DmpBlueprintSystemFieldType systemFieldType) {
|
||||||
this.type = type;
|
this.systemFieldType = systemFieldType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,123 @@
|
||||||
|
package eu.eudat.model.persist;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
|
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||||
|
import eu.eudat.commons.validation.FieldNotNullIfOtherSet;
|
||||||
|
import eu.eudat.commons.validation.ValidEnum;
|
||||||
|
import eu.eudat.commons.validation.ValidId;
|
||||||
|
import eu.eudat.model.persist.referencedefinition.DefinitionPersist;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@FieldNotNullIfOtherSet(message = "{validation.hashempty}")
|
||||||
|
public class ReferencePersist {
|
||||||
|
|
||||||
|
@ValidId(message = "{validation.invalidid}")
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
|
@NotNull(message = "{validation.empty}")
|
||||||
|
@NotEmpty(message = "{validation.empty}")
|
||||||
|
@Size(max = 250, message = "{validation.largerthanmax}")
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
@ValidEnum(message = "{validation.empty}")
|
||||||
|
private ReferenceType type;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Valid
|
||||||
|
private DefinitionPersist definition;
|
||||||
|
|
||||||
|
@NotNull(message = "{validation.empty}")
|
||||||
|
@NotEmpty(message = "{validation.empty}")
|
||||||
|
@Size(max = 1024, message = "{validation.largerthanmax}")
|
||||||
|
private String reference;
|
||||||
|
|
||||||
|
@Size(max = 50, message = "{validation.largerthanmax}")
|
||||||
|
private String abbreviation;
|
||||||
|
|
||||||
|
@Size(max = 1024, message = "{validation.largerthanmax}")
|
||||||
|
private String source;
|
||||||
|
|
||||||
|
@ValidEnum(message = "{validation.empty}")
|
||||||
|
private ReferenceSourceType referenceSourceType;
|
||||||
|
|
||||||
|
//private UserInfoPersist createdBy; ToDo
|
||||||
|
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(ReferenceType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefinitionPersist getDefinition() {
|
||||||
|
return definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefinition(DefinitionPersist definition) {
|
||||||
|
this.definition = definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReference() {
|
||||||
|
return reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReference(String reference) {
|
||||||
|
this.reference = reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAbbreviation() {
|
||||||
|
return abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbbreviation(String abbreviation) {
|
||||||
|
this.abbreviation = abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSource(String source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceSourceType getReferenceSourceType() {
|
||||||
|
return referenceSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReferenceSourceType(ReferenceSourceType referenceSourceType) {
|
||||||
|
this.referenceSourceType = referenceSourceType;
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,10 +14,11 @@ import java.util.UUID;
|
||||||
@JsonTypeInfo(
|
@JsonTypeInfo(
|
||||||
use = JsonTypeInfo.Id.NAME,
|
use = JsonTypeInfo.Id.NAME,
|
||||||
include = JsonTypeInfo.As.PROPERTY,
|
include = JsonTypeInfo.As.PROPERTY,
|
||||||
property = "category")
|
property = "category",
|
||||||
|
visible = true)
|
||||||
@JsonSubTypes({
|
@JsonSubTypes({
|
||||||
@JsonSubTypes.Type(value = SystemFieldPersist.class, name = "System"),
|
@JsonSubTypes.Type(value = SystemFieldPersist.class, name = "0"),
|
||||||
@JsonSubTypes.Type(value = ExtraFieldPersist.class, name = "Extra")
|
@JsonSubTypes.Type(value = ExtraFieldPersist.class, name = "1")
|
||||||
})
|
})
|
||||||
public abstract class FieldPersist {
|
public abstract class FieldPersist {
|
||||||
@NotNull(message = "{validation.empty}")
|
@NotNull(message = "{validation.empty}")
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package eu.eudat.model.persist.referencedefinition;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DefinitionPersist {
|
||||||
|
|
||||||
|
@NotNull(message = "{validation.empty}")
|
||||||
|
@Valid
|
||||||
|
private List<FieldPersist> fields = null;
|
||||||
|
|
||||||
|
public List<FieldPersist> getFields() {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFields(List<FieldPersist> fields) {
|
||||||
|
this.fields = fields;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package eu.eudat.model.persist.referencedefinition;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||||
|
import eu.eudat.commons.validation.ValidEnum;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
public class FieldPersist {
|
||||||
|
|
||||||
|
@NotNull(message = "{validation.empty}")
|
||||||
|
@NotEmpty(message = "{validation.empty}")
|
||||||
|
private String code = null;
|
||||||
|
|
||||||
|
@ValidEnum(message = "{validation.empty}")
|
||||||
|
private ReferenceFieldDataType dataType;
|
||||||
|
|
||||||
|
@NotNull(message = "{validation.empty}")
|
||||||
|
@NotEmpty(message = "{validation.empty}")
|
||||||
|
private String value = null;
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceFieldDataType getDataType() {
|
||||||
|
return dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataType(ReferenceFieldDataType dataType) {
|
||||||
|
this.dataType = dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package eu.eudat.model.referencedefinition;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Definition {
|
||||||
|
|
||||||
|
public final static String _fields = "fields";
|
||||||
|
private List<Field> fields;
|
||||||
|
|
||||||
|
public List<Field> getFields() {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFields(List<Field> fields) {
|
||||||
|
this.fields = fields;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package eu.eudat.model.referencedefinition;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceFieldDataType;
|
||||||
|
|
||||||
|
public class Field {
|
||||||
|
|
||||||
|
public final static String _code = "code";
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
public final static String _dataType = "dataType";
|
||||||
|
private ReferenceFieldDataType dataType;
|
||||||
|
|
||||||
|
public final static String _value = "value";
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceFieldDataType getDataType() {
|
||||||
|
return dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataType(ReferenceFieldDataType dataType) {
|
||||||
|
this.dataType = dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,220 @@
|
||||||
|
package eu.eudat.query;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
import eu.eudat.data.DescriptionReferenceEntity;
|
||||||
|
import eu.eudat.model.DescriptionReference;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.query.FieldResolver;
|
||||||
|
import gr.cite.tools.data.query.QueryBase;
|
||||||
|
import gr.cite.tools.data.query.QueryContext;
|
||||||
|
import jakarta.persistence.Tuple;
|
||||||
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
|
import jakarta.persistence.criteria.Predicate;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DescriptionReferenceQuery extends QueryBase<DescriptionReferenceEntity> {
|
||||||
|
|
||||||
|
private Collection<UUID> ids;
|
||||||
|
|
||||||
|
private Collection<UUID> excludedIds;
|
||||||
|
|
||||||
|
private Collection<IsActive> isActives;
|
||||||
|
|
||||||
|
private Collection<UUID> descriptionIds;
|
||||||
|
|
||||||
|
private Collection<UUID> referenceIds;
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
private final UserScope userScope;
|
||||||
|
|
||||||
|
private final AuthorizationService authService;
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery(UserScope userScope, AuthorizationService authService) {
|
||||||
|
this.userScope = userScope;
|
||||||
|
this.authService = authService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery ids(UUID value) {
|
||||||
|
this.ids = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery ids(UUID... value) {
|
||||||
|
this.ids = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery ids(Collection<UUID> values) {
|
||||||
|
this.ids = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery excludedIds(Collection<UUID> values) {
|
||||||
|
this.excludedIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery excludedIds(UUID value) {
|
||||||
|
this.excludedIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery excludedIds(UUID... value) {
|
||||||
|
this.excludedIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery isActive(IsActive value) {
|
||||||
|
this.isActives = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery isActive(IsActive... value) {
|
||||||
|
this.isActives = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery isActive(Collection<IsActive> values) {
|
||||||
|
this.isActives = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery descriptionIds(UUID value) {
|
||||||
|
this.descriptionIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery descriptionIds(UUID... value) {
|
||||||
|
this.descriptionIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery descriptionIds(Collection<UUID> values) {
|
||||||
|
this.descriptionIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery referenceIds(UUID value) {
|
||||||
|
this.referenceIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery referenceIds(UUID... value) {
|
||||||
|
this.referenceIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery referenceIds(Collection<UUID> values) {
|
||||||
|
this.referenceIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean isFalseQuery() {
|
||||||
|
return
|
||||||
|
this.isEmpty(this.ids) ||
|
||||||
|
this.isEmpty(this.isActives) ||
|
||||||
|
this.isEmpty(this.excludedIds) ||
|
||||||
|
this.isEmpty(this.descriptionIds) ||
|
||||||
|
this.isEmpty(this.referenceIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<DescriptionReferenceEntity> entityClass() {
|
||||||
|
return DescriptionReferenceEntity.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||||
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
if (this.ids != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionReferenceEntity._id));
|
||||||
|
for (UUID item : this.ids)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.excludedIds != null) {
|
||||||
|
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionReferenceEntity._id));
|
||||||
|
for (UUID item : this.excludedIds)
|
||||||
|
notInClause.value(item);
|
||||||
|
predicates.add(notInClause.not());
|
||||||
|
}
|
||||||
|
if (this.isActives != null) {
|
||||||
|
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionReferenceEntity._isActive));
|
||||||
|
for (IsActive item : this.isActives)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.descriptionIds != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionReferenceEntity._descriptionId));
|
||||||
|
for (UUID item : this.descriptionIds)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.referenceIds != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionReferenceEntity._referenceId));
|
||||||
|
for (UUID item : this.referenceIds)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (!predicates.isEmpty()) {
|
||||||
|
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||||
|
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String fieldNameOf(FieldResolver item) {
|
||||||
|
if (item.match(DescriptionReference._id))
|
||||||
|
return DescriptionReferenceEntity._id;
|
||||||
|
if (item.match(DescriptionReference._data))
|
||||||
|
return DescriptionReferenceEntity._data;
|
||||||
|
if (item.match(DescriptionReference._description))
|
||||||
|
return DescriptionReferenceEntity._descriptionId;
|
||||||
|
else if (item.prefix(DescriptionReference._description))
|
||||||
|
return DescriptionReferenceEntity._descriptionId;
|
||||||
|
else if (item.match(DescriptionReference._reference))
|
||||||
|
return DescriptionReferenceEntity._referenceId;
|
||||||
|
else if (item.prefix(DescriptionReference._reference))
|
||||||
|
return DescriptionReferenceEntity._referenceId;
|
||||||
|
else if (item.match(DescriptionReference._createdAt))
|
||||||
|
return DescriptionReferenceEntity._createdAt;
|
||||||
|
else if (item.match(DescriptionReference._updatedAt))
|
||||||
|
return DescriptionReferenceEntity._updatedAt;
|
||||||
|
else if (item.match(DescriptionReference._isActive))
|
||||||
|
return DescriptionReferenceEntity._isActive;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DescriptionReferenceEntity convert(Tuple tuple, Set<String> columns) {
|
||||||
|
DescriptionReferenceEntity item = new DescriptionReferenceEntity();
|
||||||
|
item.setId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._id, UUID.class));
|
||||||
|
item.setData(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._data, String.class));
|
||||||
|
item.setDescriptionId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._descriptionId, UUID.class));
|
||||||
|
item.setReferenceId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._referenceId, UUID.class));
|
||||||
|
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._createdAt, Instant.class));
|
||||||
|
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._updatedAt, Instant.class));
|
||||||
|
item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._isActive, IsActive.class));
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,158 @@
|
||||||
|
package eu.eudat.query;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
import eu.eudat.data.DmpReferenceEntity;
|
||||||
|
import eu.eudat.model.DmpReference;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.query.FieldResolver;
|
||||||
|
import gr.cite.tools.data.query.QueryBase;
|
||||||
|
import gr.cite.tools.data.query.QueryContext;
|
||||||
|
import jakarta.persistence.Tuple;
|
||||||
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
|
import jakarta.persistence.criteria.Predicate;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class DmpReferenceQuery extends QueryBase<DmpReferenceEntity> {
|
||||||
|
|
||||||
|
private Collection<UUID> ids;
|
||||||
|
|
||||||
|
private Collection<UUID> dmpIds;
|
||||||
|
|
||||||
|
private Collection<UUID> referenceIds;
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
|
||||||
|
public DmpReferenceQuery ids(UUID value) {
|
||||||
|
this.ids = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpReferenceQuery ids(UUID... value) {
|
||||||
|
this.ids = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpReferenceQuery ids(Collection<UUID> values) {
|
||||||
|
this.ids = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpReferenceQuery dmpIds(UUID value) {
|
||||||
|
this.dmpIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpReferenceQuery dmpIds(UUID... value) {
|
||||||
|
this.dmpIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpReferenceQuery dmpIds(Collection<UUID> values) {
|
||||||
|
this.dmpIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpReferenceQuery referenceIds(UUID value) {
|
||||||
|
this.referenceIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpReferenceQuery referenceIds(UUID... value) {
|
||||||
|
this.referenceIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpReferenceQuery referenceIds(Collection<UUID> values) {
|
||||||
|
this.referenceIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpReferenceQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final UserScope userScope;
|
||||||
|
|
||||||
|
private final AuthorizationService authService;
|
||||||
|
|
||||||
|
public DmpReferenceQuery(
|
||||||
|
UserScope userScope,
|
||||||
|
AuthorizationService authService
|
||||||
|
) {
|
||||||
|
this.userScope = userScope;
|
||||||
|
this.authService = authService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<DmpReferenceEntity> entityClass() {
|
||||||
|
return DmpReferenceEntity.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean isFalseQuery() {
|
||||||
|
return this.isEmpty(this.ids) || this.isEmpty(this.dmpIds) || this.isEmpty(this.referenceIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||||
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
if (this.ids != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._id));
|
||||||
|
for (UUID item : this.ids)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.dmpIds != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._dmpId));
|
||||||
|
for (UUID item : this.ids)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.referenceIds != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._referenceId));
|
||||||
|
for (UUID item : this.ids)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (!predicates.isEmpty()) {
|
||||||
|
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||||
|
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DmpReferenceEntity convert(Tuple tuple, Set<String> columns) {
|
||||||
|
DmpReferenceEntity item = new DmpReferenceEntity();
|
||||||
|
item.setId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._id, UUID.class));
|
||||||
|
item.setReferenceId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._dmpId, UUID.class));
|
||||||
|
item.setReferenceId(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._referenceId, UUID.class));
|
||||||
|
item.setData(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._data, String.class));
|
||||||
|
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._createdAt, Instant.class));
|
||||||
|
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DmpReferenceEntity._updatedAt, Instant.class));
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String fieldNameOf(FieldResolver item) {
|
||||||
|
if (item.match(DmpReference._id)) return DmpReferenceEntity._id;
|
||||||
|
else if (item.prefix(DmpReference._dmp)) return DmpReferenceEntity._dmpId;
|
||||||
|
else if (item.prefix(DmpReference._reference)) return DmpReferenceEntity._referenceId;
|
||||||
|
else if (item.match(DmpReference._data)) return DmpReferenceEntity._data;
|
||||||
|
else if (item.match(DmpReference._createdAt)) return DmpReferenceEntity._createdAt;
|
||||||
|
else if (item.match(DmpReference._updatedAt)) return DmpReferenceEntity._updatedAt;
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,231 @@
|
||||||
|
package eu.eudat.query;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||||
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.query.FieldResolver;
|
||||||
|
import gr.cite.tools.data.query.QueryBase;
|
||||||
|
import gr.cite.tools.data.query.QueryContext;
|
||||||
|
import jakarta.persistence.Tuple;
|
||||||
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
|
import jakarta.persistence.criteria.Predicate;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
||||||
|
|
||||||
|
private String like;
|
||||||
|
|
||||||
|
private Collection<UUID> ids;
|
||||||
|
|
||||||
|
private Collection<IsActive> isActives;
|
||||||
|
|
||||||
|
private Collection<ReferenceSourceType> referenceSourceTypes;
|
||||||
|
|
||||||
|
private Collection<ReferenceType> referenceTypes;
|
||||||
|
|
||||||
|
private Collection<UUID> excludedIds;
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
public ReferenceQuery like(String value) {
|
||||||
|
this.like = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery ids(UUID value) {
|
||||||
|
this.ids = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery ids(UUID... value) {
|
||||||
|
this.ids = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery ids(Collection<UUID> values) {
|
||||||
|
this.ids = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery isActive(IsActive value) {
|
||||||
|
this.isActives = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery isActive(IsActive... value) {
|
||||||
|
this.isActives = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery isActive(Collection<IsActive> values) {
|
||||||
|
this.isActives = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery referenceTypes(ReferenceType value) {
|
||||||
|
this.referenceTypes = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery referenceTypes(ReferenceType... value) {
|
||||||
|
this.referenceTypes = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery referenceTypes(Collection<ReferenceType> values) {
|
||||||
|
this.referenceTypes = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery excludedIds(Collection<UUID> values) {
|
||||||
|
this.excludedIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery excludedIds(UUID value) {
|
||||||
|
this.excludedIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery excludedIds(UUID... value) {
|
||||||
|
this.excludedIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery referenceSourceTypes(ReferenceSourceType value) {
|
||||||
|
this.referenceSourceTypes = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery referenceSourceTypes(ReferenceSourceType... value) {
|
||||||
|
this.referenceSourceTypes = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery referenceSourceTypes(Collection<ReferenceSourceType> values) {
|
||||||
|
this.referenceSourceTypes = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final UserScope userScope;
|
||||||
|
|
||||||
|
private final AuthorizationService authService;
|
||||||
|
|
||||||
|
public ReferenceQuery(
|
||||||
|
UserScope userScope,
|
||||||
|
AuthorizationService authService
|
||||||
|
) {
|
||||||
|
this.userScope = userScope;
|
||||||
|
this.authService = authService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<ReferenceEntity> entityClass() {
|
||||||
|
return ReferenceEntity.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean isFalseQuery() {
|
||||||
|
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.referenceTypes) || this.isEmpty(this.referenceSourceTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||||
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
if (this.ids != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._id));
|
||||||
|
for (UUID item : this.ids)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.like != null && !this.like.isEmpty()) {
|
||||||
|
predicates.add(queryContext.CriteriaBuilder.or(queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._label), this.like),
|
||||||
|
queryContext.CriteriaBuilder.like(queryContext.Root.get(ReferenceEntity._description), this.like)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if (this.isActives != null) {
|
||||||
|
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._isActive));
|
||||||
|
for (IsActive item : this.isActives)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.referenceSourceTypes != null) {
|
||||||
|
CriteriaBuilder.In<ReferenceSourceType> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._sourceType));
|
||||||
|
for (ReferenceSourceType item : this.referenceSourceTypes)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.referenceTypes != null) {
|
||||||
|
CriteriaBuilder.In<ReferenceType> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._type));
|
||||||
|
for (ReferenceType item : this.referenceTypes)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.excludedIds != null) {
|
||||||
|
CriteriaBuilder.In<UUID> notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._id));
|
||||||
|
for (UUID item : this.excludedIds)
|
||||||
|
notInClause.value(item);
|
||||||
|
predicates.add(notInClause.not());
|
||||||
|
}
|
||||||
|
if (!predicates.isEmpty()) {
|
||||||
|
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||||
|
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ReferenceEntity convert(Tuple tuple, Set<String> columns) {
|
||||||
|
ReferenceEntity item = new ReferenceEntity();
|
||||||
|
item.setId(QueryBase.convertSafe(tuple, columns, ReferenceEntity._id, UUID.class));
|
||||||
|
item.setLabel(QueryBase.convertSafe(tuple, columns, ReferenceEntity._label, String.class));
|
||||||
|
item.setDescription(QueryBase.convertSafe(tuple, columns, ReferenceEntity._description, String.class));
|
||||||
|
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, ReferenceEntity._createdAt, Instant.class));
|
||||||
|
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, ReferenceEntity._updatedAt, Instant.class));
|
||||||
|
item.setIsActive(QueryBase.convertSafe(tuple, columns, ReferenceEntity._isActive, IsActive.class));
|
||||||
|
item.setDefinition(QueryBase.convertSafe(tuple, columns, ReferenceEntity._definition, String.class));
|
||||||
|
item.setAbbreviation(QueryBase.convertSafe(tuple, columns, ReferenceEntity._abbreviation, String.class));
|
||||||
|
item.setReference(QueryBase.convertSafe(tuple, columns, ReferenceEntity._reference, String.class));
|
||||||
|
item.setSource(QueryBase.convertSafe(tuple, columns, ReferenceEntity._source, String.class));
|
||||||
|
item.setReferenceSourceType(QueryBase.convertSafe(tuple, columns, ReferenceEntity._sourceType, ReferenceSourceType.class));
|
||||||
|
item.setType(QueryBase.convertSafe(tuple, columns, ReferenceEntity._type, ReferenceType.class));
|
||||||
|
item.setCreatedBy(QueryBase.convertSafe(tuple, columns, ReferenceEntity._createdBy, UUID.class));
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String fieldNameOf(FieldResolver item) {
|
||||||
|
if (item.match(ReferenceEntity._id)) return ReferenceEntity._id;
|
||||||
|
else if (item.match(ReferenceEntity._label)) return ReferenceEntity._label;
|
||||||
|
else if (item.match(ReferenceEntity._description)) return ReferenceEntity._description;
|
||||||
|
else if (item.match(ReferenceEntity._createdAt)) return ReferenceEntity._createdAt;
|
||||||
|
else if (item.match(ReferenceEntity._updatedAt)) return ReferenceEntity._updatedAt;
|
||||||
|
else if (item.match(ReferenceEntity._isActive)) return ReferenceEntity._isActive;
|
||||||
|
else if (item.match(ReferenceEntity._definition)) return ReferenceEntity._definition;
|
||||||
|
else if (item.match(ReferenceEntity._abbreviation)) return ReferenceEntity._abbreviation;
|
||||||
|
else if (item.match(ReferenceEntity._reference)) return ReferenceEntity._reference;
|
||||||
|
else if (item.match(ReferenceEntity._source)) return ReferenceEntity._source;
|
||||||
|
else if (item.match(ReferenceEntity._sourceType)) return ReferenceEntity._sourceType;
|
||||||
|
else if (item.match(ReferenceEntity._type)) return ReferenceEntity._type;
|
||||||
|
//else if (item.prefix(ReferenceEntity._createdBy)) return ReferenceEntity._createdBy;
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
package eu.eudat.query.lookup;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.query.DescriptionReferenceQuery;
|
||||||
|
import gr.cite.tools.data.query.Lookup;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class DescriptionReferenceLookup extends Lookup {
|
||||||
|
|
||||||
|
private Collection<UUID> ids;
|
||||||
|
|
||||||
|
private Collection<UUID> excludedIds;
|
||||||
|
|
||||||
|
private Collection<IsActive> isActives;
|
||||||
|
|
||||||
|
private Collection<UUID> descriptionIds;
|
||||||
|
|
||||||
|
private Collection<UUID> referenceIds;
|
||||||
|
|
||||||
|
public Collection<UUID> getIds() {
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIds(Collection<UUID> ids) {
|
||||||
|
this.ids = ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<UUID> getExcludedIds() {
|
||||||
|
return excludedIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExcludedIds(Collection<UUID> excludedIds) {
|
||||||
|
this.excludedIds = excludedIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<IsActive> getIsActives() {
|
||||||
|
return isActives;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsActives(Collection<IsActive> isActives) {
|
||||||
|
this.isActives = isActives;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<UUID> getDescriptionIds() {
|
||||||
|
return descriptionIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescriptionIds(Collection<UUID> descriptionIds) {
|
||||||
|
this.descriptionIds = descriptionIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<UUID> getReferenceIds() {
|
||||||
|
return referenceIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReferenceIds(Collection<UUID> referenceIds) {
|
||||||
|
this.referenceIds = referenceIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DescriptionReferenceQuery enrich(QueryFactory queryFactory) {
|
||||||
|
DescriptionReferenceQuery query = queryFactory.query(DescriptionReferenceQuery.class);
|
||||||
|
if (this.ids != null) query.ids(this.ids);
|
||||||
|
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
|
||||||
|
if (this.isActives != null) query.isActive(this.isActives);
|
||||||
|
if (this.descriptionIds != null) query.descriptionIds(this.descriptionIds);
|
||||||
|
if (this.referenceIds != null) query.referenceIds(this.referenceIds);
|
||||||
|
|
||||||
|
this.enrichCommon(query);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package eu.eudat.query.lookup;
|
||||||
|
|
||||||
|
import eu.eudat.query.DmpReferenceQuery;
|
||||||
|
import gr.cite.tools.data.query.Lookup;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class DmpReferenceLookup extends Lookup {
|
||||||
|
|
||||||
|
private Collection<UUID> ids;
|
||||||
|
|
||||||
|
private Collection<UUID> dmpIds;
|
||||||
|
|
||||||
|
private Collection<UUID> referenceIds;
|
||||||
|
|
||||||
|
|
||||||
|
public DmpReferenceQuery enrich(QueryFactory queryFactory) {
|
||||||
|
DmpReferenceQuery query = queryFactory.query(DmpReferenceQuery.class);
|
||||||
|
if (this.ids != null) query.ids(this.ids);
|
||||||
|
if (this.dmpIds != null) query.dmpIds(this.dmpIds);
|
||||||
|
if (this.referenceIds != null) query.referenceIds(this.referenceIds);
|
||||||
|
|
||||||
|
this.enrichCommon(query);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
package eu.eudat.query.lookup;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||||
|
import eu.eudat.query.ReferenceQuery;
|
||||||
|
import gr.cite.tools.data.query.Lookup;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class ReferenceLookup extends Lookup {
|
||||||
|
|
||||||
|
private String like;
|
||||||
|
|
||||||
|
private List<IsActive> isActive;
|
||||||
|
|
||||||
|
private Collection<ReferenceSourceType> referenceSourceTypes;
|
||||||
|
|
||||||
|
private Collection<ReferenceType> referenceTypes;
|
||||||
|
|
||||||
|
private List<UUID> ids;
|
||||||
|
|
||||||
|
private List<UUID> excludedIds;
|
||||||
|
|
||||||
|
public String getLike() {
|
||||||
|
return like;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLike(String like) {
|
||||||
|
this.like = like;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IsActive> getIsActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsActive(List<IsActive> isActive) {
|
||||||
|
this.isActive = isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getIds() {
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIds(List<UUID> ids) {
|
||||||
|
this.ids = ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getExcludedIds() {
|
||||||
|
return excludedIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExcludedIds(List<UUID> excludeIds) {
|
||||||
|
this.excludedIds = excludeIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<ReferenceSourceType> getReferenceSourceTypes() {
|
||||||
|
return referenceSourceTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReferenceSourceTypes(Collection<ReferenceSourceType> referenceSourceTypes) {
|
||||||
|
this.referenceSourceTypes = referenceSourceTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<ReferenceType> getReferenceTypes() {
|
||||||
|
return referenceTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReferenceTypes(Collection<ReferenceType> referenceTypes) {
|
||||||
|
this.referenceTypes = referenceTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReferenceQuery enrich(QueryFactory queryFactory) {
|
||||||
|
ReferenceQuery query = queryFactory.query(ReferenceQuery.class);
|
||||||
|
if (this.like != null) query.like(this.like);
|
||||||
|
if (this.isActive != null) query.isActive(this.isActive);
|
||||||
|
if (this.referenceTypes != null) query.referenceTypes(this.referenceTypes);
|
||||||
|
if (this.referenceSourceTypes != null) query.referenceSourceTypes(this.referenceSourceTypes);
|
||||||
|
if (this.ids != null) query.ids(this.ids);
|
||||||
|
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
|
||||||
|
|
||||||
|
this.enrichCommon(query);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class ReferenceCriteria extends Criteria<ReferenceEntity>{
|
||||||
|
|
||||||
|
private UUID creationUserId;
|
||||||
|
|
||||||
|
public UUID getCreationUserId() {
|
||||||
|
return creationUserId;
|
||||||
|
}
|
||||||
|
public void setCreationUserId(UUID creationUserId) {
|
||||||
|
this.creationUserId = creationUserId;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,128 @@
|
||||||
|
package eu.eudat.controllers.v2;
|
||||||
|
|
||||||
|
import eu.eudat.audit.AuditableAction;
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
|
import eu.eudat.model.Description;
|
||||||
|
import eu.eudat.model.Dmp;
|
||||||
|
import eu.eudat.model.builder.DescriptionBuilder;
|
||||||
|
import eu.eudat.model.censorship.DescriptionCensor;
|
||||||
|
import eu.eudat.model.persist.DescriptionPersist;
|
||||||
|
import eu.eudat.model.result.QueryResult;
|
||||||
|
import eu.eudat.query.DescriptionQuery;
|
||||||
|
import eu.eudat.query.lookup.DescriptionLookup;
|
||||||
|
import eu.eudat.service.description.DescriptionService;
|
||||||
|
import gr.cite.tools.auditing.AuditService;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.exception.MyForbiddenException;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
|
import gr.cite.tools.validation.MyValidate;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.management.InvalidApplicationException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(path = "api/description")
|
||||||
|
public class DescriptionController {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionController.class));
|
||||||
|
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
|
||||||
|
private final AuditService auditService;
|
||||||
|
|
||||||
|
private final DescriptionService descriptionService;
|
||||||
|
|
||||||
|
private final CensorFactory censorFactory;
|
||||||
|
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
|
public DescriptionController(
|
||||||
|
BuilderFactory builderFactory,
|
||||||
|
AuditService auditService,
|
||||||
|
DescriptionService descriptionService,
|
||||||
|
CensorFactory censorFactory,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
MessageSource messageSource) {
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.auditService = auditService;
|
||||||
|
this.descriptionService = descriptionService;
|
||||||
|
this.censorFactory = censorFactory;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("query")
|
||||||
|
public QueryResult<Description> Query(@RequestBody DescriptionLookup lookup) throws MyApplicationException, MyForbiddenException {
|
||||||
|
logger.debug("querying {}", Description.class.getSimpleName());
|
||||||
|
|
||||||
|
this.censorFactory.censor(DescriptionCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
|
DescriptionQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrPermission);
|
||||||
|
|
||||||
|
List<DescriptionEntity> data = query.collectAs(lookup.getProject());
|
||||||
|
List<Description> models = this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(lookup.getProject(), data);
|
||||||
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.Description_Query, "lookup", lookup);
|
||||||
|
|
||||||
|
return new QueryResult<>(models, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("{id}")
|
||||||
|
public Description Get(@PathVariable("id") UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
||||||
|
logger.debug(new MapLogEntry("retrieving" + Description.class.getSimpleName()).And("id", id).And("fields", fieldSet));
|
||||||
|
|
||||||
|
this.censorFactory.censor(DescriptionCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
|
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrPermission).ids(id);
|
||||||
|
Description model = this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
|
if (model == null)
|
||||||
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.Description_Lookup, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
|
));
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("persist")
|
||||||
|
@Transactional
|
||||||
|
public Description Persist(@MyValidate @RequestBody DescriptionPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("persisting" + Description.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
||||||
|
Description persisted = this.descriptionService.persist(model, fieldSet);
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.Description_Persist, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("model", model),
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
|
));
|
||||||
|
|
||||||
|
return persisted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("{id}")
|
||||||
|
@Transactional
|
||||||
|
public void Delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("retrieving" + Description.class.getSimpleName()).And("id", id));
|
||||||
|
|
||||||
|
this.descriptionService.deleteAndSave(id);
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.Description_Delete, "id", id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -122,7 +122,7 @@ public class EntityDoiController {
|
||||||
|
|
||||||
this.entityDoiService.deleteAndSave(id);
|
this.entityDoiService.deleteAndSave(id);
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.DescriptionTemplateType_Delete, "id", id);
|
this.auditService.track(AuditableAction.EntityDoi_Delete, "id", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,111 +0,0 @@
|
||||||
package eu.eudat.controllers.v2;
|
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.commons.enums.ExternalReferencesType;
|
|
||||||
import eu.eudat.controllers.BaseController;
|
|
||||||
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.logic.services.externalreferences.ExternalReferencesService;
|
|
||||||
import eu.eudat.logic.services.externalreferences.FunderService;
|
|
||||||
import eu.eudat.logic.services.externalreferences.ProjectService;
|
|
||||||
import eu.eudat.models.data.ExternalReference;
|
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
||||||
import eu.eudat.types.ApiMessageCode;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping(path = {"api/external-references"})
|
|
||||||
public class ExternalReferencesController extends BaseController {
|
|
||||||
|
|
||||||
private final FunderService funderService;
|
|
||||||
private final ExternalReferencesService externalReferencesService;
|
|
||||||
private final ProjectService projectService;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public ExternalReferencesController(
|
|
||||||
ApiContext apiContext,
|
|
||||||
FunderService funderService,
|
|
||||||
ExternalReferencesService externalReferencesService,
|
|
||||||
ProjectService projectService,
|
|
||||||
AuthorizationService authorizationService) {
|
|
||||||
super(apiContext);
|
|
||||||
this.funderService = funderService;
|
|
||||||
this.externalReferencesService = externalReferencesService;
|
|
||||||
this.projectService = projectService;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @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 {
|
|
||||||
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
//
|
|
||||||
// List<Funder> dataTable = this.funderService.getCriteriaWithExternal(funderCriteria);
|
|
||||||
// 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")
|
|
||||||
// public @ResponseBody
|
|
||||||
// ResponseEntity<ResponseItem<List<Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException, InvalidApplicationException {
|
|
||||||
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
//
|
|
||||||
// List<Project> dataTable = this.projectService.getCriteriaWithExternal(projectCriteria);
|
|
||||||
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping(path = {"{externalType}"}, produces = "application/json")
|
|
||||||
public @ResponseBody ResponseEntity<ResponseItem<List<ExternalReference>>> listExternalReferecnes(@PathVariable(value = "externalType") int externalType,
|
|
||||||
@RequestParam(value = "query", required = false) String query,
|
|
||||||
@RequestParam(value = "type", required = false) String type
|
|
||||||
) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
ExternalReferencesType externalReferencesType = ExternalReferencesType.of((short) externalType);
|
|
||||||
|
|
||||||
List<ExternalReference> externalReferences = this.externalReferencesService.getExternalReference(externalReferencesType, query, type);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalReference>>().status(ApiMessageCode.NO_MESSAGE).payload(externalReferences));
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Transactional
|
|
||||||
// @PostMapping(path = {"data-repo/persist"}, consumes = "application/json", produces = "application/json")
|
|
||||||
// public @ResponseBody
|
|
||||||
// ResponseEntity<ResponseItem<ExternalReference>> createExternalReferecnes(@RequestBody ExternalReference externalReference) throws Exception {
|
|
||||||
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
//
|
|
||||||
// ExternalReference newExternalReference = this.externalReferencesService.createDataRepo(externalReference);
|
|
||||||
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalReference>().payload(newExternalReference).status(ApiMessageCode.SUCCESS_MESSAGE));
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// @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,
|
|
||||||
// @RequestParam(value = "type", required = false) String type
|
|
||||||
// ) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
|
||||||
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
//
|
|
||||||
// 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));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Transactional
|
|
||||||
// @PostMapping(value = {"{externalType}/persist"}, consumes = "application/json", produces = "application/json")
|
|
||||||
// public @ResponseBody
|
|
||||||
// ResponseEntity<ResponseItem<ExternalReference2>> create(@RequestBody ExternalReference2 externalReference) throws Exception {
|
|
||||||
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
|
||||||
//
|
|
||||||
// ExternalReference2 newExternalReference = this.externalReferencesService.create(externalReference);
|
|
||||||
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalReference2>().payload(newExternalReference).status(ApiMessageCode.SUCCESS_MESSAGE));
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,170 @@
|
||||||
|
package eu.eudat.controllers.v2;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import eu.eudat.audit.AuditableAction;
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
|
import eu.eudat.controllers.BaseController;
|
||||||
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
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.logic.services.references.ReferenceService;
|
||||||
|
import eu.eudat.model.Reference;
|
||||||
|
import eu.eudat.model.builder.ReferenceBuilder;
|
||||||
|
import eu.eudat.model.censorship.ReferenceCensor;
|
||||||
|
import eu.eudat.model.persist.ReferencePersist;
|
||||||
|
import eu.eudat.model.result.QueryResult;
|
||||||
|
import eu.eudat.models.data.FetcherReference;
|
||||||
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
|
import eu.eudat.query.ReferenceQuery;
|
||||||
|
import eu.eudat.query.lookup.ReferenceLookup;
|
||||||
|
import eu.eudat.types.ApiMessageCode;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.auditing.AuditService;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.exception.MyForbiddenException;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
|
import gr.cite.tools.validation.MyValidate;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.management.InvalidApplicationException;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(path = {"api/reference"})
|
||||||
|
public class ReferenceController extends BaseController {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceController.class));
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private final AuditService auditService;
|
||||||
|
private final ReferenceService referenceService;
|
||||||
|
private final CensorFactory censorFactory;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
private final MessageSource messageSource;
|
||||||
|
private final AuthorizationService authorizationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ReferenceController(
|
||||||
|
ApiContext apiContext,
|
||||||
|
BuilderFactory builderFactory,
|
||||||
|
ReferenceService referenceService,
|
||||||
|
AuditService auditService,
|
||||||
|
CensorFactory censorFactory,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
MessageSource messageSource, AuthorizationService authorizationService) {
|
||||||
|
super(apiContext);
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.referenceService = referenceService;
|
||||||
|
this.auditService = auditService;
|
||||||
|
this.censorFactory = censorFactory;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
this.authorizationService = authorizationService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("query")
|
||||||
|
public QueryResult<Reference> query(@RequestBody ReferenceLookup lookup) throws MyApplicationException, MyForbiddenException {
|
||||||
|
logger.debug("querying {}", Reference.class.getSimpleName());
|
||||||
|
|
||||||
|
this.censorFactory.censor(ReferenceCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
|
ReferenceQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrPermission);
|
||||||
|
List<ReferenceEntity> datas = query.collectAs(lookup.getProject());
|
||||||
|
List<Reference> models = this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(lookup.getProject(), datas);
|
||||||
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.Reference_Query, "lookup", lookup);
|
||||||
|
|
||||||
|
return new QueryResult(models, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("{id}")
|
||||||
|
public Reference get(@PathVariable("id") UUID id, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
||||||
|
logger.debug(new MapLogEntry("retrieving" + Reference.class.getSimpleName()).And("id", id).And("fields", fieldSet));
|
||||||
|
|
||||||
|
this.censorFactory.censor(ReferenceCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
|
ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).authorize(AuthorizationFlags.OwnerOrPermission).ids(id);
|
||||||
|
Reference model = this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
|
if (model == null)
|
||||||
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.Reference_Lookup, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
|
));
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("persist")
|
||||||
|
@Transactional
|
||||||
|
public Reference persist(@MyValidate @RequestBody ReferencePersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, ParserConfigurationException, JsonProcessingException, TransformerException {
|
||||||
|
logger.debug(new MapLogEntry("persisting" + Reference.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
||||||
|
this.censorFactory.censor(ReferenceCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
|
Reference persisted = this.referenceService.persist(model, fieldSet);
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.Reference_Persist, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("model", model),
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
|
));
|
||||||
|
//this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
|
||||||
|
return persisted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(path = {"search/{externalType}"}, produces = "application/json")
|
||||||
|
public @ResponseBody ResponseEntity<ResponseItem<List<FetcherReference>>> searchReference(@PathVariable(value = "externalType") int externalType,
|
||||||
|
@RequestParam(value = "query", required = false) String query,
|
||||||
|
@RequestParam(value = "type", required = false) String type
|
||||||
|
) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
||||||
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
ReferenceType referenceType = ReferenceType.of((short) externalType);
|
||||||
|
|
||||||
|
List<FetcherReference> fetcherReferences = this.referenceService.searchReference(referenceType, query, type);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<FetcherReference>>().status(ApiMessageCode.NO_MESSAGE).payload(fetcherReferences));
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("{id}")
|
||||||
|
@Transactional
|
||||||
|
public void delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||||
|
logger.debug(new MapLogEntry("retrieving" + Reference.class.getSimpleName()).And("id", id));
|
||||||
|
|
||||||
|
this.referenceService.deleteAndSave(id);
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.Reference_Delete, "id", id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @Transactional
|
||||||
|
// @PostMapping(path = {"persist"}, consumes = "application/json", produces = "application/json")
|
||||||
|
// public @ResponseBody
|
||||||
|
// ResponseEntity<ResponseItem<ExternalReference>> createExternalReferecnes(@RequestBody ExternalReference externalReference) throws Exception {
|
||||||
|
// this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
//
|
||||||
|
// ExternalReference newExternalReference = this.externalReferencesService.createDataRepo(externalReference);
|
||||||
|
// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalReference>().payload(newExternalReference).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
|
@ -5,7 +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.commons.enums.ReferenceType;
|
||||||
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;
|
||||||
|
@ -51,7 +51,7 @@ 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(ExternalReferencesType externalType, ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
public List<Map<String, String>> get(ReferenceType externalType, ExternalUrlCriteria externalUrlCriteria, String key) throws NoURLFound, HugeResultSet {
|
||||||
FetchStrategy fetchStrategy = null;
|
FetchStrategy fetchStrategy = null;
|
||||||
GenericUrls exGenericUrls = this.getExternalUrls(externalType);
|
GenericUrls exGenericUrls = this.getExternalUrls(externalType);
|
||||||
List<UrlConfiguration> urlConfigs = key != null && !key.isEmpty() ? exGenericUrls.getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
List<UrlConfiguration> urlConfigs = key != null && !key.isEmpty() ? exGenericUrls.getUrls().stream().filter(item -> item.getKey().equals(key)).collect(Collectors.toList())
|
||||||
|
@ -60,7 +60,7 @@ public class RemoteFetcher {
|
||||||
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
return getAll(urlConfigs, fetchStrategy, externalUrlCriteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenericUrls getExternalUrls(ExternalReferencesType externalType) {
|
public GenericUrls getExternalUrls(ReferenceType externalType) {
|
||||||
switch (externalType){
|
switch (externalType){
|
||||||
case Taxonomies: return configLoader.getExternalUrls().getTaxonomies();
|
case Taxonomies: return configLoader.getExternalUrls().getTaxonomies();
|
||||||
case Licenses: return configLoader.getExternalUrls().getLicenses();
|
case Licenses: return configLoader.getExternalUrls().getLicenses();
|
||||||
|
|
|
@ -1,217 +0,0 @@
|
||||||
package eu.eudat.logic.services.externalreferences;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import eu.eudat.commons.enums.ExternalReferencesType;
|
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
|
||||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
|
||||||
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
|
||||||
import eu.eudat.data.dao.criteria.RegistryCriteria;
|
|
||||||
import eu.eudat.data.dao.criteria.ServiceCriteria;
|
|
||||||
|
|
||||||
import eu.eudat.data.old.DataRepository;
|
|
||||||
import eu.eudat.data.old.ExternalDataset;
|
|
||||||
import eu.eudat.data.old.Registry;
|
|
||||||
import eu.eudat.data.old.Service;
|
|
||||||
import eu.eudat.logic.builders.model.criteria.ExternalDatasetCriteriaBuilder;
|
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.models.data.ExternalReference;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@org.springframework.stereotype.Service
|
|
||||||
public class ExternalReferencesService {
|
|
||||||
|
|
||||||
private final ApiContext apiContext;
|
|
||||||
private final UserScope userScope;
|
|
||||||
private final RemoteFetcher remoteFetcher;
|
|
||||||
|
|
||||||
public ExternalReferencesService(ApiContext apiContext, UserScope userScope, RemoteFetcher remoteFetcher) {
|
|
||||||
this.apiContext = apiContext;
|
|
||||||
this.userScope = userScope;
|
|
||||||
this.remoteFetcher = remoteFetcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
// external references:
|
|
||||||
// taxonomies,
|
|
||||||
// licenses,
|
|
||||||
// publications,
|
|
||||||
// journals,
|
|
||||||
// pubRepositories,
|
|
||||||
// dataRepositories
|
|
||||||
|
|
||||||
// public ExternalReference createDataRepo(ExternalReference externalReference) throws Exception {
|
|
||||||
// // only dataRepositories, pubRepositories, journals
|
|
||||||
// DataRepository dataRepository = externalReference.toDataModel();
|
|
||||||
// dataRepository.getCreationUser().setId(this.userScope.getUserId());
|
|
||||||
//
|
|
||||||
// dataRepository = apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao().createOrUpdate(dataRepository);
|
|
||||||
// return new ExternalReference().fromDataModel(dataRepository);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public List<ExternalReference> getExternalReference(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);
|
|
||||||
//
|
|
||||||
// DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
|
||||||
// if (!query.isEmpty()) criteria.setLike(query);
|
|
||||||
//
|
|
||||||
// List<ExternalReference> list = new LinkedList<>();
|
|
||||||
// if((externalType.equals("dataRepositories") || externalType.equals("pubRepositories") || externalType.equals("journals"))){
|
|
||||||
// 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;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// external references2:
|
|
||||||
// registries,
|
|
||||||
// services
|
|
||||||
|
|
||||||
// public ExternalReference2 create(ExternalReference2 externalReference) throws Exception {
|
|
||||||
// if (externalReference.getLabel() == null || externalReference.getAbbreviation() == null || externalReference.getUri() == null) {
|
|
||||||
// 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;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public List<ExternalReference> getExternalReference(ExternalReferencesType externalType, String query, String type) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
|
|
||||||
|
|
||||||
List<Map<String, String>> remoteRepos = null;
|
|
||||||
if (externalType.equals(ExternalReferencesType.Datasets)){
|
|
||||||
remoteRepos = remoteFetcher.getDatasets(externalUrlCriteria, type);
|
|
||||||
}else {
|
|
||||||
remoteRepos = this.apiContext.getOperationsContext().getRemoteFetcher().get(externalType, externalUrlCriteria, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ExternalReference> list = this.fetchFromDb(externalType, query, type, remoteRepos);
|
|
||||||
|
|
||||||
list.addAll(remoteRepos.stream().map(ExternalReference::fromRemoteModel).toList());
|
|
||||||
list = list.stream().filter(x -> x.getName().toLowerCase().contains(query.toLowerCase())).collect(Collectors.toList());
|
|
||||||
list.sort(Comparator.comparing(ExternalReference::getName));
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ExternalReference> fetchFromDb(ExternalReferencesType externalType, String query, String type, List<Map<String, String>> remoteRepos) throws InvalidApplicationException {
|
|
||||||
List<ExternalReference> list = new LinkedList<>();
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 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 ExternalReference().fromRegistry(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 Datasets:{
|
|
||||||
|
|
||||||
ExternalDatasetCriteria criteria = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ExternalDatasetCriteriaBuilder.class).like(query).build();
|
|
||||||
|
|
||||||
criteria.setCreationUserId(this.userScope.getUserId());
|
|
||||||
QueryableList<ExternalDataset> items = apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao().getWithCriteria(criteria);
|
|
||||||
|
|
||||||
list = items.select(item -> new ExternalReference().fromDataset(item));
|
|
||||||
}
|
|
||||||
case Taxonomies:
|
|
||||||
case Publications:
|
|
||||||
case Licenses:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
package eu.eudat.logic.services.externalreferences;
|
|
||||||
|
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
|
||||||
import eu.eudat.data.old.UserInfo;
|
|
||||||
import eu.eudat.data.query.items.item.funder.FunderCriteriaRequest;
|
|
||||||
import eu.eudat.logic.builders.model.models.FunderBuilder;
|
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.logic.utilities.helpers.ListHelper;
|
|
||||||
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
|
||||||
import eu.eudat.models.data.external.FundersExternalSourcesModel;
|
|
||||||
import eu.eudat.models.data.funder.Funder;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class FunderService {
|
|
||||||
|
|
||||||
private ApiContext apiContext;
|
|
||||||
private RemoteFetcher remoteFetcher;
|
|
||||||
private ListHelper listHelper;
|
|
||||||
private final UserScope userScope;
|
|
||||||
|
|
||||||
public FunderService(ApiContext apiContext, RemoteFetcher remoteFetcher, ListHelper listHelper, UserScope userScope) {
|
|
||||||
this.apiContext = apiContext;
|
|
||||||
this.remoteFetcher = remoteFetcher;
|
|
||||||
this.listHelper = listHelper;
|
|
||||||
this.userScope = userScope;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Funder> getCriteriaWithExternal(FunderCriteriaRequest funderCriteria) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
|
||||||
UserInfo userInfo = new UserInfo();
|
|
||||||
userInfo.setId(this.userScope.getUserId());
|
|
||||||
funderCriteria.getCriteria().setReference("dmp:");
|
|
||||||
QueryableList<eu.eudat.data.old.Funder> items = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getWithCritetia(funderCriteria.getCriteria());
|
|
||||||
QueryableList<eu.eudat.data.old.Funder> authItems = apiContext.getOperationsContext().getDatabaseRepository().getFunderDao().getAuthenticated(items, userInfo);
|
|
||||||
List<Funder> funders = authItems.select(item -> new Funder().fromDataModel(item));
|
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(funderCriteria.getCriteria().getLike());
|
|
||||||
List<Map<String, String>> remoteRepos = remoteFetcher.getFunders(externalUrlCriteria);
|
|
||||||
FundersExternalSourcesModel fundersExternalSourcesModel = new FundersExternalSourcesModel().fromExternalItem(remoteRepos);
|
|
||||||
for (ExternalSourcesItemModel externalListingItem : fundersExternalSourcesModel) {
|
|
||||||
Funder funder = apiContext.getOperationsContext().getBuilderFactory().getBuilder(FunderBuilder.class)
|
|
||||||
.reference(externalListingItem.getRemoteId()).label(externalListingItem.getName())
|
|
||||||
.status(eu.eudat.data.old.Funder.Status.fromInteger(0))
|
|
||||||
.key(externalListingItem.getKey())
|
|
||||||
.source(externalListingItem.getTag())
|
|
||||||
.build();
|
|
||||||
if (externalListingItem.getSource() != null) {
|
|
||||||
funder.setSource(externalListingItem.getSource());
|
|
||||||
} else {
|
|
||||||
funder.setSource(externalListingItem.getTag());
|
|
||||||
}
|
|
||||||
|
|
||||||
funders.add(funder);
|
|
||||||
}
|
|
||||||
funders.sort(Comparator.comparing(Funder::getLabel));
|
|
||||||
funders = funders.stream().filter(listHelper.distinctByKey(Funder::getLabel)).collect(Collectors.toList());
|
|
||||||
return funders;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
package eu.eudat.logic.services.externalreferences;
|
|
||||||
|
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
|
||||||
import eu.eudat.data.query.items.item.project.ProjectCriteriaRequest;
|
|
||||||
import eu.eudat.logic.builders.model.models.ProjectBuilder;
|
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
|
||||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
|
||||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|
||||||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
|
||||||
import eu.eudat.logic.utilities.helpers.ListHelper;
|
|
||||||
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
|
||||||
import eu.eudat.models.data.external.ProjectsExternalSourcesModel;
|
|
||||||
import eu.eudat.models.data.project.Project;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class ProjectService {
|
|
||||||
|
|
||||||
private ApiContext apiContext;
|
|
||||||
private RemoteFetcher remoteFetcher;
|
|
||||||
private ListHelper listHelper;
|
|
||||||
private final UserScope userScope;
|
|
||||||
|
|
||||||
public ProjectService(ApiContext apiContext, ListHelper listHelper, UserScope userScope) {
|
|
||||||
this.apiContext = apiContext;
|
|
||||||
this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher();
|
|
||||||
this.listHelper = listHelper;
|
|
||||||
this.userScope = userScope;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Project> getCriteriaWithExternal(ProjectCriteriaRequest projectCriteria) throws HugeResultSet, NoURLFound, InvalidApplicationException {
|
|
||||||
eu.eudat.data.old.UserInfo userInfo = new eu.eudat.data.old.UserInfo();
|
|
||||||
userInfo.setId(this.userScope.getUserId());
|
|
||||||
projectCriteria.getCriteria().setReference("dmp:");
|
|
||||||
QueryableList<eu.eudat.data.old.Project> items = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCritetia(projectCriteria.getCriteria());
|
|
||||||
QueryableList<eu.eudat.data.old.Project> authItems = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getAuthenticated(items, userInfo);
|
|
||||||
List<Project> projects = authItems.select(item -> new Project().fromDataModel(item));
|
|
||||||
ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(projectCriteria.getCriteria().getLike());
|
|
||||||
List<Map<String, String>> remoteRepos = remoteFetcher.getProjects(externalUrlCriteria);
|
|
||||||
ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos);
|
|
||||||
for (ExternalSourcesItemModel externalListingItem : projectsExternalSourcesModel) {
|
|
||||||
Project project = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ProjectBuilder.class)
|
|
||||||
.reference(externalListingItem.getRemoteId()).label(externalListingItem.getName())
|
|
||||||
.description(externalListingItem.getDescription()).uri(externalListingItem.getUri())
|
|
||||||
.abbreviation(externalListingItem.getAbbreviation()).status(eu.eudat.data.old.Project.Status.fromInteger(0))
|
|
||||||
.key(externalListingItem.getKey())
|
|
||||||
.source(externalListingItem.getTag())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
projects.add(project);
|
|
||||||
}
|
|
||||||
projects.sort(Comparator.comparing(Project::getLabel));
|
|
||||||
projects = projects.stream().filter(listHelper.distinctByKey(Project::getLabel)).collect(Collectors.toList());
|
|
||||||
return projects;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +1,10 @@
|
||||||
package eu.eudat.logic.services.externalreferences;
|
package eu.eudat.logic.services.references;
|
||||||
|
|
||||||
import gr.cite.tools.cache.CacheOptions;
|
import gr.cite.tools.cache.CacheOptions;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConfigurationProperties(prefix = "cache.external-reference")
|
@ConfigurationProperties(prefix = "cache.reference")
|
||||||
public class ExternalReferencesCacheOptions extends CacheOptions {
|
public class ReferenceCacheOptions extends CacheOptions {
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.logic.services.externalreferences;
|
package eu.eudat.logic.services.references;
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
||||||
import gr.cite.tools.cache.CacheService;
|
import gr.cite.tools.cache.CacheService;
|
||||||
|
@ -9,27 +9,27 @@ import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ExternalReferencesCacheService extends CacheService<ExternalReferencesCacheService.ExternalReferencesCacheValue> {
|
public class ReferenceCacheService extends CacheService<ReferenceCacheService.ReferenceCacheValue> {
|
||||||
|
|
||||||
public static class ExternalReferencesCacheValue {
|
public static class ReferenceCacheValue {
|
||||||
|
|
||||||
public ExternalReferencesCacheValue() {}
|
public ReferenceCacheValue() {}
|
||||||
|
|
||||||
public ExternalReferencesCacheValue(String externalType, ExternalUrlCriteria externalUrlCriteria) {
|
public ReferenceCacheValue(String type, ExternalUrlCriteria externalUrlCriteria) {
|
||||||
this.externalType = externalType;
|
this.type = type;
|
||||||
this.externalUrlCriteria = externalUrlCriteria;
|
this.externalUrlCriteria = externalUrlCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String externalType;
|
private String type;
|
||||||
|
|
||||||
private ExternalUrlCriteria externalUrlCriteria;
|
private ExternalUrlCriteria externalUrlCriteria;
|
||||||
|
|
||||||
public String getExternalType() {
|
public String getType() {
|
||||||
return externalType;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExternalType(String externalType) {
|
public void setType(String type) {
|
||||||
this.externalType = externalType;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExternalUrlCriteria getExternalUrlCriteria() {
|
public ExternalUrlCriteria getExternalUrlCriteria() {
|
||||||
|
@ -42,15 +42,15 @@ public class ExternalReferencesCacheService extends CacheService<ExternalReferen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ExternalReferencesCacheService(ExternalReferencesCacheOptions options) {
|
public ReferenceCacheService(ReferenceCacheOptions options) {
|
||||||
super(options);
|
super(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<ExternalReferencesCacheValue> valueClass() {return ExternalReferencesCacheValue.class;}
|
protected Class<ReferenceCacheValue> valueClass() {return ReferenceCacheValue.class;}
|
||||||
|
|
||||||
public String keyOf(ExternalReferencesCacheValue value) {
|
public String keyOf(ReferenceCacheValue value) {
|
||||||
return this.buildKey(value.getExternalType(), value.getExternalUrlCriteria());
|
return this.buildKey(value.getType(), value.getExternalUrlCriteria());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String buildKey(String externalType, ExternalUrlCriteria externalUrlCriteria) {
|
public String buildKey(String externalType, ExternalUrlCriteria externalUrlCriteria) {
|
|
@ -0,0 +1,238 @@
|
||||||
|
package eu.eudat.logic.services.references;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.commons.enums.ReferenceType;
|
||||||
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||||
|
import eu.eudat.commons.types.reference.FieldEntity;
|
||||||
|
import eu.eudat.configurations.referencetype.ReferenceTypeProperties;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
import eu.eudat.data.dao.criteria.*;
|
||||||
|
import eu.eudat.data.old.DataRepository;
|
||||||
|
import eu.eudat.data.old.ExternalDataset;
|
||||||
|
import eu.eudat.data.old.Registry;
|
||||||
|
import eu.eudat.data.old.Service;
|
||||||
|
import eu.eudat.logic.builders.model.criteria.ExternalDatasetCriteriaBuilder;
|
||||||
|
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
||||||
|
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||||
|
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||||
|
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
||||||
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
import eu.eudat.model.Reference;
|
||||||
|
import eu.eudat.model.builder.ReferenceBuilder;
|
||||||
|
import eu.eudat.model.deleter.ReferenceDeleter;
|
||||||
|
import eu.eudat.model.persist.ReferencePersist;
|
||||||
|
import eu.eudat.model.persist.referencedefinition.DefinitionPersist;
|
||||||
|
import eu.eudat.model.persist.referencedefinition.FieldPersist;
|
||||||
|
import eu.eudat.models.data.FetcherReference;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.exception.MyForbiddenException;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
|
import gr.cite.tools.exception.MyValidationException;
|
||||||
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.xml.bind.JAXBException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
|
||||||
|
import javax.management.InvalidApplicationException;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@org.springframework.stereotype.Service
|
||||||
|
public class ReferenceService {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ReferenceService.class));
|
||||||
|
private final ApiContext apiContext;
|
||||||
|
private final UserScope userScope;
|
||||||
|
private final RemoteFetcher remoteFetcher;
|
||||||
|
private final EntityManager entityManager;
|
||||||
|
private final AuthorizationService authorizationService;
|
||||||
|
private final DeleterFactory deleterFactory;
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private final ConventionService conventionService;
|
||||||
|
private final MessageSource messageSource;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
private final XmlHandlingService xmlHandlingService;
|
||||||
|
private final ReferenceTypeProperties referenceTypeProperties;
|
||||||
|
|
||||||
|
public ReferenceService(ApiContext apiContext,
|
||||||
|
UserScope userScope,
|
||||||
|
RemoteFetcher remoteFetcher,
|
||||||
|
EntityManager entityManager,
|
||||||
|
AuthorizationService authorizationService,
|
||||||
|
DeleterFactory deleterFactory,
|
||||||
|
BuilderFactory builderFactory,
|
||||||
|
ConventionService conventionService,
|
||||||
|
MessageSource messageSource,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
XmlHandlingService xmlHandlingService,
|
||||||
|
ReferenceTypeProperties referenceTypeProperties) {
|
||||||
|
this.apiContext = apiContext;
|
||||||
|
this.userScope = userScope;
|
||||||
|
this.remoteFetcher = remoteFetcher;
|
||||||
|
this.entityManager = entityManager;
|
||||||
|
this.authorizationService = authorizationService;
|
||||||
|
this.deleterFactory = deleterFactory;
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.conventionService = conventionService;
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.xmlHandlingService = xmlHandlingService;
|
||||||
|
this.referenceTypeProperties = referenceTypeProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Reference persist(ReferencePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, TransformerException, ParserConfigurationException {
|
||||||
|
logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields));
|
||||||
|
|
||||||
|
this.authorizationService.authorizeForce(Permission.EditDmpBlueprint);
|
||||||
|
|
||||||
|
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
|
||||||
|
|
||||||
|
ReferenceEntity data;
|
||||||
|
if (isUpdate) {
|
||||||
|
data = this.entityManager.find(ReferenceEntity.class, model.getId());
|
||||||
|
if (data == null)
|
||||||
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
} else {
|
||||||
|
data = new ReferenceEntity();
|
||||||
|
data.setId(UUID.randomUUID());
|
||||||
|
data.setIsActive(IsActive.Active);
|
||||||
|
data.setCreatedAt(Instant.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
data.setLabel(model.getLabel());
|
||||||
|
data.setType(model.getType());
|
||||||
|
data.setDescription(model.getDescription());
|
||||||
|
data.setDefinition(this.xmlHandlingService.toXmlSafe(this.buildDefinitionEntity(model.getDefinition())));
|
||||||
|
data.setUpdatedAt(Instant.now());
|
||||||
|
data.setReference(model.getReference());
|
||||||
|
data.setAbbreviation(model.getAbbreviation());
|
||||||
|
data.setSource(model.getSource());
|
||||||
|
data.setReferenceSourceType(model.getReferenceSourceType());
|
||||||
|
|
||||||
|
if (isUpdate) this.entityManager.merge(data);
|
||||||
|
else this.entityManager.persist(data);
|
||||||
|
|
||||||
|
this.entityManager.flush();
|
||||||
|
|
||||||
|
return this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(BaseFieldSet.build(fields, Reference._id), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull DefinitionEntity buildDefinitionEntity(DefinitionPersist persist){
|
||||||
|
DefinitionEntity data = new DefinitionEntity();
|
||||||
|
if (persist == null) return data;
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(persist.getFields())){
|
||||||
|
data.setFields(new ArrayList<>());
|
||||||
|
for (FieldPersist fieldPersist: persist.getFields()) {
|
||||||
|
data.getFields().add(this.buildFieldEntity(fieldPersist));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull FieldEntity buildFieldEntity(FieldPersist persist){
|
||||||
|
FieldEntity data = new FieldEntity();
|
||||||
|
if (persist == null) return data;
|
||||||
|
|
||||||
|
data.setCode(persist.getCode());
|
||||||
|
data.setDataType(persist.getDataType());
|
||||||
|
data.setCode(persist.getCode());
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||||
|
logger.debug("deleting : {}", id);
|
||||||
|
|
||||||
|
this.authorizationService.authorizeForce(Permission.DeleteReference);
|
||||||
|
|
||||||
|
this.deleterFactory.deleter(ReferenceDeleter.class).deleteAndSaveByIds(List.of(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FetcherReference> searchReference(ReferenceType 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<FetcherReference> list = this.fetchFromDb(externalType, query, type, remoteRepos);
|
||||||
|
|
||||||
|
list.addAll(remoteRepos.stream().map(FetcherReference::fromRemoteModel).toList());
|
||||||
|
list = list.stream().filter(x -> x.getName().toLowerCase().contains(query.toLowerCase())).collect(Collectors.toList());
|
||||||
|
list.sort(Comparator.comparing(FetcherReference::getName));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<FetcherReference> fetchFromDb(ReferenceType externalType, String query, String type, List<Map<String, String>> remoteRepos) throws InvalidApplicationException {
|
||||||
|
List<FetcherReference> list = new LinkedList<>();
|
||||||
|
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 FetcherReference().fromDataRepository(item)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 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 FetcherReference().fromRegistry(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 FetcherReference().fromService(item)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case Datasets:{
|
||||||
|
|
||||||
|
ExternalDatasetCriteria criteria = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ExternalDatasetCriteriaBuilder.class).like(query).build();
|
||||||
|
|
||||||
|
criteria.setCreationUserId(this.userScope.getUserId());
|
||||||
|
QueryableList<ExternalDataset> items = apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao().getWithCriteria(criteria);
|
||||||
|
|
||||||
|
list = items.select(item -> new FetcherReference().fromDataset(item));
|
||||||
|
}
|
||||||
|
case Taxonomies:
|
||||||
|
case Publications:
|
||||||
|
case Licenses:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,188 +0,0 @@
|
||||||
package eu.eudat.models.data;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.data.old.Registry;
|
|
||||||
import eu.eudat.data.old.Service;
|
|
||||||
import eu.eudat.data.old.UserInfo;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ExternalReference2 {
|
|
||||||
private UUID id;
|
|
||||||
private String label;
|
|
||||||
private String name;
|
|
||||||
private String pid;
|
|
||||||
private String abbreviation;
|
|
||||||
private String uri;
|
|
||||||
private Date created;
|
|
||||||
private Date modified;
|
|
||||||
private String reference;
|
|
||||||
private String tag;
|
|
||||||
private String source;
|
|
||||||
|
|
||||||
private String externalType;
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPid() {
|
|
||||||
return pid;
|
|
||||||
}
|
|
||||||
public void setPid(String pid) {
|
|
||||||
this.pid = pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAbbreviation() {
|
|
||||||
return abbreviation;
|
|
||||||
}
|
|
||||||
public void setAbbreviation(String abbreviation) {
|
|
||||||
this.abbreviation = abbreviation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUri() {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
public void setUri(String uri) {
|
|
||||||
this.uri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExternalType() {return externalType;}
|
|
||||||
|
|
||||||
public void setExternalType(String externalType) {this.externalType = externalType;}
|
|
||||||
|
|
||||||
public ExternalReference2 fromDataModel(Service entity) {
|
|
||||||
this.abbreviation = entity.getAbbreviation();
|
|
||||||
this.created = entity.getCreated();
|
|
||||||
this.id = entity.getId();
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
this.externalType = "services";
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExternalReference2 fromDataModel(Registry entity) {
|
|
||||||
this.id = entity.getId();
|
|
||||||
this.abbreviation = entity.getAbbreviation();
|
|
||||||
this.created = entity.getCreated();
|
|
||||||
this.label = entity.getLabel();
|
|
||||||
this.name = entity.getLabel();
|
|
||||||
this.modified = entity.getModified();
|
|
||||||
this.uri = entity.getUri();
|
|
||||||
String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
|
||||||
if (source1.equals("dmp")) {
|
|
||||||
this.source = "Internal";
|
|
||||||
} else {
|
|
||||||
this.source = source1;
|
|
||||||
}
|
|
||||||
this.reference = entity.getReference();
|
|
||||||
this.externalType = "registries";
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Service toDataModelService() throws Exception {
|
|
||||||
Service service = new Service();
|
|
||||||
service.setId(this.id != null ? this.id : UUID.randomUUID());
|
|
||||||
service.setAbbreviation(this.abbreviation);
|
|
||||||
service.setCreated(this.created != null ? this.created : new Date());
|
|
||||||
service.setLabel(this.label != null ? this.label : this.name);
|
|
||||||
service.setModified(new Date());
|
|
||||||
service.setUri(this.uri);
|
|
||||||
if (this.source == null) this.source = "dmp";
|
|
||||||
if (this.reference == null) this.reference = service.getId().toString();
|
|
||||||
if (this.source.equals(this.reference.substring(0, this.source.length()))) {
|
|
||||||
service.setReference(this.reference);
|
|
||||||
} else {
|
|
||||||
service.setReference(this.source + ":" + this.reference);
|
|
||||||
}
|
|
||||||
service.setModified(new Date());
|
|
||||||
service.setStatus((short) 0);
|
|
||||||
service.setCreationUser(new UserInfo());
|
|
||||||
return service;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Registry toDataModelRegistry() throws Exception {
|
|
||||||
Registry registry = new Registry();
|
|
||||||
registry.setAbbreviation(this.abbreviation);
|
|
||||||
registry.setCreated(this.created != null ? this.created : new Date());
|
|
||||||
registry.setId(this.id != null ? this.id : UUID.randomUUID());
|
|
||||||
registry.setLabel(this.label != null ? this.label : this.name);
|
|
||||||
registry.setUri(this.uri);
|
|
||||||
registry.setModified(new Date());
|
|
||||||
if (this.source == null) this.source = "dmp";
|
|
||||||
if (this.source.equals(registry.getId().toString().substring(0, this.source.length()))) {
|
|
||||||
registry.setReference(registry.getId().toString());
|
|
||||||
} else {
|
|
||||||
registry.setReference(this.source + ":" + registry.getId());
|
|
||||||
}
|
|
||||||
registry.setStatus((short)0);
|
|
||||||
registry.setCreationUser(new UserInfo());
|
|
||||||
return registry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHint() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,7 @@ import eu.eudat.data.old.*;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ExternalReference {
|
public class FetcherReference {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -133,28 +133,28 @@ public class ExternalReference {
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ExternalReference fromRemoteModel(Map<String, String> data) {
|
public static FetcherReference fromRemoteModel(Map<String, String> data) {
|
||||||
ExternalReference externalReference = new ExternalReference();
|
FetcherReference fetcherReference = new FetcherReference();
|
||||||
if (data == null) return externalReference;
|
if (data == null) return fetcherReference;
|
||||||
|
|
||||||
externalReference.setId(data.getOrDefault("id", null));
|
fetcherReference.setId(data.getOrDefault("id", null));
|
||||||
externalReference.setName(data.getOrDefault("name", null));
|
fetcherReference.setName(data.getOrDefault("name", null));
|
||||||
externalReference.setPid(data.getOrDefault("pid", null));
|
fetcherReference.setPid(data.getOrDefault("pid", null));
|
||||||
externalReference.setPidTypeField(data.getOrDefault("pidTypeField", null));
|
fetcherReference.setPidTypeField(data.getOrDefault("pidTypeField", null));
|
||||||
externalReference.setUri(data.getOrDefault("uri", null));
|
fetcherReference.setUri(data.getOrDefault("uri", null));
|
||||||
externalReference.setDescription(data.getOrDefault("description", null));
|
fetcherReference.setDescription(data.getOrDefault("description", null));
|
||||||
externalReference.setSource(data.getOrDefault("source", null));
|
fetcherReference.setSource(data.getOrDefault("source", null));
|
||||||
externalReference.setCount(data.getOrDefault("count", null));
|
fetcherReference.setCount(data.getOrDefault("count", null));
|
||||||
externalReference.setPath(data.getOrDefault("path", null));
|
fetcherReference.setPath(data.getOrDefault("path", null));
|
||||||
externalReference.setHost(data.getOrDefault("host", null));
|
fetcherReference.setHost(data.getOrDefault("host", null));
|
||||||
externalReference.setTypes(data.getOrDefault("types", null));
|
fetcherReference.setTypes(data.getOrDefault("types", null));
|
||||||
externalReference.setFirstName(data.getOrDefault("firstName", null));
|
fetcherReference.setFirstName(data.getOrDefault("firstName", null));
|
||||||
externalReference.setLastName(data.getOrDefault("lastName", null));
|
fetcherReference.setLastName(data.getOrDefault("lastName", null));
|
||||||
externalReference.setTag(data.getOrDefault("tag", null));
|
fetcherReference.setTag(data.getOrDefault("tag", null));
|
||||||
return externalReference;
|
return fetcherReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExternalReference fromDataRepository(DataRepository entity) {
|
public FetcherReference 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());
|
||||||
|
@ -169,7 +169,7 @@ public class ExternalReference {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExternalReference fromRegistry(Registry entity){
|
public FetcherReference fromRegistry(Registry entity){
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
// this.abbreviation = entity.getAbbreviation();
|
// this.abbreviation = entity.getAbbreviation();
|
||||||
// this.created = entity.getCreated();
|
// this.created = entity.getCreated();
|
||||||
|
@ -186,7 +186,7 @@ public class ExternalReference {
|
||||||
// this.reference = entity.getReference();
|
// this.reference = entity.getReference();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public ExternalReference fromService(Service entity) {
|
public FetcherReference fromService(Service entity) {
|
||||||
// this.abbreviation = entity.getAbbreviation();
|
// this.abbreviation = entity.getAbbreviation();
|
||||||
// this.created = entity.getCreated();
|
// this.created = entity.getCreated();
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
|
@ -203,7 +203,7 @@ public class ExternalReference {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExternalReference fromResearcher(Researcher entity){
|
public FetcherReference fromResearcher(Researcher entity){
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.name = entity.getLabel();
|
this.name = entity.getLabel();
|
||||||
String refParts[] = entity.getReference().split(":");
|
String refParts[] = entity.getReference().split(":");
|
||||||
|
@ -216,7 +216,7 @@ public class ExternalReference {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExternalReference fromOrganisation(Organisation entity){
|
public FetcherReference fromOrganisation(Organisation entity){
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.name = entity.getLabel();
|
this.name = entity.getLabel();
|
||||||
String refParts[] = entity.getReference().split(":");
|
String refParts[] = entity.getReference().split(":");
|
||||||
|
@ -229,7 +229,7 @@ public class ExternalReference {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExternalReference fromDataset(ExternalDataset entity){
|
public FetcherReference fromDataset(ExternalDataset entity){
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.name = entity.getLabel();
|
this.name = entity.getLabel();
|
||||||
String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
String source1 = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
|
@ -17,4 +17,6 @@ spring:
|
||||||
optional:classpath:config/external.yml[.yml], optional:classpath:config/external-${spring.profiles.active}.yml[.yml], optional:file:../config/external-${spring.profiles.active}.yml[.yml],
|
optional:classpath:config/external.yml[.yml], optional:classpath:config/external-${spring.profiles.active}.yml[.yml], optional:file:../config/external-${spring.profiles.active}.yml[.yml],
|
||||||
optional:classpath:config/cors.yml[.yml], optional:classpath:config/cors-${spring.profiles.active}.yml[.yml], optional:file:../config/cors-${spring.profiles.active}.yml[.yml],
|
optional:classpath:config/cors.yml[.yml], optional:classpath:config/cors-${spring.profiles.active}.yml[.yml], optional:file:../config/cors-${spring.profiles.active}.yml[.yml],
|
||||||
optional:classpath:config/swagger.yml[.yml], optional:classpath:config/swagger-${spring.profiles.active}.yml[.yml], optional:file:../config/swagger-${spring.profiles.active}.yml[.yml],
|
optional:classpath:config/swagger.yml[.yml], optional:classpath:config/swagger-${spring.profiles.active}.yml[.yml], optional:file:../config/swagger-${spring.profiles.active}.yml[.yml],
|
||||||
optional:classpath:config/deposit.yml[.yml], optional:classpath:config/deposit-${spring.profiles.active}.yml[.yml], optional:file:../config/deposit-${spring.profiles.active}.yml[.yml]
|
optional:classpath:config/deposit.yml[.yml], optional:classpath:config/deposit-${spring.profiles.active}.yml[.yml], optional:file:../config/deposit-${spring.profiles.active}.yml[.yml],
|
||||||
|
optional:classpath:config/errors.yml[.yml], optional:classpath:config/errors-${spring.profiles.active}.yml[.yml], optional:file:../config/errors-${spring.profiles.active}.yml[.yml],
|
||||||
|
optional:classpath:config/reference-type.yml[.yml], optional:classpath:config/reference-type-${spring.profiles.active}.yml[.yml], optional:file:../config/reference-type-${spring.profiles.active}.yml[.yml]
|
||||||
|
|
|
@ -26,7 +26,7 @@ cache:
|
||||||
expireAfterWriteMinutes: 10
|
expireAfterWriteMinutes: 10
|
||||||
expireAfterAccessMinutes: 10
|
expireAfterAccessMinutes: 10
|
||||||
refreshAfterWriteMinutes: 10
|
refreshAfterWriteMinutes: 10
|
||||||
- names: [ "externalReference" ]
|
- names: [ "Reference" ]
|
||||||
allowNullValues: true
|
allowNullValues: true
|
||||||
initialCapacity: 100
|
initialCapacity: 100
|
||||||
maximumSize: 500
|
maximumSize: 500
|
||||||
|
@ -44,6 +44,6 @@ cache:
|
||||||
supportiveMaterial:
|
supportiveMaterial:
|
||||||
name: supportiveMaterial
|
name: supportiveMaterial
|
||||||
keyPattern: supportive_material_$material$:v0
|
keyPattern: supportive_material_$material$:v0
|
||||||
externalReference:
|
Reference:
|
||||||
name: externalReference
|
name: Reference
|
||||||
keyPattern: external_reference_$type$_$criteria$:v0
|
keyPattern: reference_$type$_$criteria$:v0
|
|
@ -1,3 +1,7 @@
|
||||||
deposit:
|
deposit:
|
||||||
urls:
|
sources:
|
||||||
- http://localhost:8080
|
- url: http://localhost:8082
|
||||||
|
issuer-url: ${ZENODO_ISSUER_URI:IDP_APIKEY_ISSUER_URI}
|
||||||
|
client-id: ${ZENODO_DEPOSIT_CLIENT_ID:}
|
||||||
|
client-secret: ${ZENODO_DEPOSIT_CLIENT_SECRET:}
|
||||||
|
scope: ${ZENODO_DEPOSIT_SCOPE:}
|
|
@ -0,0 +1,28 @@
|
||||||
|
error-thesaurus:
|
||||||
|
hash-conflict:
|
||||||
|
code: 100
|
||||||
|
message: there is a hash conflict for the item modifed. please reload to get the latest changes
|
||||||
|
forbidden:
|
||||||
|
code: 101
|
||||||
|
message: insufficient rights
|
||||||
|
system-error:
|
||||||
|
code: 102
|
||||||
|
message: an unexpected system error occured
|
||||||
|
missing-tenant:
|
||||||
|
code: 103
|
||||||
|
message: tenant scope not provided
|
||||||
|
model-validation:
|
||||||
|
code: 106
|
||||||
|
message: validation error
|
||||||
|
tenant-code-required:
|
||||||
|
code: 108
|
||||||
|
message: tenant code required
|
||||||
|
tenant-name-required:
|
||||||
|
code: 109
|
||||||
|
message: tenant name required
|
||||||
|
index-already-exists:
|
||||||
|
code: 110
|
||||||
|
message: index already exists
|
||||||
|
tenant-not-allowed:
|
||||||
|
code: 113
|
||||||
|
message: tenant not allowed
|
|
@ -68,6 +68,26 @@ permissions:
|
||||||
clients: [ ]
|
clients: [ ]
|
||||||
allowAnonymous: true
|
allowAnonymous: true
|
||||||
allowAuthenticated: true
|
allowAuthenticated: true
|
||||||
|
# Description
|
||||||
|
BrowseDescription:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
EditDescription:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
DeleteDescription:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
claims: [ ]
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
# DescriptionTemplateType
|
# DescriptionTemplateType
|
||||||
BrowseDescriptionTemplateType:
|
BrowseDescriptionTemplateType:
|
||||||
roles:
|
roles:
|
||||||
|
@ -108,6 +128,26 @@ permissions:
|
||||||
clients: [ ]
|
clients: [ ]
|
||||||
allowAnonymous: false
|
allowAnonymous: false
|
||||||
allowAuthenticated: false
|
allowAuthenticated: false
|
||||||
|
# Dmp
|
||||||
|
BrowseDmp:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
EditDmp:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
DeleteDmp:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
claims: [ ]
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
# DmpBlueprint
|
# DmpBlueprint
|
||||||
BrowseDmpBlueprint:
|
BrowseDmpBlueprint:
|
||||||
roles:
|
roles:
|
||||||
|
@ -147,6 +187,26 @@ permissions:
|
||||||
clients: [ ]
|
clients: [ ]
|
||||||
allowAnonymous: false
|
allowAnonymous: false
|
||||||
allowAuthenticated: false
|
allowAuthenticated: false
|
||||||
|
# EntityDoi
|
||||||
|
BrowseEntityDoi:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
EditEntityDoi:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
DeleteEntityDoi:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
claims: [ ]
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
|
||||||
# ViewPage Permissions
|
# ViewPage Permissions
|
||||||
ViewDescriptionTemplateTypePage:
|
ViewDescriptionTemplateTypePage:
|
||||||
|
@ -155,3 +215,66 @@ permissions:
|
||||||
clients: [ ]
|
clients: [ ]
|
||||||
allowAnonymous: false
|
allowAnonymous: false
|
||||||
allowAuthenticated: false
|
allowAuthenticated: false
|
||||||
|
|
||||||
|
# Reference Permissions
|
||||||
|
BrowseReference:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
EditReference:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
DeleteReference:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
claims: [ ]
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
|
||||||
|
# DmpReference Permissions
|
||||||
|
BrowseDmpReference:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
EditDmpReference:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
DeleteDmpReference:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
claims: [ ]
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
|
||||||
|
# DescriptionReference Permissions
|
||||||
|
BrowseDescriptionReference:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
EditDescriptionReference:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
DeleteDescriptionReference:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
claims: [ ]
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
reference-type:
|
||||||
|
grant:
|
||||||
|
fields:
|
||||||
|
- code: startDate
|
||||||
|
dataType: date
|
||||||
|
- code: endDate
|
||||||
|
dataType: date
|
||||||
|
funder:
|
||||||
|
fields:
|
||||||
|
- code: uri
|
||||||
|
dataType: text
|
||||||
|
researcher:
|
||||||
|
fields:
|
||||||
|
- code: firstName
|
||||||
|
dataType: text
|
||||||
|
- code: lastName
|
||||||
|
dataType: text
|
||||||
|
- code: uri
|
||||||
|
dataType: text
|
||||||
|
service:
|
||||||
|
fields:
|
||||||
|
- code: uri
|
||||||
|
dataType: text
|
||||||
|
registry:
|
||||||
|
fields:
|
||||||
|
- code: uri
|
||||||
|
dataType: text
|
||||||
|
project:
|
||||||
|
fields:
|
||||||
|
- code: startDate
|
||||||
|
dataType: date
|
||||||
|
- code: endDate
|
||||||
|
dataType: date
|
||||||
|
organisation:
|
||||||
|
fields:
|
||||||
|
- code: pid
|
||||||
|
dataType: text
|
||||||
|
- code: uri
|
||||||
|
dataType: text
|
||||||
|
- code: pidTypeField
|
||||||
|
dataType: text
|
||||||
|
dataset:
|
||||||
|
fields:
|
||||||
|
- code: pid
|
||||||
|
dataType: text
|
||||||
|
- code: pidTypeField
|
||||||
|
dataType: text
|
||||||
|
dataRepository:
|
||||||
|
fields:
|
||||||
|
pubRepository:
|
||||||
|
fields:
|
||||||
|
journal:
|
||||||
|
fields:
|
||||||
|
publication:
|
||||||
|
fields:
|
||||||
|
- code: pid
|
||||||
|
dataType: text
|
||||||
|
- code: pidTypeField
|
||||||
|
dataType: text
|
||||||
|
licence:
|
||||||
|
fields:
|
||||||
|
- code: uri
|
||||||
|
dataType: text
|
||||||
|
taxonomy:
|
||||||
|
fields:
|
|
@ -1,3 +1,9 @@
|
||||||
|
DO $$DECLARE
|
||||||
|
this_version CONSTANT varchar := '00.01.004';
|
||||||
|
BEGIN
|
||||||
|
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
||||||
|
IF FOUND THEN RETURN; END IF;
|
||||||
|
|
||||||
ALTER TABLE public."DMPProfile" RENAME TO "DmpBlueprint";
|
ALTER TABLE public."DMPProfile" RENAME TO "DmpBlueprint";
|
||||||
|
|
||||||
ALTER TABLE public."DmpBlueprint" RENAME "ID" TO id;
|
ALTER TABLE public."DmpBlueprint" RENAME "ID" TO id;
|
||||||
|
@ -24,3 +30,7 @@ UPDATE public."DmpBlueprint" SET is_active = 0 where status = 99;
|
||||||
UPDATE public."DmpBlueprint" SET status = 0 where is_active = 0;
|
UPDATE public."DmpBlueprint" SET status = 0 where is_active = 0;
|
||||||
|
|
||||||
ALTER TABLE public."DmpBlueprint" ALTER COLUMN is_active SET NOT NULL;
|
ALTER TABLE public."DmpBlueprint" ALTER COLUMN is_active SET NOT NULL;
|
||||||
|
|
||||||
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.004', '2023-10-27 12:00:00.000000+02', now(), 'Align dmp blueprint table.');
|
||||||
|
|
||||||
|
END$$;
|
|
@ -0,0 +1,30 @@
|
||||||
|
DO $$DECLARE
|
||||||
|
this_version CONSTANT varchar := '00.01.005';
|
||||||
|
BEGIN
|
||||||
|
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
||||||
|
IF FOUND THEN RETURN; END IF;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS public."Dmp"
|
||||||
|
(
|
||||||
|
"id" uuid NOT NULL,
|
||||||
|
"label" character varying(250) COLLATE pg_catalog."default" NOT NULL,
|
||||||
|
"version" integer NOT NULL,
|
||||||
|
"status" smallint NOT NULL DEFAULT 0,
|
||||||
|
"properties" text COLLATE pg_catalog."default",
|
||||||
|
"dmp_properties" text COLLATE pg_catalog."default",
|
||||||
|
"group_id" uuid,
|
||||||
|
"description" text COLLATE pg_catalog."default",
|
||||||
|
"is_public" boolean NOT NULL DEFAULT false,
|
||||||
|
"extra_properties" text COLLATE pg_catalog."default",
|
||||||
|
"created_at" timestamp without time zone NOT NULL DEFAULT now(),
|
||||||
|
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
|
||||||
|
"is_active" smallint NOT NULL DEFAULT 1,
|
||||||
|
"finalized_at" timestamp without time zone,
|
||||||
|
"published_at" timestamp without time zone,
|
||||||
|
CONSTRAINT "Dmp_pkey" PRIMARY KEY (id),
|
||||||
|
CONSTRAINT "Dmp_creator_fkey" FOREIGN KEY (creator) REFERENCES public."UserInfo" (id)
|
||||||
|
)
|
||||||
|
|
||||||
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.005', '2023-10-27 12:00:00.000000+02', now(), 'Add Dmp table.');
|
||||||
|
|
||||||
|
END$$;
|
|
@ -0,0 +1,23 @@
|
||||||
|
DO $$DECLARE
|
||||||
|
this_version CONSTANT varchar := '00.01.006';
|
||||||
|
BEGIN
|
||||||
|
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
||||||
|
IF FOUND THEN RETURN; END IF;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS public."DmpReference"
|
||||||
|
(
|
||||||
|
"id" uuid NOT NULL,
|
||||||
|
"dmp_id" uuid NOT NULL,
|
||||||
|
"reference_id" uuid NOT NULL,
|
||||||
|
"data" text COLLATE pg_catalog."default",
|
||||||
|
"created_at" timestamp without time zone NOT NULL DEFAULT now(),
|
||||||
|
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
|
||||||
|
"is_active" smallint NOT NULL DEFAULT 1,
|
||||||
|
CONSTRAINT "DmpReference_pkey" PRIMARY KEY (id),
|
||||||
|
CONSTRAINT "DmpReference_dmp_id_fkey" FOREIGN KEY ("dmp_id") REFERENCES public."Dmp"("id"),
|
||||||
|
CONSTRAINT "DmpReference_reference_id_fkey" FOREIGN KEY ("reference_id") REFERENCES public."Reference"("id")
|
||||||
|
)
|
||||||
|
|
||||||
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.006', '2023-10-27 12:00:00.000000+02', now(), 'Add DescriptionReference table.');
|
||||||
|
|
||||||
|
END$$;
|
|
@ -0,0 +1,30 @@
|
||||||
|
DO $$DECLARE
|
||||||
|
this_version CONSTANT varchar := '00.01.007';
|
||||||
|
BEGIN
|
||||||
|
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
||||||
|
IF FOUND THEN RETURN; END IF;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS public."Description"
|
||||||
|
(
|
||||||
|
"id" uuid NOT NULL,
|
||||||
|
"label" character varying(250) COLLATE pg_catalog."default" NOT NULL,
|
||||||
|
"dmp" uuid,
|
||||||
|
"uri" character varying(250) COLLATE pg_catalog."default",
|
||||||
|
"properties" text COLLATE pg_catalog."default",
|
||||||
|
"profile" uuid,
|
||||||
|
"reference" text COLLATE pg_catalog."default",
|
||||||
|
"status" smallint NOT NULL DEFAULT 0,
|
||||||
|
"description" text COLLATE pg_catalog."default",
|
||||||
|
"dmp_section_index" integer NOT NULL,
|
||||||
|
"created_at" timestamp without time zone NOT NULL DEFAULT now(),
|
||||||
|
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
|
||||||
|
"is_active" smallint NOT NULL DEFAULT 1,
|
||||||
|
"finalized_at" timestamp without time zone,
|
||||||
|
CONSTRAINT "Description_pkey" PRIMARY KEY (id),
|
||||||
|
CONSTRAINT "Description_dmp_fkey" FOREIGN KEY ("dmp") REFERENCES public."Dmp"("id"),
|
||||||
|
CONSTRAINT "Description_profile_fkey" FOREIGN KEY ("profile") REFERENCES public."DescriptionTemplate"("ID")
|
||||||
|
)
|
||||||
|
|
||||||
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.007', '2023-10-27 12:00:00.000000+02', now(), 'Add Description table (former Dataset).');
|
||||||
|
|
||||||
|
END$$;
|
|
@ -0,0 +1,23 @@
|
||||||
|
DO $$DECLARE
|
||||||
|
this_version CONSTANT varchar := '00.01.008';
|
||||||
|
BEGIN
|
||||||
|
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
||||||
|
IF FOUND THEN RETURN; END IF;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS public."DescriptionReference"
|
||||||
|
(
|
||||||
|
"id" uuid NOT NULL,
|
||||||
|
"data" text COLLATE pg_catalog."default" NOT NULL,
|
||||||
|
"description_id" uuid NOT NULL,
|
||||||
|
"reference_id" uuid NOT NULL,
|
||||||
|
"created_at" timestamp without time zone NOT NULL DEFAULT now(),
|
||||||
|
"updated_at" timestamp without time zone NOT NULL DEFAULT now(),
|
||||||
|
"is_active" smallint NOT NULL DEFAULT 1,
|
||||||
|
CONSTRAINT "DescriptionReference_pkey" PRIMARY KEY (id),
|
||||||
|
CONSTRAINT "DescriptionReference_description_fkey" FOREIGN KEY ("description_id") REFERENCES public."Description"("id"),
|
||||||
|
CONSTRAINT "DescriptionReference_reference_fkey" FOREIGN KEY ("reference_id") REFERENCES public."Reference"("id")
|
||||||
|
)
|
||||||
|
|
||||||
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.008', '2023-10-27 12:00:00.000000+02', now(), 'Add DescriptionReference table.');
|
||||||
|
|
||||||
|
END$$;
|
|
@ -0,0 +1,13 @@
|
||||||
|
DO $$DECLARE
|
||||||
|
this_version CONSTANT varchar := '00.01.009';
|
||||||
|
BEGIN
|
||||||
|
PERFORM * FROM "DBVersion" WHERE version = this_version;
|
||||||
|
IF FOUND THEN RETURN; END IF;
|
||||||
|
|
||||||
|
DROP TABLE public."DatasetProfileViewstyle";
|
||||||
|
|
||||||
|
DROP TABLE public."DatasetProfileRuleset";
|
||||||
|
|
||||||
|
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.01.009', '2023-10-27 12:00:00.000000+02', now(), 'Drop old dataset related tables.');
|
||||||
|
|
||||||
|
END$$;
|
|
@ -0,0 +1,4 @@
|
||||||
|
export enum ReferenceFieldDataType {
|
||||||
|
Text = 0,
|
||||||
|
Date = 1
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
export enum ReferenceSourceType {
|
||||||
|
Internal = 0,
|
||||||
|
External = 1
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
export enum ExternalReferencesType {
|
export enum ReferenceType {
|
||||||
Taxonomies = 0,
|
Taxonomies = 0,
|
||||||
Licenses = 1,
|
Licenses = 1,
|
||||||
Publications = 2,
|
Publications = 2,
|
|
@ -55,6 +55,7 @@ import { SupportiveMaterialService } from './services/supportive-material/suppor
|
||||||
import { UserSettingsHttpService } from './services/user-settings/user-settings-http.service';
|
import { UserSettingsHttpService } from './services/user-settings/user-settings-http.service';
|
||||||
import { UserSettingsService } from './services/user-settings/user-settings.service';
|
import { UserSettingsService } from './services/user-settings/user-settings.service';
|
||||||
import { QueryParamsService } from './services/utilities/query-params.service';
|
import { QueryParamsService } from './services/utilities/query-params.service';
|
||||||
|
import { FileUtils } from './services/utilities/file-utils.service';
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// This is shared module that provides all the services. Its imported only once on the AppModule.
|
// This is shared module that provides all the services. Its imported only once on the AppModule.
|
||||||
|
@ -128,7 +129,8 @@ export class CoreServiceModule {
|
||||||
QueryParamsService,
|
QueryParamsService,
|
||||||
UserSettingsService,
|
UserSettingsService,
|
||||||
UserSettingsHttpService,
|
UserSettingsHttpService,
|
||||||
FilterService
|
FilterService,
|
||||||
|
FileUtils
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
export interface DmpAssociatedProfileModel {
|
|
||||||
id: String;
|
|
||||||
label: String;
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
export interface DmpBlueprintExternalAutoCompleteField {
|
|
||||||
url: string;
|
|
||||||
optionsRoot: string;
|
|
||||||
multiAutoComplete: boolean;
|
|
||||||
label: string;
|
|
||||||
value: string;
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
import { DmpBlueprintExtraFieldDataType } from '../../common/enum/dmp-blueprint-field-type';
|
|
||||||
import { DmpBlueprintType } from '../../common/enum/dmp-blueprint-type';
|
|
||||||
import { DmpBlueprintExternalAutoCompleteFieldDataEditorModel } from '../../../ui/admin/dmp-blueprint/editor/external-autocomplete/dmp-blueprint-external-autocomplete-field-editor.model';
|
|
||||||
|
|
||||||
export interface DmpBlueprintField {
|
|
||||||
id: string;
|
|
||||||
type: DmpBlueprintType;
|
|
||||||
dataType: DmpBlueprintExtraFieldDataType;
|
|
||||||
required: boolean;
|
|
||||||
label: string;
|
|
||||||
value: any;
|
|
||||||
externalAutocomplete?: DmpBlueprintExternalAutoCompleteFieldDataEditorModel;
|
|
||||||
}
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { DmpStatus } from "../../common/enum/dmp-status";
|
import { DmpStatus } from "../../common/enum/dmp-status";
|
||||||
import { DmpAssociatedProfileModel } from '../dmp-blueprint/dmp-associated-profile';
|
|
||||||
|
|
||||||
export interface DmpListingModel {
|
export interface DmpListingModel {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -18,7 +17,6 @@ export interface DmpListingModel {
|
||||||
groupId: string;
|
groupId: string;
|
||||||
version: number;
|
version: number;
|
||||||
datasets: any[];
|
datasets: any[];
|
||||||
associatedProfiles: DmpAssociatedProfileModel[];
|
|
||||||
users: any[];
|
users: any[];
|
||||||
public: boolean;
|
public: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { OrganizationModel } from "../organisation/organization";
|
import { OrganizationModel } from "../organisation/organization";
|
||||||
import { UserInfoListingModel } from "../user/user-info-listing";
|
import { UserInfoListingModel } from "../user/user-info-listing";
|
||||||
import { DmpAssociatedProfileModel } from "../dmp-blueprint/dmp-associated-profile";
|
|
||||||
import { ResearcherModel } from "../researcher/researcher";
|
import { ResearcherModel } from "../researcher/researcher";
|
||||||
import { GrantOverviewModel } from "../grant/grant-overview";
|
import { GrantOverviewModel } from "../grant/grant-overview";
|
||||||
import { DatasetOverviewModel } from "../dataset/dataset-overview";
|
import { DatasetOverviewModel } from "../dataset/dataset-overview";
|
||||||
|
@ -18,7 +17,6 @@ export interface DmpOverviewModel {
|
||||||
groupId: string;
|
groupId: string;
|
||||||
description: string;
|
description: string;
|
||||||
grant: GrantOverviewModel;
|
grant: GrantOverviewModel;
|
||||||
associatedProfiles: DmpAssociatedProfileModel[];
|
|
||||||
users: UserInfoListingModel[];
|
users: UserInfoListingModel[];
|
||||||
organisations: OrganizationModel[];
|
organisations: OrganizationModel[];
|
||||||
datasets: DatasetOverviewModel[];
|
datasets: DatasetOverviewModel[];
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
export interface ExternalReference {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
abbreviation: string;
|
|
||||||
pid: string;
|
|
||||||
originalId: string;
|
|
||||||
key: string;
|
|
||||||
pidTypeField: string;
|
|
||||||
uri: string;
|
|
||||||
description: string;
|
|
||||||
source: string;
|
|
||||||
count: string;
|
|
||||||
path: string;
|
|
||||||
host: string;
|
|
||||||
types: string;
|
|
||||||
firstName: string;
|
|
||||||
lastName: string;
|
|
||||||
tag: string;
|
|
||||||
}
|
|
|
@ -1,14 +1,10 @@
|
||||||
import { RecentActivityModel } from './recent-activity.model';
|
|
||||||
import { RecentDatasetModel } from './recent-dataset-activity.model';
|
|
||||||
import { DmpAssociatedProfileModel } from '../dmp-blueprint/dmp-associated-profile';
|
|
||||||
import { UserInfoListingModel } from '../user/user-info-listing';
|
|
||||||
import { DatasetUrlListing } from '../dataset/dataset-url-listing';
|
import { DatasetUrlListing } from '../dataset/dataset-url-listing';
|
||||||
|
import { RecentActivityModel } from './recent-activity.model';
|
||||||
|
|
||||||
export class RecentDmpModel extends RecentActivityModel {
|
export class RecentDmpModel extends RecentActivityModel {
|
||||||
doi: String;
|
doi: String;
|
||||||
extraProperties: Map<String, any>;
|
extraProperties: Map<String, any>;
|
||||||
datasets: DatasetUrlListing[];
|
datasets: DatasetUrlListing[];
|
||||||
associatedProfiles: DmpAssociatedProfileModel[];
|
|
||||||
organisations: String;
|
organisations: String;
|
||||||
groupId: string;
|
groupId: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
import { ReferenceType } from "@app/core/common/enum/reference-type";
|
||||||
|
import { IsActive } from "@app/core/common/enum/is-active.enum";
|
||||||
|
import { ReferenceSourceType } from "@app/core/common/enum/reference-source-type";
|
||||||
|
import { UUID } from "crypto";
|
||||||
|
import { DmpModel } from "../dmp/dmp";
|
||||||
|
import { ReferenceFieldDataType } from "@app/core/common/enum/reference-field-data-type";
|
||||||
|
|
||||||
|
export interface Reference {
|
||||||
|
id: UUID;
|
||||||
|
label: string;
|
||||||
|
type: ReferenceType;
|
||||||
|
description: string;
|
||||||
|
definition: Definition;
|
||||||
|
reference: string;
|
||||||
|
abbreviation: string;
|
||||||
|
source: string;
|
||||||
|
referenceSourceType: ReferenceSourceType;
|
||||||
|
isActive: IsActive;
|
||||||
|
createdAt: Date;
|
||||||
|
updatedAt: Date;
|
||||||
|
dmpReferences: DmpReference[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Definition {
|
||||||
|
fields: Field[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Field {
|
||||||
|
code: string;
|
||||||
|
dataType: ReferenceFieldDataType;
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DmpReference {
|
||||||
|
id: UUID;
|
||||||
|
dmp: DmpModel;
|
||||||
|
reference: Reference;
|
||||||
|
data: string;
|
||||||
|
createdAt: Date;
|
||||||
|
updatedAt: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
// old fetcher
|
||||||
|
export interface FetcherReference {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
pid: string;
|
||||||
|
pidTypeField: string;
|
||||||
|
uri: string;
|
||||||
|
description: string;
|
||||||
|
source: string;
|
||||||
|
count: string;
|
||||||
|
path: string;
|
||||||
|
host: string;
|
||||||
|
types: string;
|
||||||
|
firstName: string;
|
||||||
|
lastName: string;
|
||||||
|
tag: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Persist
|
||||||
|
|
||||||
|
export interface ReferencePersist {
|
||||||
|
id: UUID;
|
||||||
|
label: string;
|
||||||
|
type: ReferenceType;
|
||||||
|
description: string;
|
||||||
|
definition: DefinitionPersist;
|
||||||
|
reference: string;
|
||||||
|
abbreviation: string;
|
||||||
|
source: string;
|
||||||
|
referenceSourceType: ReferenceSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DefinitionPersist {
|
||||||
|
fields?: FieldPersist[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FieldPersist {
|
||||||
|
code: string;
|
||||||
|
dataType: ReferenceFieldDataType;
|
||||||
|
value: string;
|
||||||
|
}
|
|
@ -25,11 +25,9 @@ import { Observable, throwError } from 'rxjs';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DmpBlueprintService {
|
export class DmpBlueprintService {
|
||||||
|
|
||||||
private actionUrl: string;
|
|
||||||
private headers = new HttpHeaders();
|
private headers = new HttpHeaders();
|
||||||
|
|
||||||
constructor(private http: BaseHttpV2Service, private httpClient: HttpClient, private configurationService: ConfigurationService, private filterService: FilterService) {
|
constructor(private http: BaseHttpV2Service, private httpClient: HttpClient, private configurationService: ConfigurationService, private filterService: FilterService) {
|
||||||
this.actionUrl = configurationService.server + 'dmpprofile/';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private get apiBase(): string { return `${this.configurationService.server}dmp-blueprint`; }
|
private get apiBase(): string { return `${this.configurationService.server}dmp-blueprint`; }
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue