Makes Funder a mandatory entity. (Issue #182)

This commit is contained in:
gkolokythas 2019-10-08 10:58:02 +03:00
parent f2833576d3
commit f59881d7aa
2 changed files with 14 additions and 16 deletions

View File

@ -44,10 +44,12 @@ public class QuickWizardController extends BaseController {
Funder funderEntity;
//Create Funder
if (quickWizard.getFunder().getExistFunder() == null
&& quickWizard.getFunder().getLabel() == null) {
funderEntity = null;
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() != null){
if (quickWizard.getFunder() == null) {
throw new Exception("Funder is a mandatory entity");
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() == null) {
// funderEntity = null;
throw new Exception("Funder is a mandatory entity");
} else if (quickWizard.getFunder().getExistFunder() == null && quickWizard.getFunder().getLabel() != null) {
funderEntity = this.quickWizardManager.createOrUpdate(quickWizard.getFunder().toDataFunder(), principal);
} else {
funderEntity = quickWizard.getFunder().getExistFunder().toDataModel();
@ -90,8 +92,6 @@ public class QuickWizardController extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<QuickWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
}
@RequestMapping(method = RequestMethod.POST, value = {"/datasetcreate"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DatasetCreateWizardModel>> addDatasetWizard(@RequestBody DatasetCreateWizardModel datasetCreateWizardModel, Principal principal) throws Exception{
@ -101,5 +101,4 @@ public class QuickWizardController extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetCreateWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Dataset added!"));
}
}

View File

@ -293,13 +293,13 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
}
}
if(this.funder == null && this.funder.getExistFunder() == null && this.funder.getLabel() == null) {
dataManagementPlanEntity.getGrant().setFunder(null);
}
else if (this.funder != null && this.funder.getExistFunder() == null && this.funder.getLabel() == null) {
dataManagementPlanEntity.getGrant().setFunder(null);
}
else {
if (this.funder == null) {
// dataManagementPlanEntity.getGrant().setFunder(null);
throw new Exception("Funder is a mandatory entity");
} else if (this.funder.getExistFunder() == null && this.funder.getLabel() == null) {
// dataManagementPlanEntity.getGrant().setFunder(null);
throw new Exception("Funder is a mandatory entity");
} else {
if (this.funder.getLabel() != null) {
Funder funder = new Funder();
funder.setLabel(this.funder.getLabel());
@ -311,8 +311,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
funder.setModified(new Date());
dataManagementPlanEntity.getGrant().setFunder(funder);
}
else if (this.funder.getExistFunder() != null && this.funder.getLabel() == null){
} else if (this.funder.getExistFunder() != null && this.funder.getLabel() == null){
dataManagementPlanEntity.getGrant().setFunder(this.funder.getExistFunder().toDataModel());
dataManagementPlanEntity.getGrant().getFunder().setType(Funder.FunderType.EXTERNAL.getValue());
}