@Override
  public void receiveDossier(Task task, Dossier dossier) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("gender", dossier.getOwner().getGender().toString());
    params.put("lastname", dossier.getOwner().getLastName());
    params.put("nomEnfant", dossier.getCandidat().getLastname());
    params.put("prenomEnfant", dossier.getCandidat().getFirstname());
    params.put("firstname", dossier.getOwner().getFirstName());
    params.put("refdossier", dossier.getGeneratedNumDossier());

    try {
      EmailDTO email =
          emailService.populateEmail(
              EmailType.PIECES_RECEIVED, dossier.getOwner().getEmail(), sender, params, "", "");
      emailService.prepare(email);

      InboxMessage message = new InboxMessage();
      message.setParentUser(dossier.getOwner());
      message.setSubject(email.getSubject());
      message.setContent(email.getMessage());
      message.setMsgDate(new Date());
      message.setMsgStatus(InboxMessageStatus.UNREAD);
      inboxMessageRepos.save(message);
    } catch (Exception e) {
      e.printStackTrace();
    }

    taskService.complete(task.getId());
  }
  @Override
  public void rejectDossier(Task task, Dossier dossier, List<PiecejustifDTO> pieceNonavailable) {
    Map<String, Object> params = new HashMap<String, Object>();

    List<String> pieces = new ArrayList<String>();
    for (PiecejustifDTO piece : pieceNonavailable) {
      if (piece.getAvailable() == null || !piece.getAvailable()) {
        pieces.add(
            Strings.isNullOrEmpty(piece.getMotif())
                ? piece.getNom()
                : piece.getNom() + " : " + piece.getMotif());
      }
    }

    params.put("gender", dossier.getOwner().getGender().toString());
    params.put("lastname", dossier.getOwner().getLastName());
    params.put("firstname", dossier.getOwner().getFirstName());
    params.put("nomEnfant", dossier.getCandidat().getLastname());
    params.put("prenomEnfant", dossier.getCandidat().getFirstname());
    params.put("refdossier", dossier.getGeneratedNumDossier());
    params.put("pieceNonavailable", pieces);

    try {
      EmailDTO email =
          emailService.populateEmail(
              EmailType.DOSSIER_INCOMPLETE, dossier.getOwner().getEmail(), sender, params, "", "");
      emailService.prepare(email);

      InboxMessage message = new InboxMessage();
      message.setParentUser(dossier.getOwner());
      message.setSubject(email.getSubject());
      message.setContent(email.getMessage());
      message.setMsgDate(new Date());
      message.setMsgStatus(InboxMessageStatus.UNREAD);
      inboxMessageRepos.save(message);

    } catch (Exception e) {
      e.printStackTrace();
    }

    // Initialise process variables
    Map<String, Object> processParams = new HashMap<String, Object>();
    processParams.put("dossierComplet", false);
    processParams.put("piecejustifs", pieceNonavailable);

    taskService.complete(task.getId(), processParams);
  }
Esempio n. 3
0
  @Override
  public void sendEmailConvocation(DossierSession session, String link) {
    Dossier dossier = dossierRepos.findOne(session.getDossier().getId());
    DossierSession dossierSession = dossierSessionRepos.findOne(session.getId());

    if (Strings.isNullOrEmpty(dossierSession.getGeneratedConvocationPDFPath())) {
      String token =
          Base64.encode(
              dossierSession.getDossier().getGeneratedNumDossier() + "" + (new Date()).toString());
      token = token.replace("=", "E");
      dossierSession.setGeneratedConvocationPDFPath(token);
      dossierSessionRepos.save(dossierSession);
    }

    Map<String, Object> params = new HashMap<String, Object>();
    params.put("gender", dossier.getOwner().getGender().toString());
    params.put("lastname", dossier.getOwner().getLastName());
    params.put("firstname", dossier.getOwner().getFirstName());
    params.put("nomEnfant", dossier.getCandidat().getLastname());
    params.put("prenomEnfant", dossier.getCandidat().getFirstname());
    params.put("refdossier", dossier.getGeneratedNumDossier());
    params.put(
        "link",
        link + "resource/convocation?number=" + dossierSession.getGeneratedConvocationPDFPath());

    try {
      EmailDTO email =
          emailService.populateEmail(
              EmailType.CONVOCATED_FOR_TEST,
              dossier.getOwner().getEmail(),
              sender,
              params,
              sender,
              "");
      emailService.prepare(email);

      InboxMessage message = new InboxMessage();
      message.setParentUser(dossier.getOwner());
      message.setSubject(email.getSubject());
      message.setContent(email.getMessage());
      message.setMsgDate(new Date());
      message.setMsgStatus(InboxMessageStatus.UNREAD);
      inboxMessageRepos.save(message);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @Override
  public void rejectFinalDossier(Task task, Dossier dossier, Boolean choix) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("gender", dossier.getOwner().getGender().toString());
    params.put("lastname", dossier.getOwner().getLastName());
    params.put("firstname", dossier.getOwner().getFirstName());
    params.put("nomEnfant", dossier.getCandidat().getLastname());
    params.put("prenomEnfant", dossier.getCandidat().getFirstname());
    params.put("refdossier", dossier.getGeneratedNumDossier());
    if (choix) {
      params.put("choix", "N°1");
      params.put("filiere", dossier.getFiliere().getNom());
      params.put("niveau", dossier.getNiveauEtude().getNom());
    } else {
      params.put("choix", "N°2");
      params.put("filiere", dossier.getFiliere2().getNom());
      params.put("niveau", dossier.getNiveauEtude2().getNom());
    }
    try {
      EmailDTO email =
          emailService.populateEmail(
              EmailType.FINAL_REJECTION, dossier.getOwner().getEmail(), sender, params, "", "");
      emailService.prepare(email);

      InboxMessage message = new InboxMessage();
      message.setParentUser(dossier.getOwner());
      message.setSubject(email.getSubject());
      message.setContent(email.getMessage());
      message.setMsgDate(new Date());
      message.setMsgStatus(InboxMessageStatus.UNREAD);
      inboxMessageRepos.save(message);
    } catch (Exception e) {
      e.printStackTrace();
    }
    taskService.complete(task.getId());
  }
  @Override
  public void rejectAnalysedDossier(Task task, Dossier dossier) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("gender", dossier.getOwner().getGender().toString());
    params.put("lastname", dossier.getOwner().getLastName());
    params.put("firstname", dossier.getOwner().getFirstName());
    params.put("nomEnfant", dossier.getCandidat().getLastname());
    params.put("prenomEnfant", dossier.getCandidat().getFirstname());
    params.put("refdossier", dossier.getGeneratedNumDossier());
    try {
      EmailDTO email =
          emailService.populateEmail(
              EmailType.NOT_ACCEPTED_FOR_TEST,
              dossier.getOwner().getEmail(),
              sender,
              params,
              "",
              "");
      emailService.prepare(email);

      InboxMessage message = new InboxMessage();
      message.setParentUser(dossier.getOwner());
      message.setSubject(email.getSubject());
      message.setContent(email.getMessage());
      message.setMsgDate(new Date());
      message.setMsgStatus(InboxMessageStatus.UNREAD);
      inboxMessageRepos.save(message);
    } catch (Exception e) {
      e.printStackTrace();
    }

    // Initialise process variables
    Map<String, Object> processParams = new HashMap<String, Object>();
    processParams.put("accepte", false);
    taskService.complete(task.getId(), processParams);
  }
Esempio n. 6
0
  @Override
  public Boolean launchSession(SessionExamen session, String link) {
    List<DossierSession> dossierSessions =
        dossierSessionRepos.findBySessionExamenId(session.getId());
    for (DossierSession dossiersession : dossierSessions) {
      Dossier dossier = dossierRepos.findOne(dossiersession.getDossier().getId());
      String token =
          Base64.encode(
              dossiersession.getDossier().getGeneratedNumDossier() + "" + (new Date()).toString());
      token = token.replace("=", "E");
      dossiersession.setGeneratedConvocationPDFPath(token);

      DossierHistoric dossierHistoric = new DossierHistoric();
      dossierHistoric.setStatus(dossier.getStatus());
      dossierHistoric.setCreateDate(new Date());
      dossierHistoric.setDossier(dossier);
      dossierHistoricRepo.save(dossierHistoric);

      dossier.setStatus(DossierStatus.INVITED_TO_TEST);

      dossierRepos.save(dossier);
      dossierSessionRepos.save(dossiersession);

      if (dossier.getNiveauEtude().getEmailConvocation() == null
          || !dossier.getNiveauEtude().getEmailConvocation()) continue;

      // preparing the email data
      Map<String, Object> params = new HashMap<String, Object>();
      params.put("gender", dossier.getOwner().getGender().toString());
      params.put("lastname", dossier.getOwner().getLastName());
      params.put("firstname", dossier.getOwner().getFirstName());
      params.put("nomEnfant", dossier.getCandidat().getLastname());
      params.put("prenomEnfant", dossier.getCandidat().getFirstname());
      params.put("refdossier", dossier.getGeneratedNumDossier());
      params.put("link", link + "resource/convocation?number=" + token);

      try {
        EmailDTO email =
            emailService.populateEmail(
                EmailType.CONVOCATED_FOR_TEST,
                dossier.getOwner().getEmail(),
                sender,
                params,
                "",
                "");
        emailService.prepare(email);

        InboxMessage message = new InboxMessage();
        message.setParentUser(dossier.getOwner());
        message.setSubject(email.getSubject());
        message.setContent(email.getMessage());
        message.setMsgDate(new Date());
        message.setMsgStatus(InboxMessageStatus.UNREAD);
        inboxMessageRepos.save(message);
      } catch (Exception e) {
        e.printStackTrace();
        return false;
      }
    }
    session = sessionExamenRepos.findOne(session.getId());
    session.setStatus(SessionStatus.CLOSED);
    sessionExamenRepos.save(session);
    return true;
  }
