IDEMPIERE-1649 Reference of User1_id, User2_id in new table is create incorrect / based on patch from Hiep

This commit is contained in:
Carlos Ruiz 2014-03-13 11:02:16 -05:00
parent bc9b8049bc
commit b90759bae2
6 changed files with 152 additions and 56 deletions

View File

@ -0,0 +1,19 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Mar 12, 2014 4:51:42 PM COT
-- IDEMPIERE-1649 set tab default
UPDATE AD_Column SET DefaultValue='Y',Updated=TO_DATE('2014-03-12 16:51:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=166
;
-- Mar 12, 2014 4:52:00 PM COT
ALTER TABLE AD_Tab MODIFY IsSingleRow CHAR(1) DEFAULT 'Y'
;
-- Mar 12, 2014 4:52:02 PM COT
UPDATE AD_Tab SET IsSingleRow='Y' WHERE IsSingleRow IS NULL
;
SELECT register_migration_script('201403121652_IDEMPIERE-1649.sql') FROM dual
;

View File

@ -0,0 +1,16 @@
-- Mar 12, 2014 4:51:42 PM COT
-- IDEMPIERE-1649 set tab default
UPDATE AD_Column SET DefaultValue='Y',Updated=TO_TIMESTAMP('2014-03-12 16:51:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=166
;
-- Mar 12, 2014 4:52:00 PM COT
INSERT INTO t_alter_column values('ad_tab','IsSingleRow','CHAR(1)',null,'Y')
;
-- Mar 12, 2014 4:52:02 PM COT
UPDATE AD_Tab SET IsSingleRow='Y' WHERE IsSingleRow IS NULL
;
SELECT register_migration_script('201403121652_IDEMPIERE-1649.sql') FROM dual
;

View File

@ -30,7 +30,7 @@ import org.compiere.util.DisplayType;
public class Callout_AD_Column extends CalloutEngine
{
public String columnName (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
{
{ // IDEMPIERE-1011 - dup code on MColumn.setmartDefaults
I_AD_Column column = GridTabWrapper.create(mTab, I_AD_Column.class);
if (MColumn.isSuggestSelectionColumn(column.getColumnName(), true))
column.setIsSelectionColumn(true);

View File

@ -157,6 +157,21 @@ public class TabCreateFields extends SvrProcess
}
}
//set display logic for accounting dimensions
if (column.getColumnName().equalsIgnoreCase("AD_OrgTrx_ID")){
field.setDisplayLogic("@$Element_OT@=Y");
} else if (column.getColumnName().equalsIgnoreCase("C_Campaign_ID")) {
field.setDisplayLogic("@$Element_MC@=Y");
} else if (column.getColumnName().equalsIgnoreCase("C_Activity_ID")) {
field.setDisplayLogic("@$Element_AY@=Y");
} else if (column.getColumnName().equalsIgnoreCase("C_Project_ID")) {
field.setDisplayLogic("@$Element_PJ@=Y");
} else if (column.getColumnName().equalsIgnoreCase("User1_ID")) {
field.setDisplayLogic("@$Element_U1@=Y");
} else if (column.getColumnName().equalsIgnoreCase("User2_ID")) {
field.setDisplayLogic("@$Element_U2@=Y");
}
if (field.save())
{
addLog(0, null, null, column.getName());

View File

@ -273,38 +273,12 @@ public class TableCreateColumns extends SvrProcess
column.setAD_Element_ID (element.getAD_Element_ID ());
//
column.setIsMandatory ("NO".equals (nullable));
// Key
if (columnName.equalsIgnoreCase (tableName + "_ID"))
{
column.setIsKey (true);
column.setAD_Reference_ID (DisplayType.ID);
column.setIsUpdateable(false);
}
//handle uuid column xolali bug IDEMPIERE-971
if (columnName.equalsIgnoreCase (PO.getUUIDColumnName(table.getTableName())))
{
column.setAD_Reference_ID (DisplayType.String);
column.setIsUpdateable(false);
column.setIsAllowCopy(false);
}
// Account
// bug [ 1637912 ]
else if (columnName.toUpperCase ().endsWith("_ACCT")
if (columnName.toUpperCase ().endsWith("_ACCT")
&& size == 10)
column.setAD_Reference_ID (DisplayType.Account);
// Account
else if (columnName.equalsIgnoreCase ("C_Location_ID"))
column.setAD_Reference_ID (DisplayType.Location);
// Product Attribute
else if (columnName.equalsIgnoreCase ("M_AttributeSetInstance_ID"))
column.setAD_Reference_ID (DisplayType.PAttribute);
// SalesRep_ID (=User)
else if (columnName.equalsIgnoreCase ("SalesRep_ID"))
{
column.setAD_Reference_ID (DisplayType.Table);
column.setAD_Reference_Value_ID (190);
}
// ID
else if (columnName.toUpperCase().endsWith ("_ID"))
column.setAD_Reference_ID (DisplayType.TableDir);
@ -315,20 +289,6 @@ public class TableCreateColumns extends SvrProcess
|| columnName.equalsIgnoreCase ("Created")
|| columnName.equalsIgnoreCase ("Updated"))
column.setAD_Reference_ID (DisplayType.DateTime);
// CreatedBy/UpdatedBy (=User)
else if (columnName.equalsIgnoreCase ("CreatedBy")
|| columnName.equalsIgnoreCase ("UpdatedBy"))
{
column.setAD_Reference_ID (DisplayType.Table);
column.setAD_Reference_Value_ID (110);
column.setIsUpdateable(false);
}
// Entity Type
else if (columnName.equalsIgnoreCase ("EntityType"))
{
column.setAD_Reference_ID (DisplayType.Table);
column.setAD_Reference_Value_ID (389);
}
// CLOB
else if (dataType == Types.CLOB)
column.setAD_Reference_ID (DisplayType.TextLong);
@ -348,14 +308,6 @@ public class TableCreateColumns extends SvrProcess
// List
else if (size < 4 && dataType == Types.CHAR)
column.setAD_Reference_ID (DisplayType.List);
// Name, DocumentNo
else if (columnName.equalsIgnoreCase ("Name")
|| columnName.equals ("DocumentNo"))
{
column.setAD_Reference_ID (DisplayType.String);
column.setIsIdentifier (true);
column.setSeqNo (1);
}
// String, Text
else if (dataType == Types.CHAR || dataType == Types.VARCHAR
|| typeName.startsWith ("NVAR")
@ -381,6 +333,8 @@ public class TableCreateColumns extends SvrProcess
else
column.setAD_Reference_ID (DisplayType.String);
column.setSmartDefaults();
column.setFieldLength (size);
if (column.isUpdateable()
&& (table.isView()
@ -390,10 +344,6 @@ public class TableCreateColumns extends SvrProcess
|| columnName.toUpperCase().equals("UPDATED") ))
column.setIsUpdateable(false);
// Check if is a possible selection column
if (MColumn.isSuggestSelectionColumn(column.getColumnName(), false))
column.setIsSelectionColumn(true);
// Done
if (column.save ())
{

View File

@ -48,7 +48,7 @@ public class MColumn extends X_AD_Column
/**
*
*/
private static final long serialVersionUID = 4321132594207949196L;
private static final long serialVersionUID = -4372212315789445915L;
/**
* Get MColumn from Cache
@ -734,4 +734,100 @@ public class MColumn extends X_AD_Column
return foreignTable;
}
public void setSmartDefaults() { // IDEMPIERE-1649 - dup code on Callout_AD_Column.columnName
if (MColumn.isSuggestSelectionColumn(getColumnName(), true))
setIsSelectionColumn(true);
// IDEMPIERE-1011
if (PO.getUUIDColumnName(getAD_Table().getTableName()).equals(getColumnName())) {
// UUID column
setAD_Reference_ID(DisplayType.String);
setAD_Val_Rule_ID(0);
setAD_Reference_Value_ID(0);
setFieldLength(36);
setDefaultValue(null);
setMandatoryLogic(null);
setReadOnlyLogic(null);
setIsIdentifier(false);
setIsUpdateable(false);
setIsAlwaysUpdateable(false);
setIsKey(true);
} else if (getAD_Table().getTableName().concat("_ID").equals(getColumnName())) {
// ID key column
setAD_Reference_ID(DisplayType.ID);
setAD_Val_Rule_ID(0);
setAD_Reference_Value_ID(0);
setFieldLength(22);
setDefaultValue(null);
setMandatoryLogic(null);
setReadOnlyLogic(null);
setIsIdentifier(false);
setIsUpdateable(false);
setIsAlwaysUpdateable(false);
} else {
// get defaults from most used case
String sql = ""
+ "SELECT AD_Reference_ID, "
+ " AD_Val_Rule_ID, "
+ " AD_Reference_Value_ID, "
+ " FieldLength, "
+ " DefaultValue, "
+ " MandatoryLogic, "
+ " ReadOnlyLogic, "
+ " IsIdentifier, "
+ " IsUpdateable, "
+ " IsAlwaysUpdateable, "
+ " FKConstraintType,"
+ " COUNT(*) "
+ "FROM AD_Column "
+ "WHERE ColumnName = ? "
+ "GROUP BY AD_Reference_ID, "
+ " AD_Val_Rule_ID, "
+ " AD_Reference_Value_ID, "
+ " FieldLength, "
+ " DefaultValue, "
+ " MandatoryLogic, "
+ " ReadOnlyLogic, "
+ " IsIdentifier, "
+ " IsUpdateable, "
+ " IsAlwaysUpdateable, "
+ " FKConstraintType "
+ "ORDER BY COUNT(*) DESC ";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setString(1, getColumnName());
rs = pstmt.executeQuery();
if (rs.next()) {
int ad_reference_id = rs.getInt(1);
if (ad_reference_id == DisplayType.ID)
ad_reference_id = DisplayType.TableDir;
setAD_Reference_ID(ad_reference_id);
setAD_Val_Rule_ID(rs.getInt(2));
setAD_Reference_Value_ID(rs.getInt(3));
setFieldLength(rs.getInt(4));
setDefaultValue(rs.getString(5));
setMandatoryLogic(rs.getString(6));
setReadOnlyLogic(rs.getString(7));
setIsIdentifier("Y".equals(rs.getString(8)));
setIsUpdateable("Y".equals(rs.getString(9)));
setIsAlwaysUpdateable("Y".equals(rs.getString(10)));
setFKConstraintType(rs.getString(11));
}
}
catch (SQLException e)
{
throw new DBException(e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
}
} // MColumn