When exporting dataset to RDA keep ONLY the researchers as contributors
This commit is contained in:
parent
5a07e4f01b
commit
2c16e1c376
|
@ -1343,6 +1343,15 @@ public class DataManagementPlanManager {
|
|||
dmp.setVersion(0);
|
||||
dmp.setStatus((short)0);
|
||||
dmp.setGroupId(UUID.randomUUID());
|
||||
if (dmp.getResearchers() != null && !dmp.getResearchers().isEmpty()) {
|
||||
dmp.getResearchers().forEach(researcher -> {
|
||||
researcher.setId(UUID.randomUUID());
|
||||
researcher.setCreated(new Date());
|
||||
researcher.setModified(new Date());
|
||||
researcher.setStatus((short) 0);
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().createOrUpdate(researcher);
|
||||
});
|
||||
}
|
||||
databaseRepository.getDmpDao().createOrUpdate(dmp);
|
||||
assignUser(dmp, me);
|
||||
dmp.getDataset().forEach(dataset -> {
|
||||
|
|
|
@ -7,10 +7,18 @@ import java.util.UUID;
|
|||
|
||||
public class ContributorIdRDAMapper {
|
||||
|
||||
public static ContributorId toRDA(UUID id) {
|
||||
public static ContributorId toRDA(Object id) {
|
||||
ContributorId rda = new ContributorId();
|
||||
rda.setIdentifier(id.toString());
|
||||
rda.setType(ContributorId.Type.OTHER);
|
||||
String idParts[] = id.toString().split(":");
|
||||
String prefix = idParts.length > 1 ? idParts[0] : id.toString();
|
||||
if (prefix.equals("orcid")) {
|
||||
String finalId = id.toString().replace(prefix + ":", "");
|
||||
rda.setIdentifier("http://orcid.org/" + finalId);
|
||||
rda.setType(ContributorId.Type.ORCID);
|
||||
} else {
|
||||
rda.setIdentifier(id.toString());
|
||||
rda.setType(ContributorId.Type.OTHER);
|
||||
}
|
||||
return rda;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package eu.eudat.models.rda.mapper;
|
||||
|
||||
import eu.eudat.data.entities.Researcher;
|
||||
import eu.eudat.data.entities.UserDMP;
|
||||
import eu.eudat.models.rda.Contributor;
|
||||
import eu.eudat.models.rda.ContributorId;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class ContributorRDAMapper {
|
||||
|
@ -17,4 +18,34 @@ public class ContributorRDAMapper {
|
|||
rda.setRole(new HashSet<>(Arrays.asList(UserDMP.UserDMPRoles.fromInteger(userDMP.getRole()).name())));
|
||||
return rda;
|
||||
}
|
||||
|
||||
public static Contributor toRDA(Researcher researcher) {
|
||||
Contributor rda = new Contributor();
|
||||
rda.setContributorId(ContributorIdRDAMapper.toRDA(researcher.getReference()));
|
||||
rda.setName(researcher.getLabel());
|
||||
rda.setMbox(researcher.getPrimaryEmail());
|
||||
// rda.setRole(new HashSet<>(Arrays.asList(UserDMP.UserDMPRoles.fromInteger(userDMP.getRole()).name())));
|
||||
return rda;
|
||||
}
|
||||
|
||||
public static Researcher toEntity(Contributor rda) {
|
||||
Researcher entity = new Researcher();
|
||||
String reference;
|
||||
if (rda.getContributorId().getType() == ContributorId.Type.ORCID) {
|
||||
String id = rda.getContributorId().getIdentifier().replace("http://orcid.org/", "");
|
||||
reference = "orcid:" + id;
|
||||
} else {
|
||||
String idParts[] = rda.getContributorId().getIdentifier().split(":");
|
||||
if (idParts.length == 1) {
|
||||
reference = "dmp:" + rda.getContributorId().getIdentifier();
|
||||
} else {
|
||||
reference = rda.getContributorId().getIdentifier();
|
||||
}
|
||||
}
|
||||
entity.setReference(reference);
|
||||
entity.setLabel(rda.getName());
|
||||
entity.setPrimaryEmail(rda.getMbox());
|
||||
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,11 @@ public class DmpRDAMapper {
|
|||
creator = dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).map(UserDMP::getUser).findFirst().orElse(new UserInfo());
|
||||
}
|
||||
rda.setContact(ContactRDAMapper.toRDA(creator));
|
||||
rda.setContributor(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
|
||||
rda.setContributor(new ArrayList<>());
|
||||
if (dmp.getResearchers() != null && !dmp.getResearchers().isEmpty()) {
|
||||
rda.getContributor().addAll(dmp.getResearchers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
|
||||
}
|
||||
// rda.getContributor().addAll(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
|
||||
rda.setDataset(dmp.getDataset().stream().map(dataset -> datasetRDAMapper.toRDA(dataset)).collect(Collectors.toList()));
|
||||
rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant())));
|
||||
rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray());
|
||||
|
@ -56,6 +60,9 @@ public class DmpRDAMapper {
|
|||
if (rda.getDmpId().getType() == DmpId.Type.DOI) {
|
||||
entity.setDoi(rda.getDmpId().getIdentifier());
|
||||
}
|
||||
if (rda.getContributor() != null && !rda.getContributor().isEmpty()) {
|
||||
entity.setResearchers(rda.getContributor().stream().map(ContributorRDAMapper::toEntity).collect(Collectors.toSet()));
|
||||
}
|
||||
entity.setCreated(rda.getCreated());
|
||||
entity.setModified(rda.getModified());
|
||||
entity.setDescription(rda.getDescription());
|
||||
|
|
Loading…
Reference in New Issue