details:   https://code.openbravo.com/erp/devel/pi/rev/41fa0431e85a
changeset: 26869:41fa0431e85a
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Sun Jun 07 13:09:55 2015 +0200
summary:   Related to issue Related to issue 29766: Retail Operations Buffer: 
store all transactions in operations table before processing
Removed default value of imported column, set default value on importstatus, 
various smaller changes from code review comments

diffstat:

 src-db/database/model/tables/C_IMPORT_ENTRY.xml                                
       |   4 +-
 src/org/openbravo/service/importprocess/ImportEntryArchiveManager.java         
       |   7 +-----
 src/org/openbravo/service/importprocess/ImportEntryManager.java                
       |  12 +++++-----
 src/org/openbravo/service/importprocess/ImportEntryProcessor.java              
       |   4 +-
 src/org/openbravo/service/importprocess/ImportReprocessErrorEntries.java       
       |   3 +-
 
src/org/openbravo/service/importprocess/ProcessImportEntriesProcessActionHandler.java
 |   3 +-
 6 files changed, 15 insertions(+), 18 deletions(-)

diffs (144 lines):

diff -r 531993ed12e7 -r 41fa0431e85a 
src-db/database/model/tables/C_IMPORT_ENTRY.xml
--- a/src-db/database/model/tables/C_IMPORT_ENTRY.xml   Sat Jun 06 23:54:18 
2015 +0000
+++ b/src-db/database/model/tables/C_IMPORT_ENTRY.xml   Sun Jun 07 13:09:55 
2015 +0200
@@ -34,7 +34,7 @@
         <onCreateDefault/>
       </column>
       <column name="IMPORTED" primaryKey="false" required="false" 
type="TIMESTAMP" size="7" autoIncrement="false">
-        <default><![CDATA[SYSDATE]]></default>
+        <default/>
         <onCreateDefault/>
       </column>
       <column name="JSONINFO" primaryKey="false" required="false" type="CLOB" 
size="4000" autoIncrement="false">
@@ -42,7 +42,7 @@
         <onCreateDefault/>
       </column>
       <column name="IMPORTSTATUS" primaryKey="false" required="true" 
type="VARCHAR" size="60" autoIncrement="false">
-        <default/>
+        <default><![CDATA[Initial]]></default>
         <onCreateDefault/>
       </column>
       <column name="TYPEOFDATA" primaryKey="false" required="true" 
type="VARCHAR" size="60" autoIncrement="false">
diff -r 531993ed12e7 -r 41fa0431e85a 
src/org/openbravo/service/importprocess/ImportEntryArchiveManager.java
--- a/src/org/openbravo/service/importprocess/ImportEntryArchiveManager.java    
Sat Jun 06 23:54:18 2015 +0000
+++ b/src/org/openbravo/service/importprocess/ImportEntryArchiveManager.java    
Sun Jun 07 13:09:55 2015 +0200
@@ -19,7 +19,6 @@
 package org.openbravo.service.importprocess;
 
 import java.util.Date;
-import java.util.Iterator;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -146,12 +145,8 @@
 
               ImportEntryArchive archiveEntry = 
createArchiveEntry(importEntry);
 
