Skip to content

Commit

Permalink
Merge pull request #5 from Sunbird-Serve/release-need-1.1.0.0
Browse files Browse the repository at this point in the history
Release need 1.1.0.0 - Baseline version
  • Loading branch information
Sowmya-Raghuram authored Aug 22, 2024
2 parents 4cdff0d + 2c6a29e commit ba99902
Show file tree
Hide file tree
Showing 32 changed files with 1,224 additions and 424 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
2 changes: 1 addition & 1 deletion .github/workflows/create-json.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ printf '{
"secrets": [' > /tmp/__secrets.json


for line in `cat .${prefix}env`
for line in `cat .env`
do
key=$line
if [[ -z "$line" || "$line" =~ ^[[:space:]]*# ]]; then
Expand Down
37 changes: 29 additions & 8 deletions schemas/serve/NeedRequirement.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
"type": "string"
},
"startDate": {
"type": "string",
"format": "date"
},
"type": "string",
"format": "date"
},
"endDate": {
"type": "string",
"format": "date"
},
"type": "string",
"format": "date"
},
"timeSlotsAndDays": {
"type": "object",
"properties": {
Expand All @@ -66,20 +66,41 @@
}
}
},
"required": ["timeSlot", "days"],
"required": ["startTime", "endTime", "days"],
"additionalProperties": false
},
"priority": {
"type": "string"
},
"inputURLs": {
"type": "array",
"items": {
"$ref": "#/definitions/InputURLs"
}
}
},
"required": ["frequency", "volunteersRequired","startDate","endDate"],
"required": ["frequency", "volunteersRequired", "startDate", "endDate"],
"additionalProperties": true
}
},
"required": ["SkillDetail", "PrerequisiteDetail"],
"additionalProperties": false,
"definitions": {
"InputURLs": {
"type": "object",
"properties": {
"url": {
"type": "string",
"format": "uri"
},
"softwarePlatforms": {
"type": "string",
"enum": ["gmeet", "skype", "teams", "webex", "gdrive", "github", "others"]
}
},
"required": ["url", "softwarePlatforms"],
"additionalProperties": false
},
"SystemFields": {
"type": "object",
"properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import com.sunbird.serve.need.models.Need.NeedDeliverable;
import com.sunbird.serve.need.models.Need.InputParameters;
import com.sunbird.serve.need.models.Need.OutputParameters;
import com.sunbird.serve.need.models.enums.NeedDeliverableStatus;
import com.sunbird.serve.need.models.request.NeedDeliverableRequest;
import com.sunbird.serve.need.models.request.DeliverableDetailsRequest;
import com.sunbird.serve.need.models.request.OutputParametersRequest;
import com.sunbird.serve.need.models.response.NeedDeliverableResponse;
import org.springframework.http.HttpStatus;
import java.util.List;

Expand Down Expand Up @@ -53,8 +58,8 @@ public NeedDeliverableController(NeedDeliverableService needDeliverableService)
@ApiResponse(responseCode = "500", description = "Server Error")}
)
@GetMapping("/need-deliverable/{needPlanId}")
public ResponseEntity<List<NeedDeliverable>> getByNeedId(@PathVariable String needPlanId) {
List<NeedDeliverable> needDeliverable = needDeliverableService.getByNeedPlanId(needPlanId);
public ResponseEntity<NeedDeliverableResponse> getByNeedId(@PathVariable String needPlanId) {
NeedDeliverableResponse needDeliverable = needDeliverableService.getByNeedPlanId(needPlanId);
return ResponseEntity.ok(needDeliverable);
}

Expand Down Expand Up @@ -88,4 +93,51 @@ public ResponseEntity<NeedDeliverable> updateNeedDeliverable(
return ResponseEntity.ok(updatedNeedDeliverable);
}

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

List<InputParameters> updatedInputParameters = needDeliverableService.updateInputParameters(needDeliverableId, request, headers);
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 = {
@ApiResponse(responseCode = "200", description = "Successfully Created Output Parameters", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)),
@ApiResponse(responseCode = "400", description = "Bad Input"),
@ApiResponse(responseCode = "500", description = "Server Error")}
)
@PostMapping("/deliverable-output/create")
public ResponseEntity<OutputParameters> createOutputParameters(@RequestBody OutputParametersRequest request, @RequestHeader Map<String, String> headers) {
OutputParameters response = needDeliverableService.createOutputParameters(request, headers);
return ResponseEntity.status(HttpStatus.CREATED).body(response);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public ResponseEntity<List<NeedPlanResponse>> getByNeedId(@PathVariable String n
} else {
return ResponseEntity.notFound().build();
}

}


Expand All @@ -78,5 +79,18 @@ public ResponseEntity<NeedPlan> createNeedPlan(@RequestBody NeedPlanRequest requ
return ResponseEntity.status(HttpStatus.CREATED).body(response);
}

