Commit 90614abe authored by Deep Dey's avatar Deep Dey

feat: add option to schedu interview for multiple candidates

parent b20eadaa
......@@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.ByteArrayInputStream;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -81,14 +82,32 @@ public class AdmissionFormController {
public Object setAdmissionInterview(
HttpServletRequest request,
@RequestHeader("apikey") String apiKey,
@RequestParam(defaultValue = "0" ) Long formId,
@RequestParam(defaultValue = "" ) String formIds,
@RequestParam("interactionDate") String interactionDate,
@RequestParam("interactionTime") String interactionTime
) throws Exception {
List<Long> formIdList = Stream.of(formIds.split(","))
.map(Long::valueOf)
.toList();
if (formIdList.isEmpty()) {
throw new Exception("Provide formIds to schedule interview");
}
AtomicBoolean partiallyFailed = new AtomicBoolean(false);
formIdList.forEach(formId -> {
try {
if (!admissionFormDAOController
.updateInteractionDateTime(formId, interactionDate, interactionTime)) {
throw new Exception("Failed to set interview date and time");
partiallyFailed.set(true);
}
} catch (Exception e) {
partiallyFailed.set(true);
}
});
if (partiallyFailed.get()) {
throw new Exception("For Some of the forms failed to schedule interview");
}
return new ResponseEntity<>(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment