[newupgrade] Yet more changes
authorAntonio Moreno <antonio.moreno@openbravo.com>
Thu, 26 Nov 2009 18:01:31 +0100
changeset 5611 35de562d9634
parent 5610 b9828af92858
child 5612 c5482c710ef5
[newupgrade] Yet more changes
build.xml
src-db/database/build.xml
src-db/database/model/tables/AD_ERROR_LOG.xml
src/org/openbravo/erpCommon/ad_process/ApplyModules.java
src/org/openbravo/erpCommon/ad_process/ApplyModules_data.xsql
src/org/openbravo/erpCommon/modules/ApplyModule.java
src/org/openbravo/erpCommon/modules/ApplyModule_data.xsql
--- a/build.xml	Thu Nov 26 15:50:21 2009 +0100
+++ b/build.xml	Thu Nov 26 18:01:31 2009 +0100
@@ -589,7 +589,7 @@
     </condition>
     
     <antcall target="apply.modules.compile"/>
-    <ant dir="${base.db}" target="setApplied.${bbdd.rdbms}" inheritAll="true" inheritRefs="true" />
+    <ant dir="${base.db}" target="setApplied" inheritAll="true" inheritRefs="true" />
      
   </target>
   
--- a/src-db/database/build.xml	Thu Nov 26 15:50:21 2009 +0100
+++ b/src-db/database/build.xml	Thu Nov 26 18:01:31 2009 +0100
@@ -180,22 +180,7 @@
     </sql>
   </target>
 
-  <target name="setApplied.ORACLE">
-    <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" onerror="abort" autocommit="true">
-      <classpath>
-        <fileset dir="${base.lib}">
-          <include name="**/*.jar">
-          </include>
-        </fileset>
-      </classpath>
-      <transaction>
-          UPDATE AD_MODULE SET STATUS='A',ISINDEVELOPMENT='N' WHERE STATUS='P';
-          DELETE FROM AD_MODULE WHERE STATUS = 'U';
-      </transaction>
-    </sql>
-  </target>
-
-  <target name="setApplied.POSTGRE">
+  <target name="setApplied">
     <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" onerror="abort" autocommit="true">
       <classpath>
         <fileset dir="${base.lib}">
--- a/src-db/database/model/tables/AD_ERROR_LOG.xml	Thu Nov 26 15:50:21 2009 +0100
+++ b/src-db/database/model/tables/AD_ERROR_LOG.xml	Thu Nov 26 18:01:31 2009 +0100
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
   <database name="TABLE AD_ERROR_LOG">
-    <table name="AD_ERROR_LOG">
-      <column name="AD_ERROR_LOG_ID" primaryKey="false" required="true" type="VARCHAR" size="32" autoIncrement="false">
+    <table name="AD_ERROR_LOG" primaryKey="AD_ERROR_LOG_KEY">
+      <column name="AD_ERROR_LOG_ID" primaryKey="true" required="true" type="VARCHAR" size="32" autoIncrement="false">
         <default/>
         <onCreateDefault/>
       </column>
@@ -33,7 +33,7 @@
         <default/>
         <onCreateDefault/>
       </column>
-      <column name="SYSTEM_STATUS" primaryKey="false" required="false" type="VARCHAR" size="60" autoIncrement="false">
+      <column name="SYSTEM_STATUS" primaryKey="false" required="false" type="VARCHAR" size="6" autoIncrement="false">
         <default/>
         <onCreateDefault/>
       </column>
@@ -45,5 +45,11 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <foreign-key foreignTable="AD_CLIENT" name="ERRORLOGCLIENT">
+        <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
+      </foreign-key>
+      <foreign-key foreignTable="AD_ORG" name="ERRORLOGORG">
+        <reference local="AD_ORG_ID" foreign="AD_ORG_ID"/>
+      </foreign-key>
     </table>
   </database>
--- a/src/org/openbravo/erpCommon/ad_process/ApplyModules.java	Thu Nov 26 15:50:21 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/ApplyModules.java	Thu Nov 26 18:01:31 2009 +0100
@@ -137,11 +137,6 @@
 
   /**
    * Prints a page that only allows the user to restart or reload Tomcat
-   * 
-   * @param response
-   * @param vars
-   * @throws IOException
-   * @throws ServletException
    */
   private void printPageTomcat(HttpServletRequest request, HttpServletResponse response,
       VariablesSecureApp vars) throws IOException, ServletException {
@@ -216,8 +211,8 @@
   }
 
   private ApplyModulesResponse fillResponse(String state) {
-    ApplyModulesResponse pet = new ApplyModulesResponse();
-    pet.setState(Integer.parseInt(state.replace("RB", "")));
+    ApplyModulesResponse resp = new ApplyModulesResponse();
+    resp.setState(Integer.parseInt(state.replace("RB", "")));
     PreparedStatement ps = null;
     PreparedStatement ps2 = null;
     PreparedStatement ps3 = null;
@@ -230,10 +225,7 @@
       while (rs.next()) {
         warnings.add(rs.getString(1));
       }
-      String[] warns = new String[warnings.size()];
-      for (int i = 0; i < warnings.size(); i++)
-        warns[i] = warnings.get(i);
-      pet.setWarnings(warnings.toArray(new String[0]));
+      resp.setWarnings(warnings.toArray(new String[0]));
 
       ps2 = getPreparedStatement("SELECT MESSAGE FROM AD_ERROR_LOG WHERE ERROR_LEVEL='ERROR' AND SYSTEM_STATUS LIKE ?");
       ps2.setString(1, "%" + state);
@@ -243,16 +235,13 @@
       while (rs2.next()) {
         errors.add(rs2.getString(1));
       }
-      String[] errs = new String[errors.size()];
-      for (int i = 0; i < errors.size(); i++)
-        errs[i] = errors.get(i);
-      pet.setErrors(errs);
+      resp.setErrors(errors.toArray(new String[0]));
 
       ps3 = getPreparedStatement("SELECT MESSAGE FROM AD_ERROR_LOG ORDER BY CREATED DESC");
       ps3.executeQuery();
       ResultSet rs3 = ps3.getResultSet();
       if (rs3.next()) {
-        pet.setLastmessage(rs3.getString(1));
+        resp.setLastmessage(rs3.getString(1));
       }
 
     } catch (Exception e) {
@@ -263,10 +252,10 @@
         releasePreparedStatement(ps2);
         releasePreparedStatement(ps);
       } catch (SQLException e2) {
-        e2.printStackTrace();
+        log4j.error("Error when closing prepared statements while building response object", e2);
       }
     }
