details:   https://code.openbravo.com/erp/devel/pi/rev/e2fb0056c724
changeset: 15501:e2fb0056c724
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Thu Feb 16 10:45:18 2012 +0100
summary:   Related to issue 8944. Removed wrong echo

details:   https://code.openbravo.com/erp/devel/pi/rev/eb48f353d1d3
changeset: 15502:eb48f353d1d3
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Thu Feb 16 10:46:50 2012 +0100
summary:   Fixed issue 18530. Mime type will be computed for the converted 
images

details:   https://code.openbravo.com/erp/devel/pi/rev/459c8c6700f5
changeset: 15503:459c8c6700f5
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Thu Feb 16 12:11:22 2012 +0100
summary:   Fixed issue 13438. Now the import of reference data and translations 
can be forced with -DforceRefData=true

diffstat:

 build.xml                                                                      
    |    4 +-
 src-db/database/build-create.xml                                               
    |    1 -
 
src-util/modulescript/build/classes/org/openbravo/modulescript/ConvertImages.class
 |    0 
 src-util/modulescript/src/org/openbravo/modulescript/ConvertImages.java        
    |   13 ++++-
 src/org/openbravo/erpCommon/modules/ApplyModule.java                           
    |   23 +++++++++-
 src/org/openbravo/erpCommon/modules/ApplyModuleTask.java                       
    |   22 ++++++++-
 src/org/openbravo/erpCommon/modules/ApplyModule_data.xsql                      
    |   22 +++++++++
 7 files changed, 74 insertions(+), 11 deletions(-)

diffs (242 lines):

diff -r b5a6f2188265 -r 459c8c6700f5 build.xml
--- a/build.xml Thu Feb 16 12:10:03 2012 +0100
+++ b/build.xml Thu Feb 16 12:11:22 2012 +0100
@@ -777,7 +777,7 @@
     <taskdef name="applyModule" 
classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
       <classpath refid="project.class.path" />
     </taskdef>
-    <applyModule userId="0" adminMode="true" 
propertiesFile="${base.config}/Openbravo.properties"/>
+    <applyModule userId="0" adminMode="true" forceRefData="${forceRefData}" 
propertiesFile="${base.config}/Openbravo.properties"/>
   </target>
   
   <target name="compile.apply.module" depends="init">
@@ -794,7 +794,7 @@
   -->
   <target name="apply.module" depends="compile.apply.module">
     <java classname="org.openbravo.erpCommon.modules.ApplyModuleTask" 
fork="true" maxmemory="${build.maxmemory}" failonerror="true">
-      <arg line="'${base.src}' '${friendlyWarnings}'" />
+      <arg line="'${base.src}' '${friendlyWarnings}' '${forceRefData}'" />
       <classpath refid="apply.module.runtime.classpath" />
     </java>
    <delete includeEmptyDirs="true"  dir="${build.apply.module}" />
diff -r b5a6f2188265 -r 459c8c6700f5 src-db/database/build-create.xml
--- a/src-db/database/build-create.xml  Thu Feb 16 12:10:03 2012 +0100
+++ b/src-db/database/build-create.xml  Thu Feb 16 12:11:22 2012 +0100
@@ -74,7 +74,6 @@
   </target>
 
   <target name="clean.database.POSTGRE">
-    <echo message="${bbdd.url}"/>
     <sql driver="${bbdd.driver}" url="${bbdd.url}/postgres" 
userid="${bbdd.systemUser}" password="${bbdd.systemPassword}" 
onerror="continue" autocommit="true">
       <classpath>
         <fileset dir="${base.lib}">
diff -r b5a6f2188265 -r 459c8c6700f5 
src-util/modulescript/build/classes/org/openbravo/modulescript/ConvertImages.class
Binary file 
src-util/modulescript/build/classes/org/openbravo/modulescript/ConvertImages.class
 has changed
diff -r b5a6f2188265 -r 459c8c6700f5 
src-util/modulescript/src/org/openbravo/modulescript/ConvertImages.java
--- a/src-util/modulescript/src/org/openbravo/modulescript/ConvertImages.java   
Thu Feb 16 12:10:03 2012 +0100
+++ b/src-util/modulescript/src/org/openbravo/modulescript/ConvertImages.java   
Thu Feb 16 12:11:22 2012 +0100
@@ -36,10 +36,13 @@
 import java.sql.ResultSet;
 
 import javax.imageio.ImageIO;
