コード例 #1
0
 /**
  * Move data from hashtable and copy into class variables Peer object restores from database to
  * hashtable.
  */
 public void restore(Transaction t, java.util.Hashtable data) throws PersistenceException {
   setId(FormatNumber.parseInteger(data.get(DbDefaultFormsAvailablePeer.IDENTITY).toString()));
   formId = FormatNumber.parseInteger(data.get(DbDefaultFormsAvailablePeer.IDENTITY).toString());
   localeNumber =
       FormatNumber.parseInteger(data.get(DbDefaultFormsAvailablePeer.LOCALE).toString());
   description = (String) data.get(DbDefaultFormsAvailablePeer.DESCRIPTION);
   reportName = (String) data.get(DbDefaultFormsAvailablePeer.REPORTNAME);
   selectionFormula = (String) data.get(DbDefaultFormsAvailablePeer.SELFORMULA);
   category = FormatNumber.parseInteger(data.get(DbDefaultFormsAvailablePeer.CATEGORY).toString());
   exportType = data.get(DbDefaultFormsAvailablePeer.EXPORTTYPE).toString();
   marginLeft =
       FormatNumber.parseInteger(data.get(DbDefaultFormsAvailablePeer.MARGINLEFT).toString());
   marginRight =
       FormatNumber.parseInteger(data.get(DbDefaultFormsAvailablePeer.MARGINRIGHT).toString());
   marginTop =
       FormatNumber.parseInteger(data.get(DbDefaultFormsAvailablePeer.MARGINTOP).toString());
   marginBottom =
       FormatNumber.parseInteger(data.get(DbDefaultFormsAvailablePeer.MARGINBOTTOM).toString());
 }
コード例 #2
0
  private void validateForm(
      DatabaseTransaction t,
      DbUserSession sessionUser,
      fdms.ui.struts.form.CemAnStatus form,
      ActionErrors errors) {

    String checkDate = null;

    // Validate Arrange Date
    if (form.getArrangeDate() != null && form.getArrangeDate().trim().length() > 0) {
      try {
        checkDate = FormatDate.convertToDateMMDDYYYY(form.getArrangeDate());
      } catch (Exception e) {
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.ui.arrangedate"));
        formErrors.add("arrangeDate");
      }
    }

    // Chapel is required.
    if (form.getChapel() == null || form.getChapel().trim().length() == 0) {
      errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.ui.chapel"));
      formErrors.add("chapel");
    }

    // Director is required.
    if (form.getDirector() == null || form.getDirector().trim().length() == 0) {
      errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.ui.director"));
      formErrors.add("director");
    }

    // Validate PreNeed Date if entered.
    if (form.getPreneedDate() != null && form.getPreneedDate().trim().length() > 0) {
      try {
        checkDate = FormatDate.convertToDateMMDDYYYY(form.getPreneedDate());
      } catch (Exception e) {
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.ui.origpndate"));
        formErrors.add("preneedDate");
      }
    }

    // If the user changed the contract number, check for duplicate Contract Numbers.
    if (form.getContractNumber() != null
        && form.getContractNumber().trim().length() > 0
        && (!form.getContractNumber().equals(form.getNextContractNumber()))) {

      DbCase checkCase = new DbCase();
      checkCase.setNew();
      checkCase.setLocale(sessionUser.getRegion());
      if (form.getVitalsId() == null
          || form.getVitalsId().trim().length() == 0
          || form.getVitalsId() == "0") {
        checkCase.setId(0);
      } else {
        checkCase.setId(FormatNumber.parseInteger(form.getVitalsId()));
      }
      checkCase.setContractCode(form.getContractNumber());
      if (FdmsDb.getInstance().checkCaseExists(t, checkCase, DbCasePeer.CONTRACTCODE)) {
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.duplicate.contractNumber"));
        formErrors.add("contractNumber");
      }
    }

    // Deceased Memorial Name is required.
    if (form.getMemorialName() == null || form.getMemorialName().trim().length() == 0) {
      if (form.getMiddleName() != null && form.getMiddleName().trim().length() > 0) {
        form.setMemorialName(
            form.getFirstName() + " " + form.getMiddleName() + " " + form.getLastName());
      } else {
        form.setMemorialName(form.getFirstName() + " " + form.getLastName());
      }
      if (form.getMemorialName() == null || form.getMemorialName().trim().length() == 0) {
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.memorialName.required"));
        formErrors.add("memorialName");
      }
    }

    // Deceased First Name is required.
    if (form.getFirstName() == null || form.getFirstName().trim().length() == 0) {
      errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.registration.nullFirstName"));
      formErrors.add("firstName");
    }

    // Deceased Last Name is required.
    if (form.getLastName() == null || form.getLastName().trim().length() == 0) {
      errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.registration.nullLastName"));
      formErrors.add("lastName");
    }

    // Validate Date of Birth
    if (form.getBirthDate() != null && form.getBirthDate().trim().length() > 0) {
      try {
        checkDate = FormatDate.convertToDateMMDDYYYY(form.getBirthDate());
      } catch (Exception e) {
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.ui.birthdate"));
        formErrors.add("birthDate");
      }
    }

    // Validate Date of Death
    if (form.getDeathDate() != null && form.getDeathDate().trim().length() > 0) {
      try {
        checkDate = FormatDate.convertToDateMMDDYYYY(form.getDeathDate());
      } catch (Exception e) {
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.ui.deathdate"));
        formErrors.add("deathDate");
      }
    }

    // Validate Service Date
    if (form.getServiceDate() != null && form.getServiceDate().trim().length() > 0) {
      try {
        checkDate = FormatDate.convertToDateMMDDYYYY(form.getServiceDate());
      } catch (Exception e) {
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.ui.servicedate"));
        formErrors.add("serviceDate");
      }
    }

    // Validate Disposition Date
    if (form.getDispDate() != null && form.getDispDate().trim().length() > 0) {
      try {
        checkDate = FormatDate.convertToDateMMDDYYYY(form.getDispDate());
      } catch (Exception e) {
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.ui.dispdate"));
        formErrors.add("dispDate");
      }
    }

    return;
  }
