Skip to content

Commit

Permalink
included update of all need deliverables by need plan id
Browse files Browse the repository at this point in the history
  • Loading branch information
Sowmya-Raghuram committed Jun 7, 2024
1 parent 0bffe93 commit e8660a0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,23 @@ public ResponseEntity<List<InputParameters>> updateDeliverableDetails(
return ResponseEntity.ok(updatedInputParameters);
}

//Update Need Deliverable Details
@Operation(summary = "Update all Need Deliverables with appropritate values", description = "Update all need deliverable details")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully Updated all Need Deliverable Details", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)),
@ApiResponse(responseCode = "400", description = "Bad Input"),
@ApiResponse(responseCode = "500", description = "Server Error")}
)
@PutMapping("/all-deliverable-details/update/{needPlanId}")
public ResponseEntity<List<NeedDeliverable>> updateNeedDeliverableDetails(
@PathVariable String needPlanId,
@RequestBody DeliverableDetailsRequest request,
@RequestHeader Map<String, String> headers) {

List<NeedDeliverable> updatedNeedDeliverables = needDeliverableService.updateNeedDeliverables(needPlanId, request, headers);
return ResponseEntity.ok(updatedNeedDeliverables);
}

//Create Output Parameters for Deliverable Details
@Operation(summary = "Create Output Parameters", description = "Create Output Parameters for Deliverable Details")
@ApiResponses(value = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,40 @@ public NeedDeliverable updateNeedDeliverable(UUID needDeliverableId, NeedDeliver
return updatedNeedDeliverable;
}


public List<NeedDeliverable> updateNeedDeliverables(String needPlanId, DeliverableDetailsRequest request, Map<String, String> headers) {
// Fetch all deliverables based on needPlanId
List<NeedDeliverable> needDeliverableList = needDeliverableRepository.findByNeedPlanId(needPlanId);

List<NeedDeliverable> updatedDeliverables = new ArrayList<>();

for (NeedDeliverable needDeliverables : needDeliverableList) {
// new request object with details from the need deliverable
DeliverableDetailsRequest newRequest = DeliverableDetailsRequest.builder()
.inputUrl(request.getInputUrl())
.softwarePlatform(request.getSoftwarePlatform())
.startTime(request.getStartTime())
.endTime(request.getEndTime())
.build();

// Call updateInputParameters method for each deliverable
List<InputParameters> updatedInputParameters = updateInputParameters(needDeliverables.getId().toString(), newRequest, headers);

// Assuming updateInputParameters updates the needDeliverable and saves it
updatedDeliverables.add(needDeliverables);
}
return updatedDeliverables;
}



public List<InputParameters> updateInputParameters(String needDeliverableId, DeliverableDetailsRequest request, Map<String, String> headers) {
// Check if the need with the given ID exists
List<InputParameters> existingInputParameters = inputParametersRepository.findByNeedDeliverableId(needDeliverableId);

if (existingInputParameters != null) {
for (InputParameters parameter : existingInputParameters) {
parameter.setNeedDeliverableId(request.getNeedDeliverableId());
parameter.setNeedDeliverableId(needDeliverableId);
parameter.setInputUrl(request.getInputUrl());
parameter.setSoftwarePlatform(request.getSoftwarePlatform());
parameter.setStartTime(request.getStartTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
@NoArgsConstructor
@AllArgsConstructor
public class DeliverableDetailsRequest {
private String needDeliverableId;
private String inputUrl;
private SoftwarePlatform softwarePlatform;
private Instant startTime;
Expand Down

0 comments on commit e8660a0

Please sign in to comment.