-    return pet;
+    return resp;
   }
 
   private void update(HttpServletResponse response, VariablesSecureApp vars) {
@@ -277,19 +266,19 @@
       ResultSet rs = ps.getResultSet();
       rs.next();
       String state = rs.getString(1);
-      ApplyModulesResponse pet = fillResponse(state);
-      if (pet.getErrors().length > 0)
-        pet.setStatusofstate("Error");
-      else if (pet.getWarnings().length > 0)
-        pet.setStatusofstate("Warning");
+      ApplyModulesResponse resp = fillResponse(state);
+      if (resp.getErrors().length > 0)
+        resp.setStatusofstate("Error");
+      else if (resp.getWarnings().length > 0)
+        resp.setStatusofstate("Warning");
       else
-        pet.setStatusofstate("Processing");
+        resp.setStatusofstate("Processing");
       response.setContentType("text/plain; charset=UTF-8");
       final PrintWriter out = response.getWriter();
       String strResult;
       XStream xs = new XStream(new JettisonMappedXmlDriver());
       xs.alias("Response", ApplyModulesResponse.class);
-      strResult = xs.toXML(pet);
+      strResult = xs.toXML(resp);
       out.print(strResult);
       out.close();
     } catch (Exception e) {
--- a/src/org/openbravo/erpCommon/ad_process/ApplyModules_data.xsql	Thu Nov 26 15:50:21 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/ApplyModules_data.xsql	Thu Nov 26 18:01:31 2009 +0100
@@ -43,12 +43,12 @@
          SELECT count(*) as NAME FROM
             ((SELECT 1  
                 FROM AD_MODULE
-                WHERE STATUS='I'      
+                WHERE (STATUS='I' OR STATUS='P')      
                AND (AD_MODULE_ID = '0' OR TYPE='T'))
             UNION
             (SELECT 1
                 FROM AD_MODULE_INSTALL
-                WHERE STATUS='I'      
+                WHERE (STATUS='I' OR STATUS='P')      
                AND (AD_MODULE_ID = '0' OR TYPE='T'))) q
           ]]>
       </Sql>
@@ -59,7 +59,7 @@
       <Sql><![CDATA[
          SELECT count(*) as NAME
            FROM AD_MODULE
-          WHERE (STATUS='I'      
+          WHERE ((STATUS='I' OR STATUS='P')      
                  AND TYPE = 'T')
              OR (STATUS='U')
           ]]>
--- a/src/org/openbravo/erpCommon/modules/ApplyModule.java	Thu Nov 26 15:50:21 2009 +0100
+++ b/src/org/openbravo/erpCommon/modules/ApplyModule.java	Thu Nov 26 18:01:31 2009 +0100
@@ -182,10 +182,6 @@
         OBDal.getInstance().commitAndClose();
       }
 
-      // ************ Set applied as installed and delete uninstalled ************
-      // log4j.info("Set modules as installed");
-      // ApplyModuleData.setInstalled(pool);
-      // ApplyModuleData.deleteUninstalled(pool);
     } catch (final OBException e) {
       throw e;
     } catch (final Exception e) {
--- a/src/org/openbravo/erpCommon/modules/ApplyModule_data.xsql	Thu Nov 26 15:50:21 2009 +0100
+++ b/src/org/openbravo/erpCommon/modules/ApplyModule_data.xsql	Thu Nov 26 18:01:31 2009 +0100
@@ -55,24 +55,6 @@
     <Parameter name="lang"/>
   </SqlMethod>
   
-  <SqlMethod name="setInstalled" type="preparedStatement" return="rowcount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-    <![CDATA[
-       UPDATE AD_MODULE
-          SET STATUS = 'A', ISINDEVELOPMENT='N'
-        WHERE (STATUS = 'I' OR STATUS ='P')
-    ]]></Sql>
-  </SqlMethod>
-  
-  <SqlMethod name="deleteUninstalled" type="preparedStatement" return="rowcount">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-    <![CDATA[
-       DELETE FROM AD_MODULE
-       WHERE STATUS = 'U'
-    ]]></Sql>
-  </SqlMethod>
   
   
 </SqlClass>