//Fetch all need plan based on need plan id
@Operation(summary = "Fetch a Need Plan by providing NeedPlanId", description = "Fetch a NeedPlan by providing NeedPlanId")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Successfully Fetched Need Plan", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)),
@ApiResponse(responseCode = "400", description = "Bad Input"),
@ApiResponse(responseCode = "500", description = "Server Error")}
)
@GetMapping("/need-plan/read/{needPlanId}")
public ResponseEntity<NeedPlanResponse> getNeedPlanById(@PathVariable String needPlanId) {
Optional<NeedPlanResponse> needPlan = needPlanService.getNeedPlanById(UUID.fromString(needPlanId));
return needPlan.map(ResponseEntity::ok)
.orElse(ResponseEntity.notFound().build());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.sunbird.serve.need;

import com.sunbird.serve.need.models.Need.InputParameters;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.UUID;

public interface InputParametersRepository extends JpaRepository<InputParameters, UUID> {

List<InputParameters> findByNeedDeliverableId(String needDeliverableId);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.sunbird.serve.need;

import com.sunbird.serve.need.models.Need.InputParameters;
import com.sunbird.serve.need.models.Need.OutputParameters;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.UUID;

public interface OutputParametersRepository extends JpaRepository<OutputParameters, UUID> {

List<OutputParameters> findByNeedDeliverableId(String needDeliverableId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,73 @@
import com.sunbird.serve.need.models.request.NeedPlanRequest;
import com.sunbird.serve.need.models.Need.NeedPlan;
import com.sunbird.serve.need.models.request.NeedDeliverableRequest;
import com.sunbird.serve.need.models.request.OutputParametersRequest;
import com.sunbird.serve.need.models.Need.NeedDeliverable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.UUID;
import java.util.List;
import java.util.stream.Collectors;
import com.sunbird.serve.need.models.Need.OutputParameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DeliverableMapper {

private static final Logger logger = LoggerFactory.getLogger(DeliverableMapper.class);

public static NeedPlan mapToEntity(NeedPlanRequest needPlanRequest) {
// Need request is mapped to the need entity
NeedPlan needPlan = new NeedPlan();
needPlan.setAssignedUserId(needPlanRequest.getAssignedUserId());
needPlan.setNeedId(needPlanRequest.getNeedId());
needPlan.setName(needPlanRequest.getName());
needPlan.setStatus(needPlanRequest.getStatus());
needPlan.setOccurrenceId(needPlanRequest.getOccurrenceId());

return needPlan;
try {
if (needPlanRequest == null) {
throw new IllegalArgumentException("NeedPlanRequest cannot be null");
}

// Need request is mapped to the need entity
NeedPlan needPlan = new NeedPlan();
needPlan.setNeedId(needPlanRequest.getNeedId());
needPlan.setName(needPlanRequest.getName());
needPlan.setStatus(needPlanRequest.getStatus());
needPlan.setOccurrenceId(needPlanRequest.getOccurrenceId());

return needPlan;
} catch (Exception e) {
logger.error("Error mapping NeedPlanRequest to NeedPlan: " + needPlanRequest, e);
throw new RuntimeException("Error mapping NeedPlanRequest to NeedPlan", e);
}
}

public static NeedDeliverable mapToDeliverable(NeedDeliverableRequest needDeliverableRequest) {
// Need request is mapped to the need entity
NeedDeliverable needDeliverable = new NeedDeliverable();
needDeliverable.setNeedPlanId(needDeliverableRequest.getNeedPlanId());
needDeliverable.setComments(needDeliverableRequest.getComments());
needDeliverable.setStatus(needDeliverableRequest.getStatus());
needDeliverable.setDeliverableDate(needDeliverableRequest.getDeliverableDate());

return needDeliverable;
try {
if (needDeliverableRequest == null) {
throw new IllegalArgumentException("NeedDeliverableRequest cannot be null");
}

// Need request is mapped to the need entity
NeedDeliverable needDeliverable = new NeedDeliverable();
needDeliverable.setNeedPlanId(needDeliverableRequest.getNeedPlanId());
needDeliverable.setComments(needDeliverableRequest.getComments());
needDeliverable.setStatus(needDeliverableRequest.getStatus());
needDeliverable.setDeliverableDate(needDeliverableRequest.getDeliverableDate());

return needDeliverable;
} catch (Exception e) {
logger.error("Error mapping NeedDeliverableRequest to NeedDeliverable: " + needDeliverableRequest, e);
throw new RuntimeException("Error mapping NeedDeliverableRequest to NeedDeliverable", e);
}
}

}
public static OutputParameters mapToOutputParameters(OutputParametersRequest outputParametersRequest) {
try {
if (outputParametersRequest == null) {
throw new IllegalArgumentException("OutputParametersRequest cannot be null");
}

// Need request is mapped to the need entity
OutputParameters outputParameters = new OutputParameters();
outputParameters.setNeedDeliverableId(outputParametersRequest.getNeedDeliverableId());
outputParameters.setRemarks(outputParametersRequest.getRemarks());
outputParameters.setNumberOfAttendees(outputParametersRequest.getNumberOfAttendees());
outputParameters.setSubmittedUrl(outputParametersRequest.getSubmittedUrl());

return outputParameters;
} catch (Exception e) {
logger.error("Error mapping OutputParametersRequest to OutputParameters: " + outputParametersRequest, e);
throw new RuntimeException("Error mapping OutputParametersRequest to OutputParameters", e);
}
}
}
Loading

0 comments on commit ba99902

Please sign in to comment.