IDEMPIERE-671 AD_ImpFormat.Name unique is wrong - must have AD_Client in the unique index
This commit is contained in:
parent
5776804b4a
commit
de9b233f88
|
@ -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
|
||||||
|
;
|
||||||
|
|
|
@ -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
|
||||||
|
;
|
||||||
|
|
|
@ -150,14 +150,7 @@ public final class ImpFormat
|
||||||
m_tableUniqueParent = "";
|
m_tableUniqueParent = "";
|
||||||
m_tableUniqueChild = "";
|
m_tableUniqueChild = "";
|
||||||
|
|
||||||
if (m_AD_Table_ID == 311) // I_061_SyncItem
|
if (m_AD_Table_ID == TABLE_I_PRODUCT) // I_Product
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
m_tableUnique1 = "UPC"; // UPC = unique
|
m_tableUnique1 = "UPC"; // UPC = unique
|
||||||
m_tableUnique2 = "Value";
|
m_tableUnique2 = "Value";
|
||||||
|
@ -266,26 +259,24 @@ public final class ImpFormat
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Factory load
|
* Factory load
|
||||||
* @param name name
|
* @param Id id
|
||||||
* @return Import Format
|
* @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;
|
ImpFormat retValue = null;
|
||||||
String sql = "SELECT * FROM AD_ImpFormat WHERE Name=?";
|
String sql = "SELECT * FROM AD_ImpFormat WHERE AD_Impformat_ID=?";
|
||||||
int ID = 0;
|
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, null);
|
||||||
pstmt.setString (1, name);
|
pstmt.setInt (1, Id);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
{
|
{
|
||||||
retValue = new ImpFormat (name, rs.getInt("AD_Table_ID"), rs.getString("FormatType"));
|
retValue = new ImpFormat (rs.getString("Name"), rs.getInt("AD_Table_ID"), rs.getString("FormatType"));
|
||||||
ID = rs.getInt ("AD_ImpFormat_ID");
|
|
||||||
if (X_AD_ImpFormat.FORMATTYPE_CustomSeparatorChar.equals(rs.getString(I_AD_ImpFormat.COLUMNNAME_FormatType))) {
|
if (X_AD_ImpFormat.FORMATTYPE_CustomSeparatorChar.equals(rs.getString(I_AD_ImpFormat.COLUMNNAME_FormatType))) {
|
||||||
retValue.setSeparatorChar(rs.getString(I_AD_ImpFormat.COLUMNNAME_SeparatorChar));
|
retValue.setSeparatorChar(rs.getString(I_AD_ImpFormat.COLUMNNAME_SeparatorChar));
|
||||||
}
|
}
|
||||||
|
@ -302,7 +293,7 @@ public final class ImpFormat
|
||||||
rs = null;
|
rs = null;
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
loadRows (retValue, ID);
|
loadRows (retValue, Id);
|
||||||
return retValue;
|
return retValue;
|
||||||
} // getFormat
|
} // getFormat
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Ini;
|
import org.compiere.util.Ini;
|
||||||
|
import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,8 +206,8 @@ public class VFileImport extends CPanel
|
||||||
private void dynInit()
|
private void dynInit()
|
||||||
{
|
{
|
||||||
// Load Formats
|
// Load Formats
|
||||||
pickFormat.addItem(s_none);
|
pickFormat.addItem(new KeyNamePair(-1,s_none));
|
||||||
String sql = MRole.getDefault().addAccessSQL("SELECT Name FROM AD_ImpFormat", "AD_ImpFormat",
|
String sql = MRole.getDefault().addAccessSQL("SELECT AD_Impformat_ID,Name FROM AD_ImpFormat WHERE isactive='Y'", "AD_ImpFormat",
|
||||||
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
|
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
|
@ -215,7 +216,7 @@ public class VFileImport extends CPanel
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, null);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
pickFormat.addItem(rs.getString(1));
|
pickFormat.addItem(new KeyNamePair(rs.getInt(1),rs.getString(2)));
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
|
@ -373,13 +374,13 @@ public class VFileImport extends CPanel
|
||||||
// clear panel
|
// clear panel
|
||||||
previewPanel.removeAll();
|
previewPanel.removeAll();
|
||||||
//
|
//
|
||||||
String formatName = pickFormat.getSelectedItem().toString();
|
KeyNamePair pickFormatKNPair = (KeyNamePair)pickFormat.getSelectedItem();
|
||||||
if (formatName.equals(s_none))
|
if (pickFormatKNPair.getName().equals(s_none))
|
||||||
return;
|
return;
|
||||||
m_format = ImpFormat.load (formatName);
|
m_format = ImpFormat.load (pickFormatKNPair.getKey());
|
||||||
if (m_format == null)
|
if (m_format == null)
|
||||||
{
|
{
|
||||||
ADialog.error(m_WindowNo, this, "FileImportNoFormat", formatName);
|
ADialog.error(m_WindowNo, this, "FileImportNoFormat", pickFormatKNPair.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,7 @@ public class WFileImport extends ADForm implements EventListener<Event>
|
||||||
// Load Formats
|
// Load Formats
|
||||||
pickFormat.appendItem(s_none, s_none);
|
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);
|
MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
|
@ -243,7 +243,7 @@ public class WFileImport extends ADForm implements EventListener<Event>
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
|
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
pickFormat.appendItem(rs.getString(1), rs.getString(1));
|
pickFormat.appendItem(rs.getString(1), rs.getInt(2));
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
|
@ -451,12 +451,13 @@ public class WFileImport extends ADForm implements EventListener<Event>
|
||||||
|
|
||||||
ListItem listitem = pickFormat.getSelectedItem();
|
ListItem listitem = pickFormat.getSelectedItem();
|
||||||
|
|
||||||
String formatName = (String)listitem.getValue();
|
String formatName = (String)listitem.getLabel();
|
||||||
|
|
||||||
if (formatName.equals(s_none))
|
if (formatName.equals(s_none))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_format = ImpFormat.load (formatName);
|
int formatId = (Integer)listitem.getValue();
|
||||||
|
m_format = ImpFormat.load (formatId);
|
||||||
|
|
||||||
if (m_format == null)
|
if (m_format == null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue