IDEMPIERE-671 AD_ImpFormat.Name unique is wrong - must have AD_Client in the unique index

This commit is contained in:
Richard Morales 2013-03-03 13:49:06 -05:00
parent 5776804b4a
commit de9b233f88
5 changed files with 41 additions and 30 deletions

View File

@ -0,0 +1,9 @@
DROP INDEX ad_impformat_name
;
CREATE UNIQUE INDEX ad_impformat_name
ON ad_impformat (ad_client_id, name)
;
SELECT register_migration_script('201303010917_IDEMPIERE-671.sql') FROM dual
;

View File

@ -0,0 +1,9 @@
DROP INDEX ad_impformat_name
;
CREATE UNIQUE INDEX ad_impformat_name
ON ad_impformat (ad_client_id, name)
;
SELECT register_migration_script('201303010917_IDEMPIERE-671.sql') FROM dual
;

View File

@ -150,14 +150,7 @@ public final class ImpFormat
m_tableUniqueParent = "";
m_tableUniqueChild = "";
if (m_AD_Table_ID == 311) // I_061_SyncItem
{
m_tableUnique1 = "H_UPC"; // UPC = unique
m_tableUnique2 = "Value";
m_tableUniqueChild = "H_Commodity1"; // Vendor No may not be unique !
m_tableUniqueParent = "H_PartnrID"; // Makes it unique
}
else if (m_AD_Table_ID == TABLE_I_PRODUCT) // I_Product
if (m_AD_Table_ID == TABLE_I_PRODUCT) // I_Product
{
m_tableUnique1 = "UPC"; // UPC = unique
m_tableUnique2 = "Value";
@ -266,26 +259,24 @@ public final class ImpFormat
/*************************************************************************
* Factory load
* @param name name
* @param Id id
* @return Import Format
*/
public static ImpFormat load (String name)
public static ImpFormat load (int Id)
{
log.config(name);
if (log.isLoggable(Level.CONFIG))log.config(String.valueOf(Id));
ImpFormat retValue = null;
String sql = "SELECT * FROM AD_ImpFormat WHERE Name=?";
int ID = 0;
String sql = "SELECT * FROM AD_ImpFormat WHERE AD_Impformat_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setString (1, name);
pstmt.setInt (1, Id);
rs = pstmt.executeQuery();
if (rs.next())
{
retValue = new ImpFormat (name, rs.getInt("AD_Table_ID"), rs.getString("FormatType"));
ID = rs.getInt ("AD_ImpFormat_ID");
retValue = new ImpFormat (rs.getString("Name"), rs.getInt("AD_Table_ID"), rs.getString("FormatType"));
if (X_AD_ImpFormat.FORMATTYPE_CustomSeparatorChar.equals(rs.getString(I_AD_ImpFormat.COLUMNNAME_FormatType))) {
retValue.setSeparatorChar(rs.getString(I_AD_ImpFormat.COLUMNNAME_SeparatorChar));
}
@ -302,7 +293,7 @@ public final class ImpFormat
rs = null;
pstmt = null;
}
loadRows (retValue, ID);
loadRows (retValue, Id);
return retValue;
} // getFormat

View File

@ -56,6 +56,7 @@ import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Ini;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
@ -205,8 +206,8 @@ public class VFileImport extends CPanel
private void dynInit()
{
// Load Formats
pickFormat.addItem(s_none);
String sql = MRole.getDefault().addAccessSQL("SELECT Name FROM AD_ImpFormat", "AD_ImpFormat",
pickFormat.addItem(new KeyNamePair(-1,s_none));
String sql = MRole.getDefault().addAccessSQL("SELECT AD_Impformat_ID,Name FROM AD_ImpFormat WHERE isactive='Y'", "AD_ImpFormat",
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
@ -215,7 +216,7 @@ public class VFileImport extends CPanel
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
pickFormat.addItem(rs.getString(1));
pickFormat.addItem(new KeyNamePair(rs.getInt(1),rs.getString(2)));
}
catch (SQLException e)
{
@ -373,13 +374,13 @@ public class VFileImport extends CPanel
// clear panel
previewPanel.removeAll();
//
String formatName = pickFormat.getSelectedItem().toString();
if (formatName.equals(s_none))
return;
m_format = ImpFormat.load (formatName);
KeyNamePair pickFormatKNPair = (KeyNamePair)pickFormat.getSelectedItem();
if (pickFormatKNPair.getName().equals(s_none))
return;
m_format = ImpFormat.load (pickFormatKNPair.getKey());
if (m_format == null)
{
ADialog.error(m_WindowNo, this, "FileImportNoFormat", formatName);
ADialog.error(m_WindowNo, this, "FileImportNoFormat", pickFormatKNPair.getName());
return;
}

View File

@ -233,7 +233,7 @@ public class WFileImport extends ADForm implements EventListener<Event>
// Load Formats
pickFormat.appendItem(s_none, s_none);
String sql = MRole.getDefault().addAccessSQL("SELECT Name FROM AD_ImpFormat", "AD_ImpFormat",
String sql = MRole.getDefault().addAccessSQL("SELECT Name,AD_Impformat_ID FROM AD_ImpFormat WHERE isactive='Y'", "AD_ImpFormat",
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
PreparedStatement pstmt = null;
ResultSet rs = null;
@ -243,7 +243,7 @@ public class WFileImport extends ADForm implements EventListener<Event>
rs = pstmt.executeQuery();
while (rs.next())
pickFormat.appendItem(rs.getString(1), rs.getString(1));
pickFormat.appendItem(rs.getString(1), rs.getInt(2));
}
catch (SQLException e)
{
@ -451,12 +451,13 @@ public class WFileImport extends ADForm implements EventListener<Event>
ListItem listitem = pickFormat.getSelectedItem();
String formatName = (String)listitem.getValue();
String formatName = (String)listitem.getLabel();
if (formatName.equals(s_none))
return;
m_format = ImpFormat.load (formatName);
int formatId = (Integer)listitem.getValue();
m_format = ImpFormat.load (formatId);
if (m_format == null)
{