Integrate patch [ 1634851 ] Multiple contacts at BP import operation

Thanks to Matjaž Godec - agenda_gm
This commit is contained in:
Carlos Ruiz 2007-08-07 01:12:58 +00:00
parent bc96531709
commit 343acadf87
2 changed files with 26 additions and 7 deletions

View File

@ -136,7 +136,8 @@ public final class ImpFormat
} }
else if (m_AD_Table_ID == 533) // I_BPartner else if (m_AD_Table_ID == 533) // I_BPartner
{ {
m_tableUnique1 = "Value"; // the key // gody: 20070113 to allow multiple contacts per BP
// m_tableUnique1 = "Value"; // the key
} }
else if (m_AD_Table_ID == 534) // I_ElementValue else if (m_AD_Table_ID == 534) // I_ElementValue
{ {

View File

@ -256,12 +256,25 @@ public class ImportBPartner extends SvrProcess
// Go through Records // Go through Records
sql = new StringBuffer ("SELECT * FROM I_BPartner " sql = new StringBuffer ("SELECT * FROM I_BPartner "
+ "WHERE I_IsImported='N'").append(clientCheck); + "WHERE I_IsImported='N'").append(clientCheck);
// gody: 20070113 - Order so the same values are consecutive.
sql.append(" ORDER BY Value, I_BPartner_ID");
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); PreparedStatement pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
// Remember Previous BP Value BP is only first one, others are contacts.
// All contacts share BP location.
// bp and bpl declarations before loop, we need them for data.
String Old_BPValue = "" ;
MBPartner bp = null;
MBPartnerLocation bpl = null;
while (rs.next()) while (rs.next())
{ {
// Remember Value - only first occurance of the value is BP
String New_BPValue = rs.getString("Value") ;
X_I_BPartner impBP = new X_I_BPartner (getCtx(), rs, get_TrxName()); X_I_BPartner impBP = new X_I_BPartner (getCtx(), rs, get_TrxName());
log.fine("I_BPartner_ID=" + impBP.getI_BPartner_ID() log.fine("I_BPartner_ID=" + impBP.getI_BPartner_ID()
+ ", C_BPartner_ID=" + impBP.getC_BPartner_ID() + ", C_BPartner_ID=" + impBP.getC_BPartner_ID()
@ -269,8 +282,10 @@ public class ImportBPartner extends SvrProcess
+ ", AD_User_ID=" + impBP.getAD_User_ID()); + ", AD_User_ID=" + impBP.getAD_User_ID());
// **** Create/Update BPartner **** if ( ! New_BPValue.equals(Old_BPValue)) {
MBPartner bp = null; // **** Create/Update BPartner ****
bp = null;
if (impBP.getC_BPartner_ID() == 0) // Insert new BPartner if (impBP.getC_BPartner_ID() == 0) // Insert new BPartner
{ {
bp = new MBPartner(impBP); bp = new MBPartner(impBP);
@ -328,7 +343,7 @@ public class ImportBPartner extends SvrProcess
} }
// **** Create/Update BPartner Location **** // **** Create/Update BPartner Location ****
MBPartnerLocation bpl = null; bpl = null;
if (impBP.getC_BPartner_Location_ID() != 0) // Update Location if (impBP.getC_BPartner_Location_ID() != 0) // Update Location
{ {
bpl = new MBPartnerLocation(getCtx(), impBP.getC_BPartner_Location_ID(), get_TrxName()); bpl = new MBPartnerLocation(getCtx(), impBP.getC_BPartner_Location_ID(), get_TrxName());
@ -398,7 +413,10 @@ public class ImportBPartner extends SvrProcess
DB.executeUpdate(sql.toString(), get_TrxName()); DB.executeUpdate(sql.toString(), get_TrxName());
continue; continue;
} }
} }
}
Old_BPValue = New_BPValue ;
// **** Create/Update Contact **** // **** Create/Update Contact ****
MUser user = null; MUser user = null;