Search in sources :

Example 1 with FormStatusChangeEvent

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);
    }
}
Also used : Comment(org.obiba.mica.core.domain.Comment) DataAccessForm(org.obiba.mica.micaConfig.domain.DataAccessForm) DataAccessFeasibilityFormService(org.obiba.mica.micaConfig.service.DataAccessFeasibilityFormService) java.util(java.util) Roles(org.obiba.mica.security.Roles) UserProfileService(org.obiba.mica.user.UserProfileService) Controller(org.springframework.stereotype.Controller) DataAccessRequestService(org.obiba.mica.access.service.DataAccessRequestService) DataAccessAmendmentService(org.obiba.mica.access.service.DataAccessAmendmentService) Inject(javax.inject.Inject) Lists(com.google.common.collect.Lists) Subject(org.apache.shiro.subject.Subject) DataAccessFormService(org.obiba.mica.micaConfig.service.DataAccessFormService) DataAccessAmendmentForm(org.obiba.mica.micaConfig.domain.DataAccessAmendmentForm) AbstractAuditableDocument(org.obiba.mica.core.domain.AbstractAuditableDocument) DataAccessFeasibilityService(org.obiba.mica.access.service.DataAccessFeasibilityService) CommentsService(org.obiba.mica.core.service.CommentsService) FormStatusChangeEvent(org.obiba.mica.web.controller.domain.FormStatusChangeEvent) DataAccessConfigBundle(org.obiba.mica.web.controller.domain.DataAccessConfigBundle) SchemaFormConfig(org.obiba.mica.web.controller.domain.SchemaFormConfig) DataAccessRequestReportNotificationService(org.obiba.mica.access.notification.DataAccessRequestReportNotificationService) DataAccessFeasibilityForm(org.obiba.mica.micaConfig.domain.DataAccessFeasibilityForm) Collectors(java.util.stream.Collectors) NoSuchDataAccessRequestException(org.obiba.mica.access.NoSuchDataAccessRequestException) ModelAndView(org.springframework.web.servlet.ModelAndView) DataAccessAmendmentFormService(org.obiba.mica.micaConfig.service.DataAccessAmendmentFormService) org.obiba.mica.access.domain(org.obiba.mica.access.domain) DataAccessConfigService(org.obiba.mica.micaConfig.service.DataAccessConfigService) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) Pattern(java.util.regex.Pattern) SecurityUtils(org.apache.shiro.SecurityUtils) ModelAndView(org.springframework.web.servlet.ModelAndView) FormStatusChangeEvent(org.obiba.mica.web.controller.domain.FormStatusChangeEvent) Subject(org.apache.shiro.subject.Subject)

Aggregations

Lists (com.google.common.collect.Lists)1 java.util (java.util)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 SecurityUtils (org.apache.shiro.SecurityUtils)1 Subject (org.apache.shiro.subject.Subject)1 NoSuchDataAccessRequestException (org.obiba.mica.access.NoSuchDataAccessRequestException)1 org.obiba.mica.access.domain (org.obiba.mica.access.domain)1 DataAccessRequestReportNotificationService (org.obiba.mica.access.notification.DataAccessRequestReportNotificationService)1 DataAccessAmendmentService (org.obiba.mica.access.service.DataAccessAmendmentService)1 DataAccessFeasibilityService (org.obiba.mica.access.service.DataAccessFeasibilityService)1 DataAccessRequestService (org.obiba.mica.access.service.DataAccessRequestService)1 AbstractAuditableDocument (org.obiba.mica.core.domain.AbstractAuditableDocument)1 Comment (org.obiba.mica.core.domain.Comment)1 CommentsService (org.obiba.mica.core.service.CommentsService)1 DataAccessAmendmentForm (org.obiba.mica.micaConfig.domain.DataAccessAmendmentForm)1 DataAccessFeasibilityForm (org.obiba.mica.micaConfig.domain.DataAccessFeasibilityForm)1 DataAccessForm (org.obiba.mica.micaConfig.domain.DataAccessForm)1 DataAccessAmendmentFormService (org.obiba.mica.micaConfig.service.DataAccessAmendmentFormService)1