コード例 #3
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws javax.servlet.ServletException, java.io.IOException {

    logger.debug("********************************************");
    logger.debug("*** Entering ProcessFirstCallInformation ***");

    CemAnStatus form = (CemAnStatus) actionForm;
    ActionErrors errors = new ActionErrors();
    formErrors = new ArrayList();
    HttpSession session = request.getSession();
    DbUserSession sessionUser = (DbUserSession) session.getAttribute(SessionValueKeys.DB_USER);

    logger.debug("ExecutorSame request value : " + request.getParameter("executorSame"));

    DatabaseTransaction t = null;
    FdmsDb fdmsdb = null;
    DbVitalsDeceased deceased = null;
    DbVitalsInformant informant = null;
    DbVitalsFirstCall firstCall = null;
    DbCase caseinfo = null;
    DbVitalsNextKin nextkin = null;
    DbPreneed preneed = null;
    DbVitalsSchedule sched = null;
    DbVitalsExecutor executor = null;
    DbCemAtneed cematneed = null;
    boolean addmode = false;
    int vitalsid = 0;
    String directive = form.getDirective();

    // Try to set the vitalsid from the form.
    try {
      vitalsid = FormatNumber.parseInteger(form.getVitalsId());
    } catch (Exception e) {
      vitalsid = 0;
    }

    cematneed = new DbCemAtneed();
    cematneed.setNew();

    if (directive.equals("cancel")) {
      // go back to case status unless no vitalsid then, show introduction.
      vitalsid = SessionHelpers.getVitalsIdFromSession(request, sessionUser);
      if (vitalsid > 0) {
        return mapping.findForward("showCaseStatusGlobal");
      } else {
        return mapping.findForward("ShowIntroductionGlobal");
      }
    }

    if (directive.equals("help")) {
      return mapping.findForward("usingHelp");
    }

    // From this point, we need to access the database
    try {
      t = (DatabaseTransaction) DatabaseTransaction.getTransaction(sessionUser);
      fdmsdb = FdmsDb.getInstance();

      if (directive.equals("redisplay")) {
        redisplayForm(t, sessionUser, form, errors);
        form.setDirective(" ");
        session.setAttribute("cemAnStatus", form);
        return new ActionForward(mapping.getInput());
      }

      validateForm(t, sessionUser, form, errors);
      // if errors found, return to input screen without saving anything
      if (!errors.isEmpty()) {
        // AppLog.info("ProcessFirstCall Invoking forward mapping getInput() after validation.");
        saveErrors(request, errors);
        request.setAttribute("formErrors", formErrors);

        form.setDirective(" ");
        session.setAttribute("cemAnStatus", form);
        return new ActionForward(mapping.getInput());
      } else {
        // AppLog.trace("ProcessFirstCall past validation.");
      }

      // Get the DbVitalDeceased and DbVitalsFirstCall objects
      if (vitalsid == 0) {
        deceased = new DbVitalsDeceased();
        deceased.setNew();
        addmode = true;
      } else {
        deceased = fdmsdb.getVitalsDeceased(t, vitalsid);
      }

      // Set the data in the DbVitalsDeceased and DbVitalsFirstCall records
      setVitalsDeceased(deceased, informant, form, errors);
      // if errors found, return to input screen without saving anything
      if (!errors.isEmpty()) {
        // AppLog.info("ProcessFirstCall Invoking forward mapping getInput() after
        // setVitalsDeceased.");
        saveErrors(request, errors);
        request.setAttribute("formErrors", formErrors);
        session.setAttribute("cemAnStatus", form);
        form.setDirective(" ");
        return new ActionForward(mapping.getInput());
      } else {
        // AppLog.trace("ProcessFirstCall past setVitalsDeceased.");
      }

      if (vitalsid == 0) {
        t.addPersistent(deceased);
        t.save();
        t.closeConnection();
        t = null;

        vitalsid = deceased.getId();
        form.setVitalsId(String.valueOf(vitalsid));
        sessionUser.setCurrentCaseID(vitalsid);
        // Need another transaction to continue with add
        t = (DatabaseTransaction) DatabaseTransaction.getTransaction(sessionUser);
        // increment next contract number if user did not change it
        // and assign to this case
        // if user changed contract# then use the one they entered.
        if (form.getContractNumber().equals(form.getNextContractNumber())) {
          int newnextno =
              SessionHelpers.nextContractNumber(sessionUser.getDbLookup(), sessionUser.getRegion());
          form.setContractNumber(String.valueOf(newnextno));
          form.setNextContractNumber(form.getContractNumber());
          // need new transaction since save in above method ends that transaction
        }
        sched = fdmsdb.getVitalsSchedule(t, vitalsid);
        sched.setDefaultAtNeedCheckList(sessionUser.getRegion(), sessionUser.getDbLookup());
      } else {
        sched = fdmsdb.getVitalsSchedule(t, vitalsid);
      }

      // Now, lets update the other Vitals information
      SessionHelpers.setVitalsIdInRequest(request, vitalsid);
      firstCall = fdmsdb.getVitalsFirstCall(t, vitalsid);
      informant = fdmsdb.getVitalsInformant(t, vitalsid);
      caseinfo = fdmsdb.getCase(t, vitalsid);
      nextkin = fdmsdb.getVitalsNextKin(t, vitalsid);
      executor = fdmsdb.getVitalsExecutor(t, vitalsid);
      // cematneed = fdmsdb.getCemAtneed(t, vitalsid);
      if (executor == null) {
        executor = new DbVitalsExecutor();
        executor.setNew();
      }
      setVitalsRest(
          t,
          sessionUser,
          deceased,
          firstCall,
          informant,
          caseinfo,
          nextkin,
          executor,
          cematneed,
          form,
          errors);
      // if errors found, return to input screen without saving anything
      if (!errors.isEmpty()) {
        // AppLog.info("ProcessFirstCall Invoking forward mapping getInput() after setVitalsRest.");
        saveErrors(request, errors);
        request.setAttribute("formErrors", formErrors);
        session.setAttribute("cemAnStatus", form);
        form.setDirective(" ");
        return new ActionForward(mapping.getInput());
      } else {
        logger.debug("no errors exist in processfirstcall information");
        // AppLog.trace("ProcessFirstCall past setVitalsRest.");
      }

      // determine whether active preneed or deceased
      preneed = fdmsdb.getPreneed(t, vitalsid);
      String relation = "Deceased";
      if (preneed.getStatus().equals(DbPreneed.ACTIVE)) {
        relation = "Preneed";
      }
      t.removePersistent(preneed);

      // update special survivor information for searching deceased, informant, case#, contract#
      DbSurvivor.addUpdateSurvivor(
          t,
          vitalsid,
          DbSurvivor.DECEASED,
          deceased.getSalutation(),
          deceased.getDecFName(),
          deceased.getDecMName(),
          deceased.getDecLName(),
          deceased.getSuffix(),
          deceased.getMaidenName(),
          deceased.getFullName(),
          deceased.getDecResStreet() + " " + deceased.getDecAptNo(),
          "",
          deceased.getDecResMailCity(),
          deceased.getDecResState(),
          deceased.getDecResZip(),
          "",
          "",
          "",
          relation,
          "",
          "",
          "");
      DbSurvivor.addUpdateSurvivor(
          t,
          vitalsid,
          DbSurvivor.INFORMANT,
          informant.getSalutation(),
          informant.getFname(),
          informant.getMname(),
          informant.getLname(),
          "",
          "",
          "",
          informant.getStreet() + " " + informant.getRoad2() + " " + informant.getRoad3(),
          "",
          informant.getCity(),
          informant.getState(),
          informant.getZip(),
          informant.getPhone(),
          "",
          informant.getInformantEmail(),
          "Informant",
          "",
          "",
          "");
      DbSurvivor.addUpdateSurvivor(
          t,
          vitalsid,
          DbSurvivor.CONTRACT,
          "",
          deceased.getDecLName(),
          "",
          caseinfo.getContractCode(),
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          deceased.getDecFName(),
          "",
          "",
          "");
      DbSurvivor.addUpdateSurvivor(
          t,
          vitalsid,
          DbSurvivor.CASECODE,
          "",
          deceased.getDecLName(),
          "",
          caseinfo.getCaseCode(),
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          deceased.getDecFName(),
          "",
          "",
          "");

      // add informant and next-of-kin as normal survivors but only during add cycle
      if (addmode) {
        // AppLog.trace("Adding informant and NOK as survivors.");
        DbSurvivor infsurv =
            new DbSurvivor(
                vitalsid,
                informant.getSalutation(),
                informant.getFname(),
                informant.getMname(),
                informant.getLname(),
                "",
                "",
                "",
                informant.getStreet() + " " + informant.getRoad2() + " " + informant.getRoad3(),
                "",
                informant.getCity(),
                informant.getState(),
                informant.getZip(),
                informant.getPhone(),
                "",
                informant.getInformantEmail(),
                informant.getRelated(),
                "",
                "",
                "",
                "");
        t.addPersistent(infsurv);
        if (!form.getNextKinSame()) {
          DbSurvivor noksurv =
              new DbSurvivor(
                  vitalsid,
                  nextkin.getSalutation(),
                  nextkin.getFirstname(),
                  "",
                  nextkin.getLastname(),
                  "",
                  "",
                  "",
                  nextkin.getStreet() + nextkin.getRoad2() + " " + nextkin.getRoad3(),
                  "",
                  nextkin.getCity(),
                  nextkin.getState(),
                  nextkin.getZip(),
                  nextkin.getPhone(),
                  "",
                  "",
                  nextkin.getRelation(),
                  "",
                  "",
                  "",
                  "");
          t.addPersistent(noksurv);
        }
      }
      t.addPersistent(cematneed);

      if (executor != null) t.addPersistent(executor);

      // Final commit and cleanup
      t.save();

    } catch (PersistenceException pe) {
      logger.error("PersistenceException in doPerform() : ", pe);
      errors.add(
          ActionErrors.GLOBAL_ERROR, new ActionError("error.PersistenceException", pe.getCause()));
    } catch (Exception pe) {
      logger.error("Error in doPerform() : ", pe);
      errors.add(
          ActionErrors.GLOBAL_ERROR, new ActionError("error.GeneralException", pe.getMessage()));
    } finally {
      if (t != null) {
        try {
          t.closeConnection();
          t = null;
        } catch (Exception e) {
          logger.error("Error in closeConnection() : ", e);
        }
      }
    }

    if (!errors.isEmpty()) {
      // AppLog.info("ProcessFirstCallInformation Invoking forward mapping getInput().");
      saveErrors(request, errors);
      request.setAttribute("formErrors", formErrors);
      form.setDirective(" ");
      session.setAttribute("cemAnStatus", form);
      return (new ActionForward(mapping.getInput()));
    }

    // remove session variables used in FirstCall page
    SessionHelpers.removeArrangerListFromSession(request);
    SessionHelpers.removeChapelListInSession(request);
    session.removeAttribute("cemAnStatus");
    SessionHelpers.setVitalsIdInRequest(request, vitalsid);

    // Since we are forwarding to another ACTION, need to go through this exercise
    /*	ActionMappings mappings = mapping.getMappings();
           String returnPath = actionForward.getPath();
           int periodpos = returnPath.indexOf(".do");
           returnPath = returnPath.substring(0,periodpos);
           ActionMapping finalMapping = mappings.findMapping(returnPath);
           Action finalAction = null;

           try {
               Class clazz = Class.forName(finalMapping.getType());
               finalAction = (Action) clazz.newInstance();
               AppLog.trace("chaining to:"+finalAction.toString());
           } catch (Exception e) {
               AppLog.warning("Could not find chained action: " + e.getMessage());
               return forwardGlobalCancel(mapping) ;
           }

           return finalAction.perform(finalMapping,form,request,response);
    */
    // return forwardShowCaseStatusGlobal(mapping);

    if (errors.isEmpty()) {
      request.setAttribute("redirect", Boolean.TRUE);
      request.setAttribute("vitalsId", new Integer(vitalsid));
    }
    return new ActionForward(mapping.getInput());
  }
