Fixed issue 33420: Sometimes synchronization of the syncmodels are failing
authorJorge Garcia <jorge.garcia@openbravo.com>
Tue, 05 Jul 2016 12:48:48 +0200
changeset 29989 e5e6e0d26f32
parent 29988 ac1a6ff5c202
child 29990 9ec9da16c06a
Fixed issue 33420: Sometimes synchronization of the syncmodels are failing
when returning back from offline

Added a new column in c_import_entry table wich contains the timestamp in
miliseconds of the import entry.

With this new value, the import entry records are filtered.
src-db/database/model/tables/C_IMPORT_ENTRY.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_ELEMENT.xml
src/org/openbravo/service/importprocess/ImportEntryManager.java
--- a/src-db/database/model/tables/C_IMPORT_ENTRY.xml	Thu Jun 30 18:04:33 2016 +0200
+++ b/src-db/database/model/tables/C_IMPORT_ENTRY.xml	Tue Jul 05 12:48:48 2016 +0200
@@ -57,6 +57,10 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="CREATEDTIMESTAMP" primaryKey="false" required="false" type="DECIMAL" size="16,0" autoIncrement="false">
+        <default/>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_ROLE" name="C_IMPORT_ENTRY_AD_ROLE">
         <reference local="AD_ROLE_ID" foreign="AD_ROLE_ID"/>
       </foreign-key>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Thu Jun 30 18:04:33 2016 +0200
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Tue Jul 05 12:48:48 2016 +0200
@@ -236944,7 +236944,7 @@
 <!--02E827D16F9042D59CDC4FD71C4FAFAC-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--02E827D16F9042D59CDC4FD71C4FAFAC-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--02E827D16F9042D59CDC4FD71C4FAFAC-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--02E827D16F9042D59CDC4FD71C4FAFAC-->  <POSITION><![CDATA[10]]></POSITION>
+<!--02E827D16F9042D59CDC4FD71C4FAFAC-->  <POSITION><![CDATA[9]]></POSITION>
 <!--02E827D16F9042D59CDC4FD71C4FAFAC-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--02E827D16F9042D59CDC4FD71C4FAFAC-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--02E827D16F9042D59CDC4FD71C4FAFAC-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -237055,7 +237055,7 @@
 <!--02EDB5224DE54FBBA4DD9AA1C02CC5D3-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--02EDB5224DE54FBBA4DD9AA1C02CC5D3-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--02EDB5224DE54FBBA4DD9AA1C02CC5D3-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--02EDB5224DE54FBBA4DD9AA1C02CC5D3-->  <POSITION><![CDATA[16]]></POSITION>
+<!--02EDB5224DE54FBBA4DD9AA1C02CC5D3-->  <POSITION><![CDATA[14]]></POSITION>
 <!--02EDB5224DE54FBBA4DD9AA1C02CC5D3-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--02EDB5224DE54FBBA4DD9AA1C02CC5D3-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--02EDB5224DE54FBBA4DD9AA1C02CC5D3-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -280037,6 +280037,41 @@
 <!--6395A97EC1AB49A087A2EF98268EEE91-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
 <!--6395A97EC1AB49A087A2EF98268EEE91--></AD_COLUMN>
 
+<!--6399F0E18AA845A3BD26A185AE267D27--><AD_COLUMN>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <AD_COLUMN_ID><![CDATA[6399F0E18AA845A3BD26A185AE267D27]]></AD_COLUMN_ID>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <NAME><![CDATA[Createdtimestamp]]></NAME>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <COLUMNNAME><![CDATA[Createdtimestamp]]></COLUMNNAME>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <AD_TABLE_ID><![CDATA[C2968EF014C146B99A0C136BA9D6331F]]></AD_TABLE_ID>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <AD_REFERENCE_ID><![CDATA[11]]></AD_REFERENCE_ID>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <FIELDLENGTH><![CDATA[16]]></FIELDLENGTH>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <SEQNO><![CDATA[170]]></SEQNO>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <AD_ELEMENT_ID><![CDATA[873CE02C068C4E8A8E221AFDAD146011]]></AD_ELEMENT_ID>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <POSITION><![CDATA[16]]></POSITION>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ALLOWSORTING><![CDATA[Y]]></ALLOWSORTING>
+<!--6399F0E18AA845A3BD26A185AE267D27-->  <ALLOWFILTERING><![CDATA[Y]]></ALLOWFILTERING>
+<!--6399F0E18AA845A3BD26A185AE267D27--></AD_COLUMN>
+
 <!--63E3913B4A4442149EE454823668AF0F--><AD_COLUMN>
 <!--63E3913B4A4442149EE454823668AF0F-->  <AD_COLUMN_ID><![CDATA[63E3913B4A4442149EE454823668AF0F]]></AD_COLUMN_ID>
 <!--63E3913B4A4442149EE454823668AF0F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -324050,7 +324085,7 @@
 <!--9EC0340F24DC437F8381DE363CE8B509-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--9EC0340F24DC437F8381DE363CE8B509-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--9EC0340F24DC437F8381DE363CE8B509-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--9EC0340F24DC437F8381DE363CE8B509-->  <POSITION><![CDATA[12]]></POSITION>