+import org.apache.tika.Tika;
+import org.apache.tika.mime.MimeType;
 
 public class ConvertImages extends ModuleScript {
 
   private static final Logger log4j = Logger.getLogger(ModuleScript.class);
+  private Tika tika;
   
   @Override
   public void execute() {
@@ -60,7 +63,7 @@
 
       ConnectionProvider cp = getConnectionProvider();
       String sql="SELECT i.imageurl, i.ad_image_id from ad_image i, m_product 
p where ";
-      sql+=" i.ad_image_id=p.ad_image_id and binarydata is null order by 
i.ad_image_id ";
+      sql+=" i.ad_image_id=p.ad_image_id and binarydata is null and i.imageurl 
is not null order by i.ad_image_id ";
       ResultSet rs=cp.getPreparedStatement(sql).executeQuery();
       while(rs.next()){
         String imageurl=rs.getString(1);
@@ -79,12 +82,16 @@
           is.close();
           ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
           BufferedImage rImage = ImageIO.read(bis);
-          String qupdate="UPDATE ad_image set binarydata=?, width=?, height=? 
where ad_image_id=?";
+          String qupdate="UPDATE ad_image set binarydata=?, width=?, height=?, 
mimetype=? where ad_image_id=?";
           PreparedStatement ps=cp.getPreparedStatement(qupdate);
           ps.setObject(1, bytes);
           ps.setLong(2, rImage.getWidth());
           ps.setLong(3, rImage.getHeight());
-          ps.setString(4, imageid);
+          if (tika==null) {
+            tika=new Tika();
+          }
+          ps.setString(4, tika.detect(bytes));
+          ps.setString(5, imageid);
           ps.executeUpdate();
           cp.releasePreparedStatement(ps);
         }
diff -r b5a6f2188265 -r 459c8c6700f5 
src/org/openbravo/erpCommon/modules/ApplyModule.java
--- a/src/org/openbravo/erpCommon/modules/ApplyModule.java      Thu Feb 16 
12:10:03 2012 +0100
+++ b/src/org/openbravo/erpCommon/modules/ApplyModule.java      Thu Feb 16 
12:11:22 2012 +0100
@@ -54,6 +54,7 @@
   private static ConnectionProvider pool;
   static Logger log4j = Logger.getLogger(ApplyModule.class);
   private String obDir;
+  private boolean forceRefData = false;
 
   public ApplyModule(ConnectionProvider cp, String dir) {
     pool = cp;
@@ -62,6 +63,14 @@
     log4j = Logger.getLogger(ApplyModule.class);
   }
 
+  public ApplyModule(ConnectionProvider cp, String dir, boolean forceRefData) {
+    pool = cp;
+    obDir = dir;
+    PropertyConfigurator.configure(obDir + "/src/log4j.lcf");
+    log4j = Logger.getLogger(ApplyModule.class);
+    this.forceRefData = forceRefData;
+  }
+
   /**
    * Process the Installed but not applied modules, the treatement for these 
modules is: Translation
    * modules In case the module contains translations the process will: <br/>
@@ -84,7 +93,12 @@
       // **************** Translation modules ************************
       // Check whether modules to install are translations
       log4j.info("Looking for translation modules");
-      final ApplyModuleData[] data = 
ApplyModuleData.selectTranslationModules(pool);
+      final ApplyModuleData[] data;
+      if (!forceRefData) {
+        data = ApplyModuleData.selectTranslationModules(pool);
+      } else {
+        data = ApplyModuleData.selectAllTranslationModules(pool);
+      }
 
       if (data != null && data.length > 0) {
         log4j.info(data.length + " translation modules found");
@@ -123,7 +137,12 @@
 
       log4j.info("Looking for reference data modules");
 
-      final ApplyModuleData[] ds = 
ApplyModuleData.selectClientReferenceModules(pool);
+      final ApplyModuleData[] ds;
+      if (!forceRefData) {
+        ds = ApplyModuleData.selectClientReferenceModules(pool);
+      } else {
+        ds = ApplyModuleData.selectAllClientReferenceModules(pool);
+      }
 
       if (ds != null && ds.length > 0) {
         ModuleUtility.orderModuleByDependency(ds);
diff -r b5a6f2188265 -r 459c8c6700f5 
src/org/openbravo/erpCommon/modules/ApplyModuleTask.java
--- a/src/org/openbravo/erpCommon/modules/ApplyModuleTask.java  Thu Feb 16 
12:10:03 2012 +0100
+++ b/src/org/openbravo/erpCommon/modules/ApplyModuleTask.java  Thu Feb 16 
12:11:22 2012 +0100
@@ -37,18 +37,22 @@
   // private String propertiesFile;
   private String obDir;
   private static final Logger log4j = Logger.getLogger(ApplyModuleTask.class);
+  private Boolean forceRefData = false;
 
   public static void main(String[] args) {
+    Boolean lforceRefData = false;
     final String srcPath = args[0];
     String friendlyWarnings = "false";
     if (args.length >= 2) {
       friendlyWarnings = args[1];
+      lforceRefData = args[2].equalsIgnoreCase("true") || 
args[2].equalsIgnoreCase("yes");
     }
     final File srcDir = new File(srcPath);
     final File baseDir = srcDir.getParentFile();
     try {
       final AntExecutor antExecutor = new 
AntExecutor(baseDir.getAbsolutePath());
       antExecutor.setProperty("friendlyWarnings", friendlyWarnings);
+      antExecutor.setProperty("forceRefData", lforceRefData.toString());
       antExecutor.runTask("apply.module.forked");
     } catch (final Exception e) {
       throw new OBException(e);
@@ -65,7 +69,11 @@
     CPStandAlone pool = new CPStandAlone(propertiesFile);
     ApplyModuleData[] ds = null;
     try {
-      ds = ApplyModuleData.selectClientReferenceModules(pool);
+      if (!forceRefData) {
+        ds = ApplyModuleData.selectClientReferenceModules(pool);
+      } else {
+        ds = ApplyModuleData.selectAllClientReferenceModules(pool);
+      }
     } catch (Exception e) {
       log4j.error("Error checking modules with reference data", e);
     }
@@ -74,7 +82,11 @@
       super.execute();
     } else {
       try {
-        ds = ApplyModuleData.selectTranslationModules(pool);
+        if (!forceRefData) {
+          ds = ApplyModuleData.selectTranslationModules(pool);
+        } else {
+          ds = ApplyModuleData.selectAllTranslationModules(pool);
+        }
       } catch (Exception e) {
         log4j.error("Error checking modules with translation data", e);
       }
@@ -101,7 +113,7 @@
         obDir = getProject().getBaseDir().toString();
       if (propertiesFile == null || propertiesFile.equals(""))
         propertiesFile = obDir + "/config/Openbravo.properties";
-      final ApplyModule am = new ApplyModule(new CPStandAlone(propertiesFile), 
obDir);
+      final ApplyModule am = new ApplyModule(new CPStandAlone(propertiesFile), 
obDir, forceRefData);
       am.execute();
     } catch (final Exception e) {
       throw new BuildException(e);
@@ -114,4 +126,8 @@
   public void setObDir(String obDir) {
     this.obDir = obDir;
   }
+
+  public void setForceRefData(boolean forceRefData) {
+    this.forceRefData = forceRefData;
+  }
 }
diff -r b5a6f2188265 -r 459c8c6700f5 
src/org/openbravo/erpCommon/modules/ApplyModule_data.xsql
--- a/src/org/openbravo/erpCommon/modules/ApplyModule_data.xsql Thu Feb 16 
12:10:03 2012 +0100
+++ b/src/org/openbravo/erpCommon/modules/ApplyModule_data.xsql Thu Feb 16 
12:11:22 2012 +0100
@@ -31,6 +31,16 @@
          AND ISTRANSLATIONMODULE = 'Y'
     ]]></Sql>
   </SqlMethod>
+  <SqlMethod name="selectAllTranslationModules" type="preparedStatement" 
return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+    <![CDATA[
+      SELECT M.JAVAPACKAGE, M.NAME, M.AD_LANGUAGE, L.ISSYSTEMLANGUAGE, '' as 
DS_NAME, '' AS AD_MODULE_ID
+        FROM AD_MODULE M LEFT JOIN AD_LANGUAGE L
+                           ON L.AD_LANGUAGE = M.AD_LANGUAGE
+       WHERE ISTRANSLATIONMODULE = 'Y'
+    ]]></Sql>
+  </SqlMethod>
   
   <SqlMethod name="selectClientReferenceModules" type="preparedStatement" 
return="multiple">
     <SqlMethodComment></SqlMethodComment>
@@ -45,6 +55,18 @@
     ]]></Sql>
   </SqlMethod>
   
+  <SqlMethod name="selectAllClientReferenceModules" type="preparedStatement" 
return="multiple">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+    <![CDATA[
+      SELECT M.JAVAPACKAGE, M.NAME, M.AD_MODULE_ID, D.NAME as DS_NAME
+        FROM AD_MODULE M, AD_DATASET D
+       WHERE M.HASREFERENCEDATA = 'Y'
+         AND D.AD_MODULE_ID = M.AD_MODULE_ID
+         AND D.ACCESSLEVEL = '4'
+    ]]></Sql>
+  </SqlMethod>
+  
   <SqlMethod name="setSystemLanguage" type="preparedStatement" 
return="rowcount">
     <Sql>
       <![CDATA[

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to