Compare commits

...

32 Commits

Author SHA1 Message Date
Efstratios Giannopoulos da57359f5c clean up 2024-05-30 12:52:28 +03:00
Efstratios Giannopoulos a74c854379 export changes 2024-05-30 12:35:46 +03:00
Efstratios Giannopoulos 896d0148a8 export changes 2024-05-29 18:29:28 +03:00
Efstratios Giannopoulos 9b44da2aea rda export changes 2024-05-29 13:45:42 +03:00
Efstratios Giannopoulos 525a690d98 export changes 2024-05-27 18:34:29 +03:00
Efstratios Giannopoulos 0b1efaa235 no message 2024-05-24 14:05:30 +03:00
Efstratios Giannopoulos fe5832a6bf no message 2024-05-23 17:14:16 +03:00
Efstratios Giannopoulos 1dad9c105d update commons models 2024-05-22 17:43:53 +03:00
Efstratios Giannopoulos 07ffeba068 bug fix 2024-05-16 10:55:02 +03:00
Efstratios Giannopoulos 5a504dfcb3 no message 2024-05-10 13:10:26 +03:00
Efstratios Giannopoulos 89526ebca7 add logging 2024-05-10 12:52:51 +03:00
Efstratios Giannopoulos 8b4f9aa75c update packages 2024-05-09 16:37:32 +03:00
Efstratios Giannopoulos 729d3f9d56 update commons 2024-05-03 13:31:15 +03:00
Efstratios Giannopoulos 5242120aea rename to OpenCDMP 2024-04-26 15:05:47 +03:00
Efstratios Giannopoulos 5dad708034 update common models 2024-04-25 12:17:57 +03:00
Alexandros Mandilaras b50ce15284 add sonar dockerfile and update build profile 2024-04-23 16:11:32 +03:00
Efstratios Giannopoulos 3b4dddb282 update pom 2024-04-19 11:41:55 +03:00
Efstratios Giannopoulos 8b601db40c add exportEntityTypes importEntityTypes 2024-04-17 17:59:12 +03:00
Efstratios Giannopoulos b5610d7916 Merge branch 'master' of code-repo.d4science.org:MaDgiK-CITE/file-transformer-rda-json 2024-04-12 16:59:10 +03:00
Efstratios Giannopoulos 715eafaaca fix repo id 2024-04-12 16:58:50 +03:00
Alexandros Mandilaras ad84a20147 Revert "no message"
This reverts commit 9fc10977ca.
2024-04-12 16:54:15 +03:00
Alexandros Mandilaras 694907b3c2 use correct transformerID 2024-04-12 16:43:08 +03:00
Alexandros Mandilaras 9fc10977ca no message 2024-04-12 16:35:08 +03:00
Efstratios Giannopoulos 9b45e035ed update pom 2024-04-10 13:20:25 +03:00
Efstratios Giannopoulos 1b05ce17a0 upgrade pom 2024-03-22 12:21:10 +02:00
Efstratios Giannopoulos 2ba69020b7 config changes 2024-03-22 10:48:52 +02:00
Diamantis Tziotzios 266dfaf204 Revert "no message"
This reverts commit 5af0bd5467.
2024-03-13 16:58:19 +02:00
Diamantis Tziotzios 463cb3a101 no message 2024-03-13 16:46:21 +02:00
Diamantis Tziotzios a00123d756 no message 2024-03-13 15:24:28 +02:00
Diamantis Tziotzios 5af0bd5467 no message 2024-03-13 15:18:30 +02:00
Diamantis Tziotzios 15f4773099 no message 2024-03-13 15:04:44 +02:00
Diamantis Tziotzios d3e0d526c6 no message 2024-03-13 14:51:30 +02:00
93 changed files with 2331 additions and 4833 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.idea/
target/
logs/

View File

