add more prefilled fields
This commit is contained in:
parent
b6c28be3b3
commit
1a43c28496
|
@ -20,9 +20,12 @@ import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
|
|||
import eu.eudat.models.data.datasetprofile.RenderStyle;
|
||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -67,6 +70,11 @@ public class PrefillingMapper {
|
|||
//GK: Tags Special logic
|
||||
if (!value.equals("null") && prefillingMapping.getTarget().equals("tags")) {
|
||||
value = mapper.valueToTree(parseTags(value)).toString();
|
||||
List<JsonNode> nodes = JsonSearcher.findNodes(parentNode, "rdaProperty", "dataset.keyword");
|
||||
for (JsonNode node: nodes) {
|
||||
String id = node.get(0) != null ? node.get(0).get("id").asText() : node.get("id").asText();
|
||||
properties.put(id, value);
|
||||
}
|
||||
}
|
||||
setterMethod.invoke(datasetWizardModel, mapper.readValue(value, params[0]));
|
||||
}catch (InvocationTargetException | IllegalAccessException | JsonProcessingException e) {
|
||||
|
@ -74,12 +82,6 @@ public class PrefillingMapper {
|
|||
}
|
||||
} else {
|
||||
List<JsonNode> nodes = JsonSearcher.findNodes(parentNode, "rdaProperty", prefillingMapping.getMaDmpTarget());
|
||||
/*if(prefillingMapping.getMaDmpTarget().equals("dataset.distribution.available_until") && !value.equals("null")){
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd");
|
||||
LocalDate date = LocalDate.parse(value.replace("\"", ""), formatter);
|
||||
date = date.plusYears(20);
|
||||
value = date.toString();
|
||||
}*/
|
||||
String trimRegex = prefillingMapping.getTrimRegex() != null ? prefillingMapping.getTrimRegex() : "";
|
||||
if (!value.startsWith("\"") && !value.startsWith("[") && !value.equals("null")) {
|
||||
value = "\"" + value + "\"";
|
||||
|
@ -112,7 +114,27 @@ public class PrefillingMapper {
|
|||
case COMBO_BOX:
|
||||
if (parsedValues.isEmpty())
|
||||
parsedValues.add(parsedValue);
|
||||
properties.put(id, parseComboBoxValues(node, parsedValues));
|
||||
if(prefillingMapping.getMaDmpTarget().equals("dataset.distribution.data_access")){
|
||||
if(parsedValue != null && parsedValue.equals("open")){
|
||||
properties.put(id, parsedValue);
|
||||
List<JsonNode> issuedNodes = JsonSearcher.findNodes(parentNode, "rdaProperty", "dataset.issued");
|
||||
String issuedIdNode = issuedNodes.get(0).get("id").asText();
|
||||
String issuedValue = (String)properties.get(issuedIdNode);
|
||||
List<JsonNode> licStartDateNodes = JsonSearcher.findNodes(parentNode, "rdaProperty", "dataset.distribution.license.start_date");
|
||||
for (JsonNode licStartDateNode: licStartDateNodes) {
|
||||
String licStartDateId = licStartDateNode.get(0) != null ? licStartDateNode.get(0).get("id").asText() : licStartDateNode.get("id").asText();
|
||||
properties.put(licStartDateId, issuedValue);
|
||||
}
|
||||
}
|
||||
else if(parsedValue != null && parsedValue.equals("restricted")){
|
||||
properties.put(id, "shared");
|
||||
}
|
||||
else{
|
||||
properties.put(id, "closed");
|
||||
}
|
||||
}
|
||||
else
|
||||
properties.put(id, parseComboBoxValues(node, parsedValues));
|
||||
break;
|
||||
case TAGS:
|
||||
properties.put(id, parseTags(parsedValue));
|
||||
|
@ -120,22 +142,25 @@ public class PrefillingMapper {
|
|||
default:
|
||||
if (!parsedValues.isEmpty())
|
||||
properties.put(id, String.join(", ", parsedValues));
|
||||
else
|
||||
properties.put(id, parsedValue);
|
||||
else {
|
||||
if (prefillingMapping.getMaDmpTarget().equals("dataset.dataset_id")) {
|
||||
JSONObject datasetID = new JSONObject();
|
||||
datasetID.put("identifier", parsedValue);
|
||||
datasetID.put("type", "doi");
|
||||
properties.put(id, datasetID.toString());
|
||||
}
|
||||
else {
|
||||
if (prefillingMapping.getMaDmpTarget().equals("dataset.distribution.available_until") && parsedValue != null && !parsedValue.equals("null")) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd");
|
||||
LocalDate date = LocalDate.parse(parsedValue, formatter);
|
||||
date = date.plusYears(20);
|
||||
parsedValue = date.toString();
|
||||
}
|
||||
properties.put(id, parsedValue);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
/*if(prefillingMapping.getMaDmpTarget().equals("dataset.distribution.data_access")){
|
||||
value = value.replace("\"", "");
|
||||
if(value.equals("open")){
|
||||
properties.put(id, value);
|
||||
}
|
||||
else if(value.equals("restricted")){
|
||||
properties.put(id, "shared");
|
||||
}
|
||||
else{
|
||||
properties.put(id, "closed");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1187,16 +1187,26 @@ but not
|
|||
<mapping source="metadata.filesize" maDmpTarget="dataset.distribution.byte_size"/>
|
||||
<mapping source="metadata.language" maDmpTarget="dataset.metadata.language"/>
|
||||
<mapping source="metadata.dates.valid" maDmpTarget="dataset.distribution.available_until"/>
|
||||
<mapping source="metadata.access_right" maDmpTarget="dataset.distribution.data_access"/>
|
||||
<mapping source="metadata.publication_date" maDmpTarget="dataset.issued"/>
|
||||
<mapping source="metadata.license.created" maDmpTarget="dataset.distribution.license.start_date"/>
|
||||
<mapping source="metadata.embargo_date" maDmpTarget="dataset.distribution.license.start_date"/>
|
||||
<mapping source="metadata.publication_date" maDmpTarget="dataset.issued"/>
|
||||
<mapping source="metadata.access_right" maDmpTarget="dataset.distribution.data_access"/>
|
||||
<mapping source="files" subSource="filename" trimRegex="^.*\." maDmpTarget="dataset.distribution.format"/>
|
||||
<mapping source="doi" maDmpTarget="dataset.dataset_id" />
|
||||
<mapping source="doi" maDmpTarget="dataset.dataset_id.identifier" />
|
||||
</mappings>
|
||||
<fixedMappings>
|
||||
<fixedMapping maDmpTarget="dataset.distribution.host.title" value="Zenodo" />
|
||||
<fixedMapping maDmpTarget="dataset.distribution.host.availability" value="More than 99% uptime yearly" />
|
||||
<fixedMapping maDmpTarget="dataset.distribution.host.geo_location" value="CH" />
|
||||
<fixedMapping maDmpTarget="dataset.distribution.host.storage_type" value="All files uploaded to Zenodo are stored in CERN’s EOS service in an 18 petabytes disk cluster." />
|
||||
<fixedMapping maDmpTarget="dataset.dataset_id.type" value="doi" />
|
||||
<fixedMapping maDmpTarget="dataset.metadata.metadata_standard_id.identifier" value="https://schema.datacite.org/meta/kernel-4.4/" />
|
||||
<fixedMapping maDmpTarget="dataset.metadata.metadata_standard_id.type" value="url" />
|
||||
<fixedMapping maDmpTarget="dataset.metadata.language" value="eng" />
|
||||
<fixedMapping maDmpTarget="dataset.metadata.description" value="DataCite Metadata Schema" />
|
||||
<fixedMapping maDmpTarget="dataset.distribution.host.backup_frequency" value="Hourly" />
|
||||
<fixedMapping maDmpTarget="dataset.distribution.host.backup_type" value="Incremental backup" />
|
||||
<fixedMapping maDmpTarget="dataset.distribution.host.description" value="Repository hosted by Zenodo" />
|
||||
<fixedMapping maDmpTarget="dataset.distribution.host.url" value="https://zenodo.org" />
|
||||
<fixedMapping maDmpTarget="dataset.distribution.host.pid_system" value="doi" />
|
||||
|
|
Loading…
Reference in New Issue