This commit is contained in:
Diamantis Tziotzios 2023-11-23 13:15:50 +02:00
parent 9fed92dbcb
commit 4970f5812f
11 changed files with 201 additions and 151 deletions

View File

@ -1362,7 +1362,7 @@ public class DataManagementPlanManager {
DataManagementPlanBlueprintListingModel dmpBlueprintModel = new DataManagementPlanBlueprintListingModel();
dmpBlueprintModel.fromDataModel(dmpProfile);
DataManagementPlanBlueprint dmpBlueprint = dmpBlueprintModel.getDefinition();
for(Section section: dmpBlueprint.getSections()){
for(Section section: dmpBlueprint.getSections()) {
wordBuilder.addParagraphContent(section.getOrdinal() + ". " + section.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO, 0);
// XWPFParagraph sectionInfoParagraph = document.createParagraph();
// sectionInfoParagraph.setSpacingBetween(1.0);
@ -1382,14 +1382,14 @@ public class DataManagementPlanManager {
//wordBuilder.addParagraphContent("Section Fields", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
section.getFields().sort(Comparator.comparingInt(FieldModel::getOrdinal));
for(FieldModel field: section.getFields()){
if(field.getCategory() == FieldCategory.SYSTEM){
for (FieldModel field : section.getFields()) {
if (field.getCategory() == FieldCategory.SYSTEM) {
SystemField systemField = field.toSystemField();
if (systemField.getType() == SystemFieldType.LANGUAGE) continue;
XWPFParagraph systemFieldParagraph = document.createParagraph();
// systemFieldParagraph.setSpacingBetween(1.0);
XWPFRun runSyStemFieldTitle = systemFieldParagraph.createRun();
runSyStemFieldTitle.setText(systemField.getLabel() +": ");
runSyStemFieldTitle.setText(systemField.getLabel() + ": ");
runSyStemFieldTitle.setColor("000000");
// XWPFRun runSystemFieldTitleText = systemFieldParagraph.createRun();
// runSystemFieldTitleText.setText(systemField.getLabel());
@ -1419,7 +1419,7 @@ public class DataManagementPlanManager {
wordBuilder.addParagraphContent(dmpEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
break;
case RESEARCHERS:
for(Researcher researcher: dmpEntity.getResearchers()){
for (Researcher researcher : dmpEntity.getResearchers()) {
XWPFRun runResearcher = systemFieldParagraph.createRun();
runResearcher.addBreak();
runResearcher.setText("" + researcher.getLabel());
@ -1427,7 +1427,7 @@ public class DataManagementPlanManager {
}
break;
case ORGANIZATIONS:
for(Organisation organisation: dmpEntity.getOrganisations()){
for (Organisation organisation : dmpEntity.getOrganisations()) {
XWPFRun runOrganisation = systemFieldParagraph.createRun();
runOrganisation.addBreak();
runOrganisation.setText("" + organisation.getLabel());
@ -1459,7 +1459,7 @@ public class DataManagementPlanManager {
}
break;
case PROJECT:
if (dmpEntity.getProject() != null ) {
if (dmpEntity.getProject() != null) {
XWPFRun runProject = systemFieldParagraph.createRun();
runProject.setText(dmpEntity.getProject().getLabel());
runProject.setColor("116a78");
@ -1469,7 +1469,7 @@ public class DataManagementPlanManager {
Map extraProperties = objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class);
if (extraProperties.containsKey("license")) {
Map<String, String> license = ((Map<String, String>) extraProperties.get("license"));
if(!StringUtils.isEmpty(license.get("pid"))) {
if (!StringUtils.isEmpty(license.get("pid"))) {
XWPFRun runLicense = systemFieldParagraph.createRun();
runLicense.setText(license.get("pid").toString());
runLicense.setColor("116a78");
@ -1486,11 +1486,11 @@ public class DataManagementPlanManager {
break;
}
//document.createParagraph();
}
else if(field.getCategory() == FieldCategory.EXTRA){
} else if (field.getCategory() == FieldCategory.EXTRA) {
Map dmpProperties = objectMapper.readValue(dmpEntity.getProperties(), HashMap.class);
if (dmpProperties != null && (!dmpProperties.containsKey(field.getId().toString()) || StringUtils.isEmpty((String) dmpProperties.get(field.getId().toString())))) continue;
if (dmpProperties != null && (!dmpProperties.containsKey(field.getId().toString()) || StringUtils.isEmpty((String) dmpProperties.get(field.getId().toString()))))
continue;
ExtraField extraField = field.toExtraField();
XWPFParagraph extraFieldParagraph = document.createParagraph();
extraFieldParagraph.setSpacingBetween(1.0);
@ -1527,76 +1527,72 @@ public class DataManagementPlanManager {
}
//if(!section.getDescriptionTemplates().isEmpty()){
wordBuilder.addParagraphContent("Section descriptions", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
// wordBuilder.addParagraphContent("Description Templates", document, ParagraphStyle.HEADER4, BigInteger.ZERO, 0);
// for(eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate descriptionTemplate: section.getDescriptionTemplates()){
// XWPFParagraph templateParagraph = document.createParagraph();
// XWPFRun runTemplateLabel = templateParagraph.createRun();
// runTemplateLabel.setText("" + descriptionTemplate.getLabel());
// runTemplateLabel.setColor("116a78");
// }
final Boolean isFinalized = dmpEntity.getStatus() == DMP.DMPStatus.FINALISED.getValue();
final Boolean isPublic = dmpEntity.isPublic();
List<Dataset> datasets = dmpEntity.getDataset().stream()
.filter(item -> item.getStatus() != Dataset.Status.CANCELED.getValue())
.filter(item -> item.getStatus() != Dataset.Status.DELETED.getValue())
.filter(item -> !isPublic && !isFinalized || item.getStatus() == Dataset.Status.FINALISED.getValue())
.filter(item -> item.getDmpSectionIndex().equals(section.getOrdinal() - 1))
.sorted(Comparator.comparing(Dataset::getCreated)).collect(Collectors.toList());
final Boolean isFinalized = dmpEntity.getStatus() == DMP.DMPStatus.FINALISED.getValue();
final Boolean isPublic = dmpEntity.isPublic();
dmpEntity.getDataset().stream()
.filter(item -> item.getStatus() != Dataset.Status.CANCELED.getValue())
.filter(item -> item.getStatus() != Dataset.Status.DELETED.getValue())
.filter(item -> !isPublic && !isFinalized || item.getStatus() == Dataset.Status.FINALISED.getValue())
.filter(item -> item.getDmpSectionIndex().equals(section.getOrdinal() - 1))
.sorted(Comparator.comparing(Dataset::getCreated))
.forEach(datasetEntity -> {
Map<String, Object> properties = new HashMap<>();
if (datasetEntity.getProperties() != null) {
//ObjectMapper objectMapper = new ObjectMapper();
try {
properties = objectMapper.readValue(datasetEntity.getProperties(), LinkedHashMap.class);
} catch (IOException e) {
logger.error(e.getLocalizedMessage(), e);
}
if (datasets.size() > 0)
wordBuilder.addParagraphContent("Section descriptions", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0);
for (Dataset datasetEntity : datasets) {
Map<String, Object> properties = new HashMap<>();
if (datasetEntity.getProperties() != null) {
//ObjectMapper objectMapper = new ObjectMapper();
try {
properties = objectMapper.readValue(datasetEntity.getProperties(), LinkedHashMap.class);
} catch (IOException e) {
logger.error(e.getLocalizedMessage(), e);
}
/*JSONObject jObject = new JSONObject(datasetEntity.getProperties());
properties = jObject.toMap();*/
}
}
// Dataset Description custom style.
XWPFParagraph datasetDescriptionParagraph = document.createParagraph();
datasetDescriptionParagraph.setStyle("Heading4");
datasetDescriptionParagraph.setSpacingBetween(1.5);
XWPFRun datasetDescriptionRun = datasetDescriptionParagraph.createRun();
datasetDescriptionRun.setText("Description");
//datasetDescriptionRun.setColor("2E75B6");
//datasetDescriptionRun.setBold(true);
datasetDescriptionRun.setFontSize(15);
// Dataset Description custom style.
XWPFParagraph datasetDescriptionParagraph = document.createParagraph();
datasetDescriptionParagraph.setStyle("Heading4");
datasetDescriptionParagraph.setSpacingBetween(1.5);
XWPFRun datasetDescriptionRun = datasetDescriptionParagraph.createRun();
datasetDescriptionRun.setText("Description");
//datasetDescriptionRun.setColor("2E75B6");
//datasetDescriptionRun.setBold(true);
datasetDescriptionRun.setFontSize(15);
// Custom style for the Dataset title.
//wordBuilder.addParagraphContent("Title: " + datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
XWPFParagraph datasetLabelParagraph = document.createParagraph();
// Custom style for the Dataset title.
//wordBuilder.addParagraphContent("Title: " + datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
XWPFParagraph datasetLabelParagraph = document.createParagraph();
// datasetLabelParagraph.setStyle("Heading2");
datasetLabelParagraph.setSpacingBetween(1.0);
XWPFRun runDatasetTitle1 = datasetLabelParagraph.createRun();
runDatasetTitle1.setText("Title: ");
runDatasetTitle1.setColor("000000");
//runDatasetTitle1.setBold(true);
//runDatasetTitle1.setFontSize(12);
XWPFRun runDatasetTitle = datasetLabelParagraph.createRun();
runDatasetTitle.setText(datasetEntity.getLabel());
runDatasetTitle.setColor("116a78");
//runDatasetTitle.setBold(true);
//runDatasetTitle.setFontSize(12);
datasetLabelParagraph.setSpacingBetween(1.0);
XWPFRun runDatasetTitle1 = datasetLabelParagraph.createRun();
runDatasetTitle1.setText("Title: ");
runDatasetTitle1.setColor("000000");
//runDatasetTitle1.setBold(true);
//runDatasetTitle1.setFontSize(12);
XWPFRun runDatasetTitle = datasetLabelParagraph.createRun();
runDatasetTitle.setText(datasetEntity.getLabel());
runDatasetTitle.setColor("116a78");
//runDatasetTitle.setBold(true);
//runDatasetTitle.setFontSize(12);
XWPFParagraph datasetTemplateParagraph = document.createParagraph();
XWPFParagraph datasetTemplateParagraph = document.createParagraph();
// datasetTemplateParagraph.setStyle("Heading3");
XWPFRun runDatasetTemplate1 = datasetTemplateParagraph.createRun();
runDatasetTemplate1.setText("Template: ");
runDatasetTemplate1.setColor("000000");
//runDatasetTemplate1.setBold(true);
//runDatasetTemplate1.setFontSize(12);
XWPFRun runDatasetTemplate = datasetTemplateParagraph.createRun();
runDatasetTemplate.setText(datasetEntity.getProfile().getLabel());
runDatasetTemplate.setColor("116a78");
//runDatasetTemplate.setBold(true);
//runDatasetTemplate.setFontSize(12);
XWPFRun runDatasetTemplate1 = datasetTemplateParagraph.createRun();
runDatasetTemplate1.setText("Template: ");
runDatasetTemplate1.setColor("000000");
//runDatasetTemplate1.setBold(true);
//runDatasetTemplate1.setFontSize(12);
XWPFRun runDatasetTemplate = datasetTemplateParagraph.createRun();
runDatasetTemplate.setText(datasetEntity.getProfile().getLabel());
runDatasetTemplate.setColor("116a78");
//runDatasetTemplate.setBold(true);
//runDatasetTemplate.setFontSize(12);
// /*XWPFParagraph externalReferencesParagraph = document.createParagraph();
// externalReferencesParagraph.setStyle("Heading3");
@ -1634,29 +1630,29 @@ public class DataManagementPlanManager {
//
//
XWPFParagraph datasetDescParagraph = document.createParagraph();
XWPFRun runDatasetDescription1 = datasetDescParagraph.createRun();
runDatasetDescription1.setText("Description: ");
runDatasetDescription1.setColor("000000");
XWPFRun runDatasetDescription = datasetDescParagraph.createRun();
runDatasetDescription.setText(datasetEntity.getProfile().getLabel());
runDatasetDescription.setColor("116a78");
//wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
XWPFParagraph datasetDescParagraph = document.createParagraph();
XWPFRun runDatasetDescription1 = datasetDescParagraph.createRun();
runDatasetDescription1.setText("Type: ");
runDatasetDescription1.setColor("000000");
XWPFRun runDatasetDescription = datasetDescParagraph.createRun();
runDatasetDescription.setText(datasetEntity.getProfile().getType().getName());
runDatasetDescription.setColor("116a78");
//wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
document.createParagraph();
document.createParagraph();
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(dataset, datasetEntity);
visibilityRuleService.setProperties(properties);
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
try {
wordBuilder.build(document, pagedDatasetProfile, visibilityRuleService);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
// Page break at the end of the Dataset.
XWPFParagraph parBreakDataset = document.createParagraph();
parBreakDataset.setPageBreak(true);
});
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(dataset, datasetEntity);
visibilityRuleService.setProperties(properties);
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
try {
wordBuilder.build(document, pagedDatasetProfile, visibilityRuleService);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
// Page break at the end of the Dataset.
XWPFParagraph parBreakDataset = document.createParagraph();
parBreakDataset.setPageBreak(true);
}
//}
}
@ -1797,7 +1793,7 @@ public class DataManagementPlanManager {
// Funder.
Element funder = xmlDoc.createElement("funder");
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.GRANT, principal) && this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.FUNDER, principal)) {
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.GRANT, principal) && this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.FUNDER, principal) && dmp.getGrant() != null) {
Element funderLabel = xmlDoc.createElement("label");
Element funderId = xmlDoc.createElement("id");
funderLabel.setTextContent(dmp.getGrant().getFunder().getLabel());
@ -1815,7 +1811,7 @@ public class DataManagementPlanManager {
dmpElement.appendChild(funder);
// Grant.
Element grant = xmlDoc.createElement("grant");
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.GRANT, principal)) {
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.GRANT, principal) && dmp.getGrant() != null) {
Element grantLabel = xmlDoc.createElement("label");
Element grantId = xmlDoc.createElement("id");
grantLabel.setTextContent(dmp.getGrant().getLabel());
@ -1833,7 +1829,7 @@ public class DataManagementPlanManager {
dmpElement.appendChild(grant);
// Project.
Element project = xmlDoc.createElement("project");
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.PROJECT, principal)) {
if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.PROJECT, principal) && dmp.getProject() != null) {
Element projectId = xmlDoc.createElement("id");
Element projectLabel = xmlDoc.createElement("label");
Element projectDescription = xmlDoc.createElement("description");
@ -2276,6 +2272,11 @@ public class DataManagementPlanManager {
dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
this.updateIndex(dmp);
}
for(DMPDatasetProfile dmpDatasetProfile : dmp.getAssociatedDmps()){
dmpDatasetProfile.setDmp(dmp);
apiContext.getOperationsContext().getDatabaseRepository().getDmpDatasetProfileDao().createOrUpdate(dmpDatasetProfile);
}
dmp.getDataset().forEach(dataset -> {
dataset.setStatus(Dataset.Status.SAVED.getValue());
dataset.setCreated(new Date());

View File

@ -135,6 +135,17 @@ public class DataManagementProfileManager {
return false;
}
public List<Integer> sectionIndexesForDescriptionTemplate(DMPProfile dmpProfile, UUID descriptionTemplateId) {
DataManagementPlanBlueprintListingModel dmpBlueprint = new DataManagementPlanBlueprintListingModel();
dmpBlueprint.fromDataModel(dmpProfile);
List<Integer> sectionIndexes = new ArrayList<>();
for(int i = 0; i < dmpBlueprint.getDefinition().getSections().size(); i++) {
Section section = dmpBlueprint.getDefinition().getSections().get(i);
if(section.getHasTemplates() && section.getDescriptionTemplates().stream().anyMatch(x -> x.getDescriptionTemplateId().equals(descriptionTemplateId))) sectionIndexes.add(i);
}
return sectionIndexes;
}
public List<DataManagementPlanProfileListingModel> getWithCriteria(DataManagementPlanProfileCriteriaRequest dataManagementPlanProfileCriteriaRequest) throws IllegalAccessException, InstantiationException {
QueryableList<DMPProfile> items = databaseRepository.getDmpProfileDao().getWithCriteria(dataManagementPlanProfileCriteriaRequest.getCriteria());
List<DataManagementPlanProfileListingModel> datamanagementPlans = items.select(item -> new DataManagementPlanProfileListingModel().fromDataModel(item));

View File

@ -52,6 +52,7 @@ public class DatasetRDAMapper {
rda.setTitle(dataset.getLabel());
rda.setDescription(dataset.getDescription());
rda.setAdditionalProperty("template", dataset.getProfile().getId());
rda.setAdditionalProperty("dmpSectionIndex", dataset.getDmpSectionIndex());
try {
JSONObject jObject = new JSONObject(dataset.getProperties());
Map<String, Object> templateIdsToValues = jObject.toMap();
@ -284,6 +285,12 @@ public class DatasetRDAMapper {
eu.eudat.data.entities.Dataset entity = new eu.eudat.data.entities.Dataset();
entity.setLabel(rda.getTitle());
entity.setDescription(rda.getDescription());
if (rda.getAdditionalProperties().get("dmpSectionIndex") != null) {
entity.setDmpSectionIndex(Integer.parseInt(rda.getAdditionalProperties().get("dmpSectionIndex").toString()));
} else {
entity.setDmpSectionIndex(0);
}
try {
DescriptionTemplate profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString()));
entity.setProfile(profile);

View File

@ -1,8 +1,11 @@
package eu.eudat.models.rda.mapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.*;
import eu.eudat.logic.managers.DataManagementProfileManager;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
import eu.eudat.models.data.dmp.AssociatedProfile;
import eu.eudat.models.rda.Dmp;
import eu.eudat.models.rda.DmpId;
import net.minidev.json.JSONObject;
@ -24,13 +27,13 @@ public class DmpRDAMapper {
private DatasetRDAMapper datasetRDAMapper;
private ApiContext apiContext;
private DataManagementProfileManager dataManagementProfileManager;
@Autowired
public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper, ApiContext apiContext) throws IOException {
public DmpRDAMapper(DatasetRDAMapper datasetRDAMapper, ApiContext apiContext, DataManagementProfileManager dataManagementProfileManager) throws IOException {
this.datasetRDAMapper = datasetRDAMapper;
this.apiContext = apiContext;
this.dataManagementProfileManager = dataManagementProfileManager;
}
@Transactional
@ -116,10 +119,15 @@ public class DmpRDAMapper {
}
// rda.getContributor().addAll(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
rda.setDataset(dmp.getDataset().stream().filter(dataset -> dataset.getStatus() != eu.eudat.elastic.entities.Dmp.DMPStatus.DELETED.getValue()).map(dataset -> datasetRDAMapper.toRDA(dataset, rda)).collect(Collectors.toList()));
if (dmp.getProject() != null) {
rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant())));
}
rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray());
rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant())));
rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(item -> item.getDatasetprofile().getId().toString()).toArray());
rda.setAdditionalProperty("blueprintId", dmp.getProfile().getId());
rda.setAdditionalProperty("license", extraProperties.get("license"));
rda.setAdditionalProperty("visible", extraProperties.get("visible"));
rda.setAdditionalProperty("publicDate", extraProperties.get("publicDate"));
rda.setAdditionalProperty("contact", extraProperties.get("contact"));
rda.setAdditionalProperty("dmpProperties", dmp.getProperties());
return rda;
}
@ -138,26 +146,46 @@ public class DmpRDAMapper {
entity.setDois(new HashSet<>());
}
}
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 -> this.getProfile(x, entity.getId())).filter(Objects::nonNull).collect(Collectors.toSet()));
}
if (entity.getAssociatedDmps() == null) {
entity.setAssociatedDmps(new HashSet<>());
}
if (profiles != null && entity.getId() != null) {
for (String profile : profiles) {
entity.getAssociatedDmps().add(this.getProfile(profile, entity.getId()));
String blueprintId = (String) rda.getAdditionalProperties().get("blueprintId");
DMPProfile blueprint = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().find(UUID.fromString(blueprintId));
entity.setProfile(blueprint);
if (((List<String>) rda.getAdditionalProperties().get("templates")) != null && !((List<String>) rda.getAdditionalProperties().get("templates")).isEmpty()) {
List<DescriptionTemplate> descriptionTemplates = ((List<String>) rda.getAdditionalProperties().get("templates")).stream().map(this::getProfile).filter(Objects::nonNull).collect(Collectors.toList());
Set<DMPDatasetProfile> dmpDatasetProfiles = new HashSet<>();
for (DescriptionTemplate profile : descriptionTemplates) {
DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile();
dmpDatasetProfile.setDmp(entity);
dmpDatasetProfile.setDatasetprofile(profile);
String indexes = this.dataManagementProfileManager.sectionIndexesForDescriptionTemplate(blueprint, profile.getId()).stream()
.map(String::valueOf) // convert each int to a string
.collect(Collectors.joining(","));
dmpDatasetProfile.setData("{\"dmpSectionIndex\":[" + indexes + "]}");
dmpDatasetProfiles.add(dmpDatasetProfile);
}
entity.setAssociatedDmps(dmpDatasetProfiles);
}
// if (entity.getAssociatedDmps() == null) {
// entity.setAssociatedDmps(new HashSet<>());
// }
// if (profiles != null && entity.getId() != null) {
// for (String profile : profiles) {
// entity.getAssociatedDmps().add(this.getProfile(profile, entity.getId()));
// }
// }
if (rda.getContributor() != null && !rda.getContributor().isEmpty() && rda.getContributor().get(0).getContributorId() != null) {
entity.setResearchers(rda.getContributor().stream().filter(r -> r.getContributorId() != null).map(ContributorRDAMapper::toEntity).filter(StreamDistinctBy.distinctByKey(Researcher::getReference)).collect(Collectors.toSet()));
}
entity.setCreated(rda.getCreated());
entity.setModified(rda.getModified());
entity.setDescription(rda.getDescription());
DescriptionTemplate defaultProfile = ((DescriptionTemplate)entity.getAssociatedDmps().toArray()[0]);
entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1, defaultProfile)).collect(Collectors.toSet()));
if (rda.getProject().size() > 0) {
if(entity.getAssociatedDmps().size() > 0) {
DescriptionTemplate defaultProfile = entity.getAssociatedDmps().stream().findFirst().get().getDatasetprofile();
entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1, defaultProfile)).collect(Collectors.toSet()));
}
if (rda.getProject() != null && rda.getProject().size() > 0) {
Map<String, Object> result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext);
entity.setProject((Project) result.get("project"));
result.entrySet().stream().filter(entry -> entry.getKey().startsWith("grant")).forEach(entry -> entity.setGrant((Grant) entry.getValue()));
@ -165,16 +193,19 @@ public class DmpRDAMapper {
Map<String, Object> extraProperties = new HashMap<>();
extraProperties.put("language", LanguageRDAMapper.mapRDAIsoToLanguageIso(rda.getLanguage()));
if (rda.getAdditionalProperties().get("license") != null) extraProperties.put("license", rda.getAdditionalProperties().get("license"));
if (rda.getAdditionalProperties().get("visible") != null) extraProperties.put("visible", rda.getAdditionalProperties().get("visible"));
if (rda.getAdditionalProperties().get("publicDate") != null) extraProperties.put("publicDate", rda.getAdditionalProperties().get("publicDate"));
if (rda.getAdditionalProperties().get("contact") != null) extraProperties.put("contact", rda.getAdditionalProperties().get("contact"));
entity.setExtraProperties(JSONObject.toJSONString(extraProperties));
if (rda.getAdditionalProperties().get("dmpProperties") != null) entity.setProperties(rda.getAdditionalProperties().get("dmpProperties").toString());
return entity;
}
private DMPDatasetProfile getProfile(String descriptionTemplateId, UUID dmpId) {
return apiContext.getOperationsContext().getDatabaseRepository().getDmpDatasetProfileDao().asQueryable().where(((builder, root) -> builder.and(
builder.equal(root.get("datasetprofile"), UUID.fromString(descriptionTemplateId)),
builder.equal(root.get("dmp"), dmpId))
)).getSingleOrDefault();
private DescriptionTemplate getProfile(String id) {
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().asQueryable().where(((builder, root) -> builder.equal(root.get("id"), UUID.fromString(id)))).getSingleOrDefault();
}
}

View File

@ -17,13 +17,13 @@ public class ProjectRDAMapper {
public static Project toRDA(eu.eudat.data.entities.Project project, Grant grant) {
Project rda = new Project();
try {
rda.setTitle(project.getLabel());
rda.setDescription(project.getDescription());
if (project.getStartdate() != null) {
rda.setStart(project.getStartdate().toString());
rda.setTitle(grant.getLabel());
rda.setDescription(grant.getDescription());
if (grant.getStartdate() != null) {
rda.setStart(grant.getStartdate().toString());
}
if (project.getEnddate() != null) {
rda.setEnd(project.getEnddate().toString());
if (grant.getEnddate() != null) {
rda.setEnd(grant.getEnddate().toString());
}
rda.setFunding(Collections.singletonList(FundingRDAMapper.toRDA(grant)));

View File

@ -306,7 +306,7 @@
"DATASET-TEMPLATE-NAME": "Description template name",
"DATASET-TEMPLATE-NAME-HINT": "A title that determines the Description template.",
"DATASET-TEMPLATE-DESCRIPTION": "Description",
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Description is about, it's scope and objectives.",
"DESCRIPTION-TEMPLATE-TYPE": "Description template type",
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
@ -318,7 +318,7 @@
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",
"DATASET-TEMPLATE-NO-USERS-YET": "... No editors yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add Editor",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",
"TEMPLATE-OUTLINE": "Template outline",
@ -871,10 +871,10 @@
"DESCRIPTION": "Description",
"SELECT-DESCRIPTIONS-TO-CLONE": "Select which descriptions to include in the new DMP. Selected descriptions will be editable.",
"SELECT-DESCRIPTIONS-NONE": "Not available Descriptions for this DMP.",
"TEXT-INFO": "Datasets are documented following pre-defined templates which set the content of dataset descriptions. In {{ APP_NAME }}, a DMP can contain as many dataset descriptions as the datasets it documents. Browse ",
"TEXT-INFO-REST": " for a look at datasets described in {{ APP_NAME }} DMPs",
"LINK-PUBLIC-DATASETS": "Public Datasets",
"TEXT-INFO-PAR": "New datasets can be added to existing DMPs at any time and be described with more than one template. Datasets can also be cloned and re-used in other DMPs as well as be deleted without negatively affecting the DMP as a whole.",
"TEXT-INFO": "Descriptions are documented following pre-defined templates which set the content of the descriptions. In {{ APP_NAME }}, a DMP can contain as many descriptions as the entities it documents. Browse ",
"TEXT-INFO-REST": " for a look at entities described in {{ APP_NAME }} DMPs",
"LINK-PUBLIC-DATASETS": "Public Descriptions",
"TEXT-INFO-PAR": "New descriptions can be added to existing DMPs at any time and be described with more than one template. Descriptions can also be cloned and re-used in other DMPs as well as be deleted without negatively affecting the DMP as a whole.",
"COLUMNS": {
"NAME": "Name",
"REFERNCE": "Referenz",

View File

@ -27,7 +27,7 @@
"UNSUCCESSFUL-LOGOUT": "Unsuccessful Logout",
"UNSUCCESSFUL-LOGIN": "Unsuccessful Login",
"SUCCESSFUL-DATASET-PROFILE-DELETE": "Successful Delete",
"UNSUCCESSFUL-DATASET-PROFILE-DELETE": "This template can not deleted, because Datasets are associated with it",
"UNSUCCESSFUL-DATASET-PROFILE-DELETE": "This template can not deleted, because Descriptions are associated with it",
"SUCCESSFUL-DMP-BLUEPRINT-DELETE": "Successful Delete",
"UNSUCCESSFUL-DMP-BLUEPRINT-DELETE": "This blueprint can not deleted, because DMPs are associated with it",
"SUCCESSFUL-DESCRIPTION-TEMPLATE-TYPE-DELETE": "Successful Delete",
@ -306,7 +306,7 @@
"DATASET-TEMPLATE-NAME": "Description template name",
"DATASET-TEMPLATE-NAME-HINT": "A title that determines the Description template.",
"DATASET-TEMPLATE-DESCRIPTION": "Description",
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Description is about, it's scope and objectives.",
"DESCRIPTION-TEMPLATE-TYPE": "Description template type",
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
@ -634,7 +634,7 @@
"PUBLISHED": "Published",
"VERSION": "Version",
"CONTAINED-DESCRIPTIONS": "Contained Descriptions",
"TEXT-INFO": "Information in a DMP show how datasets have been collected and/or generated, how they have been processed and analyzed, i.e. using which tools, standards, methodologies etc, but also where and how datasets are backed up, published and preserved, including any costs associated with personnel dedicated for data curation/ stewardship activities or costs for acquiring or building data management services.",
"TEXT-INFO": "Information in a DMP show how descriptions have been collected and/or generated, how they have been processed and analyzed, i.e. using which tools, standards, methodologies etc, but also where and how descriptions are backed up, published and preserved, including any costs associated with personnel dedicated for data curation/ stewardship activities or costs for acquiring or building data management services.",
"TEXT-INFO-QUESTION": "Not sure how a DMP looks in practice? Browse Public DMPs and",
"LINK-ZENODO": "LIBER community in Zenodo",
"GET-IDEA": "to get an idea!",
@ -867,14 +867,14 @@
}
},
"DATASET-LISTING": {
"TITLE": "Datasets",
"TITLE": "Datensatzbeschreibungen",
"DESCRIPTION": "Description",
"SELECT-DESCRIPTIONS-TO-CLONE": "Select which descriptions to include in the new DMP. Selected descriptions will be editable.",
"SELECT-DESCRIPTIONS-NONE": "Not available Descriptions for this DMP.",
"TEXT-INFO": "Datasets are documented following pre-defined templates which set the content of dataset descriptions. In {{ APP_NAME }}, a DMP can contain as many dataset descriptions as the datasets it documents. Browse ",
"TEXT-INFO-REST": " for a look at datasets described in {{ APP_NAME }} DMPs",
"LINK-PUBLIC-DATASETS": "Public Datasets",
"TEXT-INFO-PAR": "New datasets can be added to existing DMPs at any time and be described with more than one template. Datasets can also be cloned and re-used in other DMPs as well as be deleted without negatively affecting the DMP as a whole.",
"TEXT-INFO": "Descriptions are documented following pre-defined templates which set the content of the descriptions. In {{ APP_NAME }}, a DMP can contain as many descriptions as the entities it documents. Browse ",
"TEXT-INFO-REST": " for a look at entities described in {{ APP_NAME }} DMPs",
"LINK-PUBLIC-DATASETS": "Public Descriptions",
"TEXT-INFO-PAR": "New descriptions can be added to existing DMPs at any time and be described with more than one template. Descriptions can also be cloned and re-used in other DMPs as well as be deleted without negatively affecting the DMP as a whole.",
"COLUMNS": {
"NAME": "Name",
"REFERNCE": "Reference",
@ -1185,7 +1185,7 @@
},
"DATASET-INFO": {
"INTRO": "A DMP in {{ APP_NAME }} consists of key information about research, such as purpose, objectives and researchers involved, but also about documentation of research datasets that highlight the steps followed and the means used across data management activities.",
"SECOND-INTRO": "Datasets are documented following pre-defined templates which set the content of dataset descriptions. In {{ APP_NAME }}, a DMP can contain as many dataset descriptions as the datasets it documents.",
"SECOND-INTRO": "Descriptions are documented following pre-defined templates which set the content of dataset descriptions. In {{ APP_NAME }}, a DMP can contain as many dataset descriptions as the datasets it documents.",
"FIND": "Couldn't find a suitable one?",
"HINT": "Select a template to describe your descriptions. You may select more than one template."
},
@ -1711,7 +1711,7 @@
"PERSONAL-USAGE": "Personal Usage",
"PUBLIC-USAGE": "Public Usage",
"DESCRIPTIONS": "Descriptions",
"DATASET-DESCRIPTIONS-DASHBOARD-TEXT": "Datasets",
"DATASET-DESCRIPTIONS-DASHBOARD-TEXT": "Descriptions",
"PUBLIC-DMPS": "Public DMPs",
"PUBLIC-DATASETS": "Public Datasets",
"RELATED-ORGANISATIONS": "Related Organizations",
@ -1719,7 +1719,7 @@
"ALL": "All",
"EMPTY-LIST": "Nothing here yet.",
"LATEST-ACTIVITY": "Latest Activity",
"DMP-ABOUT-BEG": "A DMP in {{ APP_NAME }} consists of key information about research, such as purpose, objectives and researchers involved, but also about documentation of research datasets, namely",
"DMP-ABOUT-BEG": "A DMP in {{ APP_NAME }} consists of key information about research, such as purpose, objectives and researchers involved, but also about documentation of research entities, namely",
"DMP-ABOUT-END": ", that highlight the steps followed and the means used across data management activities.",
"SELECT-DMP": "Select a DMP for your Dataset",
"ACTIONS": {

View File

@ -306,7 +306,7 @@
"DATASET-TEMPLATE-NAME": "Description template name",
"DATASET-TEMPLATE-NAME-HINT": "A title that determines the Description template.",
"DATASET-TEMPLATE-DESCRIPTION": "Description",
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Description is about, it's scope and objectives.",
"DESCRIPTION-TEMPLATE-TYPE": "Description template type",
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
@ -318,7 +318,7 @@
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",
"DATASET-TEMPLATE-NO-USERS-YET": "... No editors yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add Editor",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",
"TEMPLATE-OUTLINE": "Template outline",

View File

@ -306,7 +306,7 @@
"DATASET-TEMPLATE-NAME": "Description template name",
"DATASET-TEMPLATE-NAME-HINT": "A title that determines the Description template.",
"DATASET-TEMPLATE-DESCRIPTION": "Description",
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Description is about, it's scope and objectives.",
"DESCRIPTION-TEMPLATE-TYPE": "Description template type",
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
@ -318,7 +318,7 @@
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",
"DATASET-TEMPLATE-NO-USERS-YET": "... No editors yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add Editor",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",
"TEMPLATE-OUTLINE": "Template outline",

View File

@ -306,7 +306,7 @@
"DATASET-TEMPLATE-NAME": "Description template name",
"DATASET-TEMPLATE-NAME-HINT": "A title that determines the Description template.",
"DATASET-TEMPLATE-DESCRIPTION": "Description",
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Description is about, it's scope and objectives.",
"DESCRIPTION-TEMPLATE-TYPE": "Description template type",
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
@ -318,7 +318,7 @@
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",
"DATASET-TEMPLATE-NO-USERS-YET": "... No editors yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add Editor",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",
"TEMPLATE-OUTLINE": "Template outline",

View File

@ -306,7 +306,7 @@
"DATASET-TEMPLATE-NAME": "Description template name",
"DATASET-TEMPLATE-NAME-HINT": "A title that determines the Description template.",
"DATASET-TEMPLATE-DESCRIPTION": "Description",
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Dataset is about, it's scope and objectives.",
"DATASET-TEMPLATE-DESCRIPTION-HINT": "A brief description of what the Description is about, it's scope and objectives.",
"DESCRIPTION-TEMPLATE-TYPE": "Description template type",
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
@ -318,7 +318,7 @@
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",
"DATASET-TEMPLATE-NO-USERS-YET": "... No editors yet",
"DATASET-TEMPLATE-VALIDATE-AND-ADD-USER": "Validate and Add Editor",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Dataset template description",
"DATASET-TEMPLATE-DESCRIPTION-PLACEHOLDER": "Template description",
"UNTITLED": "Untitled",
"QUESTION": "Question",
"TEMPLATE-OUTLINE": "Template outline",