@ -5,9 +5,9 @@ ARG MAVEN_ACCOUNT_USR
ARG MAVEN_ACCOUNT_PSW
ARG REVISION
ARG PROFILE
ARG DEV_PROFILE_URL
ENV server_username=$MAVEN_ACCOUNT_USR
ENV server_password=$MAVEN_ACCOUNT_PSW
ARG CITE_MAVEN_REPO_URL
COPY pom.xml /build/
COPY core /build/core/
@ -19,12 +19,12 @@ RUN rm -f /build/web/src/main/resources/config/*-dev.yml
WORKDIR /build/
RUN mvn -Drevision=${REVISION} -DdevProfileUrl=${DEV_PROFILE_URL} -P${PROFILE} dependency:go-offline
# Build project
RUN mvn -Drevision=${REVISION} -DdevProfileUrl=${DEV_PROFILE_URL} -P${PROFILE} clean package
RUN mvn -Drevision=${REVISION} -DciteMavenRepoUrl=${CITE_MAVEN_REPO_URL} -P${PROFILE} clean
RUN mvn -Drevision=${REVISION} -DciteMavenRepoUrl=${CITE_MAVEN_REPO_URL} -P${PROFILE} install
RUN mvn -Drevision=${REVISION} -DciteMavenRepoUrl=${CITE_MAVEN_REPO_URL} -P${PROFILE} package
######################################## Run Stage ########################################
FROM eclipse-temurin:21-jre-alpine
FROM eclipse-temurin:21
ARG PROFILE
ARG REVISION

28
Dockerfile.Sonar Normal file
View File

@ -0,0 +1,28 @@
####################################### Build stage #######################################
FROM maven:3.9-eclipse-temurin-21-alpine
ARG MAVEN_ACCOUNT_USR
ARG MAVEN_ACCOUNT_PSW
ARG REVISION
ARG PROFILE
ARG ORACLE_URL
ARG ORACLE_TOKEN
ENV server_username=$MAVEN_ACCOUNT_USR
ENV server_password=$MAVEN_ACCOUNT_PSW
ARG CITE_MAVEN_REPO_URL
COPY pom.xml /build/
COPY core /build/core/
COPY web /build/web/
COPY settings.xml /root/.m2/settings.xml
RUN rm -f /build/web/src/main/resources/config/*-dev.yml
RUN rm -f /build/web/src/main/resources/logging/*.xml
COPY oracle.local.cite.gr.crt $JAVA_HOME/conf/security
RUN cd "$JAVA_HOME"/conf/security && keytool -cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias oraclecert -file oracle.local.cite.gr.crt
WORKDIR /build/
RUN mvn -Drevision=${REVISION} -DciteMavenRepoUrl=${CITE_MAVEN_REPO_URL} -P${PROFILE} clean
RUN mvn -Drevision=${REVISION} -DciteMavenRepoUrl=${CITE_MAVEN_REPO_URL} -P${PROFILE} install
RUN mvn -Drevision=${REVISION} -DciteMavenRepoUrl=${CITE_MAVEN_REPO_URL} -P${PROFILE} package
RUN mvn sonar:sonar -Drevision=${REVISION} -DciteMavenRepoUrl=${CITE_MAVEN_REPO_URL} -P${PROFILE} -Dsonar.projectKey=OpenDMP:file-transformer-rda-json -Dsonar.login=${ORACLE_TOKEN} -Dsonar.host.url=${ORACLE_URL} -Dsonar.projectName='OpenDMP file-transformer-rda-json'

View File

@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>gr.cite.opendmp</groupId>
<groupId>org.opencdmp</groupId>
<artifactId>file-transformer-rda-parent</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
@ -18,24 +18,23 @@
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.release>21</maven.compiler.release>
<revision>1.0.0-SNAPSHOT</revision>
<transformer-base.version>0.0.6</transformer-base.version>
<transformer-base.version>0.0.7</transformer-base.version>
</properties>
<dependencies>
<dependency>
<groupId>gr.cite.opendmp</groupId>
<artifactId>file-transformer-base</artifactId>
<version>${transformer-base.version}</version>
</dependency>
<dependency>
<groupId>gr.cite.opendmp</groupId>
<artifactId>common-models</artifactId>
<version>0.0.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>gr.cite</groupId>
<artifactId>logging</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>
<artifactId>exceptions</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
</project>

View File

@ -1,25 +0,0 @@
package eu.eudat.file.transformer.model;
import eu.eudat.commonmodels.models.reference.ReferenceModel;
public class FundingModel{
private ReferenceModel grant;
private ReferenceModel funder;
public ReferenceModel getGrant() {
return grant;
}
public void setGrant(ReferenceModel grant) {
this.grant = grant;
}
public ReferenceModel getFunder() {
return funder;
}
public void setFunder(ReferenceModel funder) {
this.funder = funder;
}
}

View File

@ -1,33 +0,0 @@
package eu.eudat.file.transformer.model;
import eu.eudat.commonmodels.models.reference.ReferenceModel;
public class ProjectModel{
private ReferenceModel project;
private ReferenceModel grant;
private ReferenceModel funder;
public ReferenceModel getGrant() {
return grant;
}
public void setGrant(ReferenceModel grant) {
this.grant = grant;
}
public ReferenceModel getFunder() {
return funder;
}
public void setFunder(ReferenceModel funder) {
this.funder = funder;
}
public ReferenceModel getProject() {
return project;
}
public void setProject(ReferenceModel project) {
this.project = project;
}
}

View File

@ -1,22 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.file.transformer.model.rda.ContactId;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
public class ContactIdRDAMapper {
public ContactId toRDA(UUID id) {
if (id == null) return null;
ContactId rda = new ContactId();
rda.setIdentifier(id.toString());
rda.setType(ContactId.Type.OTHER);
return rda;
}
public UUID toModel(ContactId rda) {
return rda == null ? null : UUID.fromString(rda.getIdentifier());
}
}

View File

@ -1,48 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.enums.ContactInfoType;
import eu.eudat.commonmodels.models.UserContactInfoModel;
import eu.eudat.commonmodels.models.UserModel;
import eu.eudat.file.transformer.model.rda.Contact;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
@Component
public class ContactRDAMapper{
private final ContactIdRDAMapper contactIdRDAMapper;
public ContactRDAMapper(ContactIdRDAMapper contactIdRDAMapper) {
this.contactIdRDAMapper = contactIdRDAMapper;
}
public Contact toRDA(UserModel model) {
if (model == null) return null;
if (model.getName() == null) throw new IllegalArgumentException("Contact Name is missing");
UserContactInfoModel emailContact = model.getContacts() != null ? model.getContacts().stream().filter(userContactInfo -> userContactInfo.getType().equals(ContactInfoType.Email)).findFirst().orElse(null) : null;
if (emailContact == null) throw new IllegalArgumentException("Contact Email is missing");
Contact rda = new Contact();
rda.setName(model.getName());
rda.setMbox(emailContact.getValue());
rda.setContactId(contactIdRDAMapper.toRDA(emailContact.getId()));
return rda;
}
public UserModel toEntity(Contact rda) {
if (rda == null) return null;
UserModel entity = new UserModel();
entity.setName(rda.getName());
UserContactInfoModel emailContactInfo = new UserContactInfoModel();
emailContactInfo.setId(contactIdRDAMapper.toModel(rda.getContactId()));
emailContactInfo.setType(ContactInfoType.Email);
emailContactInfo.setValue(rda.getMbox());
entity.setContacts(List.of(emailContactInfo));
return entity;
}
}

View File

@ -1,44 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.file.transformer.model.rda.ContributorId;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class ContributorIdRDAMapper{
public ContributorId toRDA(String id) {
if (id == null || id.isBlank()) return null;
ContributorId rda = new ContributorId();
String[] idParts = id.split(":");
String prefix = idParts.length > 1 ? idParts[0] : id;
if (prefix.equals("orcid")) {
String finalId = id.replace(prefix + ":", "");
rda.setIdentifier("http://orcid.org/" + finalId);
rda.setType(ContributorId.Type.ORCID);
} else {
rda.setIdentifier(id);
rda.setType(ContributorId.Type.OTHER);
}
return rda;
}
public String toEntity(ContributorId rda) {
if (rda.getIdentifier() != null) return null;
String referenceString;
if (rda.getType() == ContributorId.Type.ORCID) {
String id = rda.getIdentifier().replace("http://orcid.org/", "");
referenceString = "orcid:" + id;
} else {
String[] idParts = rda.getIdentifier().split(":");
if (idParts.length == 1) {
referenceString = "dmp:" + rda.getIdentifier();
} else {
referenceString = rda.getIdentifier();
}
}
return referenceString;
}
}

View File

@ -1,98 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.models.descriptiotemplate.FieldModel;
import eu.eudat.file.transformer.model.rda.Cost;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Component
public class CostRDAMapper{
private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class);
public List<Cost> toRDA(List<FieldModel> nodes, List<eu.eudat.commonmodels.models.description.FieldModel> valueFields ) {
if (nodes == null) return null;
if (valueFields == null) throw new IllegalArgumentException("valueFields is missing");
Map<String, Cost> rdaMap = new HashMap<>();
for(FieldModel node: nodes){
String rdaProperty = node.getSchematics().stream().filter(schematic -> schematic.startsWith("rda.dmp.cost")).findFirst().orElse("");
eu.eudat.commonmodels.models.description.FieldModel rdaValue = valueFields.stream().filter(x-> x.getId().equals(node.getId())).findFirst().orElse(null);
if(rdaValue == null || rdaValue.getTextValue() == null || rdaValue.getTextValue().isBlank()){
continue;
}
String key = node.getNumbering();
if(!key.contains("mult")){
key = "0";
}
else{
key = "" + key.charAt(4);
}
Cost rda;
if(rdaMap.containsKey(key)){
rda = rdaMap.get(key);
}
else{
rda = new Cost();
rdaMap.put(key, rda);
}
if(rdaProperty.contains("value")){
try {
rda.setValue(Double.valueOf(rdaValue.getTextValue()));
}
catch (NumberFormatException e) {
logger.warn("Dmp cost value " + rdaValue + " is not valid. Cost value will not be set.");
}
}
else if(rdaProperty.contains("currency_code")){
try {
// HashMap<String, String> result =
// new ObjectMapper().readValue(rdaValue, HashMap.class);
// rda.setCurrencyCode(Cost.CurrencyCode.fromValue(result.get("value")));
rda.setCurrencyCode(Cost.CurrencyCode.fromValue(rdaValue.getTextValue())); //TODO
}
catch (Exception e) {
logger.warn("Dmp cost currency code is not valid and will not be set.");
}
}
else if(rdaProperty.contains("title")){
rda.setTitle(rdaValue.getTextValue());
// Iterator<JsonNode> iter = mapper.readTree(rdaValue).elements(); //TODO
// StringBuilder title = new StringBuilder();
// while(iter.hasNext()){
// String next = iter.next().asText();
// if(!next.equals("Other")) {
// title.append(next).append(", ");
// }
// }
// if(title.length() > 2){
// rda.setTitle(title.substring(0, title.length() - 2));
// }
// else{
// String t = rda.getTitle();
// if(t == null){ // only other as title
// rda.setTitle(rdaValue.getTextValue());
// }
// else{ // option + other
// rda.setTitle(t + ", " + rdaValue);
// }
// }
}
else if(rdaProperty.contains("description")){
rda.setDescription(rdaValue.getTextValue());
}
}
List<Cost> rdaList = rdaMap.values().stream()
.filter(cost -> cost.getTitle() != null)
.collect(Collectors.toList());
return rdaList;
}
}

View File

@ -1,92 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.models.descriptiotemplate.FieldModel;
import eu.eudat.file.transformer.model.rda.DatasetId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
@Component
public class DatasetIdRDAMapper{
private static final Logger logger = LoggerFactory.getLogger(DatasetIdRDAMapper.class);
public DatasetId toRDA(List<FieldModel> nodes, List<eu.eudat.commonmodels.models.description.FieldModel> valueFields) {
if (nodes == null) return null;
if (valueFields == null) throw new IllegalArgumentException("valueFields is missing");
DatasetId data = new DatasetId();
for (FieldModel node: nodes) {
String rdaProperty = node.getSchematics().stream().filter(schematic -> schematic.startsWith("rda.dataset.dataset_id")).findFirst().orElse("");
if (node.getData() == null) {
continue;
}
eu.eudat.commonmodels.models.description.FieldModel rdaValue = valueFields.stream().filter(x-> x.getId().equals(node.getId())).findFirst().orElse(null);
if(rdaValue == null || rdaValue.getTextValue() == null || rdaValue.getTextValue().isBlank()){
continue;
}
finalRDAMap(data, rdaProperty, rdaValue.getTextValue());
// try { //TODO
// Map<String, Object> values = mapper.readValue(rdaValue, HashMap.class); //TODO
// if (!values.isEmpty()) {
// values.entrySet().forEach(entry -> finalRDAMap(data, entry.getKey(), (String) entry.getValue()));
// } else {
// finalRDAMap(data, rdaProperty, rdaValue.getTextValue());
// }
// } catch (IOException e) {
// logger.warn(e.getMessage() + ".Passing value as is");
// finalRDAMap(data, rdaProperty, rdaValue.getTextValue());
//
// }
}
if (data.getIdentifier() != null && data.getType() != null) {
return data;
}
return null;
}
private static void finalRDAMap(DatasetId rda, String property, String value) {
if (value != null) {
for (DatasetIdProperties datasetIdProperties : DatasetIdProperties.values()) {
if (property.contains(datasetIdProperties.getName())) {
switch (datasetIdProperties) {
case IDENTIFIER:
rda.setIdentifier(value);
break;
case TYPE:
try {
rda.setType(DatasetId.Type.fromValue(value));
}
catch (IllegalArgumentException e){
logger.warn("Type " + value + " from semantic rda.dataset.dataset_id.type was not found. Setting type to OTHER.");
rda.setType(DatasetId.Type.OTHER);
}
break;
}
}
}
}
}
private enum DatasetIdProperties {
IDENTIFIER("identifier"),
TYPE("type");
private final String name;
DatasetIdProperties(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
}

View File

@ -1,346 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.models.description.DescriptionModel;
import eu.eudat.commonmodels.models.description.PropertyDefinitionFieldSetItemModel;
import eu.eudat.commonmodels.models.description.PropertyDefinitionFieldSetModel;
import eu.eudat.commonmodels.models.description.PropertyDefinitionModel;
import eu.eudat.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
import eu.eudat.commonmodels.models.descriptiotemplate.FieldModel;
import eu.eudat.file.transformer.model.rda.Dataset;
import eu.eudat.file.transformer.model.rda.DatasetId;
import eu.eudat.file.transformer.model.rda.Dmp;
import eu.eudat.file.transformer.model.rda.Language;
import eu.eudat.file.transformer.service.descriptiontemplatesearcher.TemplateFieldSearcherService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.net.URI;
import java.util.*;
import java.util.stream.Collectors;
@Component
public class DatasetRDAMapper {
private static final Logger logger = LoggerFactory.getLogger(DatasetRDAMapper.class);
private final TemplateFieldSearcherService templateFieldSearcherService;
private final LanguageRDAMapper languageRDAMapper;
private final DatasetIdRDAMapper datasetIdRDAMapper;
private final MetadataRDAMapper metadataRDAMapper;
private final DistributionRDAMapper distributionRDAMapper;
private final TechnicalResourceRDAMapper technicalResourceRDAMapper;
private final CostRDAMapper costRDAMapper;
private final SecurityAndPrivacyRDAMapper securityAndPrivacyRDAMapper;
private final KeywordRDAMapper keywordRDAMapper;
@Autowired
public DatasetRDAMapper(TemplateFieldSearcherService templateFieldSearcherService, LanguageRDAMapper languageRDAMapper, DatasetIdRDAMapper datasetIdRDAMapper, MetadataRDAMapper metadataRDAMapper, DistributionRDAMapper distributionRDAMapper, TechnicalResourceRDAMapper technicalResourceRDAMapper, CostRDAMapper costRDAMapper, SecurityAndPrivacyRDAMapper securityAndPrivacyRDAMapper, KeywordRDAMapper keywordRDAMapper) {
this.templateFieldSearcherService = templateFieldSearcherService;
this.languageRDAMapper = languageRDAMapper;
this.datasetIdRDAMapper = datasetIdRDAMapper;
this.metadataRDAMapper = metadataRDAMapper;
this.distributionRDAMapper = distributionRDAMapper;
this.technicalResourceRDAMapper = technicalResourceRDAMapper;
this.costRDAMapper = costRDAMapper;
this.securityAndPrivacyRDAMapper = securityAndPrivacyRDAMapper;
this.keywordRDAMapper = keywordRDAMapper;
}
private List<eu.eudat.commonmodels.models.description.FieldModel> findValueField(FieldModel fieldModel, PropertyDefinitionModel descriptionTemplateModel){
List<eu.eudat.commonmodels.models.description.FieldModel> items = new ArrayList<>();
if (descriptionTemplateModel == null || descriptionTemplateModel.getFieldSets() == null) return items;
for (PropertyDefinitionFieldSetModel propertyDefinitionFieldSetModel : descriptionTemplateModel.getFieldSets().values()){
if (propertyDefinitionFieldSetModel.getItems() == null) continue;
for (PropertyDefinitionFieldSetItemModel propertyDefinitionFieldSetItemModel : propertyDefinitionFieldSetModel.getItems()){
if (propertyDefinitionFieldSetItemModel.getFields() == null) continue;
eu.eudat.commonmodels.models.description.FieldModel valueField = propertyDefinitionFieldSetItemModel.getFields().getOrDefault(fieldModel.getId(), null);
if (valueField != null) items.add(valueField);
}
}
return items;
}
private List<eu.eudat.commonmodels.models.description.FieldModel> getAllValueFields(PropertyDefinitionModel descriptionTemplateModel){
List<eu.eudat.commonmodels.models.description.FieldModel> items = new ArrayList<>();
if (descriptionTemplateModel == null || descriptionTemplateModel.getFieldSets() == null) return items;
for (PropertyDefinitionFieldSetModel propertyDefinitionFieldSetModel : descriptionTemplateModel.getFieldSets().values()){
if (propertyDefinitionFieldSetModel.getItems() == null) continue;
for (PropertyDefinitionFieldSetItemModel propertyDefinitionFieldSetItemModel : propertyDefinitionFieldSetModel.getItems()){
if (propertyDefinitionFieldSetItemModel.getFields() == null) continue;
items.addAll(propertyDefinitionFieldSetItemModel.getFields().values());
}
}
return items;
}
public Dataset toRDA(DescriptionModel descriptionEntity, Map<String, Object> extraData) {
if (descriptionEntity == null) return null;
if (descriptionEntity.getLabel() == null) throw new IllegalArgumentException("Dataset Label is missing");
if (extraData == null) throw new IllegalArgumentException("extraData is missing");
Object dmpObject = extraData.getOrDefault("dmp", null);
if (dmpObject == null) throw new IllegalArgumentException("Dmp is missing");
Dmp dmp = (Dmp)dmpObject;
Dataset rda = new Dataset();
rda.setTitle(descriptionEntity.getLabel());
rda.setDescription(descriptionEntity.getDescription());
rda.setAdditionalProperty("template", descriptionEntity.getDescriptionTemplate().getId());
rda.setAdditionalProperty("dmpSectionIndex", descriptionEntity.getSectionId());
//Map<String, Object> templateIdsToValues = this.createFieldIdValueMap(descriptionEntity.getDescriptionTemplate());
//rda.setAdditionalProperty("template", descriptionEntity.getDescriptionTemplate()); //TODO
try {
List<FieldModel> idNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dataset.dataset_id");
if (!idNodes.isEmpty()) {
rda.setDatasetId(datasetIdRDAMapper.toRDA(idNodes, this.getAllValueFields(descriptionEntity.getProperties())));
}
if (rda.getDatasetId() == null) {
rda.setDatasetId(new DatasetId(descriptionEntity.getId().toString(), DatasetId.Type.OTHER));
}
List<FieldModel> typeNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dataset.type");
for (FieldModel typeNode : typeNodes){
List<eu.eudat.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(typeNode, descriptionEntity.getProperties());
if (!fieldValues.isEmpty()) rda.setType(fieldValues.stream().filter(x-> x.getTextValue() != null && x.getTextValue().isBlank()).map(eu.eudat.commonmodels.models.description.FieldModel::getTextValue).findFirst().orElse(null));
if (rda.getType() != null && !rda.getType().isBlank()) break;;
}
if (rda.getType() == null || rda.getType().isBlank()) rda.setType("DMP Dataset");
List<FieldModel> languageNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dataset.language");
for (FieldModel languageNode : languageNodes){
List<eu.eudat.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(languageNode, descriptionEntity.getProperties());
try {
if (!fieldValues.isEmpty()) rda.setLanguage(fieldValues.stream().filter(x -> x.getTextValue() != null && x.getTextValue().isBlank()).map(x -> Language.fromValue(x.getTextValue())).findFirst().orElse(null));
}
catch (IllegalArgumentException e){
logger.warn("Language from semantic rda.dataset.language was not found.");
}
if (rda.getLanguage() != null) break;;
}
if (rda.getLanguage() == null) rda.setLanguage(languageRDAMapper.toRDA(descriptionEntity.getDescriptionTemplate().getLanguage()));
List<FieldModel> metadataNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dataset.metadata");
if (!metadataNodes.isEmpty()) {
Map<String, Object> valueFieldsMap = new HashMap<>();
valueFieldsMap.put("valueFields", this.getAllValueFields(descriptionEntity.getProperties()));
rda.setMetadata(metadataRDAMapper.toRDA(metadataNodes, this.getAllValueFields(descriptionEntity.getProperties())));
}else{
rda.setMetadata(new ArrayList<>());
}
//TODO
// List<FieldModel> qaNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dataset.data_quality_assurance");
// if (!qaNodes.isEmpty()) {
// rda.setDataQualityAssurance(qaNodes.stream().filter(qaNode -> qaNode.getData() != null).map(qaNode -> qaNode.getData().getValue()).collect(Collectors.toList()));
// for (int i = 0; i < qaNodes.size(); i++) {
// rda.setAdditionalProperty("qaId" + (i + 1), qaNodes.get(i).getId());
// }
// List<String> qaList = new ArrayList<>();
// String qa;
// for(FieldModel node: qaNodes){
// if (node.getData() == null) {
// continue;
// }
// JsonNode valueNode = mapper.readTree(node.getData().getValue());
// if(valueNode.isArray()){
// Iterator<JsonNode> iter = valueNode.elements();
// while(iter.hasNext()) {
// qa = iter.next().asText();
// qaList.add(qa);
// }
// }
// }
// String data_quality;
// for(FieldModel dqa: qaNodes){
// if (dqa.getData() == null) {
// continue;
// }
// data_quality = dqa.getData().getValue();
// if(!data_quality.isEmpty()){
// qaList.add(data_quality);
// rda.setAdditionalProperty("otherDQAID", dqa.getId());
// rda.setAdditionalProperty("otherDQA", data_quality);
// break;
// }
// }
// rda.setDataQualityAssurance(qaList);
// }else{
// rda.setDataQualityAssurance(new ArrayList<>());
// }
List<FieldModel> preservationNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dataset.preservation_statement");
for (FieldModel preservationNode : preservationNodes){
List<eu.eudat.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(preservationNode, descriptionEntity.getProperties());
if (!fieldValues.isEmpty()) rda.setPreservationStatement(fieldValues.stream().filter(x-> x.getTextValue() != null && x.getTextValue().isBlank()).map(eu.eudat.commonmodels.models.description.FieldModel::getTextValue).findFirst().orElse(null));
if (rda.getPreservationStatement() != null && !rda.getPreservationStatement().isBlank()) break;;
}
List<FieldModel> distributionNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dataset.distribution");
if (!distributionNodes.isEmpty()) {
rda.setDistribution(distributionRDAMapper.toRDA(distributionNodes, this.getAllValueFields(descriptionEntity.getProperties())));
}else{
rda.setDistribution(new ArrayList<>());
}
List<FieldModel> keywordNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dataset.keyword");
for (FieldModel keywordNode : keywordNodes){
List<eu.eudat.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(keywordNode, descriptionEntity.getProperties());
if (!fieldValues.isEmpty()) {
rda.setKeyword(fieldValues.stream().filter(x -> (x.getTextValue() != null && x.getTextValue().isBlank()) || (x.getTextListValue() != null && !x.getTextListValue().isEmpty())).map(x -> {
if (x.getTextListValue() != null && !x.getTextListValue().isEmpty()) {
return x.getTextListValue().stream().map(node -> keywordRDAMapper.toRDA(node)).collect(Collectors.toList());
} else {
return List.of(keywordRDAMapper.toRDA(x.getTextValue()));
}
}).filter(Objects::nonNull).flatMap(Collection::stream).collect(Collectors.toList()));
}
}
if (rda.getKeyword() != null){
int i = 0 ;
for (String keyword : rda.getKeyword()) {
rda.setAdditionalProperty("keyword" + (i + 1), keyword);
i++;
}
}
// else if (apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().exists()) { //TODO
// List<String> tags = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(descriptionEntity.getId().toString()).getTags().stream().map(Tag::getName).collect(Collectors.toList());
// rda.setKeyword(tags);
// }
List<FieldModel> personalDataNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dataset.sensitive_data");
for (FieldModel personalDataNode : personalDataNodes){
List<eu.eudat.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(personalDataNode, descriptionEntity.getProperties());
if (!fieldValues.isEmpty()) rda.setPersonalData(fieldValues.stream().filter(x-> x.getTextValue() != null && x.getTextValue().isBlank()).map(x-> Dataset.PersonalData.fromValue(x.getTextValue())).findFirst().orElse(null));
if (rda.getPersonalData() != null) break;
}
if (rda.getPersonalData() != null) rda.setPersonalData(Dataset.PersonalData.UNKNOWN);
List<FieldModel> securityAndPrivacyNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dataset.security_and_privacy");
if (!securityAndPrivacyNodes.isEmpty()) {
rda.setSecurityAndPrivacy(securityAndPrivacyRDAMapper.toRDA(securityAndPrivacyNodes, this.getAllValueFields(descriptionEntity.getProperties())));
}else{
rda.setSecurityAndPrivacy(new ArrayList<>());
}
List<FieldModel> sensitiveDataNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dataset.sensitive_data");
for (FieldModel sensitiveDataNode : sensitiveDataNodes){
List<eu.eudat.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(sensitiveDataNode, descriptionEntity.getProperties());
if (!fieldValues.isEmpty()) rda.setSensitiveData(fieldValues.stream().filter(x-> x.getTextValue() != null && x.getTextValue().isBlank()).map(x-> Dataset.SensitiveData.fromValue(x.getTextValue())).findFirst().orElse(null));
if (rda.getSensitiveData() != null) break;
}
if (rda.getSensitiveData() != null) rda.setSensitiveData(Dataset.SensitiveData.UNKNOWN);
List<FieldModel> technicalResourceNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dataset.technical_resource");
if (!technicalResourceNodes.isEmpty()) {
rda.setTechnicalResource(technicalResourceRDAMapper.toRDA(technicalResourceNodes, this.getAllValueFields(descriptionEntity.getProperties())));
}else{
rda.setTechnicalResource(new ArrayList<>());
}
List<FieldModel> issuedNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dataset.issued");
for (FieldModel issuedNode : issuedNodes){
List<eu.eudat.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(issuedNode, descriptionEntity.getProperties());
if (!fieldValues.isEmpty()) rda.setIssued(fieldValues.stream().filter(x-> x.getTextValue() != null && x.getTextValue().isBlank()).map(eu.eudat.commonmodels.models.description.FieldModel::getTextValue).findFirst().orElse(null));
if (rda.getIssued() != null && !rda.getIssued().isBlank()) break;;
}
//TODO
// List<FieldModel> contributorNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dmp.contributor");
// if (!contributorNodes.isEmpty()) {
// dmp.getContributor().addAll(contributorNodes.stream().filter(contributorNode -> contributorNode.getData() != null).map(contributorNode -> {
// try {
// JsonNode value = mapper.readTree(contributorNode.getData().getValue());
// if (value.isArray()) {
// return StreamSupport.stream(value.spliterator(), false).map(node -> DmpUserContributorRDAMapper.toRDA(node.asText())).collect(Collectors.toList());
// } else {
// return Collections.singletonList(new Contributor());
// }
// }catch (JsonProcessingException e) {
// return null;
// }
// }).filter(Objects::nonNull).flatMap(Collection::stream).toList());
// dmp.setContributor(dmp.getContributor().stream().filter(contributor -> contributor.getContributorId() != null && contributor.getName() != null).collect(Collectors.toList()));
// }
List<FieldModel> costNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dmp.cost");
if (!costNodes.isEmpty()) {
dmp.getCost().addAll(costRDAMapper.toRDA(costNodes, this.getAllValueFields(descriptionEntity.getProperties())));
}
List<FieldModel> ethicsNodes = this.templateFieldSearcherService.searchFieldsBySemantics(descriptionEntity.getDescriptionTemplate(), "rda.dmp.ethical_issues");
if (!ethicsNodes.isEmpty()) {
for(FieldModel node: ethicsNodes){
List<eu.eudat.commonmodels.models.description.FieldModel> fieldValues = this.findValueField(node, descriptionEntity.getProperties());
eu.eudat.commonmodels.models.description.FieldModel fieldValue = fieldValues.getFirst();
String rdaProperty = node.getSchematics().stream().filter(schematic -> schematic.startsWith("rda.dmp.ethical_issues")).findFirst().orElse("");
if (fieldValue == null) {
continue;
}
String rdaValue = fieldValue.getTextValue();
if(rdaValue == null || rdaValue.isEmpty()){
continue;
}
if(rdaProperty.contains("exist")){
try {
Dmp.EthicalIssuesExist exists = dmp.getEthicalIssuesExist();
if(exists == null
|| ((exists == Dmp.EthicalIssuesExist.NO || exists == Dmp.EthicalIssuesExist.UNKNOWN) && rdaValue.equals("yes"))
|| (exists == Dmp.EthicalIssuesExist.YES && !(rdaValue.equals("no") || rdaValue.equals("unknown")))
|| (exists == Dmp.EthicalIssuesExist.UNKNOWN && rdaValue.equals("no"))){
dmp.setEthicalIssuesExist(Dmp.EthicalIssuesExist.fromValue(rdaValue));
}
}catch(IllegalArgumentException e){
logger.warn(e.getLocalizedMessage() + ". Setting ethical_issues_exist to unknown");
dmp.setEthicalIssuesExist(Dmp.EthicalIssuesExist.UNKNOWN);
}
}
else if(rdaProperty.contains("description")){
if(dmp.getEthicalIssuesDescription() == null){
dmp.setEthicalIssuesDescription(rdaValue);
}
else{
dmp.setEthicalIssuesDescription(dmp.getEthicalIssuesDescription() + ", " + rdaValue);
}
}
else if(rdaProperty.contains("report")){
try {
dmp.setEthicalIssuesReport(URI.create(rdaValue));
} catch (IllegalArgumentException e) {
logger.warn(e.getLocalizedMessage() + ". Skipping url parsing");
}
}
}
}
//TODO
// List<FieldModel> foundNodes = Stream.of(typeNodes, languageNodes, metadataNodes, qaNodes , preservationNodes, distributionNodes,
// keywordNodes, personalDataNodes, securityAndPrivacyNodes, sensitiveDataNodes, technicalResourceNodes).flatMap(Collection::stream).toList();
// templateIdsToValues.entrySet().forEach(entry -> {
// boolean isFound = foundNodes.stream().anyMatch(node -> node.getId().equals(entry.getKey()));
// if (!isFound && entry.getValue() != null && !entry.getValue().toString().isEmpty()) {
// try {
// Instant time = Instant.parse(entry.getValue().toString());
// rda.setAdditionalProperty(entry.getKey(), DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(time));
// } catch (DateTimeParseException e) {
// rda.setAdditionalProperty(entry.getKey(), entry.getValue());
// }
// }
// });
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return rda;
}
public DescriptionModel toEntity(Dataset rda, DescriptionTemplateModel defaultProfile) {
throw new UnsupportedOperationException();
}
}

View File

@ -1,210 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.models.descriptiotemplate.FieldModel;
import eu.eudat.file.transformer.model.rda.Distribution;
import eu.eudat.file.transformer.model.rda.License;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.net.URI;
import java.util.*;
import java.util.stream.Collectors;
@Component
public class DistributionRDAMapper {
private static final Logger logger = LoggerFactory.getLogger(DistributionRDAMapper.class);
private final LicenseRDAMapper licenseRDAMapper;
private final HostRDAMapper hostRDAMapper;
public DistributionRDAMapper(LicenseRDAMapper licenseRDAMapper, HostRDAMapper hostRDAMapper) {
this.licenseRDAMapper = licenseRDAMapper;
this.hostRDAMapper = hostRDAMapper;
}
public List<Distribution> toRDA(List<FieldModel> nodes, List<eu.eudat.commonmodels.models.description.FieldModel> valueFields) {
if (nodes == null) return null;
if (valueFields == null) throw new IllegalArgumentException("valueFields is missing");
Map<String, Distribution> rdaMap = new HashMap<>();
for (FieldModel node: nodes) {
String rdaProperty = getRdaDistributionProperty(node);
if(rdaProperty.isEmpty() || node.getData() == null){
continue;
}
eu.eudat.commonmodels.models.description.FieldModel rdaValue = valueFields.stream().filter(x-> x.getId().equals(node.getId())).findFirst().orElse(null);
if(rdaValue == null || (rdaValue.getTextValue() == null && rdaValue.getReferences() == null)){
continue;
}
String key = node.getNumbering();
if(!key.contains("mult")){
key = "0";
}
else{
key = "" + key.charAt(4);
}
Distribution rda;
if(rdaMap.containsKey(key)){
rda = rdaMap.get(key);
}
else {
rda = new Distribution();
rdaMap.put(key, rda);
}
for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) {
if (rdaProperty.contains(exportPropertyName.getName())) {
switch (exportPropertyName) {
case ACCESS_URL:
rda.setAccessUrl(rdaValue.getTextValue());
rda.setAdditionalProperty(ImportPropertyName.ACCESS_URL.getName(), node.getId());
break;
case AVAILABLE_UNTIL:
rda.setAvailableUntil(rdaValue.getTextValue());
rda.setAdditionalProperty(ImportPropertyName.AVAILABLE_UNTIL.getName(), node.getId());
break;
case DOWNLOAD_URL:
rda.setDownloadUrl(URI.create(rdaValue.getTextValue()));
rda.setAdditionalProperty(ImportPropertyName.DOWNLOAD_URL.getName(), node.getId());
break;
case DESCRIPTION:
if(!rdaProperty.contains("host")) {
rda.setDescription(rdaValue.getTextValue());
rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.getId());
}
break;
case DATA_ACCESS:
try {
rda.setDataAccess(Distribution.DataAccess.fromValue(rdaValue.getTextValue()));
rda.setAdditionalProperty(ImportPropertyName.DATA_ACCESS.getName(), node.getId());
}
catch (IllegalArgumentException e) {
logger.warn("Distribution data access " + rdaValue + " from semantic distribution.data_access is not valid. Data access will not be set set.");
}
break;
case BYTE_SIZE:
rda.setByteSize(Integer.parseInt(rdaValue.getTextValue()));
rda.setAdditionalProperty(ImportPropertyName.BYTE_SIZE.getName(), node.getId());
break;
case LICENSE:
List<FieldModel> licenseNodes = nodes.stream().filter(lnode -> {
for(String schematic: lnode.getSchematics()){
if(schematic.startsWith("rda.dataset.distribution.license")){
return true;
}
}
return false;
}).collect(Collectors.toList());
License license = licenseRDAMapper.toRDA(licenseNodes, valueFields);
rda.setLicense(license != null? Collections.singletonList(license): new ArrayList<>());
break;
case FORMAT:
//TODO
// try {
// JsonNode valueNode = mapper.readTree(node.getData().getValue());
// if(valueNode.isArray()){
// Iterator<JsonNode> iter = valueNode.elements();
// List<String> formats = new ArrayList<>();
// int i = 1;
// while(iter.hasNext()) {
// JsonNode current = iter.next();
// String format = current.toString();
//
// Map<String, String> result = mapper.readValue(format, HashMap.class);
// format = result.get("label");
// formats.add(format);
// rda.setAdditionalProperty("format" + i++, mapper.readTree(current.toString()));
//
// }
// rda.setFormat(formats);
// }
// else{
// if(rda.getFormat() == null || rda.getFormat().isEmpty()){
// rda.setFormat(new ArrayList<>(Arrays.asList(rdaValue.replace(" ", "").split(","))));
// }
// else{
// rda.getFormat().addAll(Arrays.asList(rdaValue.replace(" ", "").split(",")));
// }
// }
// rda.setAdditionalProperty(ImportPropertyName.FORMAT.getName(), node.getId());
// }
// catch(JsonProcessingException e){
// logger.warn(e.getMessage());
// }
break;
case TITLE:
if(!rdaProperty.contains("host")) {
rda.setTitle(rdaValue.getTextValue());
rda.setAdditionalProperty(ImportPropertyName.TITLE.getName(), node.getId());
}
break;
case HOST:
rda.setHost(hostRDAMapper.toRDA(nodes, valueFields, node.getNumbering()));
break;
}
}
}
}
return rdaMap.values().stream()
.filter(distro -> distro.getTitle() != null).collect(Collectors.toList());
}
private static String getRdaDistributionProperty(FieldModel node) {
return node.getSchematics().stream().filter(schematic -> schematic.startsWith("rda.dataset.distribution")).findFirst().orElse("");
}
private enum ExportPropertyName {
ACCESS_URL("access_url"),
AVAILABLE_UNTIL("available_until"),
BYTE_SIZE("byte_size"),
DATA_ACCESS("data_access"),
DESCRIPTION("description"),
DOWNLOAD_URL("download_url"),
FORMAT("format"),
HOST("host"),
LICENSE("license"),
TITLE("title");
private final String name;
ExportPropertyName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
private enum ImportPropertyName {
ACCESS_URL("accessurlId"),
AVAILABLE_UNTIL("availableUtilId"),
BYTE_SIZE("byteSizeId"),
DATA_ACCESS("dataAccessId"),
DESCRIPTION("descriptionId"),
DOWNLOAD_URL("downloadUrlId"),
FORMAT("formatId"),
/*HOST("host"),
LICENSE("license"),*/
TITLE("titleId");
private final String name;
ImportPropertyName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static ImportPropertyName fromString(String name) throws Exception {
for (ImportPropertyName importPropertyName: ImportPropertyName.values()) {
if (importPropertyName.getName().equals(name)) {
return importPropertyName;
}
}
throw new Exception("No name available");
}
}
}

