diff --git a/src/main/java/com/sunbird/serve/need/DeliverableService/controllers/DeliverableDetailsController.java b/src/main/java/com/sunbird/serve/need/DeliverableService/controllers/DeliverableDetailsController.java index cf6809e..1db75b9 100644 --- a/src/main/java/com/sunbird/serve/need/DeliverableService/controllers/DeliverableDetailsController.java +++ b/src/main/java/com/sunbird/serve/need/DeliverableService/controllers/DeliverableDetailsController.java @@ -55,7 +55,7 @@ public DeliverableDetailsController(DeliverableDetailsService deliverableDetails @ApiResponse(responseCode = "400", description = "Bad Input"), @ApiResponse(responseCode = "500", description = "Server Error")} ) - @GetMapping("/need-deliverable/{needId}") + @GetMapping("/deliverable-details/{needId}") public ResponseEntity> getByNeedId(@PathVariable String needId) { List deliverableDetails = deliverableDetailsService.getNDByNeedId(needId); return ResponseEntity.ok(deliverableDetails); diff --git a/src/main/java/com/sunbird/serve/need/DeliverableService/services/NeedPlanService.java b/src/main/java/com/sunbird/serve/need/DeliverableService/services/NeedPlanService.java index 7b721eb..8a5cf78 100644 --- a/src/main/java/com/sunbird/serve/need/DeliverableService/services/NeedPlanService.java +++ b/src/main/java/com/sunbird/serve/need/DeliverableService/services/NeedPlanService.java @@ -113,24 +113,36 @@ private void createNeedDeliverableForPlan(NeedPlan needPlan, Map } private void createDeliverableDetails(NeedPlan needPlan, Map headers) { - - DeliverableDetails deliverableDetails = new DeliverableDetails(); - InputParameters inputParameters = new InputParameters(); - List needDeliverable = needDeliverableRepository.findByNeedPlanId(needPlan.getNeedId()); - String needDeliverableId = needDeliverable.get(0).getId().toString(); - deliverableDetails.setNeedDeliverableId(needDeliverableId); - deliverableDetails.setTaskType(TaskType.Session); + //List needDeliverable = needDeliverableRepository.findByNeedPlanId(needPlan.getNeedId()); + List needDeliverableList = needDeliverableRepository.findByNeedPlanId(needPlan.getId().toString()); - inputParameters.setInputUrl("To be added soon"); - inputParameters.setSoftwarePlatform(SoftwarePlatform.GMEET); + if (!needDeliverableList.isEmpty()) { + for (NeedDeliverable needDeliverable : needDeliverableList) { + // Create a new DeliverableDetails object for each NeedDeliverable + DeliverableDetails deliverableDetails = new DeliverableDetails(); + + // Set properties for DeliverableDetails + deliverableDetails.setNeedDeliverableId(needDeliverable.getId().toString()); + deliverableDetails.setTaskType(TaskType.Session); - DeliverableDetails savedDeliverableDetails = deliverableDetailsRepository.save(deliverableDetails); + // Save DeliverableDetails + DeliverableDetails savedDeliverableDetails = deliverableDetailsRepository.save(deliverableDetails); - InputParameters savedInputParameters = inputParametersRepository.save(inputParameters); + // Create a new InputParameters object for each NeedDeliverable + InputParameters inputParameters = new InputParameters(); - + // Set properties for InputParameters + inputParameters.setDeliverableDetailsId(savedDeliverableDetails.getId().toString()); + inputParameters.setInputUrl("To be added soon"); + inputParameters.setSoftwarePlatform(SoftwarePlatform.GMEET); + // Save InputParameters + inputParametersRepository.save(inputParameters); + } + } else { + System.out.println("No deliverables found for the given need plan ID."); + } } }