Esempio n. 7
0
  @Override
  public void cancelOrDeleteSession(Long sessionId) {
    SessionExamen session = sessionExamenRepos.findOne(sessionId);
    if (session.getStatus() == SessionStatus.CREATED
        || session.getStatus() == SessionStatus.CANCELED) {
      List<SessionNiveauEtude> matieres = sessionExamenNERepos.findBySessionExamenId(sessionId);
      sessionExamenNERepos.delete(matieres);
      sessionExamenRepos.delete(session);
    } else if (session.getStatus() == SessionStatus.OPEN) {
      List<DossierSession> dossierSessions =
          dossierSessionRepos.findBySessionExamenId(session.getId());
      for (DossierSession ds : dossierSessions) {
        Dossier dossier = dossierRepos.findOne(ds.getDossier().getId());

        DossierHistoric dossierHistoric = new DossierHistoric();
        dossierHistoric.setStatus(dossier.getStatus());
        dossierHistoric.setCreateDate(new Date());
        dossierHistoric.setDossier(dossier);
        dossierHistoricRepo.save(dossierHistoric);

        dossier.setStatus(DossierStatus.ACCEPTED_FOR_TEST);
        dossierRepos.save(dossier);
      }

      dossierSessionRepos.delete(dossierSessions);

      session.setStatus(SessionStatus.CANCELED);
      sessionExamenRepos.save(session);
    } else if (session.getStatus() == SessionStatus.CLOSED) {
      SimpleDateFormat format = new SimpleDateFormat(GlobalParameters.DATE_FORMAT);
      List<DossierSession> dossierSessions =
          dossierSessionRepos.findBySessionExamenId(session.getId());
      for (DossierSession dossiersession : dossierSessions) {
        Dossier dossier = dossiersession.getDossier();

        DossierHistoric dossierHistoric = new DossierHistoric();
        dossierHistoric.setStatus(dossier.getStatus());
        dossierHistoric.setCreateDate(new Date());
        dossierHistoric.setDossier(dossier);
        dossierHistoricRepo.save(dossierHistoric);

        dossier.setStatus(DossierStatus.ACCEPTED_FOR_TEST);
        dossierRepos.save(dossier);

        Map<String, Object> params = new HashMap<String, Object>();
        if (dossiersession.getSessionExamen().getDateSession() != null) {
          params.put(
              "dateSession", format.format(dossiersession.getSessionExamen().getDateSession()));
        } else {
          params.put("dateSession", "");
        }

        params.put("sessionNom", dossiersession.getSessionExamen().getNom());
        params.put("gender", dossier.getOwner().getGender().toString());
        params.put("lastname", dossier.getOwner().getLastName());
        params.put("firstname", dossier.getOwner().getFirstName());
        params.put("nomEnfant", dossier.getCandidat().getLastname());
        params.put("prenomEnfant", dossier.getCandidat().getFirstname());
        params.put("refdossier", dossier.getGeneratedNumDossier());

        try {
          EmailDTO email =
              emailService.populateEmail(
                  EmailType.SESSION_CANCELED,
                  dossier.getOwner().getEmail(),
                  sender,
                  params,
                  "",
                  "");
          emailService.prepare(email);

          InboxMessage message = new InboxMessage();
          message.setParentUser(dossier.getOwner());
          message.setSubject(email.getSubject());
          message.setContent(email.getMessage());
          message.setMsgDate(new Date());
          message.setMsgStatus(InboxMessageStatus.UNREAD);
          inboxMessageRepos.save(message);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }

      dossierSessionRepos.delete(dossierSessions);

      session.setStatus(SessionStatus.CANCELED);
      sessionExamenRepos.save(session);
    }
  }