View File

@ -1,40 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.models.dmp.DmpContactModel;
import eu.eudat.file.transformer.model.rda.Contact;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class DmpContactModelContactRDAMapper {
private final ContactRDAMapper contactRDAMapper;
public DmpContactModelContactRDAMapper(ContactRDAMapper contactRDAMapper) {
this.contactRDAMapper = contactRDAMapper;
}
public Contact toRDA(DmpContactModel model) {
if (model == null) return null;
Contact rda = new Contact();
if (model.getUser() != null){
rda = this.contactRDAMapper.toRDA(model.getUser());
} else {
if (model.getLastName() == null) throw new IllegalArgumentException("Last Name is missing");
if (model.getEmail() == null) throw new IllegalArgumentException("Email is missing");
rda.setName(model.getLastName() + " " + model.getFirstName());
rda.setMbox(model.getEmail());
}
return rda;
}
public DmpContactModel toEntity(Contact rda) {
if (rda == null) return null;
DmpContactModel entity = new DmpContactModel();
entity.setUser(this.contactRDAMapper.toEntity(rda));
return entity;
}
}

View File

@ -1,25 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.file.transformer.model.rda.DmpId;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
public class DmpIdRDAMapper{
public DmpId toRDA(Object id) {
if (id == null) return null;
DmpId rda = new DmpId();
rda.setIdentifier(id.toString());
if (id instanceof UUID) {
rda.setType(DmpId.Type.OTHER);
} else {
rda.setType(DmpId.Type.DOI);
}
return rda;
}
public Object toEntity(DmpId rda) {
return rda == null ? null : rda.getIdentifier();
}
}

View File

@ -1,231 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.enums.DmpAccessType;
import eu.eudat.commonmodels.enums.DmpUserRole;
import eu.eudat.commonmodels.models.DmpUserModel;
import eu.eudat.commonmodels.models.EntityDoiModel;
import eu.eudat.commonmodels.models.UserModel;
import eu.eudat.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
import eu.eudat.commonmodels.models.descriptiotemplate.FieldModel;
import eu.eudat.commonmodels.models.dmp.DmpContactModel;
import eu.eudat.commonmodels.models.dmp.DmpModel;
import eu.eudat.commonmodels.models.dmp.DmpPropertiesModel;
import eu.eudat.commonmodels.models.dmpblueprint.DmpBlueprintModel;
import eu.eudat.commonmodels.models.dmpreference.DmpReferenceModel;
import eu.eudat.commonmodels.models.reference.ReferenceModel;
import eu.eudat.file.transformer.model.ProjectModel;
import eu.eudat.file.transformer.model.rda.DmpId;
import eu.eudat.file.transformer.model.rda.Dmp;
import eu.eudat.file.transformer.service.descriptiontemplatesearcher.TemplateFieldSearcherService;
import eu.eudat.file.transformer.service.json.JsonHandlingService;
import eu.eudat.file.transformer.service.rdafiletransformer.RdaFileTransformerServiceProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.Instant;
import java.util.*;
@Component
public class DmpRDAMapper{
private final DatasetRDAMapper datasetRDAMapper;
private final DmpIdRDAMapper dmpIdRDAMapper;
private final ContactRDAMapper contactRDAMapper;
private final RdaFileTransformerServiceProperties rdaFileTransformerServiceProperties;
private final DmpContactModelContactRDAMapper dmpContactModelContactRDAMapper;
private final ReferenceContributorRDAMapper referenceContributorRDAMapper;
private final DmpUserContributorRDAMapper dmpUserContributorRDAMapper;
private final ProjectRDAMapper projectRDAMapper;
private final JsonHandlingService jsonHandlingService;
private final LanguageRDAMapper languageRDAMapper;
@Autowired
public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper, DmpIdRDAMapper dmpIdRDAMapper, ContactRDAMapper contactRDAMapper, RdaFileTransformerServiceProperties rdaFileTransformerServiceProperties, DmpContactModelContactRDAMapper dmpContactModelContactRDAMapper, ReferenceContributorRDAMapper referenceContributorRDAMapper, DmpUserContributorRDAMapper dmpUserContributorRDAMapper, ProjectRDAMapper projectRDAMapper, JsonHandlingService jsonHandlingService, LanguageRDAMapper languageRDAMapper) {
this.datasetRDAMapper = datasetRDAMapper;
this.dmpIdRDAMapper = dmpIdRDAMapper;
this.contactRDAMapper = contactRDAMapper;
this.rdaFileTransformerServiceProperties = rdaFileTransformerServiceProperties;
this.dmpContactModelContactRDAMapper = dmpContactModelContactRDAMapper;
this.referenceContributorRDAMapper = referenceContributorRDAMapper;
this.dmpUserContributorRDAMapper = dmpUserContributorRDAMapper;
this.projectRDAMapper = projectRDAMapper;
this.jsonHandlingService = jsonHandlingService;
this.languageRDAMapper = languageRDAMapper;
}
public Dmp toRDA(DmpModel dmp) {
if (dmp == null) throw new IllegalArgumentException("DMP is missing");
if (dmp.getCreatedAt() == null) throw new IllegalArgumentException("DMP Created is missing");
if (dmp.getUpdatedAt() == null) throw new IllegalArgumentException("DMP Modified is missing");
if (dmp.getLabel() == null) throw new IllegalArgumentException("DMP Label is missing");
if (dmp.getProperties() == null) throw new IllegalArgumentException("DMP is missing language and contact properties");
if (dmp.getDescriptions() == null || dmp.getDescriptions().isEmpty()) throw new IllegalArgumentException("DMP has no Datasets");
List<ReferenceModel> grants = this.getReferenceModelOfTypeCode(dmp, this.rdaFileTransformerServiceProperties.getGrantReferenceCode());
List<ReferenceModel> researchers = this.getReferenceModelOfTypeCode(dmp, this.rdaFileTransformerServiceProperties.getResearcherReferenceCode());
List<ReferenceModel> funders = this.getReferenceModelOfTypeCode(dmp, this.rdaFileTransformerServiceProperties.getFunderReferenceCode());
List<ReferenceModel> projects = this.getReferenceModelOfTypeCode(dmp, this.rdaFileTransformerServiceProperties.getProjectReferenceCode());
Dmp rda = new Dmp();
if (dmp.getEntityDois() != null && !dmp.getEntityDois().isEmpty()) {
for(EntityDoiModel doi: dmp.getEntityDois()){
if(doi.getRepositoryId() != null && doi.getRepositoryId().equals("Zenodo")){
rda.setDmpId(dmpIdRDAMapper.toRDA(doi.getDoi()));
}
}
} else {
rda.setDmpId(dmpIdRDAMapper.toRDA(dmp.getId()));
}
rda.setCreated(dmp.getCreatedAt());
rda.setDescription(dmp.getDescription());
rda.setModified(dmp.getUpdatedAt());
rda.setTitle(dmp.getLabel());
rda.setLanguage(languageRDAMapper.toRDA(dmp.getLanguage() != null ? dmp.getLanguage() : "en"));
if (dmp.getProperties() != null) {
//TODO
// if (extraProperties.get("ethicalIssues") != null) {
// rda.setEthicalIssuesExist(Dmp.EthicalIssuesExist.fromValue(extraProperties.get("ethicalIssues").toString()));
// } else {
// rda.setEthicalIssuesExist(Dmp.EthicalIssuesExist.UNKNOWN);
// }
// if (extraProperties.get("costs") != null) {
// rda.setCost(new ArrayList<>());
// ((List) extraProperties.get("costs")).forEach(costl -> {
// try {
// rda.getCost().add(CostRDAMapper.toRDA((Map)costl));
// } catch (JsonProcessingException e) {
// logger.error(e.getMessage(), e);
// }
// });
// }
if (dmp.getProperties().getContacts() != null && !dmp.getProperties().getContacts().isEmpty()){
UserModel userContact = dmp.getProperties().getContacts().stream().filter(x-> x.getUser() != null).map(DmpContactModel::getUser).findFirst().orElse(null);
if (userContact != null) {
rda.setContact(contactRDAMapper.toRDA(userContact));
} else {
rda.setContact(dmpContactModelContactRDAMapper.toRDA(dmp.getProperties().getContacts().getFirst()));
}
}
}
UserModel creator = null;
if (dmp.getCreator() != null) {
creator = dmp.getCreator();
} else if (dmp.getUsers() != null){
creator = dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(DmpUserRole.Owner)).map(DmpUserModel::getUser).findFirst().orElse(null);
}
if (creator != null) rda.setContact(contactRDAMapper.toRDA(creator));
if (!researchers.isEmpty()) rda.setContributor(referenceContributorRDAMapper.toRDAs(researchers));
if (dmp.getUsers() != null && !dmp.getUsers().isEmpty()){
if (rda.getContributor() == null) rda.setContributor(new ArrayList<>());
rda.getContributor().addAll(dmpUserContributorRDAMapper.toRDAs(dmp.getUsers()));
}
if (!projects.isEmpty() && !grants.isEmpty() && !funders.isEmpty()) {
ProjectModel projectModel = new ProjectModel();
projectModel.setFunder(funders.getFirst());
projectModel.setGrant(grants.getFirst());
projectModel.setProject(projects.getFirst());
rda.setProject(List.of(projectRDAMapper.toRDA(projectModel, null))); //TODO
}
if (dmp.getDescriptions() != null) rda.setAdditionalProperty("templates", jsonHandlingService.toJsonSafe(dmp.getDescriptions().stream().filter(x-> x.getDescriptionTemplate() != null && x.getDescriptionTemplate().getId() != null).map(descriptionModel -> descriptionModel.getDescriptionTemplate().getId()).toList()));
if (dmp.getDmpBlueprint() != null) rda.setAdditionalProperty("blueprintId", dmp.getDmpBlueprint().getId().toString());
if (dmp.getPublicAfter() != null) rda.setAdditionalProperty("publicDate", jsonHandlingService.toJsonSafe(dmp.getPublicAfter()));
if (dmp.getAccessType() != null) rda.setAdditionalProperty("visible", dmp.getAccessType());
if (dmp.getProperties() != null) rda.setAdditionalProperty("dmpProperties", jsonHandlingService.toJsonSafe(dmp.getProperties()));
Map<String, Object> datasetExtraData = new HashMap<>();
datasetExtraData.put("dmp", rda);
rda.setDataset(dmp.getDescriptions().stream().map(dataset -> datasetRDAMapper.toRDA(dataset, datasetExtraData)).toList());
return rda;
}
private List<ReferenceModel> getReferenceModelOfTypeCode(DmpModel dmp, String code){
List<ReferenceModel> response = new ArrayList<>();
if (dmp.getReferences() == null) return response;
for (DmpReferenceModel dmpReferenceModel : dmp.getReferences()){
if (dmpReferenceModel.getReference() != null && dmpReferenceModel.getReference().getType() != null && dmpReferenceModel.getReference().getType().getCode() != null && dmpReferenceModel.getReference().getType().getCode().equals(code)){
response.add(dmpReferenceModel.getReference());
}
}
return response;
}
public DmpModel toEntity(Dmp rda, Map<String, Object> extraData) {
if (extraData == null) throw new IllegalArgumentException("profiles is missing");
Object dmpObject = extraData.getOrDefault("profiles", null);
if (dmpObject == null) throw new IllegalArgumentException("profiles is missing");
List<DescriptionTemplateModel> profiles = (List<DescriptionTemplateModel>)dmpObject;
DmpModel entity = new DmpModel();
entity.setLabel(rda.getTitle());
entity.setCreatedAt(rda.getCreated());
entity.setUpdatedAt(rda.getModified());
entity.setDescription(rda.getDescription());
entity.setLanguage(languageRDAMapper.toEntity(rda.getLanguage()));
String dmpProperties = (String) rda.getAdditionalProperties().getOrDefault("dmpProperties", null);
if (dmpProperties != null && !dmpProperties.isBlank()) entity.setProperties(jsonHandlingService.fromJsonSafe(DmpPropertiesModel.class, dmpProperties));
String accessType = (String) rda.getAdditionalProperties().getOrDefault("visible", null);
if (accessType != null && !accessType.isBlank()) entity.setAccessType(DmpAccessType.of((Short.parseShort(accessType))));
String publicDate = (String) rda.getAdditionalProperties().getOrDefault("publicDate", null);
if (publicDate != null && !publicDate.isBlank()) entity.setPublicAfter(jsonHandlingService.fromJsonSafe(Instant.class, publicDate));
String blueprintId = (String) rda.getAdditionalProperties().getOrDefault("blueprintId", null);
if (blueprintId != null && !blueprintId.isBlank()){
DmpBlueprintModel blueprintModel = new DmpBlueprintModel();
blueprintModel.setId(UUID.fromString(blueprintId));
entity.setDmpBlueprint(blueprintModel);
}
if (rda.getDmpId().getType() == DmpId.Type.DOI) {
EntityDoiModel entityDoiModel = new EntityDoiModel();
entityDoiModel.setDoi(rda.getDmpId().getIdentifier());
entity.setEntityDois(List.of(entityDoiModel));
}
//TODO
/*if (((List<String>) rda.getAdditionalProperties().get("templates")) != null && !((List<String>) rda.getAdditionalProperties().get("templates")).isEmpty() && entity.getId() != null) {
entity.setAssociatedDmps(((List<String>) rda.getAdditionalProperties().get("templates")).stream().map(x -> {
try {
return this.getProfile(x, entity.getId());
} catch (InvalidApplicationException e) {
throw new RuntimeException(e);
}
}).filter(Objects::nonNull).collect(Collectors.toSet()));
}*/
entity.setReferences(new ArrayList<>());
if (rda.getContributor() != null && !rda.getContributor().isEmpty()) {
entity.getReferences().addAll(referenceContributorRDAMapper.toEntities(rda.getContributor().stream().filter(r -> r.getContributorId() != null).toList()).stream().map(reference -> {
DmpReferenceModel dmpReference = new DmpReferenceModel();
dmpReference.setReference(reference);
return dmpReference;
}).toList());
}
if (rda.getProject() != null && !rda.getProject().isEmpty()) {
entity.getReferences().addAll(projectRDAMapper.toEntities(rda.getProject()).stream().map(x-> {
List<ReferenceModel> referenceModels = new ArrayList<>();
if (x.getProject() != null) referenceModels.add(x.getProject());
if (x.getFunder() != null) referenceModels.add(x.getFunder());
if (x.getGrant() != null) referenceModels.add(x.getGrant());
return referenceModels;
}).flatMap(Collection::stream)
.map(reference -> {
DmpReferenceModel dmpReference = new DmpReferenceModel();
dmpReference.setReference(reference);
return dmpReference;
}).toList());
}
entity.setDescriptions(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1, profiles.getFirst())).toList()); //TODO
return entity;
}
}

View File

@ -1,50 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.enums.ContactInfoType;
import eu.eudat.commonmodels.models.DmpUserModel;
import eu.eudat.commonmodels.models.UserContactInfoModel;
import eu.eudat.commonmodels.models.reference.ReferenceModel;
import eu.eudat.file.transformer.model.rda.Contributor;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@Component
public class DmpUserContributorRDAMapper {
private final ContributorIdRDAMapper contributorIdRDAMapper;
public DmpUserContributorRDAMapper(ContributorIdRDAMapper contributorIdRDAMapper) {
this.contributorIdRDAMapper = contributorIdRDAMapper;
}
public Contributor toRDA(DmpUserModel userDMP) {
if (userDMP == null) return null;
if (userDMP.getUser() == null) throw new IllegalArgumentException("User is missing");
if (userDMP.getUser().getName() == null) throw new IllegalArgumentException("Contributor Name is missing");
Contributor rda = new Contributor();
rda.setContributorId(contributorIdRDAMapper.toRDA(userDMP.getUser().getId().toString()));
rda.setName(userDMP.getUser().getName());
UserContactInfoModel emailContact = userDMP.getUser().getContacts() == null ? null : userDMP.getUser().getContacts().stream().filter(userContactInfo -> userContactInfo.getType().equals(ContactInfoType.Email)).findFirst().orElse(null);
if (emailContact != null) {
rda.setMbox(emailContact.getValue());
}
rda.setRole(new HashSet<>(List.of(userDMP.getRole().name())));
return rda;
}
public List<Contributor> toRDAs(List<DmpUserModel> userDMPs) {
if (userDMPs == null) return null;
List<Contributor> items = new ArrayList<>();
for (DmpUserModel userDMP : userDMPs){
Contributor item = this.toRDA(userDMP);
if (item != null) items.add(item);
}
return items;
}
}

View File

@ -1,27 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.file.transformer.model.rda.FunderId;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.UUID;
@Component
public class FunderIdRDAMapper {
public FunderId toRDA(Object id) {
if (id == null) return null;
FunderId rda = new FunderId();
rda.setIdentifier(id.toString());
if (id instanceof UUID) {
rda.setType(FunderId.Type.OTHER);
} else {
rda.setType(FunderId.Type.FUNDREF);
}
return rda;
}
public String toEntity(FunderId rda) {
return rda == null ? null : rda.getIdentifier();
}
}

View File

@ -1,82 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.models.reference.ReferenceModel;
import eu.eudat.commonmodels.models.reference.ReferenceTypeModel;
import eu.eudat.file.transformer.model.FundingModel;
import eu.eudat.file.transformer.model.rda.Funding;
import eu.eudat.file.transformer.service.rdafiletransformer.RdaFileTransformerServiceProperties;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Component
public class FundingRDAMapper {
private final GrantIdRDAMapper grantIdRDAMapper;
private final FunderIdRDAMapper funderIdRDAMapper;
private final RdaFileTransformerServiceProperties rdaFileTransformerServiceProperties;
public FundingRDAMapper(GrantIdRDAMapper grantIdRDAMapper, FunderIdRDAMapper funderIdRDAMapper, RdaFileTransformerServiceProperties rdaFileTransformerServiceProperties) {
this.grantIdRDAMapper = grantIdRDAMapper;
this.funderIdRDAMapper = funderIdRDAMapper;
this.rdaFileTransformerServiceProperties = rdaFileTransformerServiceProperties;
}
public Funding toRDA(FundingModel model) {
if (model == null || (model.getGrant() == null && model.getFunder() == null)) return null;
Funding rda = new Funding();
String referencePrefix;
String shortReference;
int prefixLength = 0;
if (model.getFunder() != null && model.getFunder().getReference() != null) {
referencePrefix = model.getFunder().getReference().split(":")[0];
prefixLength = referencePrefix.length() == model.getFunder().getReference().length() ? referencePrefix.length() - 1 : referencePrefix.length();
shortReference = model.getFunder().getReference().substring(prefixLength + 1);
rda.setFunderId(funderIdRDAMapper.toRDA(shortReference));
} else if (model.getFunder() != null){
rda.setFunderId(funderIdRDAMapper.toRDA(model.getFunder().getId()));
}
if (model.getGrant() != null && model.getGrant() != null) {
referencePrefix = model.getGrant().getReference().split(":")[0];
prefixLength = referencePrefix.length() == model.getGrant().getReference().length() ? referencePrefix.length() - 1 : referencePrefix.length();
shortReference = model.getGrant().getReference().substring(prefixLength + 1);
rda.setGrantId(grantIdRDAMapper.toRDA(shortReference));
} else if (model.getGrant() != null) {
rda.setGrantId(grantIdRDAMapper.toRDA(model.getGrant().getId().toString()));
}
return rda;
}
public FundingModel toEntity(Funding rda) {
if (rda == null) return null;
FundingModel references = new FundingModel();
ReferenceModel funder = new ReferenceModel();
ReferenceTypeModel funderReferenceTypeModel = new ReferenceTypeModel();
funderReferenceTypeModel.setCode(rdaFileTransformerServiceProperties.getFunderReferenceCode());
funder.setType(funderReferenceTypeModel);
funder.setReference(rda.getFunderId().getIdentifier());
references.setFunder(funder);
ReferenceModel grant = new ReferenceModel();
ReferenceTypeModel grantReferenceTypeModel = new ReferenceTypeModel();
grantReferenceTypeModel.setCode(rdaFileTransformerServiceProperties.getGrantReferenceCode());
grant.setType(grantReferenceTypeModel);
grant.setReference(rda.getGrantId().getIdentifier());
references.setGrant(grant);
return references;
}
public List<FundingModel> toEntities(List<Funding> rdas) {
if (rdas == null) return null;
List<FundingModel> items = new ArrayList<>();
for (Funding rda : rdas){
FundingModel item = this.toEntity(rda);
if (item != null) items.add(item);
}
return items;
}
}

View File

@ -1,23 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.file.transformer.model.rda.GrantId;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class GrantIdRDAMapper {
public GrantId toRDA(String id) {
if (id == null || id.isBlank()) return null;
GrantId rda = new GrantId();
rda.setIdentifier(id);
rda.setType(GrantId.Type.OTHER);
return rda;
}
public String toEntity(GrantId rda) {
return rda == null ? null : rda.getIdentifier();
}
}

View File

@ -1,200 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.models.descriptiotemplate.FieldModel;
import eu.eudat.file.transformer.model.rda.Host;
import eu.eudat.file.transformer.utils.string.MyStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.net.URI;
import java.util.*;
@Component
public class HostRDAMapper {
private static final Logger logger = LoggerFactory.getLogger(HostRDAMapper.class);
public Host toRDA(List<FieldModel> nodes, List<eu.eudat.commonmodels.models.description.FieldModel> valueFields, String numbering){
if (nodes == null) return null;
if (valueFields == null) throw new IllegalArgumentException("valueFields is missing");
Host rda = new Host();
for (FieldModel node: nodes) {
String rdaProperty = node.getSchematics().stream().filter(schematic -> schematic.startsWith("rda.dataset.distribution.host")).findFirst().orElse("");
if (rdaProperty.contains("host")) {
int firstDiff = MyStringUtils.getFirstDifference(numbering, node.getNumbering());
if (firstDiff == -1 || firstDiff >= 2) {
eu.eudat.commonmodels.models.description.FieldModel rdaValue = valueFields.stream().filter(x-> x.getId().equals(node.getId())).findFirst().orElse(null);
if(rdaValue == null || rdaValue.getTextValue() == null || rdaValue.getTextValue().isBlank()){
continue;
}
for (ExportPropertyName propertyName: ExportPropertyName.values()) {
if (rdaProperty.contains(propertyName.getName())) {
switch (propertyName) {
case AVAILABILITY:
rda.setAvailability(rdaValue.getTextValue());
rda.setAdditionalProperty(ImportPropertyName.AVAILABILITY.getName(), node.getId());
break;
case BACKUP_FREQUENCY:
rda.setBackupFrequency(rdaValue.getTextValue());
rda.setAdditionalProperty(ImportPropertyName.BACKUP_FREQUENCY.getName(), node.getId());
break;
case BACKUP_TYPE:
rda.setBackupType(rdaValue.getTextValue());
rda.setAdditionalProperty(ImportPropertyName.BACKUP_TYPE.getName(), node.getId());
break;
case CERTIFIED_WITH:
try {
rda.setCertifiedWith(Host.CertifiedWith.fromValue(rdaValue.getTextValue()));
rda.setAdditionalProperty(ImportPropertyName.CERTIFIED_WITH.getName(), node.getId());
}
catch (IllegalArgumentException e) {
logger.warn("Distribution host certified with " + rdaValue + "from semantic distribution.host.certified_with is not valid. Certified_with will not be set set.");
}
break;
case DESCRIPTION:
rda.setDescription(rdaValue.getTextValue());
rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.getId());
break;
case GEO_LOCATION:
// if (rdaValue.getTextValue().startsWith("{")) {
// try {
// rdaValue = mapper.readValue(rdaValue.getTextValue(), Map.class).get("id").toString();
// } catch (JsonProcessingException e) {
// logger.warn(e.getLocalizedMessage() + ". Try to pass value as is");
// }
// }
// try {
// rda.setGeoLocation(Host.GeoLocation.fromValue(rdaValue.getTextValue()));
// rda.setAdditionalProperty(ImportPropertyName.GEO_LOCATION.getName(), node.getId());
// }
// catch (IllegalArgumentException e) {
// logger.warn("Distribution host geo location " + rdaValue.getTextValue() + "from semantic distribution.host.geo_location is not valid. Geo location will not be set set.");
// }
//TODO
rda.setGeoLocation(Host.GeoLocation.fromValue(rdaValue.getTextValue()));
rda.setAdditionalProperty(ImportPropertyName.GEO_LOCATION.getName(), node.getId());
break;
case PID_SYSTEM:
// try{
// JsonNode valueNode = mapper.readTree(rdaValue.getTextValue());
// Iterator<JsonNode> iter = valueNode.elements();
// List<String> pList = new ArrayList<>();
// while(iter.hasNext()) {
// pList.add(iter.next().asText());
// }
// List<PidSystem> pidList;
// if(pList.size() == 0){
// pidList = Arrays.stream(rdaValue.replaceAll("[\\[\"\\]]","").split(","))
// .map(PidSystem::fromValue).collect(Collectors.toList());
// }
// else{
// pidList = pList.stream().map(PidSystem::fromValue).collect(Collectors.toList());
// }
// rda.setPidSystem(pidList);
// rda.setAdditionalProperty(ImportPropertyName.PID_SYSTEM.getName(), node.getId());
// }
// catch (IllegalArgumentException e){
// rda.setPidSystem(new ArrayList<>());
// break;
// } catch (JsonProcessingException e) {
// throw new RuntimeException(e);
// }
//TODO
break;
case STORAGE_TYPE:
rda.setStorageType(rdaValue.getTextValue());
rda.setAdditionalProperty(ImportPropertyName.STORAGE_TYPE.getName(), node.getId());
break;
case SUPPORT_VERSIONING:
try {
rda.setSupportVersioning(Host.SupportVersioning.fromValue(rdaValue.getTextValue()));
rda.setAdditionalProperty(ImportPropertyName.SUPPORT_VERSIONING.getName(), node.getId());
}
catch (IllegalArgumentException e) {
logger.warn("Distribution host support versioning " + rdaValue + "from semantic distribution.host.support_versioning is not valid. Support versioning will not be set set.");
}
break;
case TITLE:
rda.setTitle(rdaValue.getTextValue());
rda.setAdditionalProperty(ImportPropertyName.TITLE.getName(), node.getId());
break;
case URL:
try {
rda.setUrl(URI.create(rdaValue.getTextValue()));
rda.setAdditionalProperty(ImportPropertyName.URL.getName(), node.getId());
} catch (IllegalArgumentException e) {
logger.warn(e.getLocalizedMessage() + ". Skipping url parsing");
}
break;
}
}
}
}
}
}
if(rda.getTitle() == null || rda.getUrl() == null){
return null;
}
return rda;
}
private enum ExportPropertyName {
AVAILABILITY("availability"),
BACKUP_FREQUENCY("backup_frequency"),
BACKUP_TYPE("backup_type"),
CERTIFIED_WITH("certified_with"),
DESCRIPTION("description"),
GEO_LOCATION("geo_location"),
PID_SYSTEM("pid_system"),
STORAGE_TYPE("storage_type"),
SUPPORT_VERSIONING("support_versioning"),
TITLE("title"),
URL("url");
private final String name;
ExportPropertyName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
private enum ImportPropertyName {
AVAILABILITY("availabilityId"),
BACKUP_FREQUENCY("backup_frequencyId"),
BACKUP_TYPE("backup_typeId"),
CERTIFIED_WITH("certified_withId"),
DESCRIPTION("descriptionId"),
GEO_LOCATION("geo_locationId"),
PID_SYSTEM("pid_systemId"),
STORAGE_TYPE("storage_typeId"),
SUPPORT_VERSIONING("support_versioningId"),
TITLE("titleId"),
URL("urlId");
private final String name;
ImportPropertyName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static ImportPropertyName fromString(String name) throws Exception {
for (ImportPropertyName importPropertyName: ImportPropertyName.values()) {
if (importPropertyName.getName().equals(name)) {
return importPropertyName;
}
}
throw new Exception("No name available");
}
}
}

View File

@ -1,16 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class KeywordRDAMapper {
public String toRDA(String value) {
return value;
}
public String toEntity(String rda) {
return rda;
}
}

View File