-              for (Iterator<? extends Object> procIter = 
manager.archiveEntryPreProcessors
-                  .iterator(); procIter.hasNext();) {
-                ImportEntryArchivePreProcessor processor = 
(ImportEntryArchivePreProcessor) procIter
-                    .next();
+              for (ImportEntryArchivePreProcessor processor : 
manager.archiveEntryPreProcessors) {
                 processor.beforeArchive(importEntry, archiveEntry);
-
               }
 
               log.debug("Processed one entry");
diff -r 531993ed12e7 -r 41fa0431e85a 
src/org/openbravo/service/importprocess/ImportEntryManager.java
--- a/src/org/openbravo/service/importprocess/ImportEntryManager.java   Sat Jun 
06 23:54:18 2015 +0000
+++ b/src/org/openbravo/service/importprocess/ImportEntryManager.java   Sun Jun 
07 13:09:55 2015 +0200
@@ -24,7 +24,6 @@
 import java.lang.annotation.Target;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ArrayBlockingQueue;
@@ -239,8 +238,10 @@
    * Note will commit the session/connection using {@link 
OBDal#commitAndClose()}
    */
   public void createImportEntry(String id, String typeOfData, String json) {
+    // make sure that everything is flushed to the db before checking import 
entry
+    // content
     OBDal.getInstance().flush();
-    OBContext.setAdminMode(false);
+    OBContext.setAdminMode(true);
     try {
       // check if it is not there already or already archived
       {
@@ -276,8 +277,7 @@
       importEntry.setTypeofdata(typeOfData);
       importEntry.setJsonInfo(json);
 
-      for (Iterator<? extends Object> procIter = 
entryPreProcessors.iterator(); procIter.hasNext();) {
-        ImportEntryPreProcessor processor = (ImportEntryPreProcessor) 
procIter.next();
+      for (ImportEntryPreProcessor processor : entryPreProcessors) {
         processor.beforeCreate(importEntry);
       }
       OBDal.getInstance().save(importEntry);
@@ -398,7 +398,8 @@
     final OBContext prevOBContext = OBContext.getOBContext();
     OBContext.setOBContext("0", "0", "0", "0");
     try {
-      OBContext.setAdminMode();
+      // no need to do client/org checks on these actions, as in error, do the 
least possible
+      OBContext.setAdminMode(false);
       ImportEntry importEntry = OBDal.getInstance().get(ImportEntry.class, 
importEntryId);
       if (importEntry != null && 
!"Processed".equals(importEntry.getImportStatus())) {
         importEntry.setImportStatus("Error");
@@ -517,7 +518,6 @@
                       // errors, so always catch them to prevent other import 
entries
                       // from not getting processed
                       manager.setImportEntryError(entry.getId(), t);
-                      OBDal.getInstance().flush();
                     }
                   }
                 } finally {
diff -r 531993ed12e7 -r 41fa0431e85a 
src/org/openbravo/service/importprocess/ImportEntryProcessor.java
--- a/src/org/openbravo/service/importprocess/ImportEntryProcessor.java Sat Jun 
06 23:54:18 2015 +0000
+++ b/src/org/openbravo/service/importprocess/ImportEntryProcessor.java Sun Jun 
07 13:09:55 2015 +0200
@@ -285,7 +285,7 @@
             setOBContext(queuedImportEntry);
 
             try {
-              OBContext.setAdminMode();
+              OBContext.setAdminMode(true);
               ImportEntry localImportEntry;
               try {
                 // reload the importEntry
@@ -398,7 +398,7 @@
     }
 
     protected void setVariablesSecureApp(OBContext obContext) {
-      OBContext.setAdminMode();
+      OBContext.setAdminMode(true);
       try {
         final VariablesSecureApp variablesSecureApp = new 
VariablesSecureApp(obContext.getUser()
             .getId(), obContext.getCurrentClient().getId(), 
obContext.getCurrentOrganization()
diff -r 531993ed12e7 -r 41fa0431e85a 
src/org/openbravo/service/importprocess/ImportReprocessErrorEntries.java
--- a/src/org/openbravo/service/importprocess/ImportReprocessErrorEntries.java  
Sat Jun 06 23:54:18 2015 +0000
+++ b/src/org/openbravo/service/importprocess/ImportReprocessErrorEntries.java  
Sun Jun 07 13:09:55 2015 +0200
@@ -40,7 +40,8 @@
   protected void doExecute(ProcessBundle bundle) throws Exception {
     super.setDoCommit(false);
     logger = bundle.getLogger();
-    OBContext.setAdminMode();
+    // don't do client/org check on resetting import error status
+    OBContext.setAdminMode(false);
     try {
       final Query qry = OBDal
           .getInstance()
diff -r 531993ed12e7 -r 41fa0431e85a 
src/org/openbravo/service/importprocess/ProcessImportEntriesProcessActionHandler.java
--- 
a/src/org/openbravo/service/importprocess/ProcessImportEntriesProcessActionHandler.java
     Sat Jun 06 23:54:18 2015 +0000
+++ 
b/src/org/openbravo/service/importprocess/ProcessImportEntriesProcessActionHandler.java
     Sun Jun 07 13:09:55 2015 +0200
@@ -56,7 +56,8 @@
       JSONObject msgTotal = new JSONObject();
       JSONArray actions = new JSONArray();
 
-      final DalConnectionProvider dalConnectionProvider = new 
DalConnectionProvider();
+      // no flush needed as only needed to get some messages
+      final DalConnectionProvider dalConnectionProvider = new 
DalConnectionProvider(false);
 
       final String importProcessLbl = Utility.messageBD(dalConnectionProvider, 
"ImportProcess",
           OBContext.getOBContext().getLanguage().getLanguage());

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to