コード例 #4
0
  /**
   * Set the DbVitals and DbCase values from the FirstCallInformation form. Creation date:
   * (10/25/2002 11:00:39 AM)
   *
   * @param t com.aldorsolutions.webfdms.database.DatabaseTransaction
   * @param firstCall com.aldorsolutions.webfdms.beans.DbVitalsFirstCall
   * @param informant com.aldorsolutions.webfdms.beans.DbVitalsInformant
   * @param caseinfo com.aldorsolutions.webfdms.beans.DbCase
   * @param nextkin com.aldorsolutions.webfdms.beans.DbVitalsNextKin
   * @param nextkin com.aldorsolutions.webfdms.beans.DbVitalsExecutor
   * @param form fdms.ui.struts.form.FirstCallInformationForm
   * @param errors org.apache.struts.action.ActionErrors
   */
  public void setVitalsRest(
      DatabaseTransaction t,
      DbUserSession sessionUser,
      DbVitalsDeceased deceased,
      DbVitalsFirstCall firstCall,
      DbVitalsInformant informant,
      DbCase caseinfo,
      DbVitalsNextKin nextkin,
      DbVitalsExecutor executor,
      DbCemAtneed cematneed,
      CemAnStatus form,
      ActionErrors errors) {

    boolean continueDuplicate = true;

    try {
      if (form.isExecutorSame()) {
        logger.debug("Executor is the same");

        executor.setIsExecutorSame("Y");
        executor.setExecutorPersonId(form.getExecutorPersonId());
        executor.setExecutorFirstname(form.getInformantFirst());
        executor.setExecutorLastname(form.getInformantLast());
        executor.setExecutorStreet(form.getInformantStreet());
        executor.setExecutorStreet2(form.getInformantStreet2());
        executor.setExecutorStreet3(form.getInformantStreet3());
        executor.setExecutorCity(form.getInformantCity());
        executor.setExecutorState(form.getInformantState());
        executor.setExecutorZip(form.getInformantZip());
        executor.setExecutorPhone(FormatString.formatPhone(form.getInformantPhone()));
        executor.setExecutorRelation(form.getInformantRelation());
        executor.setExecutorEmail(form.getInformantEmail());

        // sets the vitals id for DbExecutor so I can insert values into database
        Persistent p = (Persistent) executor;
        p.setId(new Integer(form.getVitalsId()).intValue());

      } else {
        logger.debug("Executor is not the same");

        executor.setIsExecutorSame("N");
        executor.setExecutorPersonId(form.getExecutorPersonId());
        executor.setExecutorFirstname(form.getExecutorFirstName());
        executor.setExecutorLastname(form.getExecutorLastName());
        executor.setExecutorStreet(form.getExecutorStreet());
        executor.setExecutorStreet2(form.getExecutorStreet2());
        executor.setExecutorStreet3(form.getExecutorStreet3());
        executor.setExecutorCity(form.getExecutorCity());
        executor.setExecutorState(form.getExecutorState());
        executor.setExecutorZip(form.getExecutorZip());
        executor.setExecutorPhone(FormatString.formatPhone(form.getExecutorPhone()));
        executor.setExecutorRelation(form.getExecutorRelation());
        executor.setExecutorEmail(form.getExecutorEmail());

        // sets the vitals id for DbExecutor so I can insert values into database
        Persistent p = (Persistent) executor;
        p.setId(new Integer(form.getVitalsId()).intValue());
      }

      firstCall.setArrangeDate(FormatDate.convertToDateMMDDYYYY(form.getArrangeDate()));
      firstCall.setDispositionDate(FormatDate.convertToDateMMDDYYYY(form.getDispDate()));
      firstCall.setOriginalPnDate(FormatDate.convertToDateMMDDYYYY(form.getPreneedDate()));
      firstCall.setArrangeTime(form.getTime());
      firstCall.setPlaceDeathAddr(form.getLocationDeceased());
      firstCall.setSource(form.getSource());
      firstCall.setEmbalmingReason(form.getEmbalming());
      firstCall.setPlaceDeath(form.getPlaceDeath());
      firstCall.setPlaceDeathCity(form.getPlaceDeathCity());
      firstCall.setPlaceDeathState(form.getPlaceDeathState());
      firstCall.setPlaceDeathZip(form.getPlaceDeathZip());
      firstCall.setAgeYears(FormatNumber.parseInteger(form.getAge()));

      int chapelId = 0;
      if (form.getChapel() != null) {
        try {
          chapelId = Integer.parseInt(form.getChapel());
        } catch (NumberFormatException e) {
          // unable to parse int from String
        }
      }

      logger.debug("ChapelId : " + chapelId);

      DbLocation dbLocation = FdmsDb.getInstance().getLocation(t, chapelId);
      if (dbLocation != null) {
        firstCall.setFacilityName(dbLocation.getName());
        firstCall.setFacilityStreet(dbLocation.getAddr1());
        firstCall.setFacilityCityStZip(
            dbLocation.getCity() + ", " + dbLocation.getState() + ", " + dbLocation.getZip());
        firstCall.setFacilityLicenseNo(dbLocation.getLicenseNumber());
        firstCall.setFacilityPhone(FormatString.formatPhone(dbLocation.getPhone()));
      } else {
        firstCall.setFacilityName(form.getFacilityName());
        firstCall.setFacilityStreet(form.getFacilityStreet());
        firstCall.setFacilityCityStZip(
            form.getFacilityCity() + ", " + form.getFacilityState() + ", " + form.getFacilityZip());
        firstCall.setFacilityPhone(FormatString.formatPhone(form.getFacilityPhone()));
        firstCall.setFacilityLicenseNo(form.getFacilityLicense());
      }

      firstCall.setShippingInfo(form.getShippingInfo());

      DbArrangers dbArranger =
          FdmsDb.getInstance().getArranger(t, Integer.parseInt(form.getDirector()));
      firstCall.setArrangerName(dbArranger.getName());
      firstCall.setArrangerID(dbArranger.getId());

      informant.setSalutation(form.getInformantSalutation());
      informant.setFname(form.getInformantFirst());
      informant.setMname(form.getInformantMiddle());
      informant.setLname(form.getInformantLast());
      informant.setStreet(form.getInformantStreet());
      informant.setRoad2(form.getInformantStreet2());
      informant.setRoad3(form.getInformantStreet3());
      informant.setCity(form.getInformantCity());
      informant.setState(form.getInformantState());
      informant.setZip(form.getInformantZip());
      informant.setPhone(FormatString.formatPhone(form.getInformantPhone()));
      informant.setRelated(form.getInformantRelation());
      informant.setInformantEmail(form.getInformantEmail());

      if (form.getNextKinSame()) {
        nextkin.setSameAsInformant("Y");
        nextkin.setSalutation(form.getInformantSalutation());
        nextkin.setFirstname(form.getInformantFirst());
        nextkin.setLastname(form.getInformantLast());
        nextkin.setStreet(form.getInformantStreet());
        nextkin.setRoad2(form.getInformantStreet2());
        nextkin.setRoad3(form.getInformantStreet3());
        nextkin.setCity(form.getInformantCity());
        nextkin.setState(form.getInformantState());
        nextkin.setZip(form.getInformantZip());
        nextkin.setPhone(FormatString.formatPhone(form.getInformantPhone()));
        nextkin.setRelation(form.getInformantRelation());
      } else {
        nextkin.setSameAsInformant("N");
        nextkin.setSalutation(form.getNextKinSalutation());
        nextkin.setFirstname(form.getNextKinFirst());
        nextkin.setLastname(form.getNextKinLast());
        nextkin.setStreet(form.getNextKinStreet());
        nextkin.setRoad2(form.getNextKinStreet2());
        nextkin.setRoad3(form.getNextKinStreet3());
        nextkin.setCity(form.getNextKinCity());
        nextkin.setState(form.getNextKinState());
        nextkin.setZip(form.getNextKinZip());
        nextkin.setPhone(FormatString.formatPhone(form.getNextKinPhone()));
        nextkin.setRelation(form.getNextKinRelation());
      }

      cematneed.setCem_plottype(form.getCem_plottype());
      cematneed.setCem_section(form.getCem_section());
      cematneed.setCem_block(form.getCem_block());
      cematneed.setCem_lot_tier(form.getCem_lot_tier());
      cematneed.setCem_grave_row(form.getCem_grave_row());
      cematneed.setCem_Amount(form.getCem_Amount());
      cematneed.setCem_ANBuyerAptNo(form.getCem_ANBuyerAptNo());
      cematneed.setCem_ANBuyerCity(form.getCem_ANBuyerCity());
      cematneed.setCem_ANBuyerMidName(form.getCem_ANBuyerMidName());
      cematneed.setCem_ANBuyerTitle(form.getCem_ANBuyerTitle());
      cematneed.setCem_ANBuyerPhone(form.getCem_ANBuyerPhone());
      cematneed.setCem_ANBuyerState(form.getCem_ANBuyerState());
      cematneed.setCem_ANBuyerStreet(form.getCem_ANBuyerStreet());
      cematneed.setCem_ANBuyerFirstName(form.getCem_ANBuyerFirstName());
      cematneed.setCem_ANBuyerLastName(form.getCem_ANBuyerLastName());
      cematneed.setCem_ANBuyerZip(form.getCem_ANBuyerZip());
      cematneed.setCem_MapID(form.getCem_MapID());
      cematneed.setCem_Record(form.getCem_Record());
      cematneed.setCem_ContractDate(form.getCem_ContractDate());
      cematneed.setCem_MiscDesc(form.getCem_MiscDesc());
      cematneed.setCem_MiscAmount(form.getCem_MiscAmount());

      deceased.setDecFName(form.getBeneficiaryFirst());
      deceased.setDecMName(form.getBeneficiaryMiddle());
      deceased.setDecLName(form.getBeneficiaryLast());
      deceased.setDecResStreet(form.getBeneficiaryStreet());
      deceased.setDecResMailCity(form.getBeneficiaryCity());
      deceased.setDecResState(form.getBeneficiaryState());
      deceased.setDecResZip(form.getBeneficiaryZipCode());
      deceased.setDecResPhone(form.getBeneficiaryPhone());
      deceased.setSSNo(FormatString.removeDashes(form.getBeneficiarySocialSecurityNumber()));
      deceased.setDecFullName(form.getBeneficiaryFirst() + " " + form.getBeneficiaryLast());
      deceased.setDecmrmrs(form.getBeneficiaryTitle());
      deceased.setDecAptNo(form.getBeneficiaryAptno());

      caseinfo.setChapelLocation(dbLocation.getName());
      caseinfo.setChapelNumber(dbLocation.getId());
      caseinfo.setLocale(dbLocation.getLocaleNumber());
      caseinfo.setDeathDate(FormatDate.convertToDateYYYYMMDD(form.getDeathDate()));
      caseinfo.setServiceDate(FormatDate.convertToDateYYYYMMDD(form.getServiceDate()));
      caseinfo.setSaleDate(FormatDate.convertToDateYYYYMMDD(form.getServiceDate()));

      DatabaseTransaction x = null;

      // Regardless of whether the user changed the contract number or not, we need to make sure
      // that the
      // contract number is unique before we proceed.
      if (form.getContractNumber() != null && form.getContractNumber().trim().length() > 0) {
        try {
          x = (DatabaseTransaction) DatabaseTransaction.getTransaction(sessionUser);
          while (continueDuplicate) {
            // Check for duplicate Contract Numbers.
            DbCase checkCase = new DbCase();
            checkCase.setNew();
            checkCase.setLocale(sessionUser.getRegion());
            checkCase.setId(deceased.getId());
            checkCase.setContractCode(form.getContractNumber());
            if (FdmsDb.getInstance().checkCaseExists(x, checkCase, DbCasePeer.CONTRACTCODE)) {
              // AppLog.trace("Contract " +form.getContractNumber() + " is a duplicate.");
              // If the user changed the contract number, give them an error
              if (!form.getNextContractNumber().equals(form.getContractNumber())) {
                errors.add(
                    ActionErrors.GLOBAL_ERROR, new ActionError("error.duplicate.contractNumber"));
                formErrors.add("contractNumber");
                continueDuplicate = false;
              } else {
                // contract number is same so need to increment and retest for duplicate
                form.setContractNumber(
                    String.valueOf(
                        SessionHelpers.nextContractNumber(
                            sessionUser.getDbLookup(), sessionUser.getRegion())));
                form.setNextContractNumber(form.getContractNumber());
                // AppLog.trace("Incremented contract# because duplicated. New next
                // number="+form.getContractNumber());
              }
            } else {
              continueDuplicate = false;
            }
          }
        } catch (Exception e) {
          logger.error("Error : ", e);
        } finally {
          if (x != null) {
            x.closeConnection();
            x = null;
          }
        }
      }

      caseinfo.setContractCode(form.getContractNumber());
      caseinfo.setCaseCode(form.getCaseNumber());

      // Add Informant as BillTo if no BillTos already exist.
      DbBillto[] dbBillTo = FdmsDb.getInstance().getBilltoForID(t, deceased.getId());
      if (dbBillTo == null || dbBillTo.length == 0) {
        if ((form.getInformantFirst() != null && form.getInformantFirst().trim().length() > 0)
            || (form.getInformantLast() != null && form.getInformantLast().trim().length() > 0)) {
          DbBillto newBillTo = new DbBillto();
          newBillTo.setNew();
          // newBillTo.setCashSale();
          newBillTo.setCity(form.getInformantCity());
          // newBillTo.setContractSigner();
          // newBillTo.setCounty();
          newBillTo.setEmailAddress(form.getInformantEmail());
          // newBillTo.setFileVersion();
          newBillTo.setFirstName(form.getInformantFirst());
          newBillTo.setHomePhone(FormatString.formatPhone(form.getInformantPhone()));
          newBillTo.setHonorific(form.getInformantSalutation());
          // newBillTo.setLanguage(form.getInformant);
          newBillTo.setLastName(form.getInformantLast());
          // newBillTo.setRefused(form.getInformant);
          newBillTo.setRelation(form.getInformantRelation());
          newBillTo.setSendInvoice("Y");
          newBillTo.setSeqNo(Short.parseShort("0"));
          // newBillTo.setSocialSecurityNo(form.getInformant);
          newBillTo.setState(form.getInformantState());
          newBillTo.setStreet1(form.getInformantStreet());
          newBillTo.setStreet2(form.getInformantStreet2());
          newBillTo.setStreet3(form.getInformantStreet3());
          // newBillTo.setStreet4(form.getInformant);
          newBillTo.setVitalsID(deceased.getId());
          // newBillTo.setWorkPhone(form.getInformant);
          newBillTo.setZip(form.getInformantZip());
          if (form.getInformantContractSigner()) {
            newBillTo.setContractSigner("Y");
          }
          t.addPersistent(newBillTo);
        }
      }

    } catch (Exception e) {
      logger.error("Exception in setVitalsRest() ", e);
      errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.ui.setData"));
    }

    return;
  }
