Skip to content
Snippets Groups Projects

WAITING FOR OTTO - feat: :sparkles: Add Filtering by Quarters Functionality

Files

@@ -38,6 +38,7 @@ import nl.tudelft.tam.controller.utility.PageUtil;
import nl.tudelft.tam.dto.create.ApplicationCreateDTO;
import nl.tudelft.tam.dto.util.ApplicationFilterDTO;
import nl.tudelft.tam.dto.view.details.ApplicationDetailsJobOfferDTO;
import nl.tudelft.tam.enums.AcademicPeriod;
import nl.tudelft.tam.enums.Status;
import nl.tudelft.tam.model.Application;
import nl.tudelft.tam.service.*;
@@ -133,7 +134,8 @@ public class ApplicationController {
*/
@GetMapping("my")
public String getApplications(@AuthenticatedPerson Person person,
@RequestParam(required = false) String q, Model model) {
@RequestParam(required = false) String q,
Model model) {
List<ApplicationDetailsJobOfferDTO> applications = applicationService
.getFilteredApplicationsForPerson(person.getId(), q)
.stream().filter(a -> a.getJobOffer().getEdition().getEndDate().isAfter(LocalDateTime.now()))
@@ -185,12 +187,23 @@ public class ApplicationController {
*/
@PostMapping("submit")
@PreAuthorize("@authorisationService.canSubmitApplication(#create.jobOffer.id)")
public String submitApplication(@AuthenticatedPerson Person person, ApplicationCreateDTO create,
@RequestParam(required = false) String page, @RequestParam(required = false) Long program) {
public String submitApplication(@AuthenticatedPerson Person person,
ApplicationCreateDTO create,
@RequestParam(required = false) String page,
@RequestParam(required = false) Long program,
@RequestParam(required = false, name = "period") List<AcademicPeriod> filterPeriods) {
applicationService.submit(person.getId(), create);
String url = "applications".equals(page) ? "application/my" : "job-offer/open";
return "redirect:/"
+ (url + (program == null ? "" : "?program=" + program));
Map<String, List<String>> params = new HashMap<>();
if (program != null)
params.put("program", List.of(program));
if (filterPeriods != null)
params.put("period",
filterPeriods.stream().map(AcademicPeriod::name).collect(Collectors.toList()));
return "redirect:/" + url + getURLParamsString(params);
}
/**
@@ -202,22 +215,24 @@ public class ApplicationController {
*/
@PostMapping("retract/{id}")
@PreAuthorize("@authorisationService.applicationExistsFor(#id)")
public String retractApplication(@AuthenticatedPerson Person person, @PathVariable Long id,
public String retractApplication(@AuthenticatedPerson Person person,
@PathVariable Long id,
@RequestParam(required = false) String page,
@RequestParam(required = false) String q,
@RequestParam(required = false) String tab,
@RequestParam(required = false) String program) {
@RequestParam(required = false) String program,
@RequestParam(required = false, name = "period") List<AcademicPeriod> filterPeriods) {
applicationService.retract(person.getId(), id);
String url = "applications".equals(page) ? "application/my" : "job-offer/open";
Map<String, String> params = new HashMap<>();
Map<String, List<String>> params = new HashMap<>();
if (q != null)
params.put("q", q);
if (tab != null)
params.put("tab", tab);
params.put("q", List.of(q));
if (program != null)
params.put("program", program);
params.put("program", List.of(program));
if (filterPeriods != null)
params.put("period",
filterPeriods.stream().map(AcademicPeriod::name).collect(Collectors.toList()));
return "redirect:/" + url + getURLParamsString(params);
}
@@ -245,7 +260,8 @@ public class ApplicationController {
*/
@PostMapping("reject-all-open/{offerId}")
@PreAuthorize("@authorisationService.isManagerOfJob(#offerId)")
public String rejectAllOpenInJobOffer(@AuthenticatedPerson Person person, @PathVariable Long offerId) {
public String rejectAllOpenInJobOffer(@AuthenticatedPerson Person person,
@PathVariable Long offerId) {
applicationService.rejectAllOpenInJobOffer(offerId, person.getId());
return "redirect:/job-offer/" + offerId;
}
@@ -259,7 +275,8 @@ public class ApplicationController {
*/
@PostMapping("offer/{personId}/{offerId}")
@PreAuthorize("@authorisationService.isManagerOfJob(#offerId)")
public String offerApplication(@AuthenticatedPerson Person person, @PathVariable Long personId,
public String offerApplication(@AuthenticatedPerson Person person,
@PathVariable Long personId,
@PathVariable Long offerId) {
applicationService.offer(personId, offerId, person.getId());
return "redirect:/job-offer/" + offerId;
@@ -274,7 +291,8 @@ public class ApplicationController {
*/
@PostMapping("offer/{offerId}")
@PreAuthorize("@authorisationService.isManagerOfJob(#offerId)")
public String bulkOfferApplication(@AuthenticatedPerson Person person, @PathVariable Long offerId,
public String bulkOfferApplication(@AuthenticatedPerson Person person,
@PathVariable Long offerId,
@RequestParam String identifiersAll) {
applicationService.bulkOffer(offerId, identifiersAll, person.getId());
return "redirect:/job-offer/" + offerId;
@@ -305,32 +323,37 @@ public class ApplicationController {
*/
@PostMapping("accept/{id}")
@PreAuthorize("@authorisationService.offerExistsFor(#id)")
public String acceptApplication(@AuthenticatedPerson Person person, @PathVariable Long id,
public String acceptApplication(@AuthenticatedPerson Person person,
@PathVariable Long id,
@RequestParam(required = false) String page,
@RequestParam(required = false) String q,
@RequestParam(required = false) String tab,
@RequestParam(required = false) String program) {
@RequestParam(required = false) String program,
@RequestParam(required = false, name = "period") List<AcademicPeriod> filterPeriods) {
applicationService.accept(person.getId(), id);
String url = "applications".equals(page) ? "application/my" : "job-offer/open";
Map<String, String> params = new HashMap<>();
Map<String, List<String>> params = new HashMap<>();
if (q != null)
params.put("q", q);
if (tab != null)
params.put("tab", tab);
params.put("q", List.of(q));
if (program != null)
params.put("program", program);
params.put("program", List.of(program));
if (filterPeriods != null)
params.put("period",
filterPeriods.stream().map(AcademicPeriod::name).collect(Collectors.toList()));
return "redirect:/" + url + getURLParamsString(params);
}
private static String getURLParamsString(Map<String, String> params) {
private static String getURLParamsString(Map<String, List<String>> params) {
StringBuilder result = new StringBuilder();
char sep = '?';
for (String param : params.keySet()) {
result.append(sep).append(param).append("=").append(params.get(param));
sep = '&';
for (String value : params.get(param)) {
result.append(sep);
sep = '&';
result.append(param).append("=").append(value);
}
}
return result.toString();
}
@@ -361,11 +384,16 @@ public class ApplicationController {
@GetMapping("flex-delft-export")
@PreAuthorize("@authorisationService.isCoordinatorForProgram(#filter.program)")
public ResponseEntity<Resource> exportApplicationsForFlexDelft(@AuthenticatedPerson Person person,
ApplicationFilterDTO filter, @RequestParam Integer batch)
throws IOException {
ApplicationFilterDTO filter,
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss") LocalDateTime since,
@RequestParam Long program,
@RequestParam Integer batch) throws IOException {
filter.setStatuses(List.of(Status.ACCEPTED));
List<Application> appList = applicationService.getFilteredCoordinatingApplications(person.getId(),
filter);
List<Application> appList = applicationService
.getCoordinatingApplicationsForProgram(person.getId(), program).stream()
.filter(x -> !editionService.getOrThrow(x.getJobOffer().getEditionId()).getIsArchived())
.filter(x -> x.getStatus().equals(Status.ACCEPTED))
.collect(Collectors.toList());
return csvService
.getResponse(
applicationService.exportApplicationsForFlexDelft(person, filter.getProgram(), batch,
Loading