Exemplo n.º 1
0
  /**
   * Returns an html page valid for printing
   *
   * <p>
   *
   * @param obj instance to print.
   * @return html text strem
   * @throws ObjectNotFoundException If specified object could not be found.
   * @throws SendFailedException
   */
  @PreAuthorize("hasRole('ROLE_PERSON_READ') or hasRole('ROLE_PERSON_MAP_READ')")
  @RequestMapping(value = "/emailCurrent", method = RequestMethod.POST)
  public @ResponseBody String email(
      final HttpServletResponse response,
      final @PathVariable UUID personId,
      @RequestBody final PlanOutputTO planOutputDataTO)
      throws ObjectNotFoundException {

    Plan currentPlan = service.getCurrentForStudent(personId);
    PlanTO planTO = getFactory().from(currentPlan);
    planOutputDataTO.setPlan(planTO);

    SubjectAndBody messageText = service.createOutput(planOutputDataTO);
    if (messageText == null) return null;
    Person person = personService.get(UUID.fromString(planOutputDataTO.getPlan().getPersonId()));
    Set<String> watcherAddresses = new HashSet<String>(person.getWatcherEmailAddresses());
    watcherAddresses.addAll(
        org.springframework.util.StringUtils.commaDelimitedListToSet(
            planOutputDataTO.getEmailCC()));

    messageService.createMessage(
        planOutputDataTO.getEmailTo(),
        org.springframework.util.StringUtils.arrayToCommaDelimitedString(
            watcherAddresses.toArray(new String[watcherAddresses.size()])),
        messageText);

    return "Map Plan has been queued.";
  }
Exemplo n.º 2
0
  @PreAuthorize("hasRole('ROLE_PERSON_READ') or hasRole('ROLE_PERSON_MAP_READ')")
  @RequestMapping(value = "/printCurrent", method = RequestMethod.POST)
  public @ResponseBody String printCurrent(
      final HttpServletResponse response,
      final @PathVariable UUID personId,
      @RequestBody final PlanOutputTO planOutputDataTO)
      throws ObjectNotFoundException {

    Plan currentPlan = service.getCurrentForStudent(personId);
    PlanTO planTO = getFactory().from(currentPlan);
    planOutputDataTO.setPlan(planTO);

    SubjectAndBody message = service.createOutput(planOutputDataTO);
    if (message != null) return message.getBody();

    return null;
  }
Exemplo n.º 3
0
  /**
   * Returns an html page valid for printing
   *
   * <p>
   *
   * @param obj instance to print.
   * @return html text strem
   * @throws ObjectNotFoundException If specified object could not be found.
   */
  @PreAuthorize("hasRole('ROLE_PERSON_READ') or hasRole('ROLE_PERSON_MAP_READ')")
  @RequestMapping(value = "/print", method = RequestMethod.POST)
  public @ResponseBody String print(
      final HttpServletResponse response, @RequestBody final PlanOutputTO planOutputDataTO)
      throws ObjectNotFoundException {

    SubjectAndBody message = service.createOutput(planOutputDataTO);
    if (message != null) return message.getBody();

    return null;
  }
  @RequestMapping(value = "/studentactivity", method = RequestMethod.GET)
  @PreAuthorize(Permission.SECURITY_PERSON_READ)
  public @ResponseBody List<RecentActivityTO> loadRecentStudentActivity(final @PathVariable UUID id)
      throws ObjectNotFoundException {
    List<RecentActivityTO> recentActivities = new ArrayList<RecentActivityTO>();
    Person person = personService.get(id);
    SortingAndPaging sAndP =
        SortingAndPaging.createForSingleSortWithPaging(
            ObjectStatus.ACTIVE, 0, 1000, "createdDate", "DESC", "createdDate");

    PagingWrapper<EarlyAlert> earlyAlerts = earlyAlertService.getAllForPerson(person, sAndP);
    SspUser currentUser = securityService.currentUser();
    List<EarlyAlertTO> earlyAlertTOs = earlyAlertTOFactory.asTOList(earlyAlerts.getRows());

    PagingWrapper<JournalEntry> journalEntries =
        journalEntryService.getAllForPerson(person, currentUser, sAndP);

    List<JournalEntryTO> journalEntriesTOs =
        journalEntryTOFactory.asTOList(journalEntries.getRows());

    PagingWrapper<Task> actions = taskService.getAllForPerson(person, currentUser, sAndP);

    List<TaskTO> actionsTOs = taskTOFactory.asTOList(actions.getRows());

    PagingWrapper<Plan> plans =
        planService.getAllForStudent(
            SortingAndPaging.createForSingleSortWithPaging(
                ObjectStatus.ALL, 0, 1000, null, null, null),
            id);

    List<PlanTO> planTOs = planTOFactory.asTOList(plans.getRows());

    for (EarlyAlertTO earlyAlert : earlyAlertTOs) {
      if (earlyAlert.getClosedDate() != null) {
        recentActivities.add(
            new RecentActivityTO(
                earlyAlert.getClosedById(),
                earlyAlert.getClosedByName(),
                "Early Alert Closed",
                earlyAlert.getClosedDate()));
      } else {
        recentActivities.add(
            new RecentActivityTO(
                earlyAlert.getCreatedBy().getId(),
                getPersonLiteName(earlyAlert.getCreatedBy()),
                "Early Alert Created",
                earlyAlert.getCreatedDate()));
      }
    }

    for (JournalEntryTO journalEntry : journalEntriesTOs) {
      recentActivities.add(
          new RecentActivityTO(
              journalEntry.getCreatedBy().getId(),
              getPersonLiteName(journalEntry.getCreatedBy()),
              "Journal Entry",
              journalEntry.getEntryDate()));
    }

    for (TaskTO action : actionsTOs) {
      if (action.isCompleted()) {
        recentActivities.add(
            new RecentActivityTO(
                action.getModifiedBy().getId(),
                getPersonLiteName(action.getModifiedBy()),
                "Action Plan Task Created",
                action.getCompletedDate()));
      } else {
        recentActivities.add(
            new RecentActivityTO(
                action.getCreatedBy().getId(),
                getPersonLiteName(action.getCreatedBy()),
                "Action Plan Task Created",
                action.getCreatedDate()));
      }
    }

    for (PlanTO planTO : planTOs) {
      Date testDate = DateUtils.addDays(planTO.getCreatedDate(), 1);
      String planName = planTO.getName();
      if (planTO.getModifiedDate().before(testDate)) {
        recentActivities.add(
            new RecentActivityTO(
                planTO.getCreatedBy().getId(),
                getPersonLiteName(planTO.getCreatedBy()),
                "Map Plan (" + planName + ") Created",
                planTO.getModifiedDate()));
      } else {
        recentActivities.add(
            new RecentActivityTO(
                planTO.getModifiedBy().getId(),
                getPersonLiteName(planTO.getModifiedBy()),
                "Map Plan (" + planName + ") Updated",
                planTO.getModifiedDate()));
      }
    }

    if (person.getStudentIntakeCompleteDate() != null) {
      recentActivities.add(
          new RecentActivityTO(
              person.getCoach().getId(),
              person.getCoach().getFullName(),
              "Student Intake Completed",
              person.getStudentIntakeCompleteDate()));
    }
    if (person.getStudentIntakeRequestDate() != null) {
      recentActivities.add(
          new RecentActivityTO(
              person.getCoach().getId(),
              person.getCoach().getFullName(),
              "Student Intake Requested",
              person.getStudentIntakeRequestDate()));
    }

    Collections.sort(recentActivities, RecentActivityTO.RECENT_ACTIVITY_TO_DATE_COMPARATOR);
    return recentActivities;
  }