IDEMPIERE-5105 Remove unused and/or unnecessary code in Print Format Item Script feature (#1058)

This commit is contained in:
Tony Snook 2021-12-18 17:26:52 +11:00 committed by GitHub
parent 95924e8578
commit 2eb77fc56d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 37 deletions

View File

@ -24,7 +24,6 @@ import java.sql.ResultSet;
import java.sql.ResultSetMetaData; import java.sql.ResultSetMetaData;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.sql.Types;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -1027,8 +1026,7 @@ public class DataEngine
if (pdc.hasAlias()) if (pdc.hasAlias())
{ {
// DisplayColumn first // DisplayColumn first
int displayIndex = counter++; String display = rs.getString(counter++);
String display = rs.getString(displayIndex);
if (pdc.getColumnName().endsWith("_ID")) if (pdc.getColumnName().endsWith("_ID"))
{ {
int id = rs.getInt(counter++); int id = rs.getInt(counter++);
@ -1040,49 +1038,27 @@ public class DataEngine
} }
else else
{ {
String id = rs.getString(counter++); String id = rs.getString(counter++);
if (display != null && !rs.wasNull()) if (display != null && !rs.wasNull())
{ {
/** START DEVCOFFEE: script column **/ /** START DEVCOFFEE: script column **/
int displayType = pdc.getDisplayType(); int displayType = pdc.getDisplayType();
if (display.startsWith("@SCRIPT")) {
Object value = rs.getObject(displayIndex);
int columnType = rs.getMetaData().getColumnType(displayIndex);
// String, Text
if (columnType == Types.CHAR || columnType == Types.VARCHAR)
{
displayType = DisplayType.Text;
}
else if (columnType == Types.DATE || columnType == Types.TIME
|| columnType == Types.TIMESTAMP)
{
displayType = DisplayType.DateTime;
}
// Number
else if (columnType == Types.INTEGER || columnType == Types.SMALLINT
|| columnType == Types.DECIMAL || columnType == Types.NUMERIC)
{
displayType = DisplayType.Number;
}
if (display.startsWith("@SCRIPT")) if (display.startsWith("@SCRIPT"))
{ {
displayType = DisplayType.Number; displayType = DisplayType.Number;
display = display.replace("@SCRIPT", ""); display = display.replace("@SCRIPT", "");
value = parseVariable(display, pdc, pd); Object value = parseVariable(display, pdc, pd);
Interpreter bsh = new Interpreter (); Interpreter bsh = new Interpreter ();
try { try
{
value = bsh.eval(value.toString()); value = bsh.eval(value.toString());
} catch (EvalError e)
} catch (EvalError e) { {
log.severe(e.getMessage()); log.severe(e.getMessage());
} }
}
pde = new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(), (Serializable) value, displayType, pdc.getFormatPattern()); pde = new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(), (Serializable) value, displayType, pdc.getFormatPattern());
} else { } else
{
ValueNamePair pp = new ValueNamePair(id, display); ValueNamePair pp = new ValueNamePair(id, display);
pde = new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(), pp, displayType, pdc.getFormatPattern()); pde = new PrintDataElement(pdc.getAD_PrintFormatItem_ID(), pdc.getColumnName(), pp, displayType, pdc.getFormatPattern());
} }