public LocaleManagerBean(DbUserSession user) {
   super();
   this.companyID = (int) user.getCompanyID();
   this.userID = (int) user.getId();
   this.dbLookup = user.getDbLookup();
 }
  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);
    }
  }