Updated RDA Mapper's Cardinality check
This commit is contained in:
parent
0ad797d033
commit
cbbfec2ccc
|
@ -8,7 +8,13 @@ public class ContactRDAMapper {
|
|||
|
||||
public static Contact toRDA(UserInfo creator) {
|
||||
Contact rda = new Contact();
|
||||
if (creator.getName() == null) {
|
||||
throw new IllegalArgumentException("Contact Name is missing");
|
||||
}
|
||||
rda.setName(creator.getName());
|
||||
if (creator.getEmail() == null) {
|
||||
throw new IllegalArgumentException("Contact Email is missing");
|
||||
}
|
||||
rda.setMbox(creator.getEmail());
|
||||
rda.setContactId(ContactIdRDAMapper.toRDA(creator.getId()));
|
||||
return rda;
|
||||
|
|
|
@ -17,6 +17,9 @@ public class ContributorRDAMapper {
|
|||
public static Contributor toRDA(UserDMP userDMP) {
|
||||
Contributor rda = new Contributor();
|
||||
rda.setContributorId(ContributorIdRDAMapper.toRDA(userDMP.getUser().getId()));
|
||||
if (userDMP.getUser().getName() == null) {
|
||||
throw new IllegalArgumentException("Contributor Name is missing");
|
||||
}
|
||||
rda.setName(userDMP.getUser().getName());
|
||||
rda.setMbox(userDMP.getUser().getEmail());
|
||||
rda.setRole(new HashSet<>(Arrays.asList(UserDMP.UserDMPRoles.fromInteger(userDMP.getRole()).name())));
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package eu.eudat.models.rda.mapper;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import eu.eudat.models.rda.Cost;
|
||||
|
||||
public class CostRDAMapper {
|
||||
|
||||
public static Cost toRDA(Map<String, Object> cost) {
|
||||
Cost rda = new Cost();
|
||||
Map<String, Object> code = new org.json.JSONObject((String) cost.get("code")).toMap();
|
||||
rda.setCurrencyCode(Cost.CurrencyCode.fromValue((String) code.get("value")));
|
||||
rda.setDescription((String) cost.get("description"));
|
||||
if (cost.get("title") == null) {
|
||||
throw new IllegalArgumentException("Cost Title is missing");
|
||||
}
|
||||
rda.setTitle((String) cost.get("title"));
|
||||
rda.setValue(((Integer) cost.get("value")).doubleValue());
|
||||
return rda;
|
||||
}
|
||||
|
||||
}
|
|
@ -42,6 +42,9 @@ public class DatasetRDAMapper {
|
|||
public Dataset toRDA(eu.eudat.data.entities.Dataset dataset, List<Contributor> contributors) {
|
||||
Dataset rda = new Dataset();
|
||||
// rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId()));
|
||||
if (dataset.getLabel() == null) {
|
||||
throw new IllegalArgumentException("Dataaset Label is missing");
|
||||
}
|
||||
rda.setTitle(dataset.getLabel());
|
||||
rda.setDescription(dataset.getDescription());
|
||||
rda.setAdditionalProperty("template", dataset.getProfile().getId());
|
||||
|
|
|
@ -247,6 +247,13 @@ public class DistributionRDAMapper {
|
|||
|
||||
}
|
||||
|
||||
if (rda.getTitle() == null) {
|
||||
throw new IllegalArgumentException("Distribution title is missing");
|
||||
}
|
||||
|
||||
if (rda.getDataAccess() == null) {
|
||||
throw new IllegalArgumentException("Distribution Data Access is missing");
|
||||
}
|
||||
|
||||
return rda;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,9 @@ public class DmpRDAMapper {
|
|||
|
||||
@Transactional
|
||||
public Dmp toRDA(DMP dmp) {
|
||||
if (dmp.getDataset() == null || dmp.getDataset().isEmpty()) {
|
||||
throw new IllegalArgumentException("DMP has no Datasets");
|
||||
}
|
||||
Map<String, Object> extraProperties;
|
||||
if (dmp.getExtraProperties() == null) {
|
||||
throw new IllegalArgumentException("DMP is missing required Data for RDA export");
|
||||
|
@ -49,6 +52,15 @@ public class DmpRDAMapper {
|
|||
} else {
|
||||
rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getId()));
|
||||
}
|
||||
if (dmp.getCreated() == null) {
|
||||
throw new IllegalArgumentException("DMP Created is missing");
|
||||
}
|
||||
if (dmp.getModified() == null) {
|
||||
throw new IllegalArgumentException("DMP Modified is missing");
|
||||
}
|
||||
if (dmp.getLabel() == null) {
|
||||
throw new IllegalArgumentException("DMP Label is missing");
|
||||
}
|
||||
rda.setCreated(dmp.getCreated());
|
||||
rda.setDescription(dmp.getDescription());
|
||||
rda.setModified(dmp.getModified());
|
||||
|
@ -64,13 +76,7 @@ public class DmpRDAMapper {
|
|||
if (extraProperties.get("costs") != null) {
|
||||
rda.setCost(new ArrayList<>());
|
||||
((List) extraProperties.get("costs")).forEach(costl -> {
|
||||
Cost cost = new Cost();
|
||||
Map<String, Object> code = new org.json.JSONObject((String) ((Map) costl).get("code")).toMap();
|
||||
cost.setCurrencyCode(Cost.CurrencyCode.fromValue((String) code.get("value")));
|
||||
cost.setDescription((String) ((Map) costl).get("description"));
|
||||
cost.setTitle((String) ((Map) costl).get("title"));
|
||||
cost.setValue(((Integer) ((Map) costl).get("value")).doubleValue());
|
||||
rda.getCost().add(cost);
|
||||
rda.getCost().add(CostRDAMapper.toRDA((Map)costl));
|
||||
});
|
||||
}
|
||||
UserInfo contact = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(UUID.fromString((String) extraProperties.get("contact")));
|
||||
|
|
|
@ -77,6 +77,14 @@ public class HostRDAMapper {
|
|||
}
|
||||
}
|
||||
|
||||
if (rda.getTitle() == null) {
|
||||
throw new IllegalArgumentException("Host Title is missing");
|
||||
}
|
||||
|
||||
if (rda.getUrl() == null) {
|
||||
throw new IllegalArgumentException("Host Url is missing");
|
||||
}
|
||||
|
||||
return rda;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,14 @@ public class LicenseRDAMapper {
|
|||
}*/
|
||||
}
|
||||
|
||||
if (rda.getLicenseRef() == null) {
|
||||
throw new IllegalArgumentException("Licence Reference is missing");
|
||||
}
|
||||
|
||||
if (rda.getStartDate() == null) {
|
||||
throw new IllegalArgumentException("License Start Date is missing");
|
||||
}
|
||||
|
||||
return rda;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,10 @@ public class ProjectRDAMapper {
|
|||
}
|
||||
rda.setFunding(Collections.singletonList(FundingRDAMapper.toRDA(grant)));
|
||||
|
||||
if (rda.getTitle() == null) {
|
||||
throw new IllegalArgumentException("Project Title is missing");
|
||||
}
|
||||
|
||||
return rda;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,10 +69,15 @@ public class SecurityAndPrivacyRDAMapper {
|
|||
|
||||
if (rdaProperty.contains("description")) {
|
||||
rda.setDescription(value);
|
||||
} else if (rdaProperty.contains("title")) {
|
||||
}
|
||||
if (rdaProperty.contains("title")) {
|
||||
rda.setTitle(value);
|
||||
}
|
||||
|
||||
if (rda.getTitle() == null) {
|
||||
throw new IllegalArgumentException("Security And Privacy Title is missing");
|
||||
}
|
||||
|
||||
return rda;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,10 +70,15 @@ public class TechnicalResourceRDAMapper {
|
|||
|
||||
if (rdaProperty.contains("description")) {
|
||||
rda.setDescription(value);
|
||||
} else if (rdaProperty.contains("name")) {
|
||||
}
|
||||
if (rdaProperty.contains("name")) {
|
||||
rda.setName(value);
|
||||
}
|
||||
|
||||
if (rda.getName() == null) {
|
||||
throw new IllegalArgumentException("Technical Resources Name is missing");
|
||||
}
|
||||
|
||||
return rda;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue