src/org/openbravo/materialmgmt/InventoryCountProcess.java
changeset 34193 12232bee10ef
parent 33876 c5d8fbd7e953
child 34236 20cd44382a65
child 34424 98e2d80c3032
equal deleted inserted replaced
34192:6230cdf4f146 34193:12232bee10ef
    22 import java.text.SimpleDateFormat;
    22 import java.text.SimpleDateFormat;
    23 import java.util.Calendar;
    23 import java.util.Calendar;
    24 import java.util.Date;
    24 import java.util.Date;
    25 import java.util.Iterator;
    25 import java.util.Iterator;
    26 import java.util.List;
    26 import java.util.List;
    27 import java.util.Map;
       
    28 
    27 
    29 import javax.enterprise.inject.Any;
    28 import javax.enterprise.inject.Any;
    30 import javax.enterprise.inject.Instance;
    29 import javax.enterprise.inject.Instance;
    31 import javax.inject.Inject;
    30 import javax.inject.Inject;
    32 
    31 
    33 import org.apache.commons.lang.time.DateUtils;
    32 import org.apache.commons.lang.time.DateUtils;
    34 import org.apache.log4j.Logger;
    33 import org.apache.log4j.Logger;
    35 import org.hibernate.Query;
    34 import org.hibernate.Query;
    36 import org.hibernate.QueryTimeoutException;
    35 import org.hibernate.QueryTimeoutException;
    37 import org.hibernate.Session;
    36 import org.hibernate.Session;
    38 import org.hibernate.dialect.Dialect;
       
    39 import org.hibernate.dialect.function.SQLFunction;
       
    40 import org.hibernate.dialect.function.StandardSQLFunction;
       
    41 import org.hibernate.exception.GenericJDBCException;
    37 import org.hibernate.exception.GenericJDBCException;
    42 import org.hibernate.impl.SessionFactoryImpl;
       
    43 import org.hibernate.impl.SessionImpl;
       
    44 import org.hibernate.type.DateType;
       
    45 import org.hibernate.type.StringType;
       
    46 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
    38 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
    47 import org.openbravo.base.exception.OBException;
    39 import org.openbravo.base.exception.OBException;
    48 import org.openbravo.dal.core.OBContext;
    40 import org.openbravo.dal.core.OBContext;
    49 import org.openbravo.dal.core.SessionHandler;
    41 import org.openbravo.dal.core.SessionHandler;
    50 import org.openbravo.dal.security.OrganizationStructureProvider;
    42 import org.openbravo.dal.security.OrganizationStructureProvider;
   172     OBError msg = new OBError();
   164     OBError msg = new OBError();
   173     msg.setType("Success");
   165     msg.setType("Success");
   174     msg.setTitle(OBMessageUtils.messageBD("Success"));
   166     msg.setTitle(OBMessageUtils.messageBD("Success"));
   175     runChecks(inventory);
   167     runChecks(inventory);
   176 
   168 
   177     // In case get_uuid is not already registered, it's registered now.
       
   178     final Dialect dialect = ((SessionFactoryImpl) ((SessionImpl) OBDal.getInstance().getSession())
       
   179         .getSessionFactory()).getDialect();
       
   180     Map<String, SQLFunction> function = dialect.getFunctions();
       
   181     if (!function.containsKey("get_uuid")) {
       
   182       dialect.getFunctions().put("get_uuid", new StandardSQLFunction("get_uuid", new StringType()));
       
   183     }
       
   184     if (!function.containsKey("now")) {
       
   185       dialect.getFunctions().put("now", new StandardSQLFunction("now", new DateType()));
       
   186     }
       
   187     if (!function.containsKey("to_date")) {
       
   188       dialect.getFunctions().put("to_date", new StandardSQLFunction("to_date", new DateType()));
       
   189     }
       
   190     if (!function.containsKey("to_timestamp")) {
       
   191       dialect.getFunctions().put("to_timestamp",
       
   192           new StandardSQLFunction("to_timestamp", new DateType()));
       
   193     }
       
   194     StringBuffer insert = new StringBuffer();
   169     StringBuffer insert = new StringBuffer();
   195     insert.append("insert into " + MaterialTransaction.ENTITY_NAME + "(");
   170     insert.append("insert into " + MaterialTransaction.ENTITY_NAME + "(");
   196     insert.append(" id ");
   171     insert.append(" id ");
   197     insert.append(", " + MaterialTransaction.PROPERTY_ACTIVE);
   172     insert.append(", " + MaterialTransaction.PROPERTY_ACTIVE);
   198     insert.append(", " + MaterialTransaction.PROPERTY_CLIENT);
   173     insert.append(", " + MaterialTransaction.PROPERTY_CLIENT);