Related to issue 19778.Rename to OBDateUtils and OBMessageUtils.
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Wed, 29 Feb 2012 12:28:09 +0100
changeset 15660 f84f857e2e54
parent 15659 703d879e5801
child 15661 edd121f3d210
Related to issue 19778.Rename to OBDateUtils and OBMessageUtils.
src/org/openbravo/erpCommon/utility/DateUtility.java
src/org/openbravo/erpCommon/utility/MessageUtility.java
src/org/openbravo/erpCommon/utility/OBDateUtils.java
src/org/openbravo/erpCommon/utility/OBMessageUtils.java
src/org/openbravo/erpCommon/utility/Utility.java
--- a/src/org/openbravo/erpCommon/utility/DateUtility.java	Wed Feb 15 16:58:06 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,226 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2012 Openbravo SLU
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-package org.openbravo.erpCommon.utility;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-import org.apache.commons.lang.time.DateUtils;
-import org.openbravo.base.secureApp.VariablesSecureApp;
-import org.openbravo.base.session.OBPropertiesProvider;
-
-/**
- * Date utilities to manage dates.
- */
-public class DateUtility {
-
-  /**
-   * Returns an String with the date in the <i>dateFormat.java</i> format defined in
-   * Openbravo.properties
-   * 
-   * @see DateUtility#formatDate(Date, String)
-   * 
-   * @param date
-   *          Date to be formatted.
-   * @param pattern
-   *          Format expected for the output.
-   * @return String formatted.
-   */
-  public static String formatDate(Date date) {
-    final String pattern = OBPropertiesProvider.getInstance().getOpenbravoProperties()
-        .getProperty("dateFormat.java");
-    final SimpleDateFormat dateFormatter = new SimpleDateFormat(pattern);
-    return dateFormatter.format(date);
-  }
-
-  /**
-   * Returns an String with the date in the specified format
-   * 
-   * @param date
-   *          Date to be formatted.
-   * @param pattern
-   *          Format expected for the output.
-   * @return String formatted.
-   */
-  public static String formatDate(Date date, String pattern) {
-    final SimpleDateFormat dateFormatter = new SimpleDateFormat(pattern);
-    return dateFormatter.format(date);
-  }
-
-  /**
-   * Parses the string to a date using the dateFormat.java property.
-   * 
-   * @param strDate
-   *          String containing the date
-   * @return the date
-   * @throws ParseException
-   */
-  public static Date getDate(String strDate) throws ParseException {
-    if (strDate.equals("")) {
-      return null;
-    }
-    String dateFormat = OBPropertiesProvider.getInstance().getOpenbravoProperties()
-        .getProperty("dateFormat.java");
-    SimpleDateFormat outputFormat = new SimpleDateFormat(dateFormat);
-    return outputFormat.parse(strDate);
-  }
-
-  /**
-   * Parses the string to a date with time using the dateTimeFormat defined in Openbravo.properties.
-   * If the string parameter does not have time include it will add the current hours, minutes and
-   * seconds.
-   * 
-   * @param strDate
-   *          String date.
-   * @return the date with time.
-   * @throws ParseException
-   */
-  public static Date getDateTime(String strDate) throws ParseException {
-    String dateTime = strDate;
-    Calendar cal = Calendar.getInstance();
-    if ("".equals(strDate) || strDate == null) {
-      return null;
-    }
-    if (!strDate.contains(":")) {
-      dateTime = strDate + " " + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE)
-          + ":" + cal.get(Calendar.SECOND);
-    }
-    String dateFormat = OBPropertiesProvider.getInstance().getOpenbravoProperties()
-        .getProperty("dateTimeFormat.java");
-    SimpleDateFormat outputFormat = new SimpleDateFormat(dateFormat);
-    return outputFormat.parse(dateTime);
-  }
-
-  /**
-   * Determines the labor days between two dates
-   * 
-   * @param strDate1
-   *          Date 1.
-   * @param strDate2
-   *          Date 2.
-   * @param dateFormatter
-   *          Format of the dates.
-   * @return strLaborDays as the number of days between strDate1 and strDate2.
-   */
-  public static String calculateLaborDays(String _strDate1, String _strDate2,
-      DateFormat dateFormatter) throws ParseException {
-    String strLaborDays = "";
-    String strDate1 = _strDate1;
-    String strDate2 = _strDate2;
-    if (strDate1 != null && !strDate1.equals("") && strDate2 != null && !strDate2.equals("")) {
-      Integer laborDays = 0;
-      if (isBiggerDate(strDate1, strDate2, dateFormatter)) {
-        do {
-          // Adds a day to the Date 2 until it reaches the Date 1
-          strDate2 = addDaysToDate(strDate2, 1, dateFormatter);
-          if (!isWeekendDay(strDate2, dateFormatter)) {
-            // If it is not a weekend day, it adds a day to the labor days
-            laborDays++;
-          }
-        } while (!strDate2.equals(strDate1));
-      } else {
-        do {
-          // Adds a day to the Date 1 until it reaches the Date 2
-          strDate1 = addDaysToDate(strDate1, 1, dateFormatter);
-          if (!isWeekendDay(strDate1, dateFormatter)) {
-            // If it is not a weekend day, it adds a day to the labor days
-            laborDays++;
-          }
-        } while (!strDate1.equals(strDate2));
-      }
-      strLaborDays = laborDays.toString();
-    }
-    return strLaborDays;
-  }
-
-  /**
-   * Adds an integer number of days to a given date
-   * 
-   * @param strDate
-   *          Start date.
-   * @param days
-   *          Number of days to add.
-   * @param dateFormatter
-   *          Format of the date.
-   * @return strFinalDate as the sum of strDate plus strDays.
-   * @throws ParseException
-   */
-  public static String addDaysToDate(String strDate, int days, DateFormat dateFormatter)
-      throws ParseException {
-    if (strDate == null || "".equals(strDate)) {
-      return "";
-    }
-    Date date = dateFormatter.parse(strDate);
-    Date finalDate = DateUtils.addDays(date, days);
-    return dateFormatter.format(finalDate);
-  }
-
-  /**
-   * Determines the format of the date
-   * 
-   * @param vars
-   *          Global variables.
-   * @return DateFormatter as the format of the date.
-   */
-  public static DateFormat getDateFormatter(VariablesSecureApp vars) {
-    String strFormat = vars.getJavaDateFormat();
-    final DateFormat DateFormatter = new SimpleDateFormat(strFormat);
-    return DateFormatter;
-  }
-
-  /**
-   * Determines if a day is a day of the weekend, i.e., Saturday or Sunday
-   * 
-   * @param strDay
-   *          Given Date.
-   * @param dateFormatter
-   *          Format of the date.
-   * @return true if the date is a Sunday or a Saturday.
-   */
-  public static boolean isWeekendDay(String strDay, DateFormat dateFormatter) throws ParseException {
-    final Calendar Day = Calendar.getInstance();
-    Day.setTime(dateFormatter.parse(strDay));
-    final int weekday = Day.get(Calendar.DAY_OF_WEEK);
-    // Gets the number of the day of the week: 1-Sunday, 2-Monday, 3-Tuesday, 4-Wednesday,
-    // 5-Thursday, 6-Friday, 7-Saturday
-    return weekday == 1 || weekday == 7;
-  }
-
-  /**
-   * Determines if a date 1 is bigger than a date 2
-   * 
-   * @param strDate1
-   *          Date 1.
-   * @param strDate2
-   *          Date 2.
-   * @param dateFormatter
-   *          Format of the dates.
-   * @return true if strDate1 is bigger than strDate2.
-   */
-  public static boolean isBiggerDate(String strDate1, String strDate2, DateFormat dateFormatter)
-      throws ParseException {
-    final Date date1 = dateFormatter.parse(strDate1);
-    final Date date2 = dateFormatter.parse(strDate2);
-    return date1.after(date2);
-  }
-
-}
--- a/src/org/openbravo/erpCommon/utility/MessageUtility.java	Wed Feb 15 16:58:06 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,456 +0,0 @@
-/*
- *************************************************************************
- * The contents of this file are subject to the Openbravo  Public  License
- * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
- * Version 1.1  with a permitted attribution clause; you may not  use this
- * file except in compliance with the License. You  may  obtain  a copy of
- * the License at http://www.openbravo.com/legal/license.html 
- * Software distributed under the License  is  distributed  on  an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific  language  governing  rights  and  limitations
- * under the License. 
- * The Original Code is Openbravo ERP. 
- * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2012 Openbravo SLU
- * All Rights Reserved. 
- * Contributor(s):  ______________________________________.
- ************************************************************************
- */
-package org.openbravo.erpCommon.utility;
-
-import java.util.Map;
-
-import javax.servlet.ServletException;
-
-import org.apache.log4j.Logger;
-import org.hibernate.criterion.Restrictions;
-import org.openbravo.base.secureApp.VariablesSecureApp;
-import org.openbravo.client.kernel.RequestContext;
-import org.openbravo.dal.core.OBContext;
-import org.openbravo.dal.service.OBCriteria;
-import org.openbravo.dal.service.OBDal;
-import org.openbravo.data.FieldProvider;
-import org.openbravo.database.ConnectionProvider;
-import org.openbravo.model.ad.process.ProcessInstance;
-import org.openbravo.model.ad.ui.Element;
-import org.openbravo.model.ad.ui.ElementTrl;
-import org.openbravo.model.ad.ui.Message;
-import org.openbravo.model.ad.ui.MessageTrl;
-import org.openbravo.service.db.DalConnectionProvider;
-import org.openbravo.utils.Replace;
-
-public class MessageUtility {
-  static Logger log4j = Logger.getLogger(MessageUtility.class);
-
-  /**
-   * Translate the given code into some message from the application dictionary. It searches first
-   * in AD_Message table and if there are not matchings then in AD_Element table.
-   * 
-   * @param strCode
-   *          String with the search key to search.
-   * @return String with the translated message.
-   */
-  public static String messageBD(String strCode) {
-    String strMessage = "";
-    final String strLanguage = OBContext.getOBContext().getLanguage().getLanguage();
-
-    // Search strCode in AD_Message table.
-    try {
-      OBContext.setAdminMode(false);
-      log4j.debug("messageBD - Message Code: " + strCode);
-      OBCriteria<Message> obcMessage = OBDal.getInstance().createCriteria(Message.class);
-      obcMessage.add(Restrictions.eq(Message.PROPERTY_SEARCHKEY, strCode).ignoreCase());
-      if (obcMessage.count() > 0) {
-        Message msg = obcMessage.list().get(0);
-        strMessage = msg.getMessageText();
-        for (MessageTrl msgTrl : msg.getADMessageTrlList()) {
-          if (msgTrl.getLanguage().getLanguage().equals(strLanguage)) {
-            strMessage = msgTrl.getMessageText();
-            break;
-          }
-        }
-      }
-    } catch (final Exception ignore) {
-      log4j.error("Error getting message", ignore);
-    } finally {
-      OBContext.restorePreviousMode();
-    }
-    log4j.debug("messageBD - Message description: " + strMessage);
-    // if message is still empty search in AD_Element
-    if ("".equals(strMessage)) {
-      try {
-        OBContext.setAdminMode(false);
-        OBCriteria<Element> obcElement = OBDal.getInstance().createCriteria(Element.class);
-        obcElement.add(Restrictions.eq(Element.PROPERTY_DBCOLUMNNAME, strCode).ignoreCase());
-        if (obcElement.count() > 0) {
-          Element element = obcElement.list().get(0);
-          strMessage = element.getName();
-          for (ElementTrl elementTrl : element.getADElementTrlList()) {
-            if (elementTrl.getLanguage().getLanguage().equals(strLanguage)) {
-              strMessage = elementTrl.getName();
-            }
-          }
-        }
-      } catch (final Exception e) {
-        log4j.error("Error getting message", e);
-        strMessage = strCode;
-      } finally {
-        OBContext.restorePreviousMode();
-      }
-    }
-    if ("".equals(strMessage)) {
-      strMessage = strCode;
-    }
-    strMessage = Replace.replace(Replace.replace(strMessage, "\n", "\\n"), "\"", "&quot;");
-    return strMessage;
-  }
-
-  /**
-   * @see MessageUtility#messageBD(ConnectionProvider, String, String, boolean)
-   */
-  public static String messageBD(ConnectionProvider conn, String strCode, String strLanguage) {
-    return BasicUtility.messageBD(conn, strCode, strLanguage, true);
-  }
-
-  /**
-   * Translate the given code into some message from the application dictionary.
-   * 
-   * @param conn
-   *          Handler for the database connection.
-   * @param strCode
-   *          String with the code to search.
-   * @param strLanguage
-   *          String with the translation language.
-   * @param escape
-   *          Escape \n and " characters
-   * @return String with the translated message.
-   */
-  public static String messageBD(ConnectionProvider conn, String strCode, String strLanguage,
-      boolean escape) {
-    return BasicUtility.messageBD(conn, strCode, strLanguage, escape);
-  }
-
-  /**
-   * 
-   * Formats a message String into a String for html presentation. Escapes the &, <, >, " and ®, and
-   * replace the \n by <br/>
-   * and \r for space.
-   * 
-   * IMPORTANT! : this method is designed to transform the output of Utility.messageBD method, and
-   * this method replaces \n by \\n and \" by &quote. Because of that, the first replacements revert
-   * this previous replacements.
-   * 
-   * @param message
-   *          message with java formating
-   * @return html format message
-   */
-  public static String formatMessageBDToHtml(String message) {
-    return BasicUtility.formatMessageBDToHtml(message);
-  }
-
-  /**
-   * Parse the text searching @ parameters to translate.
-   * 
-   * @param text
-   *          String with the text to translate.
-   * @return String translated.
-   */
-  public static String parseTranslation(String text) {
-    final VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
-    final String language = OBContext.getOBContext().getLanguage().getLanguage();
-    return parseTranslation(new DalConnectionProvider(false), vars, null, language, text);
-  }
-
-  /**
-   * Parse the text searching @ parameters to translate.
-   * 
-   * @param conn
-   *          Handler for the database connection.
-   * @param vars
-   *          Handler for the session info.
-   * @param language
-   *          String with the language to translate.
-   * @param text
-   *          String with the text to translate.
-   * @return String translated.
-   */
-  public static String parseTranslation(ConnectionProvider conn, VariablesSecureApp vars,
-      String language, String text) {
-    return parseTranslation(conn, vars, null, language, text);
-  }
-
-  /**
-   * Parse the text searching @ parameters to translate. If replaceMap is not null and contains a
-   * replacement value for a token then it will be used, otherwise the return value of the translate
-   * method will be used for the translation.
-   * 
-   * @param conn
-   *          Handler for the database connection.
-   * @param vars
-   *          Handler for the session info.
-   * @param replaceMap
-   *          optional Map containing replacement values for the tokens
-   * @param language
-   *          String with the language to translate.
-   * @param text
-   *          String with the text to translate.
-   * @return String translated.
-   */
-  public static String parseTranslation(ConnectionProvider conn, VariablesSecureApp vars,
-      Map<String, String> replaceMap, String language, String text) {
-    if (text == null || text.length() == 0) {
-      return text;
-    }
-
-    String inStr = text;
-    String token;
-    final StringBuffer outStr = new StringBuffer();
-
-    int i = inStr.indexOf("@");
-    while (i != -1) {
-      outStr.append(inStr.substring(0, i));
-      inStr = inStr.substring(i + 1, inStr.length());
-
-      final int j = inStr.indexOf("@");
-      if (j < 0) {
-        inStr = "@" + inStr;
-        break;
-      }
-
-      token = inStr.substring(0, j);
-      if (replaceMap != null && replaceMap.containsKey(token)) {
-        outStr.append(replaceMap.get(token));
-      } else {
-        outStr.append(translate(conn, vars, token, language));
-      }
-
-      inStr = inStr.substring(j + 1, inStr.length());
-      i = inStr.indexOf("@");
-    }
-
-    outStr.append(inStr);
-    return outStr.toString();
-  }
-
-  /**
-   * For each token found in the parseTranslation method, this method is called to find the correct
-   * translation.
-   * 
-   * @param conn
-   *          Handler for the database connection.
-   * @param vars
-   *          Handler for the session info.
-   * @param token
-   *          String with the token to translate.
-   * @param language
-   *          String with the language to translate.
-   * @return String with the token translated.
-   */
-  public static String translate(ConnectionProvider conn, VariablesSecureApp vars, String token,
-      String language) {
-    String strTranslate = vars.getSessionValue(token);
-    if (!strTranslate.equals("")) {
-      return strTranslate;
-    }
-    strTranslate = messageBD(conn, token, language);
-    if (strTranslate.equals("")) {
-      return token;
-    }
-    return strTranslate;
-  }
-
-  /**
-   * Gets the Message for the instance of the processes.
-   * 
-   * @param pInstance
-   *          ProcessInstance object
-   * @return Object with the message.
-   * @throws ServletException
-   */
-  public static OBError getProcessInstanceMessage(ProcessInstance pInstance) {
-    OBError myMessage = new OBError();
-    String message = pInstance.getErrorMsg();
-    String title = "";
-    String type = "";
-    if (pInstance.getResult() == 1L) {
-      type = "Success";
-      title = messageBD("Success");
-    } else if (pInstance.getResult() == 0L) {
-      type = "Error";
-      title = messageBD("Error");
-    } else {
-      type = "Warning";
-      title = messageBD("Warning");
-    }
-
-    final int errorPos = message.indexOf("@ERROR=");
-    if (errorPos != -1) {
-      myMessage = translateError("@CODE=@" + message.substring(errorPos + 7));
-      log4j.debug("Error Message returned: " + myMessage.getMessage());
-      if (message.substring(errorPos + 7).equals(myMessage.getMessage())) {
-        myMessage.setMessage(parseTranslation(myMessage.getMessage()));
-      }
-      if (errorPos > 0) {
-        message = message.substring(0, errorPos);
-      } else {
-        message = "";
-      }
-    }
-    if (!message.equals("") && message.indexOf("@") != -1) {
-      message = parseTranslation(message);
-    }
-    myMessage.setType(type);
-    myMessage.setTitle(title);
-    myMessage.setMessage(message + ((!message.equals("") && errorPos != -1) ? " <br> " : "")
-        + myMessage.getMessage());
-
-    return myMessage;
-  }
-
-  /**
-   * Translate the message, searching the @ parameters, and making use of the ErrorTextParser class
-   * to get the appropriated message.
-   * 
-   * @param message
-   *          String with the message to translate.
-   * @return
-   */
-  public static OBError translateError(String message) {
-    VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
-    final String strLanguage = OBContext.getOBContext().getLanguage().getLanguage();
-    return translateError(new DalConnectionProvider(false), vars, strLanguage, message);
-  }
-
-  /**
-   * Translate the message, searching the @ parameters, and making use of the ErrorTextParser class
-   * to get the appropriated message.
-   * 
-   * @param conn
-   *          Handler for the database connection.
-   * @param vars
-   *          Handler for the session info.
-   * @param strLanguage
-   *          Language to translate.
-   * @param message
-   *          String with the message to translate.
-   * @return Object with the message.
-   */
-  public static OBError translateError(ConnectionProvider conn, VariablesSecureApp vars,
-      String strLanguage, String _message) {
-    String message = _message;
-    final OBError myError = new OBError();
-    myError.setType("Error");
-    myError.setMessage(message);
-    if (message == null || message.equals("")) {
-      return myError;
-    }
-    String code = "";
-    log4j.debug("translateError - message: " + message);
-    if (message.startsWith("@CODE=@")) {
-      message = message.substring(7);
-    } else if (message.startsWith("@CODE=")) {
-      message = message.substring(6);
-      final int pos = message.indexOf("@");
-      if (pos == -1) {
-        code = message;
-        message = "";
-      } else {
-        code = message.substring(0, pos);
-        message = message.substring(pos + 1);
-      }
-    }
-    myError.setMessage(message);
-    log4j.debug("translateError - code: " + code + " - message: " + message);
-
-    // BEGIN Checking if is a pool problem
-    if (code != null && code.equals("NoConnectionAvailable")) {
-      myError.setType("Error");
-      myError.setTitle("Critical Error");
-      myError.setConnectionAvailable(false);
-      myError.setMessage("No database connection available");
-      return myError;
-    }
-    // END Checking if is a pool problem
-
-    // BEGIN Parsing message text
-    if (message != null && !message.equals("")) {
-      final String rdbms = conn.getRDBMS();
-      ErrorTextParser myParser = null;
-      try {
-        final Class<?> c = Class.forName("org.openbravo.erpCommon.utility.ErrorTextParser"
-            + rdbms.toUpperCase());
-        myParser = (ErrorTextParser) c.newInstance();
-      } catch (final ClassNotFoundException ex) {
-        log4j.warn("Couldn´t find class: org.openbravo.erpCommon.utility.ErrorTextParser"
-            + rdbms.toUpperCase());
-        myParser = null;
-      } catch (final Exception ex1) {
-        log4j.warn("Couldn´t initialize class: org.openbravo.erpCommon.utility.ErrorTextParser"
-            + rdbms.toUpperCase());
-        myParser = null;
-      }
-      if (myParser != null) {
-        myParser.setConnection(conn);
-        myParser.setLanguage(strLanguage);
-        myParser.setMessage(message);
-        myParser.setVars(vars);
-        try {
-          final OBError myErrorAux = myParser.parse();
-          if (myErrorAux != null
-              && !myErrorAux.getMessage().equals("")
-              && (code == null || code.equals("") || code.equals("0") || !myErrorAux.getMessage()
-                  .equalsIgnoreCase(message)))
-            return myErrorAux;
-        } catch (final Exception ex) {
-          log4j.error("Error while parsing text: " + ex);
-        }
-      }
-    } else {
-      myError.setMessage(code);
-    }
-    // END Parsing message text
-
-    // BEGIN Looking for error code in AD_Message
-    if (code != null && !code.equals("")) {
-      final FieldProvider fldMessage = locateMessage(conn, code, strLanguage);
-      if (fldMessage != null) {
-        myError.setType((fldMessage.getField("msgtype").equals("E") ? "Error" : (fldMessage
-            .getField("msgtype").equals("I") ? "Info"
-            : (fldMessage.getField("msgtype").equals("S") ? "Success" : "Warning"))));
-        myError.setMessage(fldMessage.getField("msgtext"));
-        return myError;
-      }
-    }
-    // END Looking for error code in AD_Message
-
-    return myError;
-  }
-
-  /**
-   * Search a message in the database.
-   * 
-   * @param conn
-   *          Handler for the database connection.
-   * @param strCode
-   *          Message to search.
-   * @param strLanguage
-   *          Language to translate.
-   * @return FieldProvider with the message info.
-   */
-  public static FieldProvider locateMessage(ConnectionProvider conn, String strCode,
-      String strLanguage) {
-    FieldProvider[] fldMessage = null;
-
-    try {
-      log4j.debug("locateMessage - Message Code: " + strCode);
-      fldMessage = MessageBDData.messageInfo(conn, strLanguage, strCode);
-    } catch (final Exception ignore) {
-    }
-    if (fldMessage != null && fldMessage.length > 0) {
-      return fldMessage[0];
-    } else {
-      return null;
-    }
-  }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/utility/OBDateUtils.java	Wed Feb 29 12:28:09 2012 +0100
@@ -0,0 +1,226 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2012 Openbravo SLU
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.erpCommon.utility;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.commons.lang.time.DateUtils;
+import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.base.session.OBPropertiesProvider;
+
+/**
+ * Utilities to manage dates.
+ */
+public class OBDateUtils {
+
+  /**
+   * Returns an String with the date in the <i>dateFormat.java</i> format defined in
+   * Openbravo.properties
+   * 
+   * @see OBDateUtils#formatDate(Date, String)
+   * 
+   * @param date
+   *          Date to be formatted.
+   * @param pattern
+   *          Format expected for the output.
+   * @return String formatted.
+   */
+  public static String formatDate(Date date) {
+    final String pattern = OBPropertiesProvider.getInstance().getOpenbravoProperties()
+        .getProperty("dateFormat.java");
+    final SimpleDateFormat dateFormatter = new SimpleDateFormat(pattern);
+    return dateFormatter.format(date);
+  }
+
+  /**
+   * Returns an String with the date in the specified format
+   * 
+   * @param date
+   *          Date to be formatted.
+   * @param pattern
+   *          Format expected for the output.
+   * @return String formatted.
+   */
+  public static String formatDate(Date date, String pattern) {
+    final SimpleDateFormat dateFormatter = new SimpleDateFormat(pattern);
+    return dateFormatter.format(date);
+  }
+
+  /**
+   * Parses the string to a date using the dateFormat.java property.
+   * 
+   * @param strDate
+   *          String containing the date
+   * @return the date
+   * @throws ParseException
+   */
+  public static Date getDate(String strDate) throws ParseException {
+    if (strDate.equals("")) {
+      return null;
+    }
+    String dateFormat = OBPropertiesProvider.getInstance().getOpenbravoProperties()
+        .getProperty("dateFormat.java");
+    SimpleDateFormat outputFormat = new SimpleDateFormat(dateFormat);
+    return outputFormat.parse(strDate);
+  }
+
+  /**
+   * Parses the string to a date with time using the dateTimeFormat defined in Openbravo.properties.
+   * If the string parameter does not have time include it will add the current hours, minutes and
+   * seconds.
+   * 
+   * @param strDate
+   *          String date.
+   * @return the date with time.
+   * @throws ParseException
+   */
+  public static Date getDateTime(String strDate) throws ParseException {
+    String dateTime = strDate;
+    Calendar cal = Calendar.getInstance();
+    if ("".equals(strDate) || strDate == null) {
+      return null;
+    }
+    if (!strDate.contains(":")) {
+      dateTime = strDate + " " + cal.get(Calendar.HOUR_OF_DAY) + ":" + cal.get(Calendar.MINUTE)
+          + ":" + cal.get(Calendar.SECOND);
+    }
+    String dateFormat = OBPropertiesProvider.getInstance().getOpenbravoProperties()
+        .getProperty("dateTimeFormat.java");
+    SimpleDateFormat outputFormat = new SimpleDateFormat(dateFormat);
+    return outputFormat.parse(dateTime);
+  }
+
+  /**
+   * Determines the labor days between two dates
+   * 
+   * @param strDate1
+   *          Date 1.
+   * @param strDate2
+   *          Date 2.
+   * @param dateFormatter
+   *          Format of the dates.
+   * @return strLaborDays as the number of days between strDate1 and strDate2.
+   */
+  public static String calculateLaborDays(String _strDate1, String _strDate2,
+      DateFormat dateFormatter) throws ParseException {
+    String strLaborDays = "";
+    String strDate1 = _strDate1;
+    String strDate2 = _strDate2;
+    if (strDate1 != null && !strDate1.equals("") && strDate2 != null && !strDate2.equals("")) {
+      Integer laborDays = 0;
+      if (isBiggerDate(strDate1, strDate2, dateFormatter)) {
+        do {
+          // Adds a day to the Date 2 until it reaches the Date 1
+          strDate2 = addDaysToDate(strDate2, 1, dateFormatter);
+          if (!isWeekendDay(strDate2, dateFormatter)) {
+            // If it is not a weekend day, it adds a day to the labor days
+            laborDays++;
+          }
+        } while (!strDate2.equals(strDate1));
+      } else {
+        do {
+          // Adds a day to the Date 1 until it reaches the Date 2
+          strDate1 = addDaysToDate(strDate1, 1, dateFormatter);
+          if (!isWeekendDay(strDate1, dateFormatter)) {
+            // If it is not a weekend day, it adds a day to the labor days
+            laborDays++;
+          }
+        } while (!strDate1.equals(strDate2));
+      }
+      strLaborDays = laborDays.toString();
+    }
+    return strLaborDays;
+  }
+
+  /**
+   * Adds an integer number of days to a given date
+   * 
+   * @param strDate
+   *          Start date.
+   * @param days
+   *          Number of days to add.
+   * @param dateFormatter
+   *          Format of the date.
+   * @return strFinalDate as the sum of strDate plus strDays.
+   * @throws ParseException
+   */
+  public static String addDaysToDate(String strDate, int days, DateFormat dateFormatter)
+      throws ParseException {
+    if (strDate == null || "".equals(strDate)) {
+      return "";
+    }
+    Date date = dateFormatter.parse(strDate);
+    Date finalDate = DateUtils.addDays(date, days);
+    return dateFormatter.format(finalDate);
+  }
+
+  /**
+   * Determines the format of the date
+   * 
+   * @param vars
+   *          Global variables.
+   * @return DateFormatter as the format of the date.
+   */
+  public static DateFormat getDateFormatter(VariablesSecureApp vars) {
+    String strFormat = vars.getJavaDateFormat();
+    final DateFormat DateFormatter = new SimpleDateFormat(strFormat);
+    return DateFormatter;
+  }
+
+  /**
+   * Determines if a day is a day of the weekend, i.e., Saturday or Sunday
+   * 
+   * @param strDay
+   *          Given Date.
+   * @param dateFormatter
+   *          Format of the date.
+   * @return true if the date is a Sunday or a Saturday.
+   */
+  public static boolean isWeekendDay(String strDay, DateFormat dateFormatter) throws ParseException {
+    final Calendar Day = Calendar.getInstance();
+    Day.setTime(dateFormatter.parse(strDay));
+    final int weekday = Day.get(Calendar.DAY_OF_WEEK);
+    // Gets the number of the day of the week: 1-Sunday, 2-Monday, 3-Tuesday, 4-Wednesday,
+    // 5-Thursday, 6-Friday, 7-Saturday
+    return weekday == 1 || weekday == 7;
+  }
+
+  /**
+   * Determines if a date 1 is bigger than a date 2
+   * 
+   * @param strDate1
+   *          Date 1.
+   * @param strDate2
+   *          Date 2.
+   * @param dateFormatter
+   *          Format of the dates.
+   * @return true if strDate1 is bigger than strDate2.
+   */
+  public static boolean isBiggerDate(String strDate1, String strDate2, DateFormat dateFormatter)
+      throws ParseException {
+    final Date date1 = dateFormatter.parse(strDate1);
+    final Date date2 = dateFormatter.parse(strDate2);
+    return date1.after(date2);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/utility/OBMessageUtils.java	Wed Feb 29 12:28:09 2012 +0100
@@ -0,0 +1,456 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2012 Openbravo SLU
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.erpCommon.utility;
+
+import java.util.Map;
+
+import javax.servlet.ServletException;
+
+import org.apache.log4j.Logger;
+import org.hibernate.criterion.Restrictions;
+import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.client.kernel.RequestContext;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.data.FieldProvider;
+import org.openbravo.database.ConnectionProvider;
+import org.openbravo.model.ad.process.ProcessInstance;
+import org.openbravo.model.ad.ui.Element;
+import org.openbravo.model.ad.ui.ElementTrl;
+import org.openbravo.model.ad.ui.Message;
+import org.openbravo.model.ad.ui.MessageTrl;
+import org.openbravo.service.db.DalConnectionProvider;
+import org.openbravo.utils.Replace;
+
+public class OBMessageUtils {
+  static Logger log4j = Logger.getLogger(OBMessageUtils.class);
+
+  /**
+   * Translate the given code into some message from the application dictionary. It searches first
+   * in AD_Message table and if there are not matchings then in AD_Element table.
+   * 
+   * @param strCode
+   *          String with the search key to search.
+   * @return String with the translated message.
+   */
+  public static String messageBD(String strCode) {
+    String strMessage = "";
+    final String strLanguage = OBContext.getOBContext().getLanguage().getLanguage();
+
+    // Search strCode in AD_Message table.
+    try {
+      OBContext.setAdminMode(false);
+      log4j.debug("messageBD - Message Code: " + strCode);
+      OBCriteria<Message> obcMessage = OBDal.getInstance().createCriteria(Message.class);
+      obcMessage.add(Restrictions.eq(Message.PROPERTY_SEARCHKEY, strCode).ignoreCase());
+      if (obcMessage.count() > 0) {
+        Message msg = obcMessage.list().get(0);
+        strMessage = msg.getMessageText();
+        for (MessageTrl msgTrl : msg.getADMessageTrlList()) {
+          if (msgTrl.getLanguage().getLanguage().equals(strLanguage)) {
+            strMessage = msgTrl.getMessageText();
+            break;
+          }
+        }
+      }
+    } catch (final Exception ignore) {
+      log4j.error("Error getting message", ignore);
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+    log4j.debug("messageBD - Message description: " + strMessage);
+    // if message is still empty search in AD_Element
+    if ("".equals(strMessage)) {
+      try {
+        OBContext.setAdminMode(false);
+        OBCriteria<Element> obcElement = OBDal.getInstance().createCriteria(Element.class);
+        obcElement.add(Restrictions.eq(Element.PROPERTY_DBCOLUMNNAME, strCode).ignoreCase());
+        if (obcElement.count() > 0) {
+          Element element = obcElement.list().get(0);
+          strMessage = element.getName();
+          for (ElementTrl elementTrl : element.getADElementTrlList()) {
+            if (elementTrl.getLanguage().getLanguage().equals(strLanguage)) {
+              strMessage = elementTrl.getName();
+            }
+          }
+        }
+      } catch (final Exception e) {
+        log4j.error("Error getting message", e);
+        strMessage = strCode;
+      } finally {
+        OBContext.restorePreviousMode();
+      }
+    }
+    if ("".equals(strMessage)) {
+      strMessage = strCode;
+    }
+    strMessage = Replace.replace(Replace.replace(strMessage, "\n", "\\n"), "\"", "&quot;");
+    return strMessage;
+  }
+
+  /**
+   * @see OBMessageUtils#messageBD(ConnectionProvider, String, String, boolean)
+   */
+  public static String messageBD(ConnectionProvider conn, String strCode, String strLanguage) {
+    return BasicUtility.messageBD(conn, strCode, strLanguage, true);
+  }
+
+  /**
+   * Translate the given code into some message from the application dictionary.
+   * 
+   * @param conn
+   *          Handler for the database connection.
+   * @param strCode
+   *          String with the code to search.
+   * @param strLanguage
+   *          String with the translation language.
+   * @param escape
+   *          Escape \n and " characters
+   * @return String with the translated message.
+   */
+  public static String messageBD(ConnectionProvider conn, String strCode, String strLanguage,
+      boolean escape) {
+    return BasicUtility.messageBD(conn, strCode, strLanguage, escape);
+  }
+
+  /**
+   * 
+   * Formats a message String into a String for html presentation. Escapes the &, <, >, " and ®, and
+   * replace the \n by <br/>
+   * and \r for space.
+   * 
+   * IMPORTANT! : this method is designed to transform the output of Utility.messageBD method, and
+   * this method replaces \n by \\n and \" by &quote. Because of that, the first replacements revert
+   * this previous replacements.
+   * 
+   * @param message
+   *          message with java formating
+   * @return html format message
+   */
+  public static String formatMessageBDToHtml(String message) {
+    return BasicUtility.formatMessageBDToHtml(message);
+  }
+
+  /**
+   * Parse the text searching @ parameters to translate.
+   * 
+   * @param text
+   *          String with the text to translate.
+   * @return String translated.
+   */
+  public static String parseTranslation(String text) {
+    final VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
+    final String language = OBContext.getOBContext().getLanguage().getLanguage();
+    return parseTranslation(new DalConnectionProvider(false), vars, null, language, text);
+  }
+
+  /**
+   * Parse the text searching @ parameters to translate.
+   * 
+   * @param conn
+   *          Handler for the database connection.
+   * @param vars
+   *          Handler for the session info.
+   * @param language
+   *          String with the language to translate.
+   * @param text
+   *          String with the text to translate.
+   * @return String translated.
+   */
+  public static String parseTranslation(ConnectionProvider conn, VariablesSecureApp vars,
+      String language, String text) {
+    return parseTranslation(conn, vars, null, language, text);
+  }
+
+  /**
+   * Parse the text searching @ parameters to translate. If replaceMap is not null and contains a
+   * replacement value for a token then it will be used, otherwise the return value of the translate
+   * method will be used for the translation.
+   * 
+   * @param conn
+   *          Handler for the database connection.
+   * @param vars
+   *          Handler for the session info.
+   * @param replaceMap
+   *          optional Map containing replacement values for the tokens
+   * @param language
+   *          String with the language to translate.
+   * @param text
+   *          String with the text to translate.
+   * @return String translated.
+   */
+  public static String parseTranslation(ConnectionProvider conn, VariablesSecureApp vars,
+      Map<String, String> replaceMap, String language, String text) {
+    if (text == null || text.length() == 0) {
+      return text;
+    }
+
+    String inStr = text;
+    String token;
+    final StringBuffer outStr = new StringBuffer();
+
+    int i = inStr.indexOf("@");
+    while (i != -1) {
+      outStr.append(inStr.substring(0, i));
+      inStr = inStr.substring(i + 1, inStr.length());
+
+      final int j = inStr.indexOf("@");
+      if (j < 0) {
+        inStr = "@" + inStr;
+        break;
+      }
+
+      token = inStr.substring(0, j);
+      if (replaceMap != null && replaceMap.containsKey(token)) {
+        outStr.append(replaceMap.get(token));
+      } else {
+        outStr.append(translate(conn, vars, token, language));
+      }
+
+      inStr = inStr.substring(j + 1, inStr.length());
+      i = inStr.indexOf("@");
+    }
+
+    outStr.append(inStr);
+    return outStr.toString();
+  }
+
+  /**
+   * For each token found in the parseTranslation method, this method is called to find the correct
+   * translation.
+   * 
+   * @param conn
+   *          Handler for the database connection.
+   * @param vars
+   *          Handler for the session info.
+   * @param token
+   *          String with the token to translate.
+   * @param language
+   *          String with the language to translate.
+   * @return String with the token translated.
+   */
+  public static String translate(ConnectionProvider conn, VariablesSecureApp vars, String token,
+      String language) {
+    String strTranslate = vars.getSessionValue(token);
+    if (!strTranslate.equals("")) {
+      return strTranslate;
+    }
+    strTranslate = messageBD(conn, token, language);
+    if (strTranslate.equals("")) {
+      return token;
+    }
+    return strTranslate;
+  }
+
+  /**
+   * Gets the Message for the instance of the processes.
+   * 
+   * @param pInstance
+   *          ProcessInstance object
+   * @return Object with the message.
+   * @throws ServletException
+   */
+  public static OBError getProcessInstanceMessage(ProcessInstance pInstance) {
+    OBError myMessage = new OBError();
+    String message = pInstance.getErrorMsg();
+    String title = "";
+    String type = "";
+    if (pInstance.getResult() == 1L) {
+      type = "Success";
+      title = messageBD("Success");
+    } else if (pInstance.getResult() == 0L) {
+      type = "Error";
+      title = messageBD("Error");
+    } else {
+      type = "Warning";
+      title = messageBD("Warning");
+    }
+
+    final int errorPos = message.indexOf("@ERROR=");
+    if (errorPos != -1) {
+      myMessage = translateError("@CODE=@" + message.substring(errorPos + 7));
+      log4j.debug("Error Message returned: " + myMessage.getMessage());
+      if (message.substring(errorPos + 7).equals(myMessage.getMessage())) {
+        myMessage.setMessage(parseTranslation(myMessage.getMessage()));
+      }
+      if (errorPos > 0) {
+        message = message.substring(0, errorPos);
+      } else {
+        message = "";
+      }
+    }
+    if (!message.equals("") && message.indexOf("@") != -1) {
+      message = parseTranslation(message);
+    }
+    myMessage.setType(type);
+    myMessage.setTitle(title);
+    myMessage.setMessage(message + ((!message.equals("") && errorPos != -1) ? " <br> " : "")
+        + myMessage.getMessage());
+
+    return myMessage;
+  }
+
+  /**
+   * Translate the message, searching the @ parameters, and making use of the ErrorTextParser class
+   * to get the appropriated message.
+   * 
+   * @param message
+   *          String with the message to translate.
+   * @return
+   */
+  public static OBError translateError(String message) {
+    VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
+    final String strLanguage = OBContext.getOBContext().getLanguage().getLanguage();
+    return translateError(new DalConnectionProvider(false), vars, strLanguage, message);
+  }
+
+  /**
+   * Translate the message, searching the @ parameters, and making use of the ErrorTextParser class
+   * to get the appropriated message.
+   * 
+   * @param conn
+   *          Handler for the database connection.
+   * @param vars
+   *          Handler for the session info.
+   * @param strLanguage
+   *          Language to translate.
+   * @param message
+   *          String with the message to translate.
+   * @return Object with the message.
+   */
+  public static OBError translateError(ConnectionProvider conn, VariablesSecureApp vars,
+      String strLanguage, String _message) {
+    String message = _message;
+    final OBError myError = new OBError();
+    myError.setType("Error");
+    myError.setMessage(message);
+    if (message == null || message.equals("")) {
+      return myError;
+    }
+    String code = "";
+    log4j.debug("translateError - message: " + message);
+    if (message.startsWith("@CODE=@")) {
+      message = message.substring(7);
+    } else if (message.startsWith("@CODE=")) {
+      message = message.substring(6);
+      final int pos = message.indexOf("@");
+      if (pos == -1) {
+        code = message;
+        message = "";
+      } else {
+        code = message.substring(0, pos);
+        message = message.substring(pos + 1);
+      }
+    }
+    myError.setMessage(message);
+    log4j.debug("translateError - code: " + code + " - message: " + message);
+
+    // BEGIN Checking if is a pool problem
+    if (code != null && code.equals("NoConnectionAvailable")) {
+      myError.setType("Error");
+      myError.setTitle("Critical Error");
+      myError.setConnectionAvailable(false);
+      myError.setMessage("No database connection available");
+      return myError;
+    }
+    // END Checking if is a pool problem
+
+    // BEGIN Parsing message text
+    if (message != null && !message.equals("")) {
+      final String rdbms = conn.getRDBMS();
+      ErrorTextParser myParser = null;
+      try {
+        final Class<?> c = Class.forName("org.openbravo.erpCommon.utility.ErrorTextParser"
+            + rdbms.toUpperCase());
+        myParser = (ErrorTextParser) c.newInstance();
+      } catch (final ClassNotFoundException ex) {
+        log4j.warn("Couldn´t find class: org.openbravo.erpCommon.utility.ErrorTextParser"
+            + rdbms.toUpperCase());
+        myParser = null;
+      } catch (final Exception ex1) {
+        log4j.warn("Couldn´t initialize class: org.openbravo.erpCommon.utility.ErrorTextParser"
+            + rdbms.toUpperCase());
+        myParser = null;
+      }
+      if (myParser != null) {
+        myParser.setConnection(conn);
+        myParser.setLanguage(strLanguage);
+        myParser.setMessage(message);
+        myParser.setVars(vars);
+        try {
+          final OBError myErrorAux = myParser.parse();
+          if (myErrorAux != null
+              && !myErrorAux.getMessage().equals("")
+              && (code == null || code.equals("") || code.equals("0") || !myErrorAux.getMessage()
+                  .equalsIgnoreCase(message)))
+            return myErrorAux;
+        } catch (final Exception ex) {
+          log4j.error("Error while parsing text: " + ex);
+        }
+      }
+    } else {
+      myError.setMessage(code);
+    }
+    // END Parsing message text
+
+    // BEGIN Looking for error code in AD_Message
+    if (code != null && !code.equals("")) {
+      final FieldProvider fldMessage = locateMessage(conn, code, strLanguage);
+      if (fldMessage != null) {
+        myError.setType((fldMessage.getField("msgtype").equals("E") ? "Error" : (fldMessage
+            .getField("msgtype").equals("I") ? "Info"
+            : (fldMessage.getField("msgtype").equals("S") ? "Success" : "Warning"))));
+        myError.setMessage(fldMessage.getField("msgtext"));
+        return myError;
+      }
+    }
+    // END Looking for error code in AD_Message
+
+    return myError;
+  }
+
+  /**
+   * Search a message in the database.
+   * 
+   * @param conn
+   *          Handler for the database connection.
+   * @param strCode
+   *          Message to search.
+   * @param strLanguage
+   *          Language to translate.
+   * @return FieldProvider with the message info.
+   */
+  public static FieldProvider locateMessage(ConnectionProvider conn, String strCode,
+      String strLanguage) {
+    FieldProvider[] fldMessage = null;
+
+    try {
+      log4j.debug("locateMessage - Message Code: " + strCode);
+      fldMessage = MessageBDData.messageInfo(conn, strLanguage, strCode);
+    } catch (final Exception ignore) {
+    }
+    if (fldMessage != null && fldMessage.length > 0) {
+      return fldMessage[0];
+    } else {
+      return null;
+    }
+  }
+
+}
--- a/src/org/openbravo/erpCommon/utility/Utility.java	Wed Feb 15 16:58:06 2012 +0100
+++ b/src/org/openbravo/erpCommon/utility/Utility.java	Wed Feb 29 12:28:09 2012 +0100
@@ -311,10 +311,10 @@
   }
 
   /**
-   * @see DateUtility#formatDate(Date, String)
+   * @see OBDateUtils#formatDate(Date, String)
    */
   public static String formatDate(Date date, String pattern) {
-    return DateUtility.formatDate(date, pattern);
+    return OBDateUtils.formatDate(date, pattern);
   }
 
   /**
@@ -338,14 +338,14 @@
   }
 
   /**
-   * @see MessageUtility#messageBD(ConnectionProvider, String, String, boolean)
+   * @see OBMessageUtils#messageBD(ConnectionProvider, String, String, boolean)
    */
   public static String messageBD(ConnectionProvider conn, String strCode, String strLanguage) {
     return BasicUtility.messageBD(conn, strCode, strLanguage, true);
   }
 
   /**
-   * @see MessageUtility#messageBD(ConnectionProvider, String, String, boolean)
+   * @see OBMessageUtils#messageBD(ConnectionProvider, String, String, boolean)
    */
   public static String messageBD(ConnectionProvider conn, String strCode, String strLanguage,
       boolean escape) {
@@ -353,7 +353,7 @@
   }
 
   /**
-   * @see MessageUtility#formatMessageBDToHtml(String)
+   * @see OBMessageUtils#formatMessageBDToHtml(String)
    */
   public static String formatMessageBDToHtml(String message) {
     return BasicUtility.formatMessageBDToHtml(message);
@@ -1041,28 +1041,28 @@
   }
 
   /**
-   * @see MessageUtility#parseTranslation(ConnectionProvider, VariablesSecureApp, String, String)
+   * @see OBMessageUtils#parseTranslation(ConnectionProvider, VariablesSecureApp, String, String)
    */
   public static String parseTranslation(ConnectionProvider conn, VariablesSecureApp vars,
       String language, String text) {
-    return MessageUtility.parseTranslation(conn, vars, language, text);
+    return OBMessageUtils.parseTranslation(conn, vars, language, text);
   }
 
   /**
-   * @see MessageUtility#parseTranslation(ConnectionProvider, VariablesSecureApp, Map, String,
+   * @see OBMessageUtils#parseTranslation(ConnectionProvider, VariablesSecureApp, Map, String,
    *      String)
    */
   public static String parseTranslation(ConnectionProvider conn, VariablesSecureApp vars,
       Map<String, String> replaceMap, String language, String text) {
-    return MessageUtility.parseTranslation(conn, vars, replaceMap, language, text);
+    return OBMessageUtils.parseTranslation(conn, vars, replaceMap, language, text);
   }
 
   /**
-   * @see MessageUtility#translate(ConnectionProvider, VariablesSecureApp, String, String)
+   * @see OBMessageUtils#translate(ConnectionProvider, VariablesSecureApp, String, String)
    */
   public static String translate(ConnectionProvider conn, VariablesSecureApp vars, String token,
       String language) {
-    return MessageUtility.translate(conn, vars, token, language);
+    return OBMessageUtils.translate(conn, vars, token, language);
   }
 
   /**
@@ -1286,7 +1286,7 @@
   }
 
   /**
-   * @see MessageUtility#getProcessInstanceMessage(ConnectionProvider, VariablesSecureApp,
+   * @see OBMessageUtils#getProcessInstanceMessage(ConnectionProvider, VariablesSecureApp,
    *      PInstanceProcessData[])
    */
   public static OBError getProcessInstanceMessage(ConnectionProvider conn, VariablesSecureApp vars,
@@ -1342,19 +1342,19 @@
   }
 
   /**
-   * @see MessageUtility#translateError(ConnectionProvider, VariablesSecureApp, String, String)
+   * @see OBMessageUtils#translateError(ConnectionProvider, VariablesSecureApp, String, String)
    */
   public static OBError translateError(ConnectionProvider conn, VariablesSecureApp vars,
       String strLanguage, String message) {
-    return MessageUtility.translateError(conn, vars, strLanguage, message);
+    return OBMessageUtils.translateError(conn, vars, strLanguage, message);
   }
 
   /**
-   * @see MessageUtility#locateMessage(ConnectionProvider, String, String)
+   * @see OBMessageUtils#locateMessage(ConnectionProvider, String, String)
    */
   public static FieldProvider locateMessage(ConnectionProvider conn, String strCode,
       String strLanguage) {
-    return MessageUtility.locateMessage(conn, strCode, strLanguage);
+    return OBMessageUtils.locateMessage(conn, strCode, strLanguage);
   }
 
   public String getServletInfo() {
@@ -1724,44 +1724,44 @@
   }
 
   /**
-   * @see DateUtility#calculateLaborDays(String, String, DateFormat)
+   * @see OBDateUtils#calculateLaborDays(String, String, DateFormat)
    */
   public static String calculateLaborDays(String strDate1, String strDate2, DateFormat DateFormatter)
       throws ParseException {
-    return DateUtility.calculateLaborDays(strDate1, strDate2, DateFormatter);
+    return OBDateUtils.calculateLaborDays(strDate1, strDate2, DateFormatter);
   }
 
   /**
-   * @see DateUtility#addDaysToDate(String, int, DateFormat)
+   * @see OBDateUtils#addDaysToDate(String, int, DateFormat)
    */
   public static String addDaysToDate(String strDate, String strDays, DateFormat DateFormatter)
       throws ParseException {
     if (strDays == null || "".equals(strDays)) {
       return "";
     }
-    return DateUtility.addDaysToDate(strDate, Integer.parseInt(strDays), DateFormatter);
+    return OBDateUtils.addDaysToDate(strDate, Integer.parseInt(strDays), DateFormatter);
   }
 
   /**
-   * @see DateUtility#getDateFormatter(VariablesSecureApp)
+   * @see OBDateUtils#getDateFormatter(VariablesSecureApp)
    */
   public static DateFormat getDateFormatter(VariablesSecureApp vars) {
-    return DateUtility.getDateFormatter(vars);
+    return OBDateUtils.getDateFormatter(vars);
   }
 
   /**
-   * @see DateUtility#isWeekendDay(String, DateFormat)
+   * @see OBDateUtils#isWeekendDay(String, DateFormat)
    */
   public static boolean isWeekendDay(String strDay, DateFormat DateFormatter) throws ParseException {
-    return DateUtility.isWeekendDay(strDay, DateFormatter);
+    return OBDateUtils.isWeekendDay(strDay, DateFormatter);
   }
 
   /**
-   * @see DateUtility#isBiggerDate(String, String, DateFormat)
+   * @see OBDateUtils#isBiggerDate(String, String, DateFormat)
    */
   public static boolean isBiggerDate(String strDate1, String strDate2, DateFormat DateFormatter)
       throws ParseException {
-    return DateUtility.isBiggerDate(strDate1, strDate2, DateFormatter);
+    return OBDateUtils.isBiggerDate(strDate1, strDate2, DateFormatter);
   }
 
   public static JasperReport getTranslatedJasperReport(ConnectionProvider conn, String reportName,