Merge branch 'Development' of code-repo.d4science.org:MaDgiK-CITE/argos into Development
This commit is contained in:
commit
0bb98a4009
|
@ -291,12 +291,12 @@ public class Datasets extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.GET, value = {"/{id}/validate"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Boolean>> validate(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
|
||||
try {
|
||||
Dataset dataset = datasetManager.getEntitySingle(id);
|
||||
datasetManager.checkDatasetValidation(dataset);
|
||||
Dataset dataset = datasetManager.getEntitySingle(id);
|
||||
String failedField = datasetManager.checkDatasetValidation(dataset);
|
||||
if (failedField == null) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Boolean>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Valid"));
|
||||
} catch (Exception datasetWizardCannotUnlockException) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Boolean>().status(ApiMessageCode.ERROR_MESSAGE).message(datasetWizardCannotUnlockException.getMessage()));
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Boolean>().status(ApiMessageCode.ERROR_MESSAGE).message("Field value of " + failedField + " must be filled."));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1220,9 +1220,12 @@ public class DataManagementPlanManager {
|
|||
wordBuilder.addParagraphContent("Datasets", document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
||||
// Space below Datasets.
|
||||
XWPFParagraph parBreakDatasets = document.createParagraph();
|
||||
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())
|
||||
.forEach(datasetEntity -> {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
if (datasetEntity.getProperties() != null) {
|
||||
|
@ -1348,7 +1351,13 @@ public class DataManagementPlanManager {
|
|||
eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||
if (!dmp.isPublic() && dmp.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
|
||||
throw new UnauthorisedException();
|
||||
List<Dataset> datasets = dmp.getDataset().stream().filter(dataset -> dataset.getStatus() != Dmp.DMPStatus.DELETED.getValue()).collect(Collectors.toList());
|
||||
final Boolean isFinalized = dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
||||
final Boolean isPublic = dmp.isPublic();
|
||||
List<Dataset> datasets = dmp.getDataset().stream()
|
||||
.filter(dataset -> dataset.getStatus() != Dataset.Status.DELETED.getValue() &&
|
||||
dataset.getStatus() != Dataset.Status.CANCELED.getValue())
|
||||
.filter(dataset -> !isPublic && !isFinalized || dataset.getStatus() == Dataset.Status.FINALISED.getValue())
|
||||
.collect(Collectors.toList());
|
||||
/*String fileName = dmp.getLabel();
|
||||
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "");*/
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
|
@ -1499,6 +1508,13 @@ public class DataManagementPlanManager {
|
|||
if (!dmp.isPublic() && dmp.getUsers().stream().noneMatch(userInfo -> userInfo.getUser().getId() == principal.getId()))
|
||||
throw new UnauthorisedException();
|
||||
// RDAExportModel rdaExportModel = new RDAExportModel().fromDataModel(dmp, datasetManager, principal);
|
||||
final Boolean isFinalized = dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
||||
final Boolean isPublic = dmp.isPublic();
|
||||
dmp.setDataset(dmp.getDataset().stream()
|
||||
.filter(dataset -> dataset.getStatus() != Dataset.Status.DELETED.getValue() &&
|
||||
dataset.getStatus() != Dataset.Status.CANCELED.getValue())
|
||||
.filter(dataset -> !isPublic && !isFinalized || dataset.getStatus() == Dataset.Status.FINALISED.getValue())
|
||||
.collect(Collectors.toSet()));
|
||||
String result = rdaManager.convertToRDA(dmp);
|
||||
|
||||
/*ObjectMapper mapper = new ObjectMapper();
|
||||
|
|
|
@ -587,8 +587,12 @@ public class DatasetManager {
|
|||
if (this.apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().getClient() != null) {
|
||||
this.getTagsFromProfile(datasetWizardModel, dataset);
|
||||
}
|
||||
if (datasetWizardModel.getStatus() == (int) Dataset.Status.FINALISED.getValue())
|
||||
checkDatasetValidation(dataset);
|
||||
if (datasetWizardModel.getStatus() == (int) Dataset.Status.FINALISED.getValue()) {
|
||||
String failedField = checkDatasetValidation(dataset);
|
||||
if (failedField != null) {
|
||||
throw new Exception("Field value of " + failedField + " must be filled.");
|
||||
}
|
||||
}
|
||||
UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
||||
dataset.setCreator(userInfo);
|
||||
|
||||
|
@ -683,7 +687,7 @@ public class DatasetManager {
|
|||
|
||||
}
|
||||
|
||||
public void checkDatasetValidation(Dataset dataset) throws Exception {
|
||||
public String checkDatasetValidation(Dataset dataset) throws Exception {
|
||||
List<String> datasetProfileValidators = new LinkedList<>();
|
||||
DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(dataset.getProfile().getId());
|
||||
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
|
||||
|
@ -712,11 +716,17 @@ public class DatasetManager {
|
|||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||
|
||||
|
||||
String failedField = null;
|
||||
|
||||
for (String validator : datasetProfileValidators) {
|
||||
if (obj.has(validator) && isNullOrEmpty(obj.getString(validator)) && isElementVisible(nodeList, validator, visibilityRuleService)) {
|
||||
throw new Exception("Field value of " + validator + " must be filled.");
|
||||
//throw new Exception("Field value of " + validator + " must be filled.");
|
||||
failedField = validator;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return failedField;
|
||||
}
|
||||
|
||||
private boolean isNullOrEmpty(String value) {
|
||||
|
|
Loading…
Reference in New Issue