@ -1,49 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.file.transformer.model.FundingModel;
import eu.eudat.file.transformer.model.rda.Funding;
import eu.eudat.file.transformer.model.rda.Language;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;
@Component
public class LanguageRDAMapper {
private final static Map<String, String> langMap = new HashMap<>();
private static final Logger logger = LoggerFactory.getLogger(LanguageRDAMapper.class);
static {
try {
ObjectMapper mapper = new ObjectMapper(); //TODO
InputStreamReader isr = new InputStreamReader(LanguageRDAMapper.class.getClassLoader().getResource("internal/rda-lang-map.json").openStream(), StandardCharsets.UTF_8);
langMap.putAll(mapper.readValue(isr, LinkedHashMap.class));
isr.close();
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
public Language toRDA(String code) {
if (code == null || code.isBlank()) return null;
return langMap.entrySet().stream().map(entry -> {
if (entry.getValue().equals(code)) {
return Language.fromValue(entry.getKey());
} else {
return null;
}
}).filter(Objects::nonNull).findFirst().orElse(null);
}
public String toEntity(Language lang) {
if (lang == null) return null;
return langMap.get(lang.value());
}
}

View File

@ -1,67 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.models.descriptiotemplate.FieldModel;
import eu.eudat.file.transformer.model.rda.License;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.net.URI;
import java.util.List;
import java.util.Map;
@Component
public class LicenseRDAMapper {
private static final Logger logger = LoggerFactory.getLogger(LicenseRDAMapper.class);
public License toRDA(List<FieldModel> nodes, List<eu.eudat.commonmodels.models.description.FieldModel> valueFields) {
if (nodes == null) return null;
if (valueFields == null) throw new IllegalArgumentException("extraData is missing");
License rda = new License();
for (FieldModel node: nodes) {
String rdaProperty = node.getSchematics().stream().filter(schematic -> schematic.startsWith("rda.dataset.distribution.license")).findFirst().orElse("");
eu.eudat.commonmodels.models.description.FieldModel valueField = valueFields.stream().filter(x-> x.getId().equals(node.getId())).findFirst().orElse(null);
if(valueField == null || valueField.getTextValue() == null || valueField.getTextValue().isBlank()){
continue;
}
for (LicenceProperties licenceProperties: LicenceProperties.values()) {
if (rdaProperty.contains(licenceProperties.getName())) {
switch (licenceProperties) {
case LICENSE_REF:
try {
rda.setLicenseRef(URI.create(valueField.getTextValue()));
} catch (IllegalArgumentException e) {
logger.warn(e.getLocalizedMessage() + ". Skipping url parsing");
}
break;
case START_DATE:
rda.setStartDate(valueField.getTextValue());
break;
}
}
}
}
if(rda.getLicenseRef() == null || rda.getStartDate() == null){
return null;
}
return rda;
}
public enum LicenceProperties {
LICENSE_REF("license_ref"),
START_DATE("start_date");
private String name;
LicenceProperties(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
}

View File

@ -1,113 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.models.descriptiotemplate.FieldModel;
import eu.eudat.commonmodels.models.reference.ReferenceFieldModel;
import eu.eudat.commonmodels.models.reference.ReferenceModel;
import eu.eudat.file.transformer.model.rda.Metadatum;
import eu.eudat.file.transformer.utils.string.MyStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.*;
@Component
public class MetadataRDAMapper{
private static final Logger logger = LoggerFactory.getLogger(MetadataRDAMapper.class);
private final MetadataStandardIdRDAMapper metadataStandardIdRDAMapper;
public MetadataRDAMapper(MetadataStandardIdRDAMapper metadataStandardIdRDAMapper) {
this.metadataStandardIdRDAMapper = metadataStandardIdRDAMapper;
}
public List<Metadatum> toRDA(List<FieldModel> nodes, List<eu.eudat.commonmodels.models.description.FieldModel> valueFields) {
if (nodes == null) return null;
if (valueFields == null) throw new IllegalArgumentException("valueFields is missing");
Map<String, String> rdaMap = new HashMap<>();
List<Metadatum> rdas = new ArrayList<>();
for (FieldModel node : nodes) {
String rdaProperty = node.getSchematics().stream().filter(schematic -> schematic.startsWith("rda.dataset.metadata")).findFirst().orElse("");
eu.eudat.commonmodels.models.description.FieldModel rdaValue = valueFields.stream().filter(x -> x.getId().equals(node.getId())).findFirst().orElse(null);
for (PropertyName propertyName : PropertyName.values()) {
if (rdaProperty.contains(propertyName.getName())) {
switch (propertyName) {
case METADATA_STANDARD_ID:
if (rdaValue != null && rdaValue.getReferences() != null) {
for (ReferenceModel referenceModel : rdaValue.getReferences()) { //TODO reference ??
String uri = referenceModel != null && referenceModel.getDefinition() != null && referenceModel.getDefinition().getFields() != null ? referenceModel.getDefinition().getFields().stream().filter(x-> x.getCode().equals("uri")).map(ReferenceFieldModel::getValue).findFirst().orElse(null) : null;
if (uri!= null && !uri.isBlank()) { //TODO
rdas.add(new Metadatum());
rdas.getLast().setMetadataStandardId(metadataStandardIdRDAMapper.toRDA(uri));
rdas.getLast().setDescription(referenceModel.getLabel());
rdas.getLast().setAdditionalProperty("fieldId", node.getId());
rdas.getLast().setAdditionalProperty("valueId", referenceModel.getReference());
rdaMap.put(uri, node.getNumbering());
}
}
} else if (rdaValue != null && rdaValue.getTextValue() != null && !rdaValue.getTextValue().isEmpty()) {
rdas.add(new Metadatum());
rdas.getLast().setMetadataStandardId(metadataStandardIdRDAMapper.toRDA(rdaValue.getTextValue()));
rdas.getLast().setAdditionalProperty("identifierId", node.getId());
rdaMap.put(rdaValue.getTextValue(), node.getNumbering());
}
break;
case DESCRIPTION:
if (rdaValue != null && rdaValue.getTextValue() != null && !rdaValue.getTextValue().isEmpty()) {
Metadatum rda = getRelative(rdas, rdaMap, node.getNumbering());
if (rda != null) {
rda.setDescription(rdaValue.getTextValue());
rda.setAdditionalProperty("descriptionId", node.getId());
} else {
rdas.stream().filter(rda1 -> rda1.getDescription() == null || rda1.getDescription().isEmpty()).forEach(rda1 -> rda1.setDescription(rdaValue.getTextValue()));
}
}
break;
case LANGUAGE:
if (rdaValue != null && rdaValue.getTextValue() != null && !rdaValue.getTextValue().isEmpty()) {
String language = rdaValue.getTextValue();
Metadatum.Language lang = Metadatum.Language.fromValue(language);
Metadatum rda = getRelative(rdas, rdaMap, node.getNumbering());
if (rda != null) {
rda.setLanguage(lang);
rda.setAdditionalProperty("languageId", node.getId());
} else {
rdas.forEach(rda1 -> rda1.setLanguage(lang));
}
}
break;
}
}
}
}
return rdas;
}
private static Metadatum getRelative(List<Metadatum> rdas, Map<String, String> rdaMap, String numbering) {
String target = rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering) > 0)
.max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getValue(), numbering))).map(Map.Entry::getKey).orElse("");
return rdas.stream().filter(rda -> rda.getMetadataStandardId().getIdentifier().equals(target)).distinct().findFirst().orElse(null);
}
private enum PropertyName {
METADATA_STANDARD_ID("metadata_standard_id"),
DESCRIPTION("description"),
LANGUAGE("language");
private final String name;
PropertyName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
}

View File

@ -1,21 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.file.transformer.model.rda.MetadataStandardId;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class MetadataStandardIdRDAMapper {
public MetadataStandardId toRDA(String uri) {
if (uri == null || uri.isBlank()) return null;
MetadataStandardId rda = new MetadataStandardId();
rda.setIdentifier(uri);
rda.setType(MetadataStandardId.Type.URL);
return rda;
}
public String toEntity(MetadataStandardId rda) {
return rda == null ? null : rda.getIdentifier();
}
}

View File

@ -1,102 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.models.reference.ReferenceDefinitionModel;
import eu.eudat.commonmodels.models.reference.ReferenceFieldModel;
import eu.eudat.commonmodels.models.reference.ReferenceModel;
import eu.eudat.commonmodels.models.reference.ReferenceTypeModel;
import eu.eudat.file.transformer.model.FundingModel;
import eu.eudat.file.transformer.model.ProjectModel;
import eu.eudat.file.transformer.model.rda.Funding;
import eu.eudat.file.transformer.model.rda.Project;
import eu.eudat.file.transformer.service.rdafiletransformer.RdaFileTransformerServiceProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.*;
@Component
public class ProjectRDAMapper {
private final static Logger logger = LoggerFactory.getLogger(ProjectRDAMapper.class);
private final FundingRDAMapper fundingRDAMapper;
private final RdaFileTransformerServiceProperties rdaFileTransformerServiceProperties;
public ProjectRDAMapper(FundingRDAMapper fundingRDAMapper, RdaFileTransformerServiceProperties rdaFileTransformerServiceProperties) {
this.fundingRDAMapper = fundingRDAMapper;
this.rdaFileTransformerServiceProperties = rdaFileTransformerServiceProperties;
}
public Project toRDA(ProjectModel model, Map<String, Object> extraData) {
if (model == null) return null;
if (model.getProject() == null) throw new IllegalArgumentException("Project is missing");
if (model.getProject().getLabel() == null || model.getProject().getLabel().isBlank()) throw new IllegalArgumentException("Project Title is missing");
Project rda = new Project();
try {
rda.setTitle(model.getProject().getLabel());
rda.setDescription(model.getProject().getDescription());
if (model.getProject().getDefinition() != null && model.getProject().getDefinition().getFields() != null) {
String startDateString = model.getProject().getDefinition().getFields().stream().filter(field -> field.getCode().equals("startDate")).map(ReferenceFieldModel::getValue).findFirst().orElse(null);
if (startDateString != null) {
rda.setStart(startDateString);
}
String endDateString = model.getProject().getDefinition().getFields().stream().filter(field -> field.getCode().equals("endDate")).map(ReferenceFieldModel::getValue).findFirst().orElse(null);
if (endDateString != null) {
rda.setEnd(endDateString);
}
}
FundingModel fundingModel = new FundingModel();
fundingModel.setGrant(model.getGrant());
fundingModel.setFunder(model.getFunder());
rda.setFunding(List.of(fundingRDAMapper.toRDA(fundingModel)));
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
}
return rda;
}
public ProjectModel toEntity(Project rda) {
ProjectModel projectModel = new ProjectModel();
ReferenceModel project = new ReferenceModel();
project.setLabel(rda.getTitle());
project.setDescription(rda.getDescription());
ReferenceTypeModel referenceTypeModel = new ReferenceTypeModel();
referenceTypeModel.setCode(rdaFileTransformerServiceProperties.getProjectReferenceCode());
project.setType(referenceTypeModel);
ReferenceDefinitionModel projectDefinition = new ReferenceDefinitionModel();
projectDefinition.setFields(new ArrayList<>());
if (rda.getStart() != null && !rda.getStart().isEmpty()) {
ReferenceFieldModel startDateField = new ReferenceFieldModel();
startDateField.setCode("startDate");
startDateField.setValue(rda.getStart());
projectDefinition.getFields().add(startDateField);
}
if (rda.getEnd() != null && !rda.getEnd().isEmpty()) {
ReferenceFieldModel startDateField = new ReferenceFieldModel();
startDateField.setCode("endDate");
startDateField.setValue(rda.getEnd());
projectDefinition.getFields().add(startDateField);
}
project.setDefinition(projectDefinition);
projectModel.setProject(project);
List<FundingModel> fundingModels = fundingRDAMapper.toEntities(rda.getFunding());
if (fundingModels != null && !fundingModels.isEmpty()){
projectModel.setFunder(fundingModels.getFirst().getFunder()); //TODO
projectModel.setGrant(fundingModels.getFirst().getGrant());
}
return projectModel;
}
public List<ProjectModel> toEntities(List<Project> rdas) {
if (rdas == null) return null;
List<ProjectModel> items = new ArrayList<>();
for (Project rda : rdas){
ProjectModel item = this.toEntity(rda);
if (item != null) items.add(item);
}
return items;
}
}

View File

@ -1,73 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.models.reference.ReferenceDefinitionModel;
import eu.eudat.commonmodels.models.reference.ReferenceFieldModel;
import eu.eudat.commonmodels.models.reference.ReferenceModel;
import eu.eudat.file.transformer.model.FundingModel;
import eu.eudat.file.transformer.model.rda.Contributor;
import eu.eudat.file.transformer.model.rda.Funding;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Component
public class ReferenceContributorRDAMapper{
private final ContributorIdRDAMapper contributorIdRDAMapper;
public ReferenceContributorRDAMapper(ContributorIdRDAMapper contributorIdRDAMapper) {
this.contributorIdRDAMapper = contributorIdRDAMapper;
}
public Contributor toRDA(ReferenceModel researcher) {
if (researcher == null) return null;
Contributor rda = new Contributor();
rda.setContributorId(contributorIdRDAMapper.toRDA(researcher.getReference()));
rda.setName(researcher.getLabel());
if (researcher.getDefinition() != null && researcher.getDefinition().getFields() != null) {
ReferenceFieldModel emailField = researcher.getDefinition().getFields().stream().filter(field -> field.getCode().equals("primaryEmail")).findFirst().orElse(null);
if (emailField != null) {
rda.setMbox(emailField.getValue());
}
}
return rda;
}
public List<Contributor> toRDAs(List<ReferenceModel> researchers) {
if (researchers == null) return null;
List<Contributor> items = new ArrayList<>();
for (ReferenceModel researcher : researchers){
Contributor item = this.toRDA(researcher);
if (item != null) items.add(item);
}
return items;
}
public ReferenceModel toEntity(Contributor rda) {
if (rda == null || rda.getContributorId() == null) return null;
ReferenceModel reference = new ReferenceModel();
reference.setReference(contributorIdRDAMapper.toEntity(rda.getContributorId()));
reference.setLabel(rda.getName());
ReferenceFieldModel field = new ReferenceFieldModel();
field.setCode("primaryEmail");
field.setValue(rda.getMbox());
reference.setDefinition(new ReferenceDefinitionModel());
reference.getDefinition().setFields(List.of(field));
return reference;
}
public List<ReferenceModel> toEntities(List<Contributor> rdas) {
if (rdas == null) return null;
List<ReferenceModel> items = new ArrayList<>();
for (Contributor rda : rdas){
ReferenceModel item = this.toEntity(rda);
if (item != null) items.add(item);
}
return items;
}
}

View File

@ -1,97 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.models.descriptiotemplate.FieldModel;
import eu.eudat.file.transformer.model.rda.SecurityAndPrivacy;
import eu.eudat.file.transformer.utils.string.MyStringUtils;
import org.apache.commons.lang3.NotImplementedException;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
@Component
public class SecurityAndPrivacyRDAMapper {
public List<SecurityAndPrivacy> toRDA(List<FieldModel> nodes, List<eu.eudat.commonmodels.models.description.FieldModel> valueFields) {
if (nodes == null) return null;
if (valueFields == null) throw new IllegalArgumentException("valueFields is missing");
Map<String, SecurityAndPrivacy> rdaMap = new HashMap<>();
for (FieldModel node: nodes) {
String rdaProperty = node.getSchematics().stream().filter(schematic -> schematic.startsWith("rda.dataset.security_and_privacy")).findFirst().orElse("");
if (node.getData() == null) {
continue;
}
eu.eudat.commonmodels.models.description.FieldModel rdaValue = valueFields.stream().filter(x-> x.getId().equals(node.getId())).findFirst().orElse(null);
if(rdaValue == null || rdaValue.getTextValue() == null || rdaValue.getTextValue().isBlank()){
continue;
}
SecurityAndPrivacy rda = getRelative(rdaMap, node.getNumbering());
if (!rdaMap.containsValue(rda)) {
rdaMap.put(node.getNumbering(), rda);
}
for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) {
if (rdaProperty.contains(exportPropertyName.getName())) {
switch (exportPropertyName) {
case TITLE:
rda.setTitle(rdaValue.getTextValue());
rda.getAdditionalProperties().put(ImportPropertyName.TITLE.getName(), node.getId());
break;
case DESCRIPTION:
rda.setDescription(rdaValue.getTextValue());
rda.getAdditionalProperties().put(ImportPropertyName.DESCRIPTION.getName(), node.getId());
break;
}
}
}
}
return rdaMap.values().stream()
.filter(sap -> sap.getTitle() != null)
.collect(Collectors.toList());
}
private static SecurityAndPrivacy getRelative(Map<String, SecurityAndPrivacy> rdaMap, String numbering) {
return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0)
.max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new SecurityAndPrivacy());
}
private enum ExportPropertyName {
TITLE("title"),
DESCRIPTION("description");
private String name;
ExportPropertyName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
private enum ImportPropertyName {
TITLE("titleId"),
DESCRIPTION("descriptionId");
private String name;
ImportPropertyName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static ImportPropertyName fromString(String name) throws Exception {
for (ImportPropertyName importPropertyName: ImportPropertyName.values()) {
if (importPropertyName.getName().equals(name)) {
return importPropertyName;
}
}
throw new Exception("Property not available");
}
}
}

View File

@ -1,21 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.models.TagModel;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class TagRDAMapper {
public String toRDA(TagModel value) {
return value == null ? null : value.getLabel();
}
public TagModel toEntity(String rda) {
if (rda == null || rda.isBlank()) return null;
TagModel tagModel = new TagModel();
tagModel.setLabel(rda);
return tagModel;
}
}

View File

@ -1,96 +0,0 @@
package eu.eudat.file.transformer.model.rda.mapper;
import eu.eudat.commonmodels.models.descriptiotemplate.FieldModel;
import eu.eudat.file.transformer.model.rda.TechnicalResource;
import eu.eudat.file.transformer.utils.string.MyStringUtils;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
@Component
public class TechnicalResourceRDAMapper {
public List<TechnicalResource> toRDA(List<FieldModel> nodes, List<eu.eudat.commonmodels.models.description.FieldModel> valueFields ) {
if (nodes == null) return null;
if (valueFields == null) throw new IllegalArgumentException("valueFields is missing");
Map<String, TechnicalResource> rdaMap = new HashMap<>();
for (FieldModel node: nodes) {
String rdaProperty = node.getSchematics().stream().filter(schematic -> schematic.startsWith("rda.dataset.technical_resource")).findFirst().orElse("");
if (node.getData() == null) {
continue;
}
eu.eudat.commonmodels.models.description.FieldModel rdaValue = valueFields.stream().filter(x-> x.getId().equals(node.getId())).findFirst().orElse(null);
if(rdaValue == null || rdaValue.getTextValue() == null || rdaValue.getTextValue().isBlank()){
continue;
}
TechnicalResource rda = getRelative(rdaMap, node.getNumbering());
if (!rdaMap.containsValue(rda)) {
rdaMap.put(node.getNumbering(), rda);
}
for (ExportPropertyName exportPropertyName : ExportPropertyName.values()) {
if (rdaProperty.contains(exportPropertyName.getName())) {
switch (exportPropertyName) {
case NAME:
rda.setName(rdaValue.getTextValue());
rda.setAdditionalProperty(ImportPropertyName.NAME.getName(), node.getId());
break;
case DESCRIPTION:
rda.setDescription(rdaValue.getTextValue());
rda.setAdditionalProperty(ImportPropertyName.DESCRIPTION.getName(), node.getId());
break;
}
}
}
}
return rdaMap.values().stream()
.filter(tr -> tr.getName() != null)
.collect(Collectors.toList());
}
private static TechnicalResource getRelative(Map<String, TechnicalResource> rdaMap, String numbering) {
return rdaMap.entrySet().stream().filter(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering) > 0)
.max(Comparator.comparingInt(entry -> MyStringUtils.getFirstDifference(entry.getKey(), numbering))).map(Map.Entry::getValue).orElse(new TechnicalResource());
}
private enum ExportPropertyName {
NAME("name"),
DESCRIPTION("description");
private String name;
ExportPropertyName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
private enum ImportPropertyName {
NAME("nameId"),
DESCRIPTION("descriptionId");
private String name;
ImportPropertyName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static ImportPropertyName fromString(String name) throws Exception {
for (ImportPropertyName importPropertyName: ImportPropertyName.values()) {
if (importPropertyName.getName().equals(name)) {
return importPropertyName;
}
}
throw new Exception("Property name not available");
}
}
}

View File

@ -1,12 +0,0 @@
package eu.eudat.file.transformer.service.descriptiontemplatesearcher;
import eu.eudat.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
import eu.eudat.commonmodels.models.descriptiotemplate.FieldModel;
import java.util.List;
public interface TemplateFieldSearcherService {
List<FieldModel> searchFieldsById(DescriptionTemplateModel template, String value);
List<FieldModel> searchFieldsBySemantics(DescriptionTemplateModel template, String value);
}

View File

@ -1,25 +0,0 @@
package eu.eudat.file.transformer.service.descriptiontemplatesearcher;
import eu.eudat.commonmodels.models.descriptiotemplate.*;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
public class TemplateFieldSearcherServiceImpl implements TemplateFieldSearcherService {
@Override
public List<FieldModel> searchFieldsById(DescriptionTemplateModel template, String value) {
if (template == null || template.getDefinition() == null) return new ArrayList<>();
return template.getDefinition().getFieldById(value);
}
@Override
public List<FieldModel> searchFieldsBySemantics(DescriptionTemplateModel template, String value) {
if (template == null || template.getDefinition() == null) return new ArrayList<>();
List<FieldModel> fieldModels = template.getDefinition().getAllField();
if (fieldModels == null) return new ArrayList<>();
return fieldModels.stream().filter(x-> x.getSchematics() != null && x.getSchematics().contains(value)).toList();
}
}

View File

@ -1,104 +0,0 @@
package eu.eudat.file.transformer.service.rdafiletransformer;
import eu.eudat.commonmodels.models.FileEnvelopeModel;
import eu.eudat.commonmodels.models.description.DescriptionModel;
import eu.eudat.commonmodels.models.dmp.DmpModel;
import eu.eudat.file.transformer.interfaces.FileTransformerClient;
import eu.eudat.file.transformer.interfaces.FileTransformerConfiguration;
import eu.eudat.file.transformer.models.misc.FileFormat;
import eu.eudat.file.transformer.model.rda.Dataset;
import eu.eudat.file.transformer.model.rda.Dmp;
import eu.eudat.file.transformer.model.rda.RDAModel;
import eu.eudat.file.transformer.model.rda.mapper.DatasetRDAMapper;
import eu.eudat.file.transformer.model.rda.mapper.DmpRDAMapper;
import eu.eudat.file.transformer.service.json.JsonHandlingService;
import eu.eudat.file.transformer.service.storage.FileStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import javax.management.InvalidApplicationException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class RdaFileTransformerService implements FileTransformerClient {
private final DmpRDAMapper dmpRDAMapper;
private final DatasetRDAMapper descriptionRDAMapper;
private final FileStorageService storageService;
private final RdaFileTransformerServiceProperties properties;
private final JsonHandlingService jsonHandlingService;
@Autowired
public RdaFileTransformerService(DmpRDAMapper dmpRDAMapper, DatasetRDAMapper descriptionRDAMapper, FileStorageService storageService, RdaFileTransformerServiceProperties properties, JsonHandlingService jsonHandlingService) {
this.dmpRDAMapper = dmpRDAMapper;
this.descriptionRDAMapper = descriptionRDAMapper;
this.storageService = storageService;
this.properties = properties;
this.jsonHandlingService = jsonHandlingService;
}
@Override
public FileEnvelopeModel exportDmp(DmpModel dmpFileTransformerModel, String variant) throws IOException {
Dmp dmp = this.dmpRDAMapper.toRDA(dmpFileTransformerModel);
RDAModel rdaModel = new RDAModel();
rdaModel.setDmp(dmp);
String dmpJson = jsonHandlingService.toJsonSafe(rdaModel);
byte[] bytes = dmpJson.getBytes(StandardCharsets.UTF_8);
FileEnvelopeModel wordFile = new FileEnvelopeModel();
if (this.getConfiguration().isUseSharedStorage()) {
String fileRef = this.storageService.storeFile(bytes);
wordFile.setFileRef(fileRef);
} else {
wordFile.setFile(bytes);
}
wordFile.setFilename(dmpFileTransformerModel.getLabel() + ".json");
return wordFile;
}
@Override
public FileEnvelopeModel exportDescription(DescriptionModel descriptionFileTransformerModel, String format) throws InvalidApplicationException, IOException {
Dmp dmp = this.dmpRDAMapper.toRDA(descriptionFileTransformerModel.getDmp());
Map<String, Object> datasetExtraData = new HashMap<>();
datasetExtraData.put("dmp", dmp);
Dataset dataset = this.descriptionRDAMapper.toRDA(descriptionFileTransformerModel, datasetExtraData);
String dmpJson = jsonHandlingService.toJsonSafe(dataset);
byte[] bytes = dmpJson.getBytes(StandardCharsets.UTF_8);
FileEnvelopeModel wordFile = new FileEnvelopeModel();
if (this.getConfiguration().isUseSharedStorage()) {
String fileRef = this.storageService.storeFile(bytes);
wordFile.setFileRef(fileRef);
} else {
wordFile.setFile(bytes);
}
wordFile.setFilename(descriptionFileTransformerModel.getLabel() + ".json");
return wordFile;
}
@Override
public DmpModel importDmp(FileEnvelopeModel envelope) {
throw new UnsupportedOperationException("import not supported");
}
@Override
public DescriptionModel importDescription(FileEnvelopeModel envelope) {
throw new UnsupportedOperationException("import not supported");
}
@Override
public FileTransformerConfiguration getConfiguration() {
List<FileFormat> supportedFormats = List.of(new FileFormat("json", false, null));
FileTransformerConfiguration configuration = new FileTransformerConfiguration();
configuration.setFileTransformerId(this.properties.getTransformerId());
configuration.setExportVariants(supportedFormats);
configuration.setImportVariants(null);
configuration.setUseSharedStorage(this.properties.isUseSharedStorage());
return configuration;
}
}

View File

@ -1,9 +0,0 @@
package eu.eudat.file.transformer.service.rdafiletransformer;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties({RdaFileTransformerServiceProperties.class})
public class RdaFileTransformerServiceConfiguration {
}

View File

@ -0,0 +1,15 @@
package org.opencdmp.filetransformer.rda.audit;
import gr.cite.tools.logging.EventId;
public class AuditableAction {
public static final EventId FileTransformer_ExportDmp = new EventId(1000, "FileTransformer_ExportDmp");
public static final EventId FileTransformer_ExportDescription = new EventId(1001, "FileTransformer_ExportDescription");
public static final EventId FileTransformer_ImportFileToDmp = new EventId(1002, "FileTransformer_ImportFileToDmp");
public static final EventId FileTransformer_ImportFileToDescription = new EventId(1003, "FileTransformer_ImportFileToDescription");
public static final EventId FileTransformer_GetSupportedFormats = new EventId(1004, "FileTransformer_GetSupportedFormats");
}

View File

