示例#1
0
  @Override
  public String addForm(Form form) throws AddFormException {
    logger.info("------------> Adding a new Form 848");
    try {
      logger.info("Finding principal user");

      User user = null;
      try {
        user = userManager.findUserByName(sc.getCallerPrincipal().getName());
      } catch (Exception e1) {
        logger.error("Imposible to retrieve principal user.", e1);
        throw new AddFormException(e1.getClass() + " --> " + e1.getMessage());
      }

      Form848 form848 = new Form848(user);

      form848.fillForm(form);
      em.persist(form848);
      form848.setPrePrintedNumber(form848.getId().toString());

      return form848.getId().toString();

    } catch (FillFormException e) {
      logger.error(e);
      throw new AddFormException(e.getClass() + " --> " + e.getMessage());
    }
  }
示例#2
0
  @Override
  public void updateForm(Form form) throws UpdateFormException {
    try {
      Form848 form848 = findByPrePrintedNumber((String) form.getCell("prePrintedNumber").getData());

      form848.fillForm(form);
      em.persist(form848);

    } catch (FormNotFoundException e) {
      logger.error(e);
      throw new UpdateFormException(e.getClass() + " --> " + e.getMessage());
    } catch (FillFormException e) {
      logger.error(e);
      throw new UpdateFormException(e.getClass() + " --> " + e.getMessage());
    }
  }