use of org.obiba.mica.web.controller.domain.FormStatusChangeEvent in project mica2 by obiba.
the class DataAccessController method getHistory.
@GetMapping("/data-access-history/{id:.+}")
public ModelAndView getHistory(@PathVariable String id) {
Subject subject = SecurityUtils.getSubject();
if (subject.isAuthenticated()) {
Map<String, Object> params = newParameters(id);
DataAccessRequest dar = (DataAccessRequest) params.get("dar");
addDataAccessConfiguration(params);
// merge change history from main form, feasibility and amendment forms
final List<FormStatusChangeEvent> events = Lists.newArrayList(dar.getStatusChangeHistory().stream().map(e -> new FormStatusChangeEvent(userProfileService, dar, e)).collect(Collectors.toList()));
getDataAccessFeasibilities(params).forEach(a -> {
a.getStatusChangeHistory().stream().map(e -> new FormStatusChangeEvent(userProfileService, a, e)).forEach(events::add);
});
getDataAccessAmendments(params).forEach(a -> {
a.getStatusChangeHistory().stream().map(e -> new FormStatusChangeEvent(userProfileService, a, e)).forEach(events::add);
});
// order change events
params.put("statusChangeEvents", events.stream().sorted(new Comparator<FormStatusChangeEvent>() {
@Override
public int compare(FormStatusChangeEvent event1, FormStatusChangeEvent event2) {
return event1.getDate().compareTo(event2.getDate());
}
}).collect(Collectors.toList()));
return new ModelAndView("data-access-history", params);
} else {
return new ModelAndView("redirect:../signin?redirect=" + micaConfigService.getContextPath() + "/data-access-history%2F" + id);
}
}
Aggregations