@ -1,5 +1,5 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
@ -54,7 +54,7 @@ public class Contact implements Serializable
@JsonPropertyDescription("Name of the contact person")
private String name;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = -2062619884605400321L;
/**

View File

@ -1,7 +1,8 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
import gr.cite.tools.exception.MyApplicationException;
import java.io.Serializable;
import java.util.HashMap;
@ -43,7 +44,7 @@ public class ContactId implements Serializable
@JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other")
private Type type;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = -7066973565810615822L;
/**
@ -121,7 +122,7 @@ public class ContactId implements Serializable
}
}
private Type(String value) {
Type(String value) {
this.value = value;
}
@ -139,7 +140,7 @@ public class ContactId implements Serializable
public static Type fromValue(String value) {
Type constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,5 +1,5 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@ -68,7 +68,7 @@ public class Contributor implements Serializable
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Set<String> role = null;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = 3452606902359513114L;
/**

View File

@ -1,7 +1,8 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
import gr.cite.tools.exception.MyApplicationException;
import java.io.Serializable;
import java.util.HashMap;
@ -44,7 +45,7 @@ public class ContributorId implements Serializable
@JsonPropertyDescription("Identifier type. Allowed values: orcid, isni, openid, other")
private Type type;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = 3089650417960767482L;
/**
@ -122,7 +123,7 @@ public class ContributorId implements Serializable
}
}
private Type(String value) {
Type(String value) {
this.value = value;
}
@ -140,7 +141,7 @@ public class ContributorId implements Serializable
public static Type fromValue(String value) {
Type constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,7 +1,8 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
import gr.cite.tools.exception.MyApplicationException;
import java.io.Serializable;
import java.util.HashMap;
@ -63,7 +64,7 @@ public class Cost implements Serializable
@JsonPropertyDescription("Value")
private Double value;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = -322637784848035165L;
/**
@ -341,7 +342,7 @@ public class Cost implements Serializable
}
}
private CurrencyCode(String value) {
CurrencyCode(String value) {
this.value = value;
}
@ -359,7 +360,7 @@ public class Cost implements Serializable
public static CurrencyCode fromValue(String value) {
CurrencyCode constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,7 +1,8 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
import gr.cite.tools.exception.MyApplicationException;
import java.io.Serializable;
import java.util.HashMap;
@ -185,7 +186,7 @@ public class Dataset implements Serializable
private String type;
@JsonProperty("additional_properties")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = -6931119120629009399L;
/**
@ -550,7 +551,7 @@ public class Dataset implements Serializable
}
}
private PersonalData(String value) {
PersonalData(String value) {
this.value = value;
}
@ -568,7 +569,7 @@ public class Dataset implements Serializable
public static PersonalData fromValue(String value) {
PersonalData constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}
@ -590,7 +591,7 @@ public class Dataset implements Serializable
}
}
private SensitiveData(String value) {
SensitiveData(String value) {
this.value = value;
}
@ -608,7 +609,7 @@ public class Dataset implements Serializable
public static SensitiveData fromValue(String value) {
SensitiveData constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,7 +1,8 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
import gr.cite.tools.exception.MyApplicationException;
import java.io.Serializable;
import java.util.HashMap;
@ -44,7 +45,7 @@ public class DatasetId implements Serializable
@JsonPropertyDescription("Dataset identifier type. Allowed values: handle, doi, ark, url, other")
private Type type;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = -6295164005851378031L;
public DatasetId() {
@ -131,7 +132,7 @@ public class DatasetId implements Serializable
}
}
private Type(String value) {
Type(String value) {
this.value = value;
}
@ -149,7 +150,7 @@ public class DatasetId implements Serializable
public static Type fromValue(String value) {
Type constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,7 +1,8 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
import gr.cite.tools.exception.MyApplicationException;
import java.io.Serializable;
import java.net.URI;
@ -130,7 +131,7 @@ public class Distribution implements Serializable
private String title;
@JsonProperty("additional_properties")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = -6018365280419917902L;
/**
@ -381,7 +382,7 @@ public class Distribution implements Serializable
}
}
private DataAccess(String value) {
DataAccess(String value) {
this.value = value;
}
@ -399,7 +400,7 @@ public class Distribution implements Serializable
public static DataAccess fromValue(String value) {
DataAccess constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,7 +1,8 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
import gr.cite.tools.exception.MyApplicationException;
import java.io.Serializable;
import java.net.URI;
@ -173,7 +174,7 @@ public class Dmp implements Serializable
private String title;
@JsonProperty("additional_properties")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = 4599713332472772292L;
/**
@ -522,7 +523,7 @@ public class Dmp implements Serializable
}
}
private EthicalIssuesExist(String value) {
EthicalIssuesExist(String value) {
this.value = value;
}
@ -540,7 +541,7 @@ public class Dmp implements Serializable
public static EthicalIssuesExist fromValue(String value) {
EthicalIssuesExist constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,7 +1,8 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
import gr.cite.tools.exception.MyApplicationException;
import java.io.Serializable;
import java.util.HashMap;
@ -44,7 +45,7 @@ public class DmpId implements Serializable
@JsonPropertyDescription("The DMP Identifier Type. Allowed values: handle, doi, ark, url, other")
private Type type;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = -6059908070202476841L;
/**
@ -123,7 +124,7 @@ public class DmpId implements Serializable
}
}
private Type(String value) {
Type(String value) {
this.value = value;
}
@ -141,7 +142,7 @@ public class DmpId implements Serializable
public static Type fromValue(String value) {
Type constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,7 +1,8 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
import gr.cite.tools.exception.MyApplicationException;
import java.io.Serializable;
import java.util.HashMap;
@ -44,7 +45,7 @@ public class FunderId implements Serializable
@JsonPropertyDescription("Identifier type. Allowed values: fundref, url, other")
private Type type;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = 1783349151334366078L;
/**
@ -121,7 +122,7 @@ public class FunderId implements Serializable
}
}
private Type(String value) {
Type(String value) {
this.value = value;
}
@ -139,7 +140,7 @@ public class FunderId implements Serializable
public static Type fromValue(String value) {
Type constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,7 +1,8 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
import gr.cite.tools.exception.MyApplicationException;
import java.io.Serializable;
import java.util.HashMap;
@ -54,7 +55,7 @@ public class Funding implements Serializable
@JsonPropertyDescription("Grant ID of the associated project")
private GrantId grantId;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = 8962229321225336165L;
/**
@ -154,7 +155,7 @@ public class Funding implements Serializable
}
}
private FundingStatus(String value) {
FundingStatus(String value) {
this.value = value;
}
@ -172,7 +173,7 @@ public class Funding implements Serializable
public static FundingStatus fromValue(String value) {
FundingStatus constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,7 +1,8 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
import gr.cite.tools.exception.MyApplicationException;
import java.io.Serializable;
import java.util.HashMap;
@ -44,7 +45,7 @@ public class GrantId implements Serializable
@JsonPropertyDescription("Identifier type. Allowed values: url, other")
private Type type;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = -7738072672837592065L;
/**
@ -120,7 +121,7 @@ public class GrantId implements Serializable
}
}
private Type(String value) {
Type(String value) {
this.value = value;
}
@ -138,7 +139,7 @@ public class GrantId implements Serializable
public static Type fromValue(String value) {
Type constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,7 +1,8 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
import gr.cite.tools.exception.MyApplicationException;
import java.io.Serializable;
import java.net.URI;
@ -137,7 +138,7 @@ public class Host implements Serializable
@JsonPropertyDescription("The URL of the system hosting a distribution of a dataset")
private URI url;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = 8564338806797654115L;
/**
@ -417,7 +418,7 @@ public class Host implements Serializable
}
}
private CertifiedWith(String value) {
CertifiedWith(String value) {
this.value = value;
}
@ -435,7 +436,7 @@ public class Host implements Serializable
public static CertifiedWith fromValue(String value) {
CertifiedWith constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}
@ -703,7 +704,7 @@ public class Host implements Serializable
}
}
private GeoLocation(String value) {
GeoLocation(String value) {
this.value = value;
}
@ -721,7 +722,7 @@ public class Host implements Serializable
public static GeoLocation fromValue(String value) {
GeoLocation constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}
@ -743,7 +744,7 @@ public class Host implements Serializable
}
}
private SupportVersioning(String value) {
SupportVersioning(String value) {
this.value = value;
}
@ -761,7 +762,7 @@ public class Host implements Serializable
public static SupportVersioning fromValue(String value) {
SupportVersioning constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,7 +1,8 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import gr.cite.tools.exception.MyApplicationException;
import java.util.HashMap;
import java.util.Map;
@ -202,7 +203,7 @@ public enum Language {
}
}
private Language(String value) {
Language(String value) {
this.value = value;
}
@ -220,7 +221,7 @@ public enum Language {
public static Language fromValue(String value) {
Language constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,5 +1,5 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
@ -45,7 +45,7 @@ public class License implements Serializable
@JsonPropertyDescription("Starting date of license. If date is set in the future, it indicates embargo period.")
private String startDate;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = 4148207295817559010L;
/**

View File

@ -1,7 +1,8 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
import gr.cite.tools.exception.MyApplicationException;
import java.io.Serializable;
import java.util.HashMap;
@ -44,7 +45,7 @@ public class MetadataStandardId implements Serializable
@JsonPropertyDescription("Identifier type. Allowed values: url, other")
private Type type;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = -7641042701935397947L;
/**
@ -120,7 +121,7 @@ public class MetadataStandardId implements Serializable
}
}
private Type(String value) {
Type(String value) {
this.value = value;
}
@ -138,7 +139,7 @@ public class MetadataStandardId implements Serializable
public static Type fromValue(String value) {
Type constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,5 +1,5 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
@ -55,7 +55,7 @@ public class Metadatum implements Serializable
private MetadataStandardId metadataStandardId;
@JsonProperty("additional_properties")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = 6511312853153406190L;
/**
@ -334,7 +334,7 @@ public class Metadatum implements Serializable
}
}
private Language(String value) {
Language(String value) {
this.value = value;
}
@ -351,12 +351,8 @@ public class Metadatum implements Serializable
@JsonCreator
public static Language fromValue(String value) {
Language constant = CONSTANTS.get(value);
if (constant == null) {
return null;
// throw new IllegalArgumentException(value);
} else {
return constant;
}
// throw new MyApplicationException(value);
return constant;
}
}

View File

@ -1,8 +1,9 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import gr.cite.tools.exception.MyApplicationException;
import java.util.HashMap;
import java.util.Map;
@ -37,7 +38,7 @@ public enum PidSystem {
}
}
private PidSystem(String value) {
PidSystem(String value) {
this.value = value;
}
@ -55,7 +56,7 @@ public enum PidSystem {
public static PidSystem fromValue(String value) {
PidSystem constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
throw new MyApplicationException(value);
} else {
return constant;
}

View File

@ -1,5 +1,5 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
@ -77,7 +77,7 @@ public class Project implements Serializable
@JsonPropertyDescription("Project title")
private String title;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = 1437619307195890472L;
/**

View File

@ -1,5 +1,5 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;

View File

@ -1,5 +1,5 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
@ -45,7 +45,7 @@ public class SecurityAndPrivacy implements Serializable
private String title;
@JsonProperty("additional_properties")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = 7863747935827682977L;
/**

View File

@ -1,5 +1,5 @@
package eu.eudat.file.transformer.model.rda;
package org.opencdmp.filetransformer.rda.model.rda;
import com.fasterxml.jackson.annotation.*;
@ -45,7 +45,7 @@ public class TechnicalResource implements Serializable
private String name;
@JsonProperty("additional_properties")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final Map<String, Object> additionalProperties = new HashMap<String, Object>();
private final static long serialVersionUID = -7451757227129483110L;
/**

View File

@ -0,0 +1,15 @@
package org.opencdmp.filetransformer.rda.service.descriptiontemplatesearcher;
import org.opencdmp.commonmodels.models.descriptiotemplate.DescriptionTemplateModel;
import org.opencdmp.commonmodels.models.descriptiotemplate.FieldModel;
import org.opencdmp.commonmodels.models.descriptiotemplate.FieldSetModel;
import java.util.List;
public interface TemplateFieldSearcherService {
FieldModel findFieldBySemantic(FieldSetModel fieldSetModel, String semantic);
List<FieldSetModel> searchFieldSetsBySemantics(DescriptionTemplateModel template, List<String> Semantics);
List<FieldModel> searchFieldsBySemantics(DescriptionTemplateModel template, String value);
}

View File

@ -0,0 +1,86 @@
package org.opencdmp.filetransformer.rda.service.descriptiontemplatesearcher;
import org.opencdmp.commonmodels.models.descriptiotemplate.*;
import org.springframework.stereotype.Component;
import java.util.*;
@Component
public class TemplateFieldSearcherServiceImpl implements TemplateFieldSearcherService {
@Override
public FieldModel findFieldBySemantic(FieldSetModel fieldSetModel, String semantic){
if (fieldSetModel == null || fieldSetModel.getFields() == null) return null;
List<FieldModel> fieldModels = fieldSetModel.getAllField();
if (fieldModels == null) return null;
return fieldModels.stream().filter(x-> x.getSemantics() != null && x.getSemantics().contains(semantic)).findFirst().orElse(null);
}
@Override
public List<FieldSetModel> searchFieldSetsBySemantics(DescriptionTemplateModel template, List<String> Semantics){
if (template == null || template.getDefinition() == null) return new ArrayList<>();
List<FieldModel> fieldModels = template.getDefinition().getAllField();
if (fieldModels == null) return new ArrayList<>();
fieldModels = fieldModels.stream().filter(x-> x.getSemantics() != null && x.getSemantics().stream().anyMatch(Semantics::contains)).toList();
List<FieldSetModel> response = new ArrayList<>();
HashSet<String> fieldSetIds = new HashSet<>();
for (FieldModel fieldModel : fieldModels){
FieldSetModel fieldSetModel = this.findFieldSet(template, fieldModel);
if (fieldSetIds.contains(fieldSetModel.getId())) continue;
fieldSetIds.add(fieldSetModel.getId());
response.add(fieldSetModel);
}
return response;
}
private FieldSetModel findFieldSet(DescriptionTemplateModel template, FieldModel fieldModel){
if (template == null || template.getDefinition() == null || template.getDefinition().getPages() == null) return null;
for (PageModel pageModel : template.getDefinition().getPages().stream().sorted(Comparator.comparing(PageModel::getOrdinal)).toList()){
FieldSetModel fieldSet = this.findFieldSet(pageModel, fieldModel);
if (fieldSet != null) return fieldSet;
}
return null;
}
private FieldSetModel findFieldSet(PageModel pageModel, FieldModel fieldModel){
if (pageModel == null || pageModel.getSections() == null) return null;
for (SectionModel sectionModel : pageModel.getSections().stream().sorted(Comparator.comparing(SectionModel::getOrdinal)).toList()){
FieldSetModel fieldSet = this.findFieldSet(sectionModel, fieldModel);
if (fieldSet != null) return fieldSet;
}
return null;
}
private FieldSetModel findFieldSet(SectionModel sectionModel, FieldModel fieldModel){
if (sectionModel == null) return null;
if (sectionModel.getSections() != null) {
for (SectionModel innerSectionModel : sectionModel.getSections().stream().sorted(Comparator.comparing(SectionModel::getOrdinal)).toList()) {
FieldSetModel fieldSet = this.findFieldSet(innerSectionModel, fieldModel);
if (fieldSet != null) return fieldSet;
}
}
if (sectionModel.getFieldSets() != null) {
for (FieldSetModel fieldSetModel : sectionModel.getFieldSets().stream().sorted(Comparator.comparing(FieldSetModel::getOrdinal)).toList()) {
FieldSetModel fieldSet = this.findFieldSet(fieldSetModel, fieldModel);
if (fieldSet != null) return fieldSet;
}
}
return null;
}
private FieldSetModel findFieldSet(FieldSetModel fieldSetModel, FieldModel fieldModel){
if (fieldSetModel == null || fieldSetModel.getFields() == null) return null;
for (FieldModel currentFieldModel : fieldSetModel.getFields().stream().sorted(Comparator.comparing(FieldModel::getOrdinal)).toList()){
if (currentFieldModel.getId().equals(fieldModel.getId())) return fieldSetModel;
}
return null;
}
@Override
public List<FieldModel> searchFieldsBySemantics(DescriptionTemplateModel template, String value) {
if (template == null || template.getDefinition() == null) return new ArrayList<>();
List<FieldModel> fieldModels = template.getDefinition().getAllField();
if (fieldModels == null) return new ArrayList<>();
return fieldModels.stream().filter(x-> x.getSemantics() != null && x.getSemantics().contains(value)).toList();
}
}

View File

@ -1,4 +1,4 @@
package eu.eudat.file.transformer.service.json;
package org.opencdmp.filetransformer.rda.service.json;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

View File

@ -0,0 +1,18 @@
package org.opencdmp.filetransformer.rda.service.rdafiletransformer;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties({RdaFileTransformerServiceProperties.class})
public class RdaFileTransformerServiceConfiguration {
private final RdaFileTransformerServiceProperties rdaFileTransformerServiceProperties;
public RdaFileTransformerServiceConfiguration(RdaFileTransformerServiceProperties rdaFileTransformerServiceProperties) {
this.rdaFileTransformerServiceProperties = rdaFileTransformerServiceProperties;
}
public RdaFileTransformerServiceProperties getRdaFileTransformerServiceProperties() {
return rdaFileTransformerServiceProperties;
}
}

View File

@ -1,7 +1,9 @@
package eu.eudat.file.transformer.service.rdafiletransformer;
package org.opencdmp.filetransformer.rda.service.rdafiletransformer;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.Map;
@ConfigurationProperties(prefix = "rda-file-transformer")
public class RdaFileTransformerServiceProperties {
private String transformerId;
@ -14,6 +16,13 @@ public class RdaFileTransformerServiceProperties {
private String projectReferenceCode;
private String datasetReferenceCode;
private String publicationReferenceCode;
private String researcherMalCode;
private String projectStartDateCode;
private String projectEndDateCode;
private String licenseRefCode;
private String licenseStartDateCode;
private Map<String, String> languageMap;
public String getTransformerId() {
@ -95,4 +104,52 @@ public class RdaFileTransformerServiceProperties {
public void setPublicationReferenceCode(String publicationReferenceCode) {
this.publicationReferenceCode = publicationReferenceCode;
}
public String getResearcherMalCode() {
return researcherMalCode;
}
public String getProjectStartDateCode() {
return projectStartDateCode;
}
public void setProjectStartDateCode(String projectStartDateCode) {
this.projectStartDateCode = projectStartDateCode;
}
public String getProjectEndDateCode() {
return projectEndDateCode;
}
public void setProjectEndDateCode(String projectEndDateCode) {
this.projectEndDateCode = projectEndDateCode;
}
public void setResearcherMalCode(String researcherMalCode) {
this.researcherMalCode = researcherMalCode;
}
public Map<String, String> getLanguageMap() {
return languageMap;
}
public void setLanguageMap(Map<String, String> languageMap) {
this.languageMap = languageMap;
}
public String getLicenseRefCode() {
return licenseRefCode;
}
public void setLicenseRefCode(String licenseRefCode) {
this.licenseRefCode = licenseRefCode;
}
public String getLicenseStartDateCode() {
return licenseStartDateCode;
}
public void setLicenseStartDateCode(String licenseStartDateCode) {
this.licenseStartDateCode = licenseStartDateCode;
}
}

View File

@ -1,4 +1,4 @@
package eu.eudat.file.transformer.service.storage;
package org.opencdmp.filetransformer.rda.service.storage;
public interface FileStorageService {
String storeFile(byte[] data);

View File

@ -1,4 +1,4 @@
package eu.eudat.file.transformer.service.storage;
package org.opencdmp.filetransformer.rda.service.storage;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

View File

@ -1,6 +1,6 @@
package eu.eudat.file.transformer.service.storage;
package org.opencdmp.filetransformer.rda.service.storage;
import org.slf4j.Logger;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -11,8 +11,8 @@ import java.util.UUID;
@Service
public class FileStorageServiceImpl implements FileStorageService {
private final static Logger logger = LoggerFactory.getLogger(FileStorageServiceImpl.class);
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(FileStorageServiceImpl.class));
private final FileStorageServiceProperties properties;
@Autowired

View File

@ -1,4 +1,4 @@
package eu.eudat.file.transformer.service.storage;
package org.opencdmp.filetransformer.rda.service.storage;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.bind.ConstructorBinding;

View File

@ -1,4 +1,4 @@
package eu.eudat.file.transformer.utils.string;
package org.opencdmp.filetransformer.rda.utils.string;
public class MyStringUtils {

31
pom.xml
View File

@ -5,11 +5,11 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.3</version>
<version>3.2.4</version>
<relativePath/>
</parent>
<groupId>gr.cite.opendmp</groupId>
<groupId>org.opencdmp</groupId>
<artifactId>file-transformer-rda-parent</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
@ -18,6 +18,8 @@
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.release>21</maven.compiler.release>
<log4j.version>1.2.17</log4j.version>
<log4j2.version>2.15.0</log4j2.version>
<revision>1.0.0-SNAPSHOT</revision>
</properties>
@ -25,7 +27,17 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.0</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.opencdmp</groupId>
<artifactId>file-transformer-base</artifactId>
<version>0.0.22</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>
<artifactId>logging</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
@ -51,6 +63,19 @@
</repository>
</distributionManagement>
</profile>
<profile>
<id>cite-dev</id>
<repositories>
<repository>
<id>cite-maven</id>
<name>CITE Maven Repository</name>
<url>https://crepo.cite.gr/repository/cite-maven/</url>
</repository>
</repositories>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
</project>

View File

@ -1,29 +1,33 @@
<settings>
<pluginGroups>
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<servers>
<server>
<id>ossrh</id>
<username>${server_username}</username>
<password>${server_password}</password>
</server>
<server>
<id>dev</id>
<id>cite-repo</id>
<username>${server_username}</username>
<password>${server_password}</password>
</server>
</servers>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<id>release</id>
<repositories>
<repository>
<id>dev</id>
<name>Dev Profile</name>
<url>${devProfileUrl}</url>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>cite-repo</id>
<name>CITE Maven Repo</name>
<url>${citeMavenRepoUrl}</url>
</repository>
</repositories>
</profile>
</profiles>
</settings>
</settings>

View File

@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>gr.cite.opendmp</groupId>
<groupId>org.opencdmp</groupId>
<artifactId>file-transformer-rda-parent</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
@ -22,7 +22,7 @@
<dependencies>
<dependency>
<groupId>gr.cite.opendmp</groupId>
<groupId>org.opencdmp</groupId>
<artifactId>file-transformer-rda</artifactId>
<version>${revision}</version>
</dependency>
@ -33,7 +33,7 @@
<dependency>
<groupId>gr.cite</groupId>
<artifactId>oidc-authn</artifactId>
<version>2.1.0</version>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>gr.cite</groupId>
@ -44,6 +44,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>gr.cite</groupId>
<artifactId>exceptions</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
<build>

View File

@ -1,43 +0,0 @@
package eu.eudat.file.transformer.controller;
import eu.eudat.commonmodels.models.FileEnvelopeModel;
import eu.eudat.commonmodels.models.description.DescriptionModel;
import eu.eudat.commonmodels.models.dmp.DmpModel;
import eu.eudat.file.transformer.interfaces.FileTransformerClient;
import eu.eudat.file.transformer.interfaces.FileTransformerConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/file-transformer")
public class FileTransformerController implements eu.eudat.file.transformer.interfaces.FileTransformerController {
private final FileTransformerClient fileTransformerExecutor;
@Autowired
public FileTransformerController(FileTransformerClient fileTransformerExecutor) {
this.fileTransformerExecutor = fileTransformerExecutor;
}
public FileEnvelopeModel exportDmp(@RequestBody DmpModel dmpDepositModel, @RequestParam(value = "format",required = false)String format) throws Exception {
return fileTransformerExecutor.exportDmp(dmpDepositModel, format);
}
public FileEnvelopeModel exportDescription(@RequestBody DescriptionModel descriptionModel, @RequestParam(value = "format",required = false)String format) throws Exception {
return fileTransformerExecutor.exportDescription(descriptionModel, format);
}
public DmpModel importFileToDmp(@RequestBody FileEnvelopeModel fileEnvelope) {
return fileTransformerExecutor.importDmp(fileEnvelope);
}
public DescriptionModel importFileToDescription(@RequestBody FileEnvelopeModel fileEnvelope) {
return fileTransformerExecutor.importDescription(fileEnvelope);
}
public FileTransformerConfiguration getSupportedFormats() {
return fileTransformerExecutor.getConfiguration();
}
}

View File

@ -1,10 +1,11 @@
package eu.eudat.file.transformer;
package org.opencdmp.filetransformer.rda;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(scanBasePackages = {
"eu.eudat.file.transformer.*",
"org.opencdmp.filetransformerbase.*",
"org.opencdmp.filetransformer.rda.*",
"gr.cite.tools",
"gr.cite.commons"
})

View File

@ -1,4 +1,4 @@
package eu.eudat.file.transformer.config;
package org.opencdmp.filetransformer.rda.config;
import gr.cite.commons.web.oidc.configuration.WebSecurityProperties;
import gr.cite.commons.web.oidc.configuration.filter.ApiKeyFilter;

View File

@ -0,0 +1,90 @@
package org.opencdmp.filetransformer.rda.controller;
import gr.cite.tools.auditing.AuditService;
import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry;
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
import org.opencdmp.commonmodels.models.description.DescriptionModel;
import org.opencdmp.commonmodels.models.dmp.DmpModel;
import org.opencdmp.filetransformer.rda.audit.AuditableAction;
import org.opencdmp.filetransformerbase.interfaces.FileTransformerClient;
import org.opencdmp.filetransformerbase.interfaces.FileTransformerConfiguration;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.AbstractMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api/file-transformer")
public class FileTransformerController implements org.opencdmp.filetransformerbase.interfaces.FileTransformerController {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(FileTransformerController.class));
private final FileTransformerClient fileTransformerExecutor;
private final AuditService auditService;
@Autowired
public FileTransformerController(FileTransformerClient fileTransformerExecutor, AuditService auditService) {
this.fileTransformerExecutor = fileTransformerExecutor;
this.auditService = auditService;
}
public FileEnvelopeModel exportDmp(@RequestBody DmpModel dmpDepositModel, @RequestParam(value = "format",required = false)String format) throws Exception {
logger.debug(new MapLogEntry("exportDmp " + DmpModel.class.getSimpleName()).And("dmpDepositModel", dmpDepositModel).And("format", format));
FileEnvelopeModel model = fileTransformerExecutor.exportDmp(dmpDepositModel, format);
this.auditService.track(AuditableAction.FileTransformer_ExportDmp, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("dmpDepositModel", dmpDepositModel),
new AbstractMap.SimpleEntry<String, Object>("format", format)
));
return model;
}
public FileEnvelopeModel exportDescription(@RequestBody DescriptionModel descriptionModel, @RequestParam(value = "format",required = false)String format) throws Exception {
logger.debug(new MapLogEntry("exportDescription " + DescriptionModel.class.getSimpleName()).And("descriptionModel", descriptionModel).And("format", format));
FileEnvelopeModel model = fileTransformerExecutor.exportDescription(descriptionModel, format);
this.auditService.track(AuditableAction.FileTransformer_ExportDescription, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("descriptionModel", descriptionModel),
new AbstractMap.SimpleEntry<String, Object>("format", format)
));
return model;
}
public DmpModel importFileToDmp(@RequestBody FileEnvelopeModel fileEnvelope) {
logger.debug(new MapLogEntry("importFileToDmp " + FileEnvelopeModel.class.getSimpleName()).And("fileEnvelope", fileEnvelope));
DmpModel model = fileTransformerExecutor.importDmp(fileEnvelope);
this.auditService.track(AuditableAction.FileTransformer_ImportFileToDmp, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("fileEnvelope", fileEnvelope)
));
return model;
}
public DescriptionModel importFileToDescription(@RequestBody FileEnvelopeModel fileEnvelope) {
logger.debug(new MapLogEntry("importFileToDescription " + FileEnvelopeModel.class.getSimpleName()).And("fileEnvelope", fileEnvelope));
DescriptionModel model = fileTransformerExecutor.importDescription(fileEnvelope);
this.auditService.track(AuditableAction.FileTransformer_ImportFileToDescription, Map.ofEntries(
new AbstractMap.SimpleEntry<String, Object>("importFileToDescription ", fileEnvelope)
));
return model;
}
public FileTransformerConfiguration getSupportedFormats() {
logger.debug(new MapLogEntry("getSupportedFormats"));
FileTransformerConfiguration model = fileTransformerExecutor.getConfiguration();
this.auditService.track(AuditableAction.FileTransformer_GetSupportedFormats);
return model;
}
}

View File

@ -0,0 +1,202 @@
package org.opencdmp.filetransformer.rda.controller.controllerhandler;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import gr.cite.tools.exception.*;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.WebRequest;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
@RestControllerAdvice
@ControllerAdvice
public class GlobalExceptionHandler {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(GlobalExceptionHandler.class));
private final ObjectMapper objectMapper;
public GlobalExceptionHandler() {
this.objectMapper = new ObjectMapper();
this.objectMapper.registerModule(new JavaTimeModule());
}
@ExceptionHandler(Exception.class)
public ResponseEntity<?> handleUnexpectedErrors(Exception exception, WebRequest request) throws Exception {
HandledException handled = this.handleException(exception, request);
this.log(handled.getLevel(), exception, MessageFormat.format("returning code {0} and payload {1}", handled.getStatusCode(), handled.getMessage()));
return new ResponseEntity<>(handled.getMessage(), handled.getStatusCode());
}
public String toJsonSafe(Object item) {
if (item == null) return null;
try {
return this.objectMapper.writeValueAsString(item);
} catch (Exception ex) {
return null;
}
}
public void log(System.Logger.Level level, Exception e, String message) {
if (level != null) {
switch (level) {
case TRACE:
logger.trace(message, e);
break;
case DEBUG:
logger.debug(message, e);
break;
case INFO:
logger.info(message, e);
break;
case WARNING:
logger.warn(message, e);
break;
case ERROR:
logger.error(message, e);
break;
default:
logger.error(e);
}
} else {
logger.error(e);
}
}
public HandledException handleException(Exception exception, WebRequest request) throws Exception {
HttpStatus statusCode;
Map<String, Object> result;
System.Logger.Level logLevel;
switch (exception){
case MyNotFoundException myNotFoundException -> {
logLevel = System.Logger.Level.DEBUG;
statusCode = HttpStatus.NOT_FOUND;
int code = myNotFoundException.getCode();
if (code > 0) {
result = Map.ofEntries(
Map.entry("code", code),
Map.entry("error", myNotFoundException.getMessage())
);
}
else {
result = Map.ofEntries(
Map.entry("error", myNotFoundException.getMessage())
);
}
}
case MyUnauthorizedException myUnauthorizedException -> {
logLevel = System.Logger.Level.DEBUG;
statusCode = HttpStatus.UNAUTHORIZED;
int code = myUnauthorizedException.getCode();
if (code > 0) {
result = Map.ofEntries(
Map.entry("code", code),
Map.entry("error", myUnauthorizedException.getMessage())
);
}
else {
result = Map.ofEntries(
Map.entry("error", myUnauthorizedException.getMessage())
);
}
}
case MyForbiddenException myForbiddenException -> {
logLevel = System.Logger.Level.DEBUG;
statusCode = HttpStatus.FORBIDDEN;
int code = myForbiddenException.getCode();
if (code > 0) {
result = Map.ofEntries(
Map.entry("code", code),
Map.entry("error", myForbiddenException.getMessage())
);
}
else {
result = Map.ofEntries(
Map.entry("error", myForbiddenException.getMessage())
);
}
}
case MyValidationException myValidationException -> {
logLevel = System.Logger.Level.DEBUG;
statusCode = HttpStatus.BAD_REQUEST;
int code = myValidationException.getCode();
result = new HashMap<>();
if (code > 0) result.put("code", code);
if (myValidationException.getMessage() != null) result.put("error", myValidationException.getMessage());
if (myValidationException.getErrors() != null) result.put("message", myValidationException.getErrors());
}
case MyApplicationException myApplicationException -> {
logLevel = System.Logger.Level.ERROR;
statusCode = HttpStatus.INTERNAL_SERVER_ERROR;
int code = myApplicationException.getCode();
if (code > 0) {
result = Map.ofEntries(
Map.entry("code", code),
Map.entry("error", myApplicationException.getMessage())
);
}
else {
result = Map.ofEntries(
Map.entry("error", myApplicationException.getMessage())
);
}
}
default -> {
logLevel = System.Logger.Level.ERROR;
statusCode = HttpStatus.INTERNAL_SERVER_ERROR;
result = Map.ofEntries(
Map.entry("error", "System error")
);
}
}
String serialization = this.toJsonSafe(result);
return new HandledException(statusCode, serialization, logLevel);
}
public static class HandledException{
public HttpStatus statusCode;
public String message;
public System.Logger.Level level;
public HandledException(HttpStatus statusCode, String message, System.Logger.Level level) {
this.statusCode = statusCode;
this.message = message;
this.level = level;
}
public HttpStatus getStatusCode() {
return statusCode;
}
public void setStatusCode(HttpStatus statusCode) {
this.statusCode = statusCode;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public System.Logger.Level getLevel() {
return level;
}
public void setLevel(System.Logger.Level level) {
this.level = level;
}
}
}

View File

@ -7,5 +7,7 @@ spring:
optional:classpath:config/storage.yml[.yml], optional:classpath:config/storage-${spring.profiles.active}.yml[.yml], optional:file:../config/storage-${spring.profiles.active}.yml[.yml],
optional:classpath:config/security.yml[.yml], optional:classpath:config/security-${spring.profiles.active}.yml[.yml], optional:file:../config/security-${spring.profiles.active}.yml[.yml],
optional:classpath:config/cache.yml[.yml], optional:classpath:config/cache-${spring.profiles.active}.yml[.yml], optional:file:../config/cache-${spring.profiles.active}.yml[.yml],
optional:classpath:config/rda-file-transformer.yml[.yml], optional:classpath:config/rda-file-transformer-${spring.profiles.active}.yml[.yml], optional:file:../config/rda-file-transformer-${spring.profiles.active}.yml[.yml]
optional:classpath:config/rda-file-transformer.yml[.yml], optional:classpath:config/rda-file-transformer-${spring.profiles.active}.yml[.yml], optional:file:../config/rda-file-transformer-${spring.profiles.active}.yml[.yml],
optional:classpath:config/logging.yml[.yml], optional:classpath:config/logging-${spring.profiles.active}.yml[.yml], optional:file:../config/logging-${spring.profiles.active}.yml[.yml],
optional:classpath:config/idpclaims.yml[.yml], optional:classpath:config/idpclaims-${spring.profiles.active}.yml[.yml], optional:file:../config/idpclaims-${spring.profiles.active}.yml[.yml]

View File

@ -0,0 +1,41 @@
idpclient:
claims:
mapping:
Subject:
- type: sub
Name:
- type: name
Client:
- type: client_id
AuthenticationMethod:
- type: amr
NotBefore:
- type: nbf
AuthenticatedAt:
- type: auth_time
ExpiresAt:
- type: exp
Email:
- type: email
Roles:
- type: resource_access
path: dmp_zenodo_bridge.roles
Scope:
- type: scope
AccessToken:
- type: x-access-token
visibility: SENSITIVE
IssuedAt:
- type: iat
Issuer:
- type: iss
Audience:
- type: aud
TokenType:
- type: typ
AuthorizedParty:
- type: azp
Authorities:
- type: authorities
ExternalProviderName:
- type: identity_provider

View File

@ -0,0 +1,36 @@
logging:
config: classpath:logging/logback-${spring.profiles.active}.xml
context:
request:
requestIdKey: req.id
requestRemoteHostKey: req.remoteHost
requestUriKey: req.requestURI
requestQueryStringKey: req.queryString
requestUrlKey : req.requestURL
requestMethodKey: req.method
requestUserAgentKey: req.userAgent
requestForwardedForKey: req.xForwardedFor
requestSchemeKey: req.scheme
requestRemoteAddressKey: req.remoteAddr
requestRemotePortKey: req.remotePort
requestRemoteUserKey: req.remoteUser
principal:
subjectKey: usr.subject
nameKey: usr.name
clientKey: usr.client
audit:
enable: true
requestRemoteHostKey: req.remoteHost
requestUriKey: req.requestURI
requestQueryStringKey: req.queryString
requestUrlKey : req.requestURL
requestMethodKey: req.method
requestUserAgentKey: req.userAgent
requestForwardedForKey: req.xForwardedFor
requestSchemeKey: req.scheme
requestRemoteAddressKey: req.remoteAddr
requestRemotePortKey: req.remotePort
requestRemoteUserKey: req.remoteUser
principalSubjectKey: usr.subject
principalNameKey: usr.name
principalClientKey: usr.client

View File

@ -0,0 +1,35 @@
logging:
context:
request:
requestIdKey: req.id
requestRemoteHostKey: req.remoteHost
requestUriKey: req.requestURI
requestQueryStringKey: req.queryString
requestUrlKey : req.requestURL
requestMethodKey: req.method
requestUserAgentKey: req.userAgent
requestForwardedForKey: req.xForwardedFor
requestSchemeKey: req.scheme
requestRemoteAddressKey: req.remoteAddr
requestRemotePortKey: req.remotePort
requestRemoteUserKey: req.remoteUser
principal:
subjectKey: usr.subject
nameKey: usr.name
clientKey: usr.client
audit:
enable: true
requestRemoteHostKey: req.remoteHost
requestUriKey: req.requestURI
requestQueryStringKey: req.queryString
requestUrlKey : req.requestURL
requestMethodKey: req.method
requestUserAgentKey: req.userAgent
requestForwardedForKey: req.xForwardedFor
requestSchemeKey: req.scheme
requestRemoteAddressKey: req.remoteAddr
requestRemotePortKey: req.remotePort
requestRemoteUserKey: req.remoteUser
principalSubjectKey: usr.subject
principalNameKey: usr.name
principalClientKey: usr.client

View File

@ -1,2 +1,2 @@
rda-file-transformer:
useSharedStorage: true
useSharedStorage: false

View File

@ -1,5 +1,5 @@
rda-file-transformer:
transformerId: "json"
transformerId: "rda-file-transformer"
organizationReferenceCode: "organisations"
grantReferenceCode: "grants"
funderReferenceCode: "funders"
@ -8,3 +8,194 @@ rda-file-transformer:
projectReferenceCode: "projects"
datasetReferenceCode: "datasets"
publicationReferenceCode: "publications"
researcherMalCode: "primaryEmail"
projectStartDateCode: "startDate"
projectEndDateCode: "endDate"
licenseRefCode: "license_ref"
licenseStartDateCode: "start_date"
language-map:
aa: aar
ab: abk
af: afr
ak: aka
am: amh
ar: ara
an: arg
as: asm
av: ava
ae: ave
ay: aym
az: aze
ba: bak
bm: bam
be: bel
bn: ben
bi: bis
bo: bod
bs: bos
br: bre
bg: bul
ca: cat
cs: ces
ch: cha
ce: che
cu: chu
cv: chv
kw: cor
co: cos
cr: cre
cy: cym
da: dan
de: deu
dv: div
dz: dzo
el: ell
en: eng
eo: epo
et: est
eu: eus
ee: ewe
fo: fao
fa: fas
fj: fij
fi: fin
fr: fra
fy: fry
ff: ful
gd: gla
ga: gle
gl: glg
gv: glv
gn: grn
gu: guj
ht: hat
ha: hau
sh: hbs
he: heb
hz: her
hi: hin
ho: hmo
hr: hrv
hu: hun
hy: hye
ig: ibo
io: ido
ii: iii
iu: iku
ie: ile
ia: ina
id: ind
ik: ipk
is: isl
it: ita
jv: jav
ja: jpn
kl: kal
kn: kan
ks: kas
ka: kat
kr: kau
kk: kaz
km: khm
ki: kik
rw: kin
ky: kir
kv: kom
kg: kon
ko: kor
kj: kua
ku: kur
lo: lao
la: lat
lv: lav
li: lim
ln: lin
lt: lit
lb: ltz
lu: lub
lg: lug
mh: mah
ml: mal
mr: mar
mk: mkd
mg: mlg
mt: mlt
mn: mon
mi: mri
ms: msa
my: mya
na: nau
nv: nav
nr: nbl
nd: nde
ng: ndo
ne: nep
nl: nld
nn: nno
nb: nob
'no': nor
ny: nya
oc: oci
oj: oji
or: ori
om: orm
os: oss
pa: pan
pi: pli
pl: pol
pt: por
ps: pus
qu: que
rm: roh
ro: ron
rn: run
ru: rus
sg: sag
sa: san
si: sin
sk: slk
sl: slv
se: sme
sm: smo
sn: sna
sd: snd
so: som
st: sot
es: spa
sq: sqi
sc: srd
sr: srp
ss: ssw
su: sun
sw: swa
sv: swe
ty: tah
ta: tam
tt: tat
te: tel
tg: tgk
tl: tgl
th: tha
ti: tir
to: ton
tn: tsn
ts: tso
tk: tuk
tr: tur
tw: twi
ug: uig
uk: ukr
ur: urd
uz: uzb
ve: ven
vi: vie
vo: vol
wa: wln
wo: wol
xh: xho
yi: yid
yo: yor
za: zha
zh: zho
zu: zul

File diff suppressed because one or more lines are too long

View File

@ -1,13 +0,0 @@
<fetchConfig>
<configs>
<config>
<type>currency</type>
<fileType>xml</fileType>
<filePath>internal/iso-4217.xml</filePath>
<parseClass>eu.eudat.logic.proxy.fetching.entities.CurrencyModel</parseClass>
<parseField>currencies</parseField>
<name>currency</name>
<value>code</value>
</config>
</configs>
</fetchConfig>

File diff suppressed because it is too large Load Diff

View File

@ -1,186 +0,0 @@
{
"aar": "aa",
"abk": "ab",
"afr": "af",
"aka": "ak",
"amh": "am",
"ara": "ar",
"arg": "an",
"asm": "as",
"ava": "av",
"ave": "ae",
"aym": "ay",
"aze": "az",
"bak": "ba",
"bam": "bm",
"bel": "be",
"ben": "bn",
"bis": "bi",
"bod": "bo",
"bos": "bs",
"bre": "br",
"bul": "bg",
"cat": "ca",
"ces": "cs",
"cha": "ch",
"che": "ce",
"chu": "cu",
"chv": "cv",
"cor": "kw",
"cos": "co",
"cre": "cr",
"cym": "cy",
"dan": "da",
"deu": "de",
"div": "dv",
"dzo": "dz",
"ell": "el",
"eng": "en",
"epo": "eo",
"est": "et",
"eus": "eu",
"ewe": "ee",
"fao": "fo",
"fas": "fa",
"fij": "fj",
"fin": "fi",
"fra": "fr",
"fry": "fy",
"ful": "ff",
"gla": "gd",
"gle": "ga",
"glg": "gl",
"glv": "gv",
"grn": "gn",
"guj": "gu",
"hat": "ht",
"hau": "ha",
"hbs": "sh",
"heb": "he",
"her": "hz",
"hin": "hi",
"hmo": "ho",
"hrv": "hr",
"hun": "hu",
"hye": "hy",
"ibo": "ig",
"ido": "io",
"iii": "ii",
"iku": "iu",
"ile": "ie",
"ina": "ia",
"ind": "id",
"ipk": "ik",
"isl": "is",
"ita": "it",
"jav": "jv",
"jpn": "ja",
"kal": "kl",
"kan": "kn",
"kas": "ks",
"kat": "ka",
"kau": "kr",
"kaz": "kk",
"khm": "km",
"kik": "ki",
"kin": "rw",
"kir": "ky",
"kom": "kv",
"kon": "kg",
"kor": "ko",
"kua": "kj",
"kur": "ku",
"lao": "lo",
"lat": "la",
"lav": "lv",
"lim": "li",
"lin": "ln",
"lit": "lt",
"ltz": "lb",
"lub": "lu",
"lug": "lg",
"mah": "mh",
"mal": "ml",
"mar": "mr",
"mkd": "mk",
"mlg": "mg",
"mlt": "mt",
"mon": "mn",
"mri": "mi",
"msa": "ms",
"mya": "my",
"nau": "na",
"nav": "nv",
"nbl": "nr",
"nde": "nd",
"ndo": "ng",
"nep": "ne",
"nld": "nl",
"nno": "nn",
"nob": "nb",
"nor": "no",
"nya": "ny",
"oci": "oc",
"oji": "oj",
"ori": "or",
"orm": "om",
"oss": "os",
"pan": "pa",
"pli": "pi",
"pol": "pl",
"por": "pt",
"pus": "ps",
"que": "qu",
"roh": "rm",
"ron": "ro",
"run": "rn",
"rus": "ru",
"sag": "sg",
"san": "sa",
"sin": "si",
"slk": "sk",
"slv": "sl",
"sme": "se",
"smo": "sm",
"sna": "sn",
"snd": "sd",
"som": "so",
"sot": "st",
"spa": "es",
"sqi": "sq",
"srd": "sc",
"srp": "sr",
"ssw": "ss",
"sun": "su",
"swa": "sw",
"swe": "sv",
"tah": "ty",
"tam": "ta",
"tat": "tt",
"tel": "te",
"tgk": "tg",
"tgl": "tl",
"tha": "th",
"tir": "ti",
"ton": "to",
"tsn": "tn",
"tso": "ts",
"tuk": "tk",
"tur": "tr",
"twi": "tw",
"uig": "ug",
"ukr": "uk",
"urd": "ur",
"uzb": "uz",
"ven": "ve",
"vie": "vi",
"vol": "vo",
"wln": "wa",
"wol": "wo",
"xho": "xh",
"yid": "yi",
"yor": "yo",
"zha": "za",
"zho": "zh",
"zul": "zu"
}

View File

@ -0,0 +1,62 @@
<configuration debug="true">
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%date{ISO8601} [%thread] %-5level %logger{36} [%X{req.id}] - %message%n</Pattern>
</encoder>
</appender>
<appender name="TROUBLESHOOTING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/logging.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/logging.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>15</maxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%date{ISO8601} [%thread] %-5level %logger{36} [%X{req.id}] - %message%n</Pattern>
</encoder>
</appender>
<appender name="AUDITING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/auditing.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/auditing.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>15</maxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%date{ISO8601} - %X{req.id} - %message%n</Pattern>
</encoder>
</appender>
<logger name="org.springframework.web" level="INFO" additivity="false">
<appender-ref ref="TROUBLESHOOTING"/>
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.hibernate" level="INFO" additivity="false">
<appender-ref ref="TROUBLESHOOTING"/>
<appender-ref ref="STDOUT"/>
</logger>
<logger name="gr.cite" level="DEBUG" additivity="false">
<appender-ref ref="TROUBLESHOOTING"/>
<appender-ref ref="STDOUT"/>
</logger>
<logger name="org.opencdmp" level="DEBUG" additivity="false">
<appender-ref ref="TROUBLESHOOTING"/>
<appender-ref ref="STDOUT"/>
</logger>
<logger name="audit" level="INFO" additivity="false">
<appender-ref ref="AUDITING"/>
<appender-ref ref="STDOUT"/>
</logger>
<root level="info">
<appender-ref ref="TROUBLESHOOTING"/>
<appender-ref ref="STDOUT"/>
</root>
</configuration>

View File

@ -1,100 +0,0 @@
{
"pidLinks": [
{
"pid": "doi",
"link": "https://doi.org/{pid}"
},
{
"pid": "uniprot",
"link": "https://uniprot.org/uniprotkb/{pid}"
},
{
"pid": "handle",
"link": "https://hdl.handle.net/{pid}"
},
{
"pid": "arxiv",
"link": "https://arxiv.org/abs/{pid}"
},
{
"pid": "ascl",
"link": "https://ascl.net/{pid}"
},
{
"pid": "orcid",
"link": "https://orcid.org/{pid}"
},
{
"pid": "pmid",
"link": "https://pubmed.ncbi.nlm.nih.gov/{pid}"
},
{
"pid": "ads",
"link": "https://ui.adsabs.harvard.edu/#abs/{pid}"
},
{
"pid": "pmcid",
"link": "https://ncbi.nlm.nih.gov/pmc/{pid}"
},
{
"pid": "gnd",
"link": "https://d-nb.info/gnd/{pid}"
},
{
"pid": "urn",
"link": "https://nbn-resolving.org/{pid}"
},
{
"pid": "sra",
"link": "https://ebi.ac.uk/ena/data/view/{pid}"
},
{
"pid": "bioproject",
"link": "https://ebi.ac.uk/ena/data/view/{pid}"
},
{
"pid": "biosample",
"link": "https://ebi.ac.uk/ena/data/view/{pid}"
},
{
"pid": "ensembl",
"link": "https://ensembl.org/id/{pid}"
},
{
"pid": "refseq",
"link": "https://ncbi.nlm.nih.gov/entrez/viewer.fcgi?val={pid}"
},
{
"pid": "genome",
"link": "https://ncbi.nlm.nih.gov/assembly/{pid}"
},
{
"pid": "geo",
"link": "https://ncbi.nlm.nih.gov/geo/query/acc.cgi?acc={pid}"
},
{
"pid": "arrayexpress_array",
"link": "https://ebi.ac.uk/arrayexpress/arrays/{pid}"
},
{
"pid": "arrayexpress_experiment",
"link": "https://ebi.ac.uk/arrayexpress/experiments/{pid}"
},
{
"pid": "hal",
"link": "https://hal.archives-ouvertes.fr/{pid}"
},
{
"pid": "swh",
"link": "https://archive.softwareheritage.org/{pid}"
},
{
"pid": "ror",
"link": "https://ror.org/{pid}"
},
{
"pid": "viaf",
"link": "https://viaf.org/viaf/{pid}"
}
]
}