+<!--9EC0340F24DC437F8381DE363CE8B509-->  <POSITION><![CDATA[11]]></POSITION>
 <!--9EC0340F24DC437F8381DE363CE8B509-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--9EC0340F24DC437F8381DE363CE8B509-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--9EC0340F24DC437F8381DE363CE8B509-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -324613,7 +324648,7 @@
 <!--9FD5B3AAA35C42B39EC38CA5BDE5BF1F-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--9FD5B3AAA35C42B39EC38CA5BDE5BF1F-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--9FD5B3AAA35C42B39EC38CA5BDE5BF1F-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--9FD5B3AAA35C42B39EC38CA5BDE5BF1F-->  <POSITION><![CDATA[11]]></POSITION>
+<!--9FD5B3AAA35C42B39EC38CA5BDE5BF1F-->  <POSITION><![CDATA[10]]></POSITION>
 <!--9FD5B3AAA35C42B39EC38CA5BDE5BF1F-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--9FD5B3AAA35C42B39EC38CA5BDE5BF1F-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--9FD5B3AAA35C42B39EC38CA5BDE5BF1F-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -343614,7 +343649,7 @@
 <!--C9D54228F6074BB5AAE975FB2A784CDB-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--C9D54228F6074BB5AAE975FB2A784CDB-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--C9D54228F6074BB5AAE975FB2A784CDB-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--C9D54228F6074BB5AAE975FB2A784CDB-->  <POSITION><![CDATA[13]]></POSITION>
+<!--C9D54228F6074BB5AAE975FB2A784CDB-->  <POSITION><![CDATA[12]]></POSITION>
 <!--C9D54228F6074BB5AAE975FB2A784CDB-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--C9D54228F6074BB5AAE975FB2A784CDB-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--C9D54228F6074BB5AAE975FB2A784CDB-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
@@ -354599,7 +354634,7 @@
 <!--D9A9BEACE89C41AE8035A4F7D892E5CC-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
 <!--D9A9BEACE89C41AE8035A4F7D892E5CC-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--D9A9BEACE89C41AE8035A4F7D892E5CC-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--D9A9BEACE89C41AE8035A4F7D892E5CC-->  <POSITION><![CDATA[14]]></POSITION>
+<!--D9A9BEACE89C41AE8035A4F7D892E5CC-->  <POSITION><![CDATA[13]]></POSITION>
 <!--D9A9BEACE89C41AE8035A4F7D892E5CC-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--D9A9BEACE89C41AE8035A4F7D892E5CC-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
 <!--D9A9BEACE89C41AE8035A4F7D892E5CC-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
--- a/src-db/database/sourcedata/AD_ELEMENT.xml	Thu Jun 30 18:04:33 2016 +0200
+++ b/src-db/database/sourcedata/AD_ELEMENT.xml	Tue Jul 05 12:48:48 2016 +0200
@@ -28708,6 +28708,18 @@
 <!--86DF1B3B331B03FEE040007F0101757D-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--86DF1B3B331B03FEE040007F0101757D--></AD_ELEMENT>
 
+<!--873CE02C068C4E8A8E221AFDAD146011--><AD_ELEMENT>
+<!--873CE02C068C4E8A8E221AFDAD146011-->  <AD_ELEMENT_ID><![CDATA[873CE02C068C4E8A8E221AFDAD146011]]></AD_ELEMENT_ID>
+<!--873CE02C068C4E8A8E221AFDAD146011-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--873CE02C068C4E8A8E221AFDAD146011-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--873CE02C068C4E8A8E221AFDAD146011-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--873CE02C068C4E8A8E221AFDAD146011-->  <COLUMNNAME><![CDATA[Createdtimestamp]]></COLUMNNAME>
+<!--873CE02C068C4E8A8E221AFDAD146011-->  <NAME><![CDATA[Createdtimestamp]]></NAME>
+<!--873CE02C068C4E8A8E221AFDAD146011-->  <PRINTNAME><![CDATA[Createdtimestamp]]></PRINTNAME>
+<!--873CE02C068C4E8A8E221AFDAD146011-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--873CE02C068C4E8A8E221AFDAD146011-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--873CE02C068C4E8A8E221AFDAD146011--></AD_ELEMENT>
+
 <!--8769BF2DBAED417E95CB5F5B31DC851A--><AD_ELEMENT>
 <!--8769BF2DBAED417E95CB5F5B31DC851A-->  <AD_ELEMENT_ID><![CDATA[8769BF2DBAED417E95CB5F5B31DC851A]]></AD_ELEMENT_ID>
 <!--8769BF2DBAED417E95CB5F5B31DC851A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/service/importprocess/ImportEntryManager.java	Thu Jun 30 18:04:33 2016 +0200
+++ b/src/org/openbravo/service/importprocess/ImportEntryManager.java	Tue Jul 05 12:48:48 2016 +0200
@@ -305,6 +305,7 @@
           OBContext.getOBContext().getRole().getId()));
       importEntry.setNewOBObject(true);
       importEntry.setImportStatus("Initial");
+      importEntry.setCreatedtimestamp((new Date()).getTime());
       importEntry.setImported(null);
       importEntry.setTypeofdata(typeOfData);
       importEntry.setJsonInfo(json);
@@ -563,7 +564,8 @@
                 final String importEntryQryStr = "from " + ImportEntry.ENTITY_NAME + " where "
                     + ImportEntry.PROPERTY_TYPEOFDATA + "='" + typeOfData + "' and "
                     + ImportEntry.PROPERTY_IMPORTSTATUS + "='Initial' order by "
-                    + ImportEntry.PROPERTY_CREATIONDATE;
+                    + ImportEntry.PROPERTY_CREATIONDATE + ", "
+                    + ImportEntry.PROPERTY_CREATEDTIMESTAMP;
 
                 final Query entriesQry = OBDal.getInstance().getSession()
                     .createQuery(importEntryQryStr);