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")) { if (display.startsWith("@SCRIPT"))
Object value = rs.getObject(displayIndex); {
int columnType = rs.getMetaData().getColumnType(displayIndex); displayType = DisplayType.Number;
// String, Text display = display.replace("@SCRIPT", "");
if (columnType == Types.CHAR || columnType == Types.VARCHAR) Object value = parseVariable(display, pdc, pd);
Interpreter bsh = new Interpreter ();
try
{ {
displayType = DisplayType.Text; value = bsh.eval(value.toString());
} } catch (EvalError e)
else if (columnType == Types.DATE || columnType == Types.TIME
|| columnType == Types.TIMESTAMP)
{ {
displayType = DisplayType.DateTime; log.severe(e.getMessage());
}
// Number
else if (columnType == Types.INTEGER || columnType == Types.SMALLINT
|| columnType == Types.DECIMAL || columnType == Types.NUMERIC)
{
displayType = DisplayType.Number;
}
if (display.startsWith("@SCRIPT"))
{
displayType = DisplayType.Number;
display = display.replace("@SCRIPT", "");
value = parseVariable(display, pdc, pd);
Interpreter bsh = new Interpreter ();
try {
value = bsh.eval(value.toString());
} catch (EvalError e) {
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());
} }