Compare commits
56 Commits
master
...
update-con
@ -1,30 +0,0 @@
|
||||
package eu.eudat.configurations;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.Module;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import eu.eudat.criteria.entities.Criteria;
|
||||
import eu.eudat.criteria.serialzier.CriteriaSerializer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Configuration
|
||||
public class JacksonConfiguration {
|
||||
@Bean
|
||||
public ObjectMapper buildObjectMapper() {
|
||||
|
||||
ArrayList<Module> modules = new ArrayList<>();
|
||||
SimpleModule criteriaSerializerModule = new SimpleModule();
|
||||
criteriaSerializerModule.addDeserializer(Criteria.class, new CriteriaSerializer());
|
||||
modules.add(criteriaSerializerModule);
|
||||
|
||||
return new ObjectMapper()
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
.registerModules(modules);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package eu.eudat.configurations.file;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties({TmpProperties.class, PermProperties.class})
|
||||
public class FileTimeConfiguration {
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package eu.eudat.configurations.file;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "perm")
|
||||
public class PermProperties {
|
||||
|
||||
private TimeProperties time;
|
||||
|
||||
public TimeProperties getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(TimeProperties time) {
|
||||
this.time = time;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package eu.eudat.configurations.file;
|
||||
|
||||
public class StartTimeProperties {
|
||||
private Integer month;
|
||||
private String dayOfWeekName;
|
||||
private Integer dayOfWeek;
|
||||
|
||||
private Integer dayOfMonth;
|
||||
private Integer hour;
|
||||
private Integer minute;
|
||||
|
||||
public Integer getMonth() {
|
||||
return month;
|
||||
}
|
||||
|
||||
public void setMonth(Integer month) {
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
public String getDayOfWeekName() {
|
||||
return dayOfWeekName;
|
||||
}
|
||||
|
||||
public void setDayOfWeekName(String dayOfWeekName) {
|
||||
this.dayOfWeekName = dayOfWeekName;
|
||||
}
|
||||
|
||||
public Integer getDayOfWeek() {
|
||||
return dayOfWeek;
|
||||
}
|
||||
|
||||
public void setDayOfWeek(Integer dayOfWeek) {
|
||||
this.dayOfWeek = dayOfWeek;
|
||||
}
|
||||
|
||||
public Integer getDayOfMonth() {
|
||||
return dayOfMonth;
|
||||
}
|
||||
|
||||
public void setDayOfMonth(Integer dayOfMonth) {
|
||||
this.dayOfMonth = dayOfMonth;
|
||||
}
|
||||
|
||||
public Integer getHour() {
|
||||
return hour;
|
||||
}
|
||||
|
||||
public void setHour(Integer hour) {
|
||||
this.hour = hour;
|
||||
}
|
||||
|
||||
public Integer getMinute() {
|
||||
return minute;
|
||||
}
|
||||
|
||||
public void setMinute(Integer minute) {
|
||||
this.minute = minute;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package eu.eudat.configurations.file;
|
||||
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
public class TimeProperties {
|
||||
private Integer interval;
|
||||
private ChronoUnit timeUnit;
|
||||
private StartTimeProperties startTime;
|
||||
|
||||
public Integer getInterval() {
|
||||
return interval;
|
||||
}
|
||||
|
||||
public void setInterval(Integer interval) {
|
||||
this.interval = interval;
|
||||
}
|
||||
|
||||
public ChronoUnit getTimeUnit() {
|
||||
return timeUnit;
|
||||
}
|
||||
|
||||
public void setTimeUnit(ChronoUnit timeUnit) {
|
||||
this.timeUnit = timeUnit;
|
||||
}
|
||||
|
||||
public StartTimeProperties getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(StartTimeProperties startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package eu.eudat.configurations.file;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "tmp")
|
||||
public class TmpProperties {
|
||||
|
||||
private TimeProperties time;
|
||||
|
||||
public TimeProperties getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(TimeProperties time) {
|
||||
this.time = time;
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package eu.eudat.logic.utilities.helpers;
|
||||
|
||||
import eu.eudat.models.data.components.commons.datafield.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class FieldFactory {
|
||||
private static final Logger logger = LoggerFactory.getLogger(FieldFactory.class);
|
||||
private static final Map<String, Class<? extends FieldData>> fieldMap = Stream.of(new Object[][]{
|
||||
{"combobox", ComboBoxData.class},
|
||||
{"autocomplete", AutoCompleteData.class},
|
||||
{"wordlist", WordListData.class},
|
||||
{"internalDmpEntities", InternalDmpEntitiesData.class},
|
||||
{"researchers", ResearcherData.class},
|
||||
{"datasets", DatasetsAutoCompleteData.class},
|
||||
{"dmps", DMPsAutoCompleteData.class},
|
||||
{"booleanDecision", BooleanDecisionData.class},
|
||||
{"radiobox", RadioBoxData.class},
|
||||
{"checkBox", CheckBoxData.class},
|
||||
{"freetext", FreeTextData.class},
|
||||
{"textarea", TextAreaData.class},
|
||||
{"richTextarea", RichTextAreaData.class},
|
||||
{"upload", UploadData.class},
|
||||
{"datePicker", DatePickerData.class},
|
||||
{"externalDatasets", ExternalDatasetsData.class},
|
||||
{"dataRepositories", DataRepositoriesData.class},
|
||||
{"pubRepositories", DataRepositoriesData.class},
|
||||
{"journalRepositories", DataRepositoriesData.class},
|
||||
{"taxonomies", TaxonomiesData.class},
|
||||
{"licenses", LicensesData.class},
|
||||
{"publications", PublicationsData.class},
|
||||
{"registries", RegistriesData.class},
|
||||
{"services", ServicesData.class},
|
||||
{"tags", TagsData.class},
|
||||
{"organizations", OrganizationsData.class},
|
||||
{"datasetIdentifier", DatasetIdentifierData.class},
|
||||
{"currency", CurrencyData.class},
|
||||
{"validation", ValidationData.class}
|
||||
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Class<? extends FieldData>) data[1]));
|
||||
|
||||
public static FieldData fromData(String type, Object data, String subType) {
|
||||
if (Modifier.isAbstract(fieldMap.get(type).getModifiers())) {
|
||||
return fromData(subType, data);
|
||||
} else {
|
||||
return fromData(type, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static FieldData fromData(String type, Object data) {
|
||||
try {
|
||||
return (FieldData) fieldMap.get(type).newInstance().fromData(data);
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package eu.eudat.logic.utilities.schedule.file;
|
||||
|
||||
import eu.eudat.configurations.file.PermProperties;
|
||||
import eu.eudat.configurations.file.TimeProperties;
|
||||
import eu.eudat.configurations.file.TmpProperties;
|
||||
import eu.eudat.data.entities.FileUpload;
|
||||
import eu.eudat.logic.managers.FileManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class FileCleanUpJobs {
|
||||
private static final Logger logger = LoggerFactory.getLogger(FileCleanUpJobs.class);
|
||||
|
||||
private final FileManager fileManager;
|
||||
private final Environment environment;
|
||||
|
||||
@Autowired
|
||||
public FileCleanUpJobs(FileManager fileManager, Environment environment, PermProperties permProperties, TmpProperties tmpProperties) {
|
||||
this.fileManager = fileManager;
|
||||
this.environment = environment;
|
||||
if (permProperties != null) {
|
||||
System.getProperties().put("perm.cron", createCron(permProperties.getTime()));
|
||||
}
|
||||
if (tmpProperties != null) {
|
||||
System.getProperties().put("temp.cron", createCron(tmpProperties.getTime()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Scheduled(cron = "${perm.cron}")
|
||||
public void deleteUnusedPermFiles() {
|
||||
logger.info("Start deleting unused permanent files");
|
||||
List<FileUpload> fileUploads = fileManager.getDeletedFileUploads();
|
||||
try {
|
||||
List<Path> tempFilePaths = Files.walk(Paths.get(Objects.requireNonNull(environment.getProperty("file.storage")))).filter(Files::isRegularFile).collect(Collectors.toList());
|
||||
for (Path tempFilePath : tempFilePaths) {
|
||||
if (fileUploads.stream().map(FileUpload::getId).anyMatch(uuid -> tempFilePath.endsWith(uuid.toString()))) {
|
||||
Files.deleteIfExists(tempFilePath);
|
||||
}
|
||||
}
|
||||
logger.info("Unused permanent files have been successfully deleted");
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Scheduled(cron = "${temp.cron}")
|
||||
public void deleteTempFiles() {
|
||||
logger.info("Start deleting temporary files");
|
||||
try {
|
||||
List<Path> tempFilePaths = Files.walk(Paths.get(Objects.requireNonNull(environment.getProperty("temp.temp")))).filter(Files::isRegularFile).collect(Collectors.toList());
|
||||
for (Path tempFilePath : tempFilePaths) {
|
||||
Files.deleteIfExists(tempFilePath);
|
||||
}
|
||||
logger.info("Temporary files have been successfully deleted");
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private String createCron(TimeProperties timeProperties) {
|
||||
List<String> cronList = new LinkedList<>();
|
||||
cronList.add("0");
|
||||
switch (timeProperties.getTimeUnit()) {
|
||||
case MINUTES:
|
||||
cronList.add("0/" + timeProperties.getInterval());
|
||||
break;
|
||||
case HOURS:
|
||||
cronList.add(toSafeString(timeProperties.getStartTime().getMinute()));
|
||||
cronList.add("0/" + timeProperties.getInterval());
|
||||
break;
|
||||
case DAYS:
|
||||
cronList.add(toSafeString(timeProperties.getStartTime().getMinute()));
|
||||
cronList.add(toSafeString(timeProperties.getStartTime().getHour()));
|
||||
cronList.add("*/" + timeProperties.getInterval());
|
||||
break;
|
||||
case MONTHS:
|
||||
cronList.add(toSafeString(timeProperties.getStartTime().getMinute()));
|
||||
cronList.add(toSafeString(timeProperties.getStartTime().getHour()));
|
||||
cronList.add(toSafeString(timeProperties.getStartTime().getDayOfMonth(), "1"));
|
||||
cronList.add("*/" + timeProperties.getInterval());
|
||||
break;
|
||||
case WEEKS:
|
||||
cronList.add(toSafeString(timeProperties.getStartTime().getMinute()));
|
||||
cronList.add(toSafeString(timeProperties.getStartTime().getHour()));
|
||||
cronList.add("*/" + (timeProperties.getInterval() * 7));
|
||||
cronList.add("*");
|
||||
cronList.add(toSafeString(timeProperties.getStartTime().getDayOfWeek(), "1"));
|
||||
break;
|
||||
}
|
||||
if (cronList.size() < 6) {
|
||||
for (int i = cronList.size(); i < 6; i++) {
|
||||
cronList.add("*");
|
||||
}
|
||||
}
|
||||
return String.join(" ", cronList);
|
||||
}
|
||||
|
||||
private String toSafeString(Object object) {
|
||||
return toSafeString(object, "0");
|
||||
}
|
||||
|
||||
private String toSafeString(Object object, String defaultValue) {
|
||||
return object != null ? object.toString() : defaultValue;
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
|
||||
public class ContactRDAExportModel {
|
||||
private String mbox;
|
||||
private String name;
|
||||
private IdRDAExportModel contact_id;
|
||||
|
||||
public String getMbox() {
|
||||
return mbox;
|
||||
}
|
||||
public void setMbox(String mbox) {
|
||||
this.mbox = mbox;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public IdRDAExportModel getContact_id() {
|
||||
return contact_id;
|
||||
}
|
||||
public void setContact_id(IdRDAExportModel contact_id) {
|
||||
this.contact_id = contact_id;
|
||||
}
|
||||
|
||||
public ContactRDAExportModel fromDataModel(UserInfo entity) {
|
||||
ContactRDAExportModel contact = new ContactRDAExportModel();
|
||||
contact.mbox = entity.getEmail();
|
||||
contact.name = entity.getName();
|
||||
// TODO: we should use a contact_id and not our UUID.
|
||||
if (!entity.getId().toString().isEmpty()) {
|
||||
contact.contact_id = new IdRDAExportModel(entity.getId().toString(), "other");
|
||||
}
|
||||
else {
|
||||
contact.contact_id = null;
|
||||
}
|
||||
return contact;
|
||||
}
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DatasetDistributionRDAExportModel {
|
||||
private String access_url;
|
||||
private String available_till;
|
||||
private String byte_size;
|
||||
private String data_access; // Allowed values: open / shared / closed
|
||||
private String description;
|
||||
private String download_url;
|
||||
private List<String> format; // Format according to: https://www.iana.org/assignments/media-types/media-types.xhtml if appropriate, otherwise use the common name for this format
|
||||
private HostRDAExportModel host;
|
||||
private List<LicenseRDAExportModel> license;
|
||||
private String title;
|
||||
|
||||
public String getAccess_url() {
|
||||
return access_url;
|
||||
}
|
||||
public void setAccess_url(String access_url) {
|
||||
this.access_url = access_url;
|
||||
}
|
||||
|
||||
public String getAvailable_till() {
|
||||
return available_till;
|
||||
}
|
||||
public void setAvailable_till(String available_till) {
|
||||
this.available_till = available_till;
|
||||
}
|
||||
|
||||
public String getByte_size() {
|
||||
return byte_size;
|
||||
}
|
||||
public void setByte_size(String byte_size) {
|
||||
this.byte_size = byte_size;
|
||||
}
|
||||
|
||||
public String getData_access() {
|
||||
return data_access;
|
||||
}
|
||||
public void setData_access(String data_access) {
|
||||
this.data_access = data_access;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDownload_url() {
|
||||
return download_url;
|
||||
}
|
||||
public void setDownload_url(String download_url) {
|
||||
this.download_url = download_url;
|
||||
}
|
||||
|
||||
public List<String> getFormat() {
|
||||
return format;
|
||||
}
|
||||
public void setFormat(List<String> format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public HostRDAExportModel getHost() {
|
||||
return host;
|
||||
}
|
||||
public void setHost(HostRDAExportModel host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public List<LicenseRDAExportModel> getLicense() {
|
||||
return license;
|
||||
}
|
||||
public void setLicense(List<LicenseRDAExportModel> license) {
|
||||
this.license = license;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isValid() {
|
||||
return title != null || data_access != null;
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
public class DatasetMetadataRDAExportModel {
|
||||
private String description; // Not mandatory.
|
||||
private String language;
|
||||
private IdRDAExportModel metadata_standard_id;
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public IdRDAExportModel getMetadata_standard_id() {
|
||||
return metadata_standard_id;
|
||||
}
|
||||
public void setMetadata_standard_id(IdRDAExportModel metadata_standard_id) {
|
||||
this.metadata_standard_id = metadata_standard_id;
|
||||
}
|
||||
|
||||
public DatasetMetadataRDAExportModel fromDataModel(String key, Object value) {
|
||||
DatasetMetadataRDAExportModel metadataRDAExportModel = new DatasetMetadataRDAExportModel();
|
||||
if (key.contains("metadata_standard_id"))
|
||||
metadataRDAExportModel.setMetadata_standard_id(new IdRDAExportModel(value.toString(), "other"));
|
||||
else if (key.contains("language"))
|
||||
metadataRDAExportModel.setLanguage(value.toString());
|
||||
else if (key.contains("description"))
|
||||
metadataRDAExportModel.setDescription(value.toString());
|
||||
|
||||
return metadataRDAExportModel;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isValid() {
|
||||
return description != null || language != null || metadata_standard_id != null;
|
||||
}
|
||||
}
|
@ -1,474 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.logic.managers.DatasetManager;
|
||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import javax.xml.xpath.*;
|
||||
import java.text.DateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static java.util.stream.Collectors.groupingBy;
|
||||
|
||||
public class DatasetRDAExportModel {
|
||||
private static final Logger logger = LoggerFactory.getLogger(DatasetRDAExportModel.class);
|
||||
|
||||
private static final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
private Map<String, String> multiplicityIdToFieldSetId = new HashMap<>();
|
||||
|
||||
private List<String> data_quality_assurance;
|
||||
private IdRDAExportModel dataset_id;
|
||||
private String description;
|
||||
private List<DatasetDistributionRDAExportModel> distribution;
|
||||
private String issued; // Created Date, could also use finalized one.
|
||||
private List<String> keyword;
|
||||
private String language;
|
||||
private List<DatasetMetadataRDAExportModel> metadata;
|
||||
private String personal_data; // Allowed Values: yes no unknown.
|
||||
private String preservation_statement;
|
||||
private List<DatasetSecurityAndPrivacyRDAExportModel> security_and_privacy;
|
||||
private String sensitive_data; // Allowed Values: yes no unknown.
|
||||
private List<DatasetTechnicalResourceRDAExportModel> technical_resource;
|
||||
private String title;
|
||||
private String type; // Type according to: http://vocabularies.coar-repositories.org/pubby/resource_type.html
|
||||
|
||||
public List<String> getData_quality_assurance() {
|
||||
return data_quality_assurance;
|
||||
}
|
||||
public void setData_quality_assurance(List<String> data_quality_assurance) {
|
||||
this.data_quality_assurance = data_quality_assurance;
|
||||
}
|
||||
|
||||
public IdRDAExportModel getDataset_id() {
|
||||
return dataset_id;
|
||||
}
|
||||
public void setDataset_id(IdRDAExportModel dataset_id) {
|
||||
this.dataset_id = dataset_id;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<DatasetDistributionRDAExportModel> getDistribution() {
|
||||
return distribution;
|
||||
}
|
||||
public void setDistribution(List<DatasetDistributionRDAExportModel> distribution) {
|
||||
this.distribution = distribution;
|
||||
}
|
||||
|
||||
public String getIssued() {
|
||||
return issued;
|
||||
}
|
||||
public void setIssued(String issued) {
|
||||
this.issued = issued;
|
||||
}
|
||||
|
||||
public List<String> getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
public void setKeyword(List<String> keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public List<DatasetMetadataRDAExportModel> getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
public void setMetadata(List<DatasetMetadataRDAExportModel> metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public String getPersonal_data() {
|
||||
return personal_data;
|
||||
}
|
||||
public void setPersonal_data(String personal_data) {
|
||||
this.personal_data = personal_data;
|
||||
}
|
||||
|
||||
public String getPreservation_statement() {
|
||||
return preservation_statement;
|
||||
}
|
||||
public void setPreservation_statement(String preservation_statement) {
|
||||
this.preservation_statement = preservation_statement;
|
||||
}
|
||||
|
||||
public List<DatasetSecurityAndPrivacyRDAExportModel> getSecurity_and_privacy() {
|
||||
return security_and_privacy;
|
||||
}
|
||||
public void setSecurity_and_privacy(List<DatasetSecurityAndPrivacyRDAExportModel> security_and_privacy) {
|
||||
this.security_and_privacy = security_and_privacy;
|
||||
}
|
||||
|
||||
public String getSensitive_data() {
|
||||
return sensitive_data;
|
||||
}
|
||||
public void setSensitive_data(String sensitive_data) {
|
||||
this.sensitive_data = sensitive_data;
|
||||
}
|
||||
|
||||
public List<DatasetTechnicalResourceRDAExportModel> getTechnical_resource() {
|
||||
return technical_resource;
|
||||
}
|
||||
public void setTechnical_resource(List<DatasetTechnicalResourceRDAExportModel> technical_resource) {
|
||||
this.technical_resource = technical_resource;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
public DatasetRDAExportModel fromDataModel(Dataset dataset, DatasetManager datasetManager, Principal principal) {
|
||||
// Map of template Ids to rda values.
|
||||
JSONObject jObject = new JSONObject(dataset.getProperties());
|
||||
Map<String, Object> templateIdsToValues = jObject.toMap();
|
||||
|
||||
/*--------- Building dataset rda export model ---------*/
|
||||
DatasetRDAExportModel datasetRDAExportModel = new DatasetRDAExportModel();
|
||||
datasetRDAExportModel.setDataset_id(new IdRDAExportModel(dataset.getId().toString(), "other"));
|
||||
if (dataset.getDescription() != null) datasetRDAExportModel.setDescription(dataset.getDescription().replace("\n", " "));
|
||||
datasetRDAExportModel.setIssued(DateFormat.getDateInstance(DateFormat.SHORT).format(dataset.getCreated()));
|
||||
datasetRDAExportModel.setLanguage("en"); // mock data
|
||||
datasetRDAExportModel.setTitle(dataset.getLabel());
|
||||
|
||||
// Transform the answered dataset description to json so we can parse it and fill the rda model.
|
||||
JSONObject datasetDescriptionJson = null;
|
||||
try {
|
||||
String jsonResult = mapper.writeValueAsString(datasetManager.getSingle(dataset.getId().toString(), principal).getDatasetProfileDefinition());
|
||||
datasetDescriptionJson = new JSONObject(jsonResult);
|
||||
} catch (JsonProcessingException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
setMultiplicityIdToFieldSetId(datasetDescriptionJson);
|
||||
|
||||
/*--------- Building personal data. ---------*/
|
||||
String personalData = buildSingleProperties("dataset.personal_data", datasetDescriptionJson, templateIdsToValues);
|
||||
if (personalData != null) {
|
||||
datasetRDAExportModel.setPersonal_data(personalData);
|
||||
} else {
|
||||
datasetRDAExportModel.setPersonal_data("unknown");
|
||||
}
|
||||
|
||||
/*--------- Building preservation statement. ---------*/
|
||||
datasetRDAExportModel.setPreservation_statement(buildSingleProperties("dataset.preservation_statement", datasetDescriptionJson, templateIdsToValues));
|
||||
|
||||
/*--------- Building sensitive data. ---------*/
|
||||
String sensitiveData = buildSingleProperties("dataset.sensitive_data", datasetDescriptionJson, templateIdsToValues);
|
||||
if (personalData != null) {
|
||||
datasetRDAExportModel.setSensitive_data(sensitiveData);
|
||||
} else {
|
||||
datasetRDAExportModel.setSensitive_data("unknown");
|
||||
}
|
||||
|
||||
/*--------- Building type. ---------*/
|
||||
datasetRDAExportModel.setType(buildSingleProperties("dataset.type", datasetDescriptionJson, templateIdsToValues));
|
||||
|
||||
/*--------- Building data_quality_assurance. ---------*/
|
||||
datasetRDAExportModel.setData_quality_assurance(buildDataQualityAssurance(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
||||
|
||||
/*--------- Building distribution. ---------*/
|
||||
datasetRDAExportModel.setDistribution(buildDistribution(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
||||
|
||||
/*--------- Building keywords. ---------*/
|
||||
datasetRDAExportModel.setKeyword(buildKeywords(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
||||
|
||||
/*--------- Building metadata items. ---------*/
|
||||
datasetRDAExportModel.setMetadata(buildMetadata(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
||||
|
||||
/*--------- Building security and privacy items. ---------*/
|
||||
datasetRDAExportModel.setSecurity_and_privacy(buildSecurityAndPrivacy(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
||||
|
||||
/*--------- Building technical_resource. ---------*/
|
||||
datasetRDAExportModel.setTechnical_resource(buildTechnicalResource(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
||||
|
||||
return datasetRDAExportModel;
|
||||
}
|
||||
|
||||
private String buildSingleProperties(String rdaKey, JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues) {
|
||||
String expression = "$..fields[*][?(@.rdaProperty == \"" + rdaKey + "\" )].id";
|
||||
List<String> list = jsonValueListFromExpression(datasetDescriptionJson, expression);
|
||||
if (!list.isEmpty()) {
|
||||
return templateIdsToValues.get(list.get(0)).toString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> buildDataQualityAssurance(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
|
||||
List<RdaField> dataQualityFields = getRDAFieldsFromJson(datasetDescriptionJson, new String[]{"dataset.data_quality_assurance"}, datasetProfileDefinition);
|
||||
for (RdaField rdaField : dataQualityFields) {
|
||||
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
|
||||
}
|
||||
List<String> dataQualityAssuranceList = new LinkedList<>();
|
||||
for (RdaField rdaField : dataQualityFields) {
|
||||
dataQualityAssuranceList.add(rdaField.getRdaValue());
|
||||
}
|
||||
|
||||
return dataQualityAssuranceList;
|
||||
}
|
||||
|
||||
private List<DatasetDistributionRDAExportModel> buildDistribution(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
|
||||
DatasetDistributionRDAExportModel distributionModel = new DatasetDistributionRDAExportModel();
|
||||
distributionModel.setAccess_url(buildSingleProperties("dataset.distribution.access_url", datasetDescriptionJson, templateIdsToValues));
|
||||
distributionModel.setAvailable_till(buildSingleProperties("dataset.distribution.available_till", datasetDescriptionJson, templateIdsToValues));
|
||||
distributionModel.setByte_size(buildSingleProperties("dataset.distribution.byte_size", datasetDescriptionJson, templateIdsToValues));
|
||||
distributionModel.setData_access(buildSingleProperties("dataset.distribution.data_access", datasetDescriptionJson, templateIdsToValues));
|
||||
distributionModel.setDescription(buildSingleProperties("dataset.distribution.description", datasetDescriptionJson, templateIdsToValues));
|
||||
distributionModel.setDownload_url(buildSingleProperties("dataset.distribution.download_url", datasetDescriptionJson, templateIdsToValues));
|
||||
distributionModel.setTitle(buildSingleProperties("dataset.distribution.title", datasetDescriptionJson, templateIdsToValues));
|
||||
|
||||
/*--------- Building format. ---------*/
|
||||
|
||||
|
||||
// We currently support the return of only one distribution.
|
||||
List<DatasetDistributionRDAExportModel> distributionList = new LinkedList<>();
|
||||
if (distributionModel.isValid()) {
|
||||
distributionList.add(distributionModel);
|
||||
} else {
|
||||
DatasetDistributionRDAExportModel model = new DatasetDistributionRDAExportModel();
|
||||
model.setDescription("Distribution data was not valid");
|
||||
distributionList.add(model);
|
||||
}
|
||||
|
||||
return distributionList;
|
||||
}
|
||||
|
||||
private List<String> buildKeywords(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
|
||||
List<RdaField> keywordFields = getRDAFieldsFromJson(datasetDescriptionJson, new String[]{"dataset.keyword"}, datasetProfileDefinition);
|
||||
for (RdaField rdaField : keywordFields) {
|
||||
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
|
||||
}
|
||||
List<String> keywordsList = new LinkedList<>();
|
||||
for (RdaField rdaField : keywordFields) {
|
||||
keywordsList.add(rdaField.getRdaValue());
|
||||
}
|
||||
|
||||
return keywordsList;
|
||||
}
|
||||
|
||||
private List<DatasetMetadataRDAExportModel> buildMetadata(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
|
||||
List<RdaField> metadataFields = getRDAFieldsFromJson(datasetDescriptionJson,
|
||||
new String[]{"dataset.metadata.metadata_standard_id.type", "dataset.metadata.metadata_standard_id.identifier", "dataset.metadata.description", "dataset.metadata.language", "dataset.metadata.metadata_standard_id"},
|
||||
datasetProfileDefinition);
|
||||
|
||||
// Adding rdaValue and FieldSetIds on metadataFields.
|
||||
for (RdaField rdaField : metadataFields) {
|
||||
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
|
||||
}
|
||||
// Group metadataFields based on their field set id.
|
||||
Map<String, List<RdaField>> groupedMetadataFields = metadataFields.stream().collect(groupingBy(RdaField::getFieldSetId));
|
||||
|
||||
// Creating the metadata.
|
||||
List<DatasetMetadataRDAExportModel> metadataRDAExportModelList = new LinkedList<>();
|
||||
for (String fieldSetId : groupedMetadataFields.keySet()) {
|
||||
DatasetMetadataRDAExportModel metadataRda = new DatasetMetadataRDAExportModel();
|
||||
for (RdaField rdaField : groupedMetadataFields.get(fieldSetId)) {
|
||||
if (rdaField.getRdaProperty().equals("dataset.metadata.metadata_standard_id.identifier")) {
|
||||
if (metadataRda.getMetadata_standard_id() != null) {
|
||||
metadataRda.getMetadata_standard_id().setIdentifier(rdaField.getRdaValue());
|
||||
} else {
|
||||
metadataRda.setMetadata_standard_id(new IdRDAExportModel(rdaField.getRdaValue(), "other"));
|
||||
}
|
||||
}
|
||||
if (rdaField.getRdaProperty().equals("dataset.metadata.metadata_standard_id.type")) {
|
||||
if (metadataRda.getMetadata_standard_id() != null) {
|
||||
metadataRda.getMetadata_standard_id().setType(rdaField.getRdaValue());
|
||||
} else {
|
||||
metadataRda.setMetadata_standard_id(new IdRDAExportModel("", rdaField.getRdaValue()));
|
||||
}
|
||||
}
|
||||
if (rdaField.getRdaProperty().equals("dataset.metadata.description")) {
|
||||
metadataRda.setDescription(rdaField.getRdaValue());
|
||||
}
|
||||
if (rdaField.getRdaProperty().equals("dataset.metadata.language")) {
|
||||
metadataRda.setLanguage(rdaField.getRdaValue());
|
||||
}
|
||||
if (rdaField.getRdaProperty().equals("dataset.metadata.metadata_standard_id") && !rdaField.getRdaValue().isEmpty()) {
|
||||
JSONArray jsonArray = new JSONArray(rdaField.getRdaValue());
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
Map<String, Object> jsonObjectMap = jsonObject.toMap();
|
||||
DatasetMetadataRDAExportModel metadataRda1 = new DatasetMetadataRDAExportModel();
|
||||
// metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString()));
|
||||
metadataRda1.setMetadata_standard_id(new IdRDAExportModel(jsonObjectMap.get("uri").toString(), "url"));
|
||||
metadataRDAExportModelList.add(metadataRda1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (metadataRda.isValid()) {
|
||||
metadataRDAExportModelList.add(metadataRda);
|
||||
}
|
||||
}
|
||||
|
||||
return new LinkedList<>(metadataRDAExportModelList);
|
||||
}
|
||||
|
||||
private List<DatasetSecurityAndPrivacyRDAExportModel> buildSecurityAndPrivacy(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
|
||||
List<RdaField> secAndPrFields = getRDAFieldsFromJson(
|
||||
datasetDescriptionJson,
|
||||
new String[]{"dataset.security_and_privacy.description", "dataset.security_and_privacy.title", "dataset.security_and_privacy"},
|
||||
datasetProfileDefinition);
|
||||
for (RdaField rdaField : secAndPrFields) {
|
||||
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
|
||||
}
|
||||
Map<String, List<RdaField>> groupedSecurityAndPrivacyFields = secAndPrFields.stream().collect(groupingBy(RdaField::getFieldSetId));
|
||||
|
||||
List<DatasetSecurityAndPrivacyRDAExportModel> securityAndPrivacyRDAExportModelList = new LinkedList<>();
|
||||
for (String fieldSetId : groupedSecurityAndPrivacyFields.keySet()) {
|
||||
DatasetSecurityAndPrivacyRDAExportModel securityAndPrivacyModel = new DatasetSecurityAndPrivacyRDAExportModel();
|
||||
for (RdaField rdaField : groupedSecurityAndPrivacyFields.get(fieldSetId)) {
|
||||
if (rdaField.getRdaProperty().equals("dataset.security_and_privacy.description")) {
|
||||
securityAndPrivacyModel.setDescription(rdaField.getRdaValue());
|
||||
}
|
||||
if (rdaField.getRdaProperty().equals("dataset.security_and_privacy.title")) {
|
||||
securityAndPrivacyModel.setTitle(rdaField.getRdaValue());
|
||||
}
|
||||
if (rdaField.getRdaProperty().equals("dataset.security_and_privacy")) {
|
||||
JSONArray jsonArray = new JSONArray(rdaField.getRdaValue());
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
Map<String, Object> jsonObjectMap = jsonObject.toMap();
|
||||
DatasetSecurityAndPrivacyRDAExportModel secAndPrivacy = new DatasetSecurityAndPrivacyRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("source").toString());
|
||||
securityAndPrivacyRDAExportModelList.add(secAndPrivacy);
|
||||
}
|
||||
}
|
||||
}
|
||||
securityAndPrivacyRDAExportModelList.add(securityAndPrivacyModel);
|
||||
}
|
||||
|
||||
return securityAndPrivacyRDAExportModelList;
|
||||
}
|
||||
|
||||
private List<DatasetTechnicalResourceRDAExportModel> buildTechnicalResource(JSONObject datasetDescriptionJson, Map<String, Object> templateIdsToValues, String datasetProfileDefinition) {
|
||||
List<RdaField> dataQualityFields = getRDAFieldsFromJson(datasetDescriptionJson,
|
||||
new String[]{"dataset.technical_resource.technical_resource", "dataset.technical_resource.technical_resource.description", "dataset.technical_resource.technical_resource.name"},
|
||||
datasetProfileDefinition);
|
||||
for (RdaField rdaField : dataQualityFields) {
|
||||
rdaField.setRdaValue(templateIdsToValues.get(rdaField.getFieldId()).toString());
|
||||
}
|
||||
List<DatasetTechnicalResourceRDAExportModel> technicalResourceList = new LinkedList<>();
|
||||
Map<String, List<RdaField>> groupedDataQualityFields = dataQualityFields.stream().collect(groupingBy(RdaField::getFieldSetId));
|
||||
for (String fieldSetId : groupedDataQualityFields.keySet()) {
|
||||
DatasetTechnicalResourceRDAExportModel technicalResourceModel = new DatasetTechnicalResourceRDAExportModel();
|
||||
for (RdaField rdaField : groupedDataQualityFields.get(fieldSetId)) {
|
||||
if (rdaField.getRdaProperty().equals("dataset.technical_resource.technical_resource.description")) {
|
||||
technicalResourceModel.setDescription(rdaField.getRdaValue());
|
||||
}
|
||||
if (rdaField.getRdaProperty().equals("dataset.technical_resource.technical_resource.name")) {
|
||||
technicalResourceModel.setName(rdaField.getRdaValue());
|
||||
}
|
||||
if (rdaField.getRdaProperty().equals("dataset.security_and_privacy")) {
|
||||
JSONArray jsonArray = new JSONArray(rdaField.getRdaValue());
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
Map<String, Object> jsonObjectMap = jsonObject.toMap();
|
||||
DatasetTechnicalResourceRDAExportModel technicalResource = new DatasetTechnicalResourceRDAExportModel(jsonObjectMap.get("label").toString(), jsonObjectMap.get("label").toString());
|
||||
technicalResourceList.add(technicalResource);
|
||||
}
|
||||
}
|
||||
}
|
||||
technicalResourceList.add(technicalResourceModel);
|
||||
}
|
||||
|
||||
return technicalResourceList;
|
||||
}
|
||||
|
||||
private void setMultiplicityIdToFieldSetId(JSONObject json) {
|
||||
String multiplicityItemsFieldSetIdExp = "$..multiplicityItems[*].id";
|
||||
List<String> multiplicityItemsFieldSetIdList = jsonValueListFromExpression(json, multiplicityItemsFieldSetIdExp);
|
||||
for (String fieldSetId : multiplicityItemsFieldSetIdList) {
|
||||
String fieldsFromFieldSetIdExp = "$..multiplicityItems[*][?(@.id == \""+ fieldSetId +"\")].fields[*].id";
|
||||
List<String> fieldsIdList = jsonValueListFromExpression(json, fieldsFromFieldSetIdExp);
|
||||
for (String fieldId : fieldsIdList) {
|
||||
this.multiplicityIdToFieldSetId.put(fieldId, fieldSetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<RdaField> getRDAFieldsFromJson(JSONObject json, String[] rdaKey, String datasetProfileDefinition) {
|
||||
List<RdaField> rdaFields = new LinkedList<>();
|
||||
for (String key : rdaKey) {
|
||||
String fieldIdExpression = "$..fields[*][?(@.rdaProperty == \"" + key + "\" )].id";
|
||||
List<String> listFromExpression = jsonValueListFromExpression(json, fieldIdExpression);
|
||||
for (String fieldId : listFromExpression) {
|
||||
RdaField rdaField = new RdaField();
|
||||
rdaField.setRdaProperty(key);
|
||||
rdaField.setFieldId(fieldId);
|
||||
if (fieldId.startsWith("multiple_")) {
|
||||
rdaField.setFieldSetId(this.multiplicityIdToFieldSetId.get(fieldId));
|
||||
} else {
|
||||
rdaField.setFieldSetId(getFieldSetIdForFieldFromXML(datasetProfileDefinition, fieldId));
|
||||
}
|
||||
rdaFields.add(rdaField);
|
||||
}
|
||||
}
|
||||
return rdaFields;
|
||||
}
|
||||
|
||||
private List<String> jsonValueListFromExpression(JSONObject json, String expression) {
|
||||
net.minidev.json.JSONArray jsonArray = JsonPath.parse(json.toString()).read(expression);
|
||||
List<String> valueList = new LinkedList<>();
|
||||
for (Object o : jsonArray) {
|
||||
valueList.add(o.toString());
|
||||
}
|
||||
return valueList;
|
||||
}
|
||||
|
||||
private String getFieldSetIdForFieldFromXML(String datasetProfileDefinition, String fieldId) {
|
||||
String fieldSetIdExpression = "//field[@id ='" + fieldId + "']/ancestor::fieldSet/@id";
|
||||
List<String> listFromExpression = xmlValueListFromExpression(datasetProfileDefinition, fieldSetIdExpression);
|
||||
if (listFromExpression.size() == 1) return listFromExpression.get(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<String> xmlValueListFromExpression(String xml, String expression) {
|
||||
List<String> valuesList = new LinkedList<>();
|
||||
Document document = XmlBuilder.fromXml(xml);
|
||||
XPathFactory xpathFactory = XPathFactory.newInstance();
|
||||
XPath xpath = xpathFactory.newXPath();
|
||||
try {
|
||||
XPathExpression expr = xpath.compile(expression);
|
||||
NodeList nodeList = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
|
||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
Node node = nodeList.item(i);
|
||||
valuesList.add(node.getNodeValue());
|
||||
}
|
||||
} catch (XPathExpressionException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
return valuesList;
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
public class DatasetSecurityAndPrivacyRDAExportModel {
|
||||
private String description;
|
||||
private String title;
|
||||
|
||||
public DatasetSecurityAndPrivacyRDAExportModel() {
|
||||
|
||||
}
|
||||
|
||||
public DatasetSecurityAndPrivacyRDAExportModel(String description, String title) {
|
||||
this.description = description;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
public class DatasetTechnicalResourceRDAExportModel {
|
||||
private String description;
|
||||
private String name;
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public DatasetTechnicalResourceRDAExportModel(String description, String name) {
|
||||
this.description = description;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public DatasetTechnicalResourceRDAExportModel() {
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class DmpContributorRDAExportModel {
|
||||
private IdRDAExportModel contributor_id;
|
||||
private String mbox;
|
||||
private String name;
|
||||
private List<String> role;
|
||||
|
||||
public IdRDAExportModel getContributor_id() {
|
||||
return contributor_id;
|
||||
}
|
||||
public void setContributor_id(IdRDAExportModel contributor_id) {
|
||||
this.contributor_id = contributor_id;
|
||||
}
|
||||
|
||||
public String getMbox() {
|
||||
return mbox;
|
||||
}
|
||||
public void setMbox(String mbox) {
|
||||
this.mbox = mbox;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<String> getRole() {
|
||||
return role;
|
||||
}
|
||||
public void setRole(List<String> role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public DmpContributorRDAExportModel fromDataModel(UserInfo user, String role) {
|
||||
DmpContributorRDAExportModel contributor = new DmpContributorRDAExportModel();
|
||||
contributor.contributor_id = new IdRDAExportModel(user.getId().toString(), "other");
|
||||
contributor.mbox = user.getEmail();
|
||||
contributor.name = user.getName();
|
||||
contributor.role = new LinkedList<>();
|
||||
contributor.role.add(role);
|
||||
|
||||
return contributor;
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
public class DmpCostRDAExportModel {
|
||||
private String currency_code; //Allowed values defined by ISO 4217.
|
||||
private String description;
|
||||
private String title;
|
||||
private String value;
|
||||
|
||||
public String getCurrency_code() {
|
||||
return currency_code;
|
||||
}
|
||||
public void setCurrency_code(String currency_code) {
|
||||
this.currency_code = currency_code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
@ -1,164 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.data.entities.UserDMP;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.logic.managers.DatasetManager;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DmpRDAExportModel {
|
||||
private ContactRDAExportModel contact;
|
||||
private List<DmpContributorRDAExportModel> contributor;
|
||||
private List<DmpCostRDAExportModel> cost;
|
||||
private String created;
|
||||
private List<DatasetRDAExportModel> dataset;
|
||||
private String description;
|
||||
private IdRDAExportModel dmp_id;
|
||||
private String ethical_issues_description;
|
||||
private String ethical_issues_exist; // Allowed Values: yes no unknown.
|
||||
private String ethical_issues_report;
|
||||
private String language;
|
||||
private String modified;
|
||||
private ProjectRDAExportModel project;
|
||||
private String title;
|
||||
|
||||
public ContactRDAExportModel getContact() {
|
||||
return contact;
|
||||
}
|
||||
public void setContact(ContactRDAExportModel contact) {
|
||||
this.contact = contact;
|
||||
}
|
||||
|
||||
public List<DmpContributorRDAExportModel> getContributor() {
|
||||
return contributor;
|
||||
}
|
||||
public void setContributor(List<DmpContributorRDAExportModel> contributor) {
|
||||
this.contributor = contributor;
|
||||
}
|
||||
|
||||
public List<DmpCostRDAExportModel> getCost() {
|
||||
return cost;
|
||||
}
|
||||
public void setCost(List<DmpCostRDAExportModel> cost) {
|
||||
this.cost = cost;
|
||||
}
|
||||
|
||||
public String getCreated() {
|
||||
return created;
|
||||
}
|
||||
public void setCreated(String created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public List<DatasetRDAExportModel> getDataset() {
|
||||
return dataset;
|
||||
}
|
||||
public void setDataset(List<DatasetRDAExportModel> dataset) {
|
||||
this.dataset = dataset;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public IdRDAExportModel getDmp_id() {
|
||||
return dmp_id;
|
||||
}
|
||||
public void setDmp_id(IdRDAExportModel dmp_id) {
|
||||
this.dmp_id = dmp_id;
|
||||
}
|
||||
|
||||
public String getEthical_issues_description() {
|
||||
return ethical_issues_description;
|
||||
}
|
||||
public void setEthical_issues_description(String ethical_issues_description) {
|
||||
this.ethical_issues_description = ethical_issues_description;
|
||||
}
|
||||
|
||||
public String getEthical_issues_exist() {
|
||||
return ethical_issues_exist;
|
||||
}
|
||||
public void setEthical_issues_exist(String ethical_issues_exist) {
|
||||
this.ethical_issues_exist = ethical_issues_exist;
|
||||
}
|
||||
|
||||
public String getEthical_issues_report() {
|
||||
return ethical_issues_report;
|
||||
}
|
||||
public void setEthical_issues_report(String ethical_issues_report) {
|
||||
this.ethical_issues_report = ethical_issues_report;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public String getModified() {
|
||||
return modified;
|
||||
}
|
||||
public void setModified(String modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
public ProjectRDAExportModel getProject() {
|
||||
return project;
|
||||
}
|
||||
public void setProject(ProjectRDAExportModel project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public DmpRDAExportModel fromDataModel(DMP entity, DatasetManager datasetManager, Principal principal) {
|
||||
DmpRDAExportModel dmpRda = new DmpRDAExportModel();
|
||||
dmpRda.contact = new ContactRDAExportModel().fromDataModel(entity.getUsers().stream().filter(x -> x.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
||||
if (entity.getUsers().stream().anyMatch(x -> x.getRole().equals(UserDMP.UserDMPRoles.USER.getValue()))) {
|
||||
dmpRda.contributor = new LinkedList<>();
|
||||
for (UserDMP userdmp : entity.getUsers().stream().filter(x -> x.getRole().equals(UserDMP.UserDMPRoles.USER.getValue())).collect(Collectors.toList())) {
|
||||
dmpRda.contributor.add(new DmpContributorRDAExportModel().fromDataModel(userdmp.getUser(), UserDMP.UserDMPRoles.fromInteger(userdmp.getRole()).toString()));
|
||||
}
|
||||
}
|
||||
dmpRda.cost = null;
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
|
||||
dmpRda.created = formatter.format(entity.getCreated());
|
||||
dmpRda.dataset = new LinkedList<>();
|
||||
for (Dataset dataset : entity.getDataset()) {
|
||||
if (dataset.getStatus() != Dataset.Status.DELETED.getValue() && dataset.getStatus() != Dataset.Status.CANCELED.getValue())
|
||||
dmpRda.dataset.add(new DatasetRDAExportModel().fromDataModel(dataset, datasetManager, principal));
|
||||
}
|
||||
dmpRda.description = entity.getDescription().replace("\n", " ");
|
||||
if (entity.getDoi() != null) {
|
||||
dmpRda.dmp_id = new IdRDAExportModel(entity.getDoi(), "zenodo");
|
||||
}
|
||||
else {
|
||||
dmpRda.dmp_id = new IdRDAExportModel(entity.getId().toString(), "other");
|
||||
}
|
||||
// Mock up data on "language" and "ethical_issues_*" for now.
|
||||
dmpRda.ethical_issues_exist = "unknown";
|
||||
dmpRda.language = "en";
|
||||
dmpRda.modified = formatter.format(new Date());
|
||||
dmpRda.project = new ProjectRDAExportModel().fromDataModel(entity.getGrant());
|
||||
dmpRda.title = entity.getLabel();
|
||||
|
||||
return dmpRda;
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
import eu.eudat.data.entities.Funder;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
|
||||
public class FundingRDAExportModel {
|
||||
private IdRDAExportModel funder_id;
|
||||
private IdRDAExportModel grant_id;
|
||||
private String funding_status;
|
||||
|
||||
public IdRDAExportModel getFunder_id() {
|
||||
return funder_id;
|
||||
}
|
||||
public void setFunder_id(IdRDAExportModel funder_id) {
|
||||
this.funder_id = funder_id;
|
||||
}
|
||||
|
||||
public IdRDAExportModel getGrant_id() {
|
||||
return grant_id;
|
||||
}
|
||||
public void setGrant_id(IdRDAExportModel grant_id) {
|
||||
this.grant_id = grant_id;
|
||||
}
|
||||
|
||||
public String getFunding_status() {
|
||||
return funding_status;
|
||||
}
|
||||
public void setFunding_status(String funding_status) {
|
||||
this.funding_status = funding_status;
|
||||
}
|
||||
|
||||
public FundingRDAExportModel fromDataModel(Funder funder, Grant grant) {
|
||||
FundingRDAExportModel funding = new FundingRDAExportModel();
|
||||
funding.funding_status = "planned"; // mock data
|
||||
if (funder != null) {
|
||||
funding.funder_id = new IdRDAExportModel(funder.getReference(), "other");
|
||||
}
|
||||
if (grant != null) {
|
||||
funding.grant_id = new IdRDAExportModel(grant.getReference(), "other");
|
||||
}
|
||||
return funding;
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HostRDAExportModel {
|
||||
private String availability;
|
||||
private String backup__frequency;
|
||||
private String backup_type;
|
||||
private String certified_with; // Repository certified with one the following standards: DIN31644 / DINI-Zertifikat / DSA / ISO16363 / ISO16919 /TRAC / WDS / CoreTrustSeal
|
||||
private String description;
|
||||
private String geo_location; // Physical location of the data expressed using ISO 3166-1 country code.
|
||||
private List<String> pid_system; // PID System: ark arxiv bibcode doi ean13 eissn handle igsn isbn issn istc lissn lsid pmid purl upc url urn other
|
||||
private String storage_type;
|
||||
private String support_versioning; // Allowed values: yes / no / unknown
|
||||
private String title;
|
||||
|
||||
public String getAvailability() {
|
||||
return availability;
|
||||
}
|
||||
public void setAvailability(String availability) {
|
||||
this.availability = availability;
|
||||
}
|
||||
|
||||
public String getBackup__frequency() {
|
||||
return backup__frequency;
|
||||
}
|
||||
public void setBackup__frequency(String backup__frequency) {
|
||||
this.backup__frequency = backup__frequency;
|
||||
}
|
||||
|
||||
public String getBackup_type() {
|
||||
return backup_type;
|
||||
}
|
||||
public void setBackup_type(String backup_type) {
|
||||
this.backup_type = backup_type;
|
||||
}
|
||||
|
||||
public String getCertified_with() {
|
||||
return certified_with;
|
||||
}
|
||||
public void setCertified_with(String certified_with) {
|
||||
this.certified_with = certified_with;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getGeo_location() {
|
||||
return geo_location;
|
||||
}
|
||||
public void setGeo_location(String geo_location) {
|
||||
this.geo_location = geo_location;
|
||||
}
|
||||
|
||||
public List<String> getPid_system() {
|
||||
return pid_system;
|
||||
}
|
||||
public void setPid_system(List<String> pid_system) {
|
||||
this.pid_system = pid_system;
|
||||
}
|
||||
|
||||
public String getStorage_type() {
|
||||
return storage_type;
|
||||
}
|
||||
public void setStorage_type(String storage_type) {
|
||||
this.storage_type = storage_type;
|
||||
}
|
||||
|
||||
public String getSupport_versioning() {
|
||||
return support_versioning;
|
||||
}
|
||||
public void setSupport_versioning(String support_versioning) {
|
||||
this.support_versioning = support_versioning;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
public class IdRDAExportModel {
|
||||
private String identifier;
|
||||
private String type;
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
IdRDAExportModel(String identifier, String type) {
|
||||
this.identifier = identifier;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
public class LicenseRDAExportModel {
|
||||
private String license_ref;
|
||||
private String start_date; // If date is set in the future, it indicates embargo period.
|
||||
|
||||
public String getLicense_ref() {
|
||||
return license_ref;
|
||||
}
|
||||
public void setLicense_ref(String license_ref) {
|
||||
this.license_ref = license_ref;
|
||||
}
|
||||
|
||||
public String getStart_date() {
|
||||
return start_date;
|
||||
}
|
||||
public void setStart_date(String start_date) {
|
||||
this.start_date = start_date;
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
import eu.eudat.data.entities.Grant;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class ProjectRDAExportModel {
|
||||
private String title;
|
||||
private String description;
|
||||
private Date project_start;
|
||||
private Date project_end;
|
||||
private FundingRDAExportModel funding;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Date getProject_start() {
|
||||
return project_start;
|
||||
}
|
||||
public void setProject_start(Date project_start) {
|
||||
this.project_start = project_start;
|
||||
}
|
||||
|
||||
public Date getProject_end() {
|
||||
return project_end;
|
||||
}
|
||||
public void setProject_end(Date project_end) {
|
||||
this.project_end = project_end;
|
||||
}
|
||||
|
||||
public FundingRDAExportModel getFunding() {
|
||||
return funding;
|
||||
}
|
||||
public void setFunding(FundingRDAExportModel funding) {
|
||||
this.funding = funding;
|
||||
}
|
||||
|
||||
|
||||
public ProjectRDAExportModel fromDataModel(Grant grant) {
|
||||
this.funding = new FundingRDAExportModel().fromDataModel(grant.getFunder(), grant);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.logic.managers.DatasetManager;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class RDAExportModel {
|
||||
private DmpRDAExportModel dmp;
|
||||
|
||||
public DmpRDAExportModel getDmp() {
|
||||
return dmp;
|
||||
}
|
||||
public void setDmp(DmpRDAExportModel dmp) {
|
||||
this.dmp = dmp;
|
||||
}
|
||||
|
||||
public RDAExportModel fromDataModel(DMP dmp, DatasetManager datasetManager, Principal principal) {
|
||||
this.dmp = new DmpRDAExportModel().fromDataModel(dmp, datasetManager, principal);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package eu.eudat.models.data.rda;
|
||||
|
||||
public class RdaField {
|
||||
private String rdaProperty;
|
||||
private String rdaValue;
|
||||
private String fieldId;
|
||||
private String fieldSetId;
|
||||
|
||||
public String getRdaProperty() {
|
||||
return rdaProperty;
|
||||
}
|
||||
public void setRdaProperty(String rdaProperty) {
|
||||
this.rdaProperty = rdaProperty;
|
||||
}
|
||||
|
||||
public String getRdaValue() {
|
||||
return rdaValue;
|
||||
}
|
||||
public void setRdaValue(String rdaValue) {
|
||||
this.rdaValue = rdaValue;
|
||||
}
|
||||
|
||||
public String getFieldId() {
|
||||
return fieldId;
|
||||
}
|
||||
public void setFieldId(String fieldId) {
|
||||
this.fieldId = fieldId;
|
||||
}
|
||||
|
||||
public String getFieldSetId() {
|
||||
return fieldSetId;
|
||||
}
|
||||
public void setFieldSetId(String fieldSetId) {
|
||||
this.fieldSetId = fieldSetId;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue