Skip to content

Commit

Permalink
fix: MPInstancePara duplicate keys and display value with others lo…
Browse files Browse the repository at this point in the history
…okups. (#70)
  • Loading branch information
EdwinBetanc0urt authored Aug 12, 2024
1 parent 1b22668 commit 557d0e3
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions base/src/org/compiere/model/MPInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand All @@ -31,6 +33,7 @@
import org.adempiere.core.domains.models.I_AD_PInstance_Para;
import org.adempiere.core.domains.models.X_AD_PInstance;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;

Expand Down Expand Up @@ -129,25 +132,20 @@ public MPInstance (Properties ctx, int AD_Process_ID, int Record_ID)
} // MPInstance


/** Parameters */
private MPInstancePara[] m_parameters = null;

/**
* Get Parameters
* @return parameter array
*/
public MPInstancePara[] getParameters()
{
if (m_parameters != null)
return m_parameters;
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
final String whereClause = "AD_PInstance_ID=?";
List <MPInstancePara> list = new Query(getCtx(), I_AD_PInstance_Para.Table_Name, whereClause, null) // @TODO: Review implications of using transaction
.setParameters(getAD_PInstance_ID())
.list();

//
m_parameters = new MPInstancePara[list.size()];
MPInstancePara[] m_parameters = new MPInstancePara[list.size()];
list.toArray(m_parameters);
return m_parameters;
} // getParameters
Expand Down Expand Up @@ -390,12 +388,37 @@ private String getDisplayParameterValue(MProcessPara parameter, Object value) {
}
String displayValue = null;
try {
Lookup lookup = MLookupFactory.get (parameter.getCtx(), 0,
if (DisplayType.isLookup(parameter.getAD_Reference_ID())) {
Lookup lookup = MLookupFactory.get(
parameter.getCtx(), 0,
0, parameter.getAD_Reference_ID(),
Env.getLanguage(parameter.getCtx()), parameter.getColumnName(),
parameter.getAD_Reference_Value_ID(),
false, null);
displayValue = lookup.getDisplay(value);
false, null
);
displayValue = lookup.getDisplay(value);
} else if (DisplayType.YesNo == parameter.getAD_Reference_ID()) {
displayValue = Msg.translate(
parameter.getCtx(),
value.toString()
);
} else if (DisplayType.isDate(parameter.getAD_Reference_ID())) {
SimpleDateFormat dateTimeFormat = DisplayType.getDateFormat(
parameter.getAD_Reference_ID(),
Env.getLanguage(parameter.getCtx())
);
displayValue = dateTimeFormat.format(
(Timestamp) value
);
} else if (DisplayType.isNumeric(parameter.getAD_Reference_ID())) {
DecimalFormat numberFormat = DisplayType.getNumberFormat(
parameter.getAD_Reference_ID(),
Env.getLanguage(parameter.getCtx())
);
displayValue = numberFormat.format(
value
);
}
} catch (Exception e) {
log.warning(e.getLocalizedMessage());
}
Expand Down

0 comments on commit 557d0e3

Please sign in to comment.