Importers
This page is related to bug with artifact ID 2915713 titled "Importers ignoring exceptions".
This page shall help discuss and fix this bug.
Contents
- 1 Bug details
- 2 Importers
- 3 Related Process
- 4 Fixing the bug
Bug details
Most of importers have a big bad practice logic ignoring exceptions.
Some of them just report the exception and continue, like ImportPayment
catch(Exception e) { log.log(Level.SEVERE, sql.toString(), e); }
Other are even worst like ImportProduct catch (SQLException e) { }
We need a deep review on correct behavior - some exceptions must break the process completely, others can be checked and logged.
This is priority 9 because it can lead to data errors as the import proceed importing some records and others don't, but potentially don't notify the user and/or update the imported record.
Regards,
Carlos Ruiz
Importers
The import processes are in
package org.compiere.process
ImportAccount
Purpose
- Import Accounts from I_ElementValue
Parameters
- AD_Client_ID
- C_Element_ID
- UpdateDefaultAccounts
- CreateNewCombination
- DeleteOldImported
Code
// Delete Old Imported // Set Client, Org, IsActive, Created/Updated // Set Element // // // No Name, Value // Set Column // // Set Post* Defaults (ignore errors) // Summary // Doc Controlled // Check Account Type A (E) L M O R // // Check Account Sign (N) C B // // No Value // **** Update ElementValue from existing // ------------------------------------------------------------------- // Go through Records try { // **** Create/Update ElementValue } catch (SQLException e) { throw new Exception ("create", e); } // Set Error to indicator to not imported // ***** Set Parent try { } catch (SQLException e) { log.log(Level.SEVERE, "(ParentUpdateLoop) " + sql.toString(), e); } // Reset Processing Flag // Update Description // Done
ImportBankStatement
Purpose
- Import Bank Statement from I_BankStatement
Parameters
- AD_Client_ID
- AD_Org_ID
- C_BankAccount_ID
- DeleteOldImported
Code
// Delete Old Imported // Set Client, Org, IsActive, Created/Updated // Set Bank Account // // // Set Currency // // // Set Amount // // // Set Valuta Date // Check Payment<->Invoice combination // Check Payment<->BPartner combination // Check Invoice<->BPartner combination // Check Invoice.BPartner<->Payment.BPartner combination // Detect Duplicates try { } catch(Exception e) { log.log(Level.SEVERE, "DetectDuplicates " + e.getMessage()); } //Import Bank Statement try { } catch(Exception e) { log.log(Level.SEVERE, sql.toString(), e); } // Set Error to indicator to not imported
ImportBPartner
Purpose
- Import BPartners from I_BPartner
Parameters
- AD_Client_ID
- DeleteOldImported
- IsValidateOnly
Code
// Delete Old Imported // Set Client, Org, IsActive, Created/Updated // Set BP_Group // // // Set Country // // // Set Region // Set Greeting // // // Existing User ? // Existing BPartner ? Match Value // Existing Contact ? Match Name // Existing Location ? Exact Match // Interest Area // Value is mandatory error // Go through Records try { // **** Create/Update BPartner **** // **** Create/Update BPartner Location **** // **** Create/Update Contact **** // Interest Area } catch (SQLException e) { rollback(); //log.log(Level.SEVERE, "", e); throw new DBException(e, sql.toString()); } finally { DB.close(rs, pstmt); rs = null; pstmt = null; // Set Error to indicator to not imported sql = new StringBuffer ("UPDATE I_BPartner " + "SET I_IsImported='N', Updated=SysDate " + "WHERE I_IsImported<>'Y'").append(clientCheck); no = DB.executeUpdateEx(sql.toString(), get_TrxName()); addLog (0, null, new BigDecimal (no), "@Errors@"); addLog (0, null, new BigDecimal (noInsert), "@C_BPartner_ID@: @Inserted@"); addLog (0, null, new BigDecimal (noUpdate), "@C_BPartner_ID@: @Updated@"); }
ImportConversionRate
ImpportGLJournal
ImportInOutConfirm
ImportInventory
ImportInvoice
ImportOrder
ImportPayment
ImportProduct
ImportReportLine
Related Process
ImportDelete
Purpose
Parameters
Code
Fixing the bug
The collection of exceptions to be thrown where applicable (besides java.lang.Exception) are in
package org.adempiere.exceptions
- AdempiereException
- Any exception that occurs inside the Adempiere core
- DBException
- This RuntimeException is used to pass SQLException up the chain of calling
- methods to determine what to do where needed.
package org.compiere.util
- Adempiere User Error.
- Cuased by (lack of) user input/selection.
- (No program error)
- Adempiere System Error.
- Error caused by invalid configurations, etc.
- (No program error)