コード例 #5
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws javax.servlet.ServletException, java.io.IOException {

    formErrors = new ArrayList();
    MiscCashReceiptsForm form = (MiscCashReceiptsForm) actionForm;
    ActionErrors errors = new ActionErrors();
    HttpSession session = request.getSession();
    DbUserSession sessionUser = SessionHelpers.getUserSession(request);
    DatabaseTransaction t = null;
    DbHistory dbHistory = null;

    if (form.getSubmitButton() != null && form.getSubmitButton().equals("exit")) {
      ActionForward actionForward = mapping.findForward("financial");
      return actionForward;
    }

    try {
      t = (DatabaseTransaction) DatabaseTransaction.getTransaction(sessionUser);
      // AppLog.trace("ProcessMiscCashReceipts submit ="+form.getSubmitButton());

      // --- HANDLE PRINTING A RECEIPT ---
      if (form.getFormId() != null
          && form.getFormId().trim().length() > 0
          && (!form.getFormId().equals("None"))) {
        // AppLog.trace("ProcessMiscCashReceipts printing receipt form: "+form.getFormId());
        if (FormatNumber.parseInteger(form.getFormId()) < 1) {
          // AppLog.error("ProcessMiscCashReceipts - No receipt type selected.");
          errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.tables.noselect"));
          formErrors.add("formId");
          t.closeConnection();
          return (new ActionForward(mapping.getInput()));
        }
      }

      if (form.getSubmitButton().equals("save")) {
        dbHistory = new DbHistory();
        dbHistory.setNew();
        validateData(form, errors);
        if (errors.isEmpty()) {
          setHistory(t, sessionUser, dbHistory, form, errors);
          if (errors.isEmpty()) {
            t.save();
          } else {
            // AppLog.criticalError("Exception in ProcessMiscCashReceipts.setHistory.");
          }
        } else {
          // AppLog.trace("Validation Errors in ProcessMiscCashReceipts; returning to
          // MiscCashReceipts form.");
        }
      }

      // --- HANDLE PRINTING A RECEIPT ---
      if (errors.isEmpty() && FormatNumber.parseInteger(form.getFormId()) > 0) {

        String crystalFlag =
            UtilSingleton.getInstance()
                .getProperty(sessionUser.getConfigID(), "CrystalServer.useReportingService");
        String pageName = null;

        if (crystalFlag != null && "true".equals(crystalFlag)) {
          CrystalReportManagerBean crystalServerReport =
              new CrystalReportManagerBean(sessionUser.getConfigID());
          pageName =
              crystalServerReport.printReport(
                  sessionUser,
                  FormatNumber.parseInteger(form.getFormId()),
                  "",
                  "",
                  null,
                  "",
                  Integer.toString(dbHistory.getId()),
                  true);
        } else {
          ExportReport crystal = new ExportReport();
          crystal.setRecordIdSelParam(dbHistory.getId()); // selection parameter
          pageName =
              crystal.printForm(
                  sessionUser,
                  FormatNumber.parseInteger(form.getFormId()),
                  "",
                  "",
                  null,
                  "",
                  request,
                  response,
                  servlet.getServletContext());
        }

        form = new MiscCashReceiptsForm();
        setNewForm(request, sessionUser, session, form, errors);
        form.setPreviewFile(pageName);
        // AppLog.trace("Setting miscCashReceipts collection arrays into session scope.");
        session.setAttribute("miscCashReceipts", form);
        ActionForward actionForward = mapping.findForward("showMiscCashReceipts");
        return actionForward;
      }

    } catch (PersistenceException pe) {
      logger.error("Persistence Exception in ProcessMiscCashReceipts.doPerform. " + pe);
      errors.add(
          ActionErrors.GLOBAL_ERROR, new ActionError("error.PersistenceException", pe.getCause()));
    } catch (Exception pe) {
      logger.error("Exception in ProcessMiscCashReceipts.doPerform. ", pe);
      errors.add(
          ActionErrors.GLOBAL_ERROR, new ActionError("error.GeneralException", pe.getMessage()));
    } finally {
      if (t != null) {
        t.closeConnection();
      }
    }

    // Action Forward Logic

    ActionForward actionForward = mapping.findForward("showMiscCashReceiptsGlobal");

    if (!errors.isEmpty()) {
      // AppLog.info("ProcessMiscCashReceipts Invoking forward mapping getInput() ");
      saveErrors(request, errors);
      request.setAttribute("formErrors", formErrors);
      actionForward = new ActionForward(mapping.getInput());
    }

    logger.debug("Leaving ProcessMiscCashReceipts.");
    return actionForward;
  }
