IDEMPIERE-5444 Refactoring of GridTabVO and GridFieldVO (#1519)

This commit is contained in:
hengsin 2022-10-11 22:00:08 +08:00 committed by GitHub
parent 4474a0ede2
commit 62bbb83cb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 131 additions and 190 deletions

View File

@ -21,7 +21,6 @@ import static org.compiere.model.SystemIDs.REFERENCE_AD_USER;
import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Comparator;
import java.util.Properties;
@ -88,8 +87,8 @@ public class GridFieldVO implements Serializable, Cloneable
* @param AD_Window_ID window
* @param AD_Tab_ID tab
* @param readOnly r/o
* @param rs resultset AD_Field_v
* @return MFieldVO
* @param rs resultset AD_Field_v/AD_Field_vt
* @return GridFieldVO
*/
public static GridFieldVO create (Properties ctx, int WindowNo, int TabNo,
int AD_Window_ID, int AD_Tab_ID, boolean readOnly, ResultSet rs)
@ -224,165 +223,97 @@ public class GridFieldVO implements Serializable, Cloneable
boolean readOnly, ResultSet rs) {
GridFieldVO vo = new GridFieldVO (ctx, WindowNo, TabNo,
AD_Window_ID, AD_Tab_ID, readOnly);
String columnName = "ColumnName";
try
{
vo.ColumnName = rs.getString("ColumnName");
if (vo.ColumnName == null)
return null;
CLogger.get().fine(vo.ColumnName);
ResultSetMetaData rsmd = rs.getMetaData();
for (int i = 1; i <= rsmd.getColumnCount(); i++)
vo.Header = rs.getString ("Name");
vo.displayType = rs.getInt ("AD_Reference_ID");
vo.AD_Column_ID = rs.getInt ("AD_Column_ID");
vo.AD_Table_ID = rs.getInt ("AD_Table_ID");
vo.DisplayLength = rs.getInt ("DisplayLength");
vo.IsSameLine = "Y".equals(rs.getString ("IsSameLine"));
vo.IsDisplayed = "Y".equals(rs.getString ("IsDisplayed"));
vo.IsDisplayedGrid = "Y".equals(rs.getString ("IsDisplayedGrid"));
vo.SeqNo = rs.getInt ("SeqNo");
vo.SeqNoGrid = rs.getInt ("SeqNoGrid");
vo.DisplayLogic = rs.getString ("DisplayLogic");
vo.DefaultValue = rs.getString ("DefaultValue");
vo.IsMandatory = "Y".equals(rs.getString ("IsMandatory"));
vo.IsReadOnly = "Y".equals(rs.getString ("IsReadOnly"));
vo.IsUpdateable = "Y".equals(rs.getString ("IsUpdateable"));
vo.IsAlwaysUpdateable = "Y".equals(rs.getString ("IsAlwaysUpdateable"));
vo.IsHeading = "Y".equals(rs.getString ("IsHeading"));
vo.IsFieldOnly = "Y".equals(rs.getString ("IsFieldOnly"));
vo.IsEncryptedField = "Y".equals(rs.getString ("IsEncryptedField"));
vo.IsEncryptedColumn = "Y".equals(rs.getString ("IsEncryptedColumn"));
vo.IsSelectionColumn = "Y".equals(rs.getString ("IsSelectionColumn"));
vo.SeqNoSelection = rs.getInt ("SeqNoSelection");
vo.SortNo = rs.getInt ("SortNo");
vo.FieldLength = rs.getInt ("FieldLength");
vo.VFormat = rs.getString ("VFormat");
vo.FormatPattern = rs.getString ("FormatPattern");
vo.ValueMin = rs.getString ("ValueMin");
vo.ValueMax = rs.getString ("ValueMax");
vo.FieldGroup = rs.getString ("FieldGroup");
vo.FieldGroupType = rs.getString ("FieldGroupType");
vo.IsKey = "Y".equals(rs.getString ("IsKey"));
vo.IsParent = "Y".equals(rs.getString ("IsParent"));
{
columnName = rsmd.getColumnName (i);
if (columnName.equalsIgnoreCase("Name"))
vo.Header = rs.getString (i);
else if (columnName.equalsIgnoreCase("AD_Reference_ID"))
vo.displayType = rs.getInt (i);
else if (columnName.equalsIgnoreCase("AD_Column_ID"))
vo.AD_Column_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("AD_Table_ID"))
vo.AD_Table_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("DisplayLength"))
vo.DisplayLength = rs.getInt (i);
else if (columnName.equalsIgnoreCase("IsSameLine"))
vo.IsSameLine = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsDisplayed"))
vo.IsDisplayed = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsDisplayedGrid"))
vo.IsDisplayedGrid = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("SeqNo"))
vo.SeqNo = rs.getInt (i);
else if (columnName.equalsIgnoreCase("SeqNoGrid"))
vo.SeqNoGrid = rs.getInt (i);
else if (columnName.equalsIgnoreCase("DisplayLogic"))
vo.DisplayLogic = rs.getString (i);
else if (columnName.equalsIgnoreCase("DefaultValue"))
vo.DefaultValue = rs.getString (i);
else if (columnName.equalsIgnoreCase("IsMandatory"))
vo.IsMandatory = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsReadOnly"))
vo.IsReadOnly = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsUpdateable"))
vo.IsUpdateable = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsAlwaysUpdateable"))
vo.IsAlwaysUpdateable = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsHeading"))
vo.IsHeading = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsFieldOnly"))
vo.IsFieldOnly = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsEncryptedField"))
vo.IsEncryptedField = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsEncryptedColumn"))
vo.IsEncryptedColumn = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsSelectionColumn"))
vo.IsSelectionColumn = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("SeqNoSelection"))
vo.SeqNoSelection = rs.getInt (i);
else if (columnName.equalsIgnoreCase("SortNo"))
vo.SortNo = rs.getInt (i);
else if (columnName.equalsIgnoreCase("FieldLength"))
vo.FieldLength = rs.getInt (i);
else if (columnName.equalsIgnoreCase("VFormat"))
vo.VFormat = rs.getString (i);
else if (columnName.equalsIgnoreCase("FormatPattern"))
vo.FormatPattern = rs.getString (i);
else if (columnName.equalsIgnoreCase("ValueMin"))
vo.ValueMin = rs.getString (i);
else if (columnName.equalsIgnoreCase("ValueMax"))
vo.ValueMax = rs.getString (i);
else if (columnName.equalsIgnoreCase("FieldGroup"))
vo.FieldGroup = rs.getString (i);
else if (columnName.equalsIgnoreCase("FieldGroupType"))
vo.FieldGroupType = rs.getString (i);
else if (columnName.equalsIgnoreCase("IsKey"))
vo.IsKey = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("IsParent"))
vo.IsParent = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("Description"))
{
String s = rs.getString (i);
String s = rs.getString ("Description");
vo.Description = s != null ? s.intern() : s;
}
else if (columnName.equalsIgnoreCase("Help"))
{
String s = rs.getString (i);
String s = rs.getString ("Help");
vo.Help = s != null ? s.intern() : s;
}
else if (columnName.equalsIgnoreCase("Callout"))
vo.Callout = rs.getString (i);
else if (columnName.equalsIgnoreCase("AD_Process_ID"))
vo.AD_Process_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("AD_InfoWindow_ID"))
vo.AD_InfoWindow_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("ReadOnlyLogic"))
vo.ReadOnlyLogic = rs.getString (i);
else if (columnName.equalsIgnoreCase("AlwaysUpdatableLogic"))
vo.AlwaysUpdatableLogic = rs.getString (i);
else if (columnName.equalsIgnoreCase("MandatoryLogic"))
vo.MandatoryLogic = rs.getString (i);
else if (columnName.equalsIgnoreCase("ObscureType"))
vo.ObscureType = rs.getString (i);
else if (columnName.equalsIgnoreCase("IsDefaultFocus"))
vo.IsDefaultFocus = "Y".equals(rs.getString(i));
//
else if (columnName.equalsIgnoreCase("AD_Reference_Value_ID"))
vo.AD_Reference_Value_ID = rs.getInt(i);
else if (columnName.equalsIgnoreCase("ValidationCode"))
vo.ValidationCode = rs.getString(i);
else if (columnName.equalsIgnoreCase("ValidationCodeLookup"))
vo.ValidationCodeLookup = rs.getString(i);
else if (columnName.equalsIgnoreCase("IsQuickForm"))
vo.IsQuickForm = "Y".equals(rs.getString (i));
else if (columnName.equalsIgnoreCase("ColumnSQL")) {
vo.ColumnSQL = rs.getString(i);
vo.Callout = rs.getString ("Callout");
vo.AD_Process_ID = rs.getInt ("AD_Process_ID");
vo.AD_InfoWindow_ID = rs.getInt ("AD_InfoWindow_ID");
vo.ReadOnlyLogic = rs.getString ("ReadOnlyLogic");
vo.AlwaysUpdatableLogic = rs.getString ("AlwaysUpdatableLogic");
vo.MandatoryLogic = rs.getString ("MandatoryLogic");
vo.ObscureType = rs.getString ("ObscureType");
vo.IsDefaultFocus = "Y".equals(rs.getString("IsDefaultFocus"));
vo.AD_Reference_Value_ID = rs.getInt("AD_Reference_Value_ID");
vo.ValidationCode = rs.getString("ValidationCode");
vo.ValidationCodeLookup = rs.getString("ValidationCodeLookup");
vo.IsQuickForm = "Y".equals(rs.getString ("IsQuickForm"));
{
vo.ColumnSQL = rs.getString("ColumnSQL");
if (vo.ColumnSQL != null && !vo.ColumnSQL.startsWith("@SQL=") && !vo.ColumnSQL.startsWith("@SQLFIND=") && vo.ColumnSQL.contains("@")) {
// NOTE: cannot use window context because this is set globally on the query, not per record
vo.ColumnSQL = Env.parseContext(ctx, -1, vo.ColumnSQL, false, true);
}
//Feature Request FR [ 1757088 ]
} else if (columnName.equalsIgnoreCase("Included_Tab_ID"))
vo.Included_Tab_ID = rs.getInt(i);
// Collapse Default State
else if (columnName.equalsIgnoreCase("IsCollapsedByDefault"))
vo.IsCollapsedByDefault = "Y".equals(rs.getString(i));
// Feature Request FR [ 2003044 ]
else if (columnName.equalsIgnoreCase("IsAutocomplete"))
vo.IsAutocomplete = "Y".equals(rs.getString(i));
else if (columnName.equalsIgnoreCase("IsAllowCopy"))
vo.IsAllowCopy = "Y".equals(rs.getString(i));
else if (columnName.equalsIgnoreCase("AD_Field_ID"))
vo.AD_Field_ID = rs.getInt(i);
/*IDEMPIERE-358*/
else if (columnName.equalsIgnoreCase("XPosition"))
vo.XPosition=rs.getInt(i);
else if (columnName.equalsIgnoreCase("ColumnSpan"))
vo.ColumnSpan=rs.getInt(i);
else if (columnName.equalsIgnoreCase("NumLines"))
vo.NumLines=rs.getInt(i);
else if (columnName.equalsIgnoreCase("IsToolbarButton"))
vo.IsToolbarButton = rs.getString(i);
else if (columnName.equalsIgnoreCase("AD_Chart_ID"))
vo.AD_Chart_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("AD_LabelStyle_ID"))
vo.AD_LabelStyle_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("AD_FieldStyle_ID"))
vo.AD_FieldStyle_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("PA_DashboardContent_ID"))
vo.PA_DashboardContent_ID = rs.getInt (i);
else if (columnName.equalsIgnoreCase("placeholder"))
vo.Placeholder = rs.getString(i);
else if (columnName.equalsIgnoreCase("IsHtml"))
vo.IsHtml = "Y".equals(rs.getString(i));
}
//Feature Request FR [ 1757088 ]
vo.Included_Tab_ID = rs.getInt("Included_Tab_ID");
// Collapse Default State
vo.IsCollapsedByDefault = "Y".equals(rs.getString("IsCollapsedByDefault"));
// Feature Request FR [ 2003044 ]
vo.IsAutocomplete = "Y".equals(rs.getString("IsAutocomplete"));
vo.IsAllowCopy = "Y".equals(rs.getString("IsAllowCopy"));
vo.AD_Field_ID = rs.getInt("AD_Field_ID");
/*IDEMPIERE-358*/
vo.XPosition=rs.getInt("XPosition");
vo.ColumnSpan=rs.getInt("ColumnSpan");
vo.NumLines=rs.getInt("NumLines");
vo.IsToolbarButton = rs.getString("IsToolbarButton");
vo.AD_Chart_ID = rs.getInt ("AD_Chart_ID");
vo.AD_LabelStyle_ID = rs.getInt ("AD_LabelStyle_ID");
vo.AD_FieldStyle_ID = rs.getInt ("AD_FieldStyle_ID");
vo.PA_DashboardContent_ID = rs.getInt ("PA_DashboardContent_ID");
vo.Placeholder = rs.getString("Placeholder");
vo.IsHtml = "Y".equals(rs.getString("IsHtml"));
if (vo.Header == null)
vo.Header = vo.ColumnName;
}
catch (SQLException e)
{
CLogger.get().log(Level.SEVERE, "ColumnName=" + columnName, e);
CLogger.get().log(Level.SEVERE, e.getMessage(), e);
return null;
}
return vo;
@ -392,8 +323,11 @@ public class GridFieldVO implements Serializable, Cloneable
* Init Field for Process Parameter
* @param ctx context
* @param WindowNo window
* @param ProcessIDOfPanel
* @param WindowIDOfPanel
* @param InfoWindowIDOfPanel
* @param rs result set AD_Process_Para
* @return MFieldVO
* @return GridFieldVO
*/
public static GridFieldVO createParameter (Properties ctx, int WindowNo, int ProcessIDOfPanel, int WindowIDOfPanel, int InfoWindowIDOfPanel, ResultSet rs)
{
@ -446,7 +380,6 @@ public class GridFieldVO implements Serializable, Cloneable
{
CLogger.get().log(Level.SEVERE, "createParameter", e);
}
//devCoffee - #3858
if(vo.IsDisplayed) {
MUserDefProcParameter userDef = MUserDefProcParameter.get(ctx, vo.AD_Column_ID, vo.AD_Process_ID_Of_Panel);
if(userDef != null) {
@ -495,7 +428,6 @@ public class GridFieldVO implements Serializable, Cloneable
}
}
}
//fim devCoffee - 3858
//
vo.initFinish();
if (vo.DefaultValue2 == null)
@ -509,7 +441,7 @@ public class GridFieldVO implements Serializable, Cloneable
/**
* Create range "to" Parameter Field from "from" Parameter Field
* @param voF field value object
* @return to MFieldVO
* @return to GridFieldVO
*/
public static GridFieldVO createParameter (GridFieldVO voF)
{
@ -557,6 +489,8 @@ public class GridFieldVO implements Serializable, Cloneable
* Create parameter for infoWindow
* @param ctx ctx
* @param WindowNo WindowNo
* @param WindowIDOfPanel
* @param infoWindowID
* @param AD_Column_ID AD_Column_ID
* @param ColumnName ColumnName
* @param Name Name
@ -564,7 +498,8 @@ public class GridFieldVO implements Serializable, Cloneable
* @param AD_Reference_Value_ID AD_Reference_Value_ID
* @param IsMandatory IsMandatory
* @param IsEncrypted IsEncrypted
* @return GridFieldV0 v0
* @param Placeholder
* @return GridFieldV0
*/
public static GridFieldVO createParameter (Properties ctx, int WindowNo, int WindowIDOfPanel, int infoWindowID,
int AD_Column_ID, String ColumnName, String Name, int AD_Reference_ID, int AD_Reference_Value_ID,
@ -601,7 +536,7 @@ public class GridFieldVO implements Serializable, Cloneable
* @param tabReadOnly rab is r/o
* @param isCreated is Created field
* @param isTimestamp is the timestamp (not by)
* @return MFieldVO
* @return GridFieldVO
*/
public static GridFieldVO createStdField (Properties ctx, int WindowNo, int TabNo,
int AD_Window_ID, int AD_Tab_ID, boolean tabReadOnly,
@ -940,7 +875,7 @@ public class GridFieldVO implements Serializable, Cloneable
*/
public String toString ()
{
StringBuilder sb = new StringBuilder ("MFieldVO[");
StringBuilder sb = new StringBuilder ("GridFieldVO[");
sb.append(AD_Column_ID).append("-").append(ColumnName)
.append ("]");
return sb.toString ();

View File

@ -394,39 +394,45 @@ public class GridTabVO implements Evaluatee, Serializable
MClient client = MClient.get(ctx);
String ASPFilter = "";
if (client.isUseASP())
ASPFilter =
" AND ( AD_Tab_ID IN ( "
{
StringBuilder stringBuilder = new StringBuilder()
// Just ASP subscribed tabs for client "
+ " SELECT t.AD_Tab_ID "
+ " FROM ASP_Tab t, ASP_Window w, ASP_Level l, ASP_ClientLevel cl "
+ " WHERE w.ASP_Level_ID = l.ASP_Level_ID "
+ " AND cl.AD_Client_ID = " + client.getAD_Client_ID()
+ " AND cl.ASP_Level_ID = l.ASP_Level_ID "
+ " AND t.ASP_Window_ID = w.ASP_Window_ID "
+ " AND t.IsActive = 'Y' "
+ " AND w.IsActive = 'Y' "
+ " AND l.IsActive = 'Y' "
+ " AND cl.IsActive = 'Y' "
+ " AND t.ASP_Status = 'S') " // Show
+ " OR AD_Tab_ID IN ( "
.append(" AND ( AD_Tab_ID IN ( ")
.append(" SELECT t.AD_Tab_ID ")
.append(" FROM ASP_Tab t, ASP_Window w, ASP_Level l, ASP_ClientLevel cl ")
.append(" WHERE w.ASP_Level_ID = l.ASP_Level_ID ")
.append(" AND cl.AD_Client_ID = ")
.append(client.getAD_Client_ID())
.append(" AND cl.ASP_Level_ID = l.ASP_Level_ID ")
.append(" AND t.ASP_Window_ID = w.ASP_Window_ID ")
.append(" AND t.IsActive = 'Y' ")
.append(" AND w.IsActive = 'Y' ")
.append(" AND l.IsActive = 'Y' ")
.append(" AND cl.IsActive = 'Y' ")
.append(" AND t.ASP_Status = 'S') ") // Show
.append(" OR AD_Tab_ID IN ( ")
// + show ASP exceptions for client
+ " SELECT AD_Tab_ID "
+ " FROM ASP_ClientException ce "
+ " WHERE ce.AD_Client_ID = " + client.getAD_Client_ID()
+ " AND ce.IsActive = 'Y' "
+ " AND ce.AD_Tab_ID IS NOT NULL "
+ " AND ce.AD_Field_ID IS NULL "
+ " AND ce.ASP_Status = 'S') " // Show
+ " ) "
+ " AND AD_Tab_ID NOT IN ( "
.append(" SELECT AD_Tab_ID ")
.append(" FROM ASP_ClientException ce ")
.append(" WHERE ce.AD_Client_ID = ")
.append(client.getAD_Client_ID())
.append(" AND ce.IsActive = 'Y' ")
.append(" AND ce.AD_Tab_ID IS NOT NULL ")
.append(" AND ce.AD_Field_ID IS NULL ")
.append(" AND ce.ASP_Status = 'S') ") // Show
.append(" ) ")
.append(" AND AD_Tab_ID NOT IN ( ")
// minus hide ASP exceptions for client
+ " SELECT AD_Tab_ID "
+ " FROM ASP_ClientException ce "
+ " WHERE ce.AD_Client_ID = " + client.getAD_Client_ID()
+ " AND ce.IsActive = 'Y' "
+ " AND ce.AD_Tab_ID IS NOT NULL "
+ " AND ce.AD_Field_ID IS NULL "
+ " AND ce.ASP_Status = 'H')"; // Hide
.append(" SELECT AD_Tab_ID ")
.append(" FROM ASP_ClientException ce ")
.append(" WHERE ce.AD_Client_ID = ")
.append(client.getAD_Client_ID())
.append(" AND ce.IsActive = 'Y' ")
.append(" AND ce.AD_Tab_ID IS NOT NULL ")
.append(" AND ce.AD_Field_ID IS NULL ")
.append(" AND ce.ASP_Status = 'H')"); // Hide
ASPFilter = stringBuilder.toString();
}
// View only returns IsActive='Y'
MRole role = MRole.getDefault(ctx, false);
String advancedFilter=" AND IsAdvancedTab='N' ";
@ -460,7 +466,7 @@ public class GridTabVO implements Evaluatee, Serializable
{
ctx = Ctx;
WindowNo = windowNo;
} // MTabVO
}
/** Context - replicated */
public Properties ctx;