コード例 #6
0
  /**
   * Called from ProcessMiscCashReceipts, this Method sets the History record from the
   * MiscCashReceipts form values. If am error occurs, the error is stored in the errors collection.
   * Creation date: (8/13/2002 3:41:43 PM)
   */
  public void setHistory(
      DatabaseTransaction t,
      DbUserSession sessionUser,
      DbHistory dbHistory,
      fdms.ui.struts.form.MiscCashReceiptsForm form,
      ActionErrors errors) {

    String errorField = new String();
    String formField = null;
    DbLocale userlocale = null;
    DatabaseTransaction tlocale = null;
    int receiptNumber = 0;

    try {

      errorField = "VitalsMasterKey";
      dbHistory.setLMainKey(0);

      errorField = "ARAcct";
      formField = "arAcct";
      dbHistory.setCHistARacct(form.getArAcct());

      errorField = "Date";
      formField = "dateOfTran";
      dbHistory.setCHistDate(
          new java.sql.Date(FormatDate.convertToDate(form.getDateOfTran()).getTime()));

      errorField = "Description";
      formField = "description";
      dbHistory.setCHistDesc(form.getDescription());

      errorField = "GLAcct";
      formField = "glAcct";
      dbHistory.setCHistGLAcct(form.getGlAcct());

      errorField = "ManualReceipt";
      formField = "manualReceiptNo";
      dbHistory.setCHistManualReceipt(form.getManualReceiptNo());

      errorField = "OriginalPosting";
      formField = "";
      dbHistory.setCHistOriginalPosting('N');

      errorField = "PayMethod";
      formField = "getPayMethod";
      dbHistory.setCHistPayMethod(form.getPayMethod());

      errorField = "Posted";
      formField = "";
      dbHistory.setCHistPosted('N');

      errorField = "SPF";
      formField = "";
      dbHistory.setCHistSPF('R');

      // Set Receipt Number from locale
      try {
        tlocale = (DatabaseTransaction) DatabaseTransaction.getTransaction(sessionUser);
        userlocale = FdmsDb.getInstance().getLocaleWithLock(tlocale, sessionUser.getRegion());
        if (userlocale == null) {
          throw new java.sql.SQLException("No locale for user region.");
        }
        receiptNumber = userlocale.getNextReceiptNo();
        userlocale.setNextReceiptNo(receiptNumber + 1);
        tlocale.addPersistent(userlocale);
        tlocale.save();
        // AppLog.trace("ProcessMiscCashReceipts: next receipt number = " +receiptNumber);

      } catch (java.sql.SQLException e) {
        if (e.getErrorCode() == 1205) {
          // AppLog.warning("ProcessMiscCashReceipts - DbLocale locked from updating."
          // +sessionUser.getRegion());
          throw new PersistenceException("User locale temporarily locked. Try again.");
        }
        // AppLog.warning("ProcessMiscCashReceipts - invalid region for user "
        // +sessionUser.getUserName());
        throw new PersistenceException("Invalid region for user", e);
      } finally {
        if (t != null) {
          t.closeConnection();
        }
      }

      errorField = "ReceiptNo";
      dbHistory.setLHistReceiptNo(receiptNumber);

      errorField = "Amount";
      dbHistory.setLHistAmount(
          FormatNumber.parseInteger(
              String.valueOf(FormatCurrency.convertToCurrency(form.getAmountOfTran()))));

      errorField = "LocationId";
      dbHistory.setLocationId(Integer.parseInt(form.getLocationId()));

      t.addPersistent(dbHistory);

    } catch (Exception e) {
      errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.receipts.set" + errorField));
      formErrors.add(formField);
    }

    return;
  }
コード例 #7
0
  /**
   * Method execute
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws javax.servlet.ServletException, java.io.IOException {

    HttpSession session = request.getSession();
    DbUserSession user = (DbUserSession) session.getAttribute(SessionValueKeys.DB_USER);
    ReportForm reportForm = (ReportForm) form;
    ActionMessages errors = new ActionMessages();

    // ArrayList <CheckListBean> checkURL = new ArrayList <CheckListBean>();
    // session.setAttribute("checkURL", checkURL);

    String requestType = reportForm.getRequestType();
    if (requestType == null) {
      requestType = "";
    }
    String pageName = "";
    reportForm.setReportURL(pageName);
    setReport(reportForm, user, session, errors, request);

    if (reportForm.getListType() == null) {
      reportForm.setListType(request.getParameter("all"));
    } else {
      reportForm.setListType(reportForm.getListType());
    }

    if (requestType.compareToIgnoreCase("changeLocale") == 0) {
      changeLocale(reportForm, user, session, errors, request);
      // changeCategory(reportForm, user, session, errors, request);
      return (mapping.findForward("localeChange"));
    } else if (requestType.compareToIgnoreCase("changeLocation") == 0) {
      // changeCategory(reportForm, user, session, errors, request);
      return (mapping.findForward("localeChange"));
    } else if (requestType.compareToIgnoreCase("changeCategory") == 0) {
      // changeCategory(reportForm, user, session, errors, request);
      return (mapping.findForward("localeChange"));
    } else {

      // ArrayList <OptionsList> reports = new ArrayList<OptionsList>();
      // reports.add( new OptionsList( "0" ,"--Select--"));
      // request.setAttribute("reports",reports);
    }

    if (requestType.compareToIgnoreCase("print") == 0) {

      //			Timer smsTimer = new Timer("SMSThread", true);
      //			CompanyManagerBean cmBean = new CompanyManagerBean();
      //			CompanyDTO company = cmBean.getCompany(user.getCompanyID());
      //			smsTimer.schedule(new SMSGenerator(company,1), 0l);

      ReportSchedulingDTO reportScheduling = new ReportSchedulingDTO();
      setReportScheduling(reportForm, reportScheduling, errors, user);
      reportScheduling.setReportType(ReportSchedulingDTO.REPORT_TYPE_REALTIME);
      reportScheduling.setStatus("Q");
      ReportSchedulingDAO reportScheDAo = new ReportSchedulingDAO(user);
      try {
        reportScheDAo.addReportScheduling(reportScheduling);
      } catch (Exception e) {

      }

      String crystalFlag =
          UtilSingleton.getInstance()
              .getProperty(user.getConfigID(), "CrystalServer.useReportingService");

      if (crystalFlag != null && "true".equals(crystalFlag)) {
        CompanyManagerBean cmBean = new CompanyManagerBean();
        CompanyDTO company = cmBean.getCompany(user.getCompanyID());
        runNow(reportScheduling, company);
      }

      reportForm.setFromDate(FormatDate.getCurrentDateFormatedMMDDYYYY());
      reportForm.setToDate(FormatDate.getCurrentDateFormatedMMDDYYYY());
      reportForm.setUserLocaleId("0");
      reportForm.setUserLocationId("0");
      reportForm.setCategory("0");

    } else if (requestType.compareToIgnoreCase("schedule") == 0) {

      ReportSchedulingDTO reportScheduling = new ReportSchedulingDTO();
      setReportScheduling(reportForm, reportScheduling, errors, user);

      int repeatNumber = 0;
      try {
        repeatNumber = FormatNumber.parseInteger(reportForm.getRepeatNumber());
      } catch (Exception e) {
        //
      }
      String fromDate = getFromDate(reportForm, errors);
      java.util.Date fDate = FormatDate.convertToDateYYMMDD(fromDate);
      String toDate = getToDate(reportForm, errors);
      java.util.Date tDate = FormatDate.convertToDateYYMMDD(toDate);
      Date rDate = new Date();
      try {
        rDate = FormatDate.convertToDate(reportForm.getRunDate());
      } catch (Exception e) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.date.rundate"));
        formErrors.add("runDate");
      }

      ReportSchedulingDAO reportScheDAo = new ReportSchedulingDAO(user);

      if (repeatNumber > 0) { // do more than 1 time.

        boolean scheduleNow = true;
        Timer timer = new Timer(true);

        for (int i = 0; i < repeatNumber; i++) {
          try {
            //						ReportSchedulingDTO aSchedule = new ReportSchedulingDTO();
            //						copyObj(reportScheduling,aSchedule);
            reportScheDAo.addReportScheduling(reportScheduling);
            if (scheduleNow) {
              Calendar date = Calendar.getInstance();
              date.setTime((java.util.Date) reportScheduling.getRunDate());
              // date.add(Calendar.MINUTE, 5);
              // set runtime. (CDT)
              date.set(Calendar.HOUR_OF_DAY, reportScheduling.getRunTimeHH()); // 0-23

              date.set(Calendar.MINUTE, reportScheduling.getRunTimeMM());
              if (date.getTimeInMillis() <= System.currentTimeMillis()) {
                CompanyManagerBean cmBean = new CompanyManagerBean();
                CompanyDTO company = cmBean.getCompany(user.getCompanyID());
                runNow(reportScheduling, company);
              } else {
                scheduleNow = false;
              }
            }
            // setSchedule(timer, aSchedule, user);
            ReportSchedulingDTO aSchedule = new ReportSchedulingDTO();
            copyObj(reportScheduling, aSchedule);
            reportScheduling = aSchedule;
          } catch (Exception e) {

          }

          String strFDate = FormatDate.convertDateToMMDDYYYY(fDate);
          String strTDate = FormatDate.convertDateToMMDDYYYY(tDate);
          String strRDate = FormatDate.convertDateToMMDDYYYY(rDate);
          int field = -1;
          if (reportForm.getRepeatType().compareToIgnoreCase("D") == 0) {
            field = 1;

          } else if (reportForm.getRepeatType().compareToIgnoreCase("W") == 0) {
            field = 7;

          } else if (reportForm.getRepeatType().compareToIgnoreCase("M") == 0) {
            field = 0;
          }
          if (field > -1) {
            strRDate = FormatDate.addToDateMMDDYYYY(strRDate, field, (field == 0 ? 1 : 0));
            strFDate = FormatDate.addToDateMMDDYYYY(strFDate, field, (field == 0 ? 1 : 0));
            strTDate = FormatDate.addToDateMMDDYYYY(strTDate, field, (field == 0 ? 1 : 0));
            rDate = FormatDate.convertMMDDYYYYToDateYYMMDD(strRDate);
            fDate = FormatDate.convertMMDDYYYYToDateYYMMDD(strFDate);
            tDate = FormatDate.convertMMDDYYYYToDateYYMMDD(strTDate);
            reportScheduling.setRunDate(new java.sql.Date(rDate.getTime()));
            reportScheduling.setFromDate(new java.sql.Date(fDate.getTime()));
            reportScheduling.setToDate(new java.sql.Date(tDate.getTime()));
          }
        }
      } else { // do only one time
        try {
          reportScheDAo.addReportScheduling(reportScheduling);
          Calendar date = Calendar.getInstance();
          date.setTime((java.util.Date) reportScheduling.getRunDate());
          // date.add(Calendar.MINUTE, 5);
          // set runtime. (CDT)
          date.set(Calendar.HOUR_OF_DAY, reportScheduling.getRunTimeHH()); // 0-23

          date.set(Calendar.MINUTE, reportScheduling.getRunTimeMM());
          if (date.getTimeInMillis() <= System.currentTimeMillis()) {
            CompanyManagerBean cmBean = new CompanyManagerBean();
            CompanyDTO company = cmBean.getCompany(user.getCompanyID());
            runNow(reportScheduling, company);
          }
          // setSchedule( null, reportScheduling,  user);
        } catch (Exception e) {

        }
      }
    }
    // we comment it out because we don't want it to do the pupup but let the user look at the
    // printed report list.
    // reportForm.setReportURL(pageName);
    return (mapping.findForward("localeChange"));
  }
コード例 #8
0
  private void changeLocation(ReportForm form, DbUserSession sessionUser) {

    logger.debug("Updating userDefaultLocation : " + form.getUserLocationId());
    sessionUser.setLocationId(FormatNumber.parseInteger(form.getUserLocationId()));
  }
コード例 #9
0
  private void setReportScheduling(
      ReportForm reportForm,
      ReportSchedulingDTO reportScheduling,
      ActionMessages errors,
      DbUserSession user) {
    int formID = 0;
    try {
      formID = FormatNumber.parseInteger(reportForm.getSelectReport());
    } catch (Exception e) {
      //
    }

    // for only locale/location
    // Get selected location
    String location = null;
    try {
      location = reportForm.getUserLocationId();
    } catch (Exception e) {
      //
    }
    // Get selected location
    String locale = null;
    try {
      locale = reportForm.getUserLocaleId();
    } catch (Exception e) {
      //
    }

    // for this array version we don't need.
    //		String strLocale = null;
    //		String strLocation = null;
    //		if (Constants.GLOBAL_LOCALE_STRING.equals(reportForm.getType())) { // for all locales
    //			strLocale = "ALL";
    //			strLocation = "ALL";
    //
    //		} else if (Constants.GLOBAL_LOCATION_STRING.equals(reportForm.getType())) { // for specific
    // locales
    //			String[] localeIds = reportForm.getLocaleIds();
    //			strLocale = "[";
    //			for (int i = 0; i < localeIds.length; i++) {
    //				if (strLocale.length()> 1){
    //	        		strLocale += ",";
    //				}
    //	        	strLocale = strLocale+localeIds[i];
    //			}
    //			 strLocale = strLocale+"]";
    //			 strLocation = "ALL";
    //		}
    //		else { //for specific locations.
    //			strLocale="ALL";
    //			String[] locationIds = reportForm.getLocaleIds();
    //			strLocation="[";
    //			for (int i = 0; i < locationIds.length; i++) {
    //				if (strLocation.length()> 1){
    //					strLocation += ",";
    //				}
    //				strLocation = strLocation+locationIds[i];
    //			}
    //			strLocation = strLocation+"]";
    //		}
    // end for this version

    String repeatType = "N";
    int repeatNumber = 0;

    reportScheduling.setFormID(formID);
    reportScheduling.setUserId(user.getId());
    // for only one locale version
    reportScheduling.setLocale(locale);
    reportScheduling.setLocation(location);
    // end

    // for this locals/locations
    //		reportScheduling.setLocale(strLocale);
    //		reportScheduling.setLocation(strLocation);
    // end version

    String fromDate = getFromDate(reportForm, errors);
    java.util.Date fDate = FormatDate.convertToDateYYMMDD(fromDate);

    try {
      reportScheduling.setFromDate(new java.sql.Date(fDate.getTime()));
    } catch (Exception e) {
      errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.date.fromdate"));
      formErrors.add("fromDate");
    }

    String toDate = getToDate(reportForm, errors);
    java.util.Date tDate = FormatDate.convertToDateYYMMDD(toDate);
    try {
      reportScheduling.setToDate(new java.sql.Date(tDate.getTime()));
    } catch (Exception e) {
      errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.date.todate"));
      formErrors.add("toDate");
    }

    Date rDate = new Date();

    try {
      reportScheduling.setRunDate(new java.sql.Date(rDate.getTime()));
    } catch (Exception e) {
      errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.date.todate"));
      formErrors.add("toDate");
    }

    int runHH = reportForm.getHH();
    reportScheduling.setRunTimeHH(runHH);
    int runMM = reportForm.getMM();
    reportScheduling.setRunTimeMM(runMM);

    reportScheduling.setRepeatType(repeatType);
    reportScheduling.setRepeatNumber(repeatNumber);
    long createdTimestamp = System.currentTimeMillis();
    reportScheduling.setDatetime(createdTimestamp);

    String emailTo = "";
    reportScheduling.setEmailTo(emailTo);
    String emailCC = "";
    reportScheduling.setEmailCC(emailCC);

    reportScheduling.setStatus("");
    reportScheduling.setReportName("");

    String requestType = reportForm.getRequestType();
    if (requestType == null) {
      requestType = "";
    }
    if (requestType.compareToIgnoreCase("schedule") == 0) {
      repeatType = reportForm.getRepeatType();
      repeatNumber = 0;
      try {
        repeatNumber = FormatNumber.parseInteger(reportForm.getRepeatNumber());
      } catch (Exception e) {
        //
      }
      reportScheduling.setRepeatType(repeatType);

      try {
        rDate = FormatDate.convertToDate(reportForm.getRunDate());
      } catch (Exception e) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.date.rundate"));
        formErrors.add("runDate");
      }

      try {
        reportScheduling.setRunDate(new java.sql.Date(rDate.getTime()));
      } catch (Exception e) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.date.runDate"));
        formErrors.add("runDate");
      }

      reportScheduling.setRepeatType(repeatType);
      reportScheduling.setRepeatNumber(repeatNumber);
      createdTimestamp = System.currentTimeMillis();
      reportScheduling.setDatetime(createdTimestamp);
      reportScheduling.setReportName("");
      emailTo = "";
      emailTo = reportForm.getRecipientsTo().replace(':', ';');
      emailTo = emailTo.replace(' ', ';');
      emailTo = emailTo.replace(',', ';');
      reportScheduling.setEmailTo(emailTo);
      emailCC = "";
      emailCC = reportForm.getRecipientsCC().replace(':', ';');
      emailCC = emailCC.replace(' ', ';');
      emailCC = emailCC.replace(',', ';');
      reportScheduling.setEmailCC(emailCC);
      reportScheduling.setStatus("Q");
      reportScheduling.setReportType(ReportSchedulingDTO.REPORT_TYPE_SCHEDULING);
    }
  }