use of org.compiere.util.NamePair in project adempiere by adempiere.
the class FieldRecordInfo method addLine.
// dynInit
/**
* Add Line
* @param AD_Column_ID column
* @param Updated updated
* @param UpdatedBy user
* @param OldValue old
* @param NewValue new
*/
private void addLine(int AD_Column_ID, Timestamp Updated, int UpdatedBy, String OldValue, String NewValue) {
Vector<String> line = new Vector<String>();
// Column
MColumn column = MColumn.get(Env.getCtx(), AD_Column_ID);
//
if (OldValue != null && OldValue.equals(MChangeLog.NULL))
OldValue = null;
String showOldValue = OldValue;
if (NewValue != null && NewValue.equals(MChangeLog.NULL))
NewValue = null;
String showNewValue = NewValue;
//
try {
if (DisplayType.isText(column.getAD_Reference_ID()))
;
else if (column.getAD_Reference_ID() == DisplayType.YesNo) {
if (OldValue != null) {
boolean yes = OldValue.equals("true") || OldValue.equals("Y");
showOldValue = Msg.getMsg(Env.getCtx(), yes ? "Y" : "N");
}
if (NewValue != null) {
boolean yes = NewValue.equals("true") || NewValue.equals("Y");
showNewValue = Msg.getMsg(Env.getCtx(), yes ? "Y" : "N");
}
} else if (column.getAD_Reference_ID() == DisplayType.Amount) {
if (OldValue != null)
showOldValue = m_amtFormat.format(new BigDecimal(OldValue));
if (NewValue != null)
showNewValue = m_amtFormat.format(new BigDecimal(NewValue));
} else if (column.getAD_Reference_ID() == DisplayType.Integer) {
if (OldValue != null)
showOldValue = m_intFormat.format(new Integer(OldValue));
if (NewValue != null)
showNewValue = m_intFormat.format(new Integer(NewValue));
} else if (DisplayType.isNumeric(column.getAD_Reference_ID())) {
if (OldValue != null)
showOldValue = m_numberFormat.format(new BigDecimal(OldValue));
if (NewValue != null)
showNewValue = m_numberFormat.format(new BigDecimal(NewValue));
} else if (column.getAD_Reference_ID() == DisplayType.Date) {
if (OldValue != null)
showOldValue = m_dateFormat.format(Timestamp.valueOf(OldValue));
if (NewValue != null)
showNewValue = m_dateFormat.format(Timestamp.valueOf(NewValue));
} else if (column.getAD_Reference_ID() == DisplayType.DateTime) {
if (OldValue != null)
showOldValue = m_dateTimeFormat.format(Timestamp.valueOf(OldValue));
if (NewValue != null)
showNewValue = m_dateTimeFormat.format(Timestamp.valueOf(NewValue));
} else if (DisplayType.isLookup(column.getAD_Reference_ID())) {
MLookup lookup = MLookupFactory.get(Env.getCtx(), 0, AD_Column_ID, column.getAD_Reference_ID(), Env.getLanguage(Env.getCtx()), column.getColumnName(), column.getAD_Reference_Value_ID(), column.isParent(), null);
if (OldValue != null) {
Object key = OldValue;
NamePair pp = lookup.get(key);
if (pp != null)
showOldValue = pp.getName();
}
if (NewValue != null) {
Object key = NewValue;
NamePair pp = lookup.get(key);
if (pp != null)
showNewValue = pp.getName();
}
} else if (DisplayType.isLOB(column.getAD_Reference_ID()))
;
} catch (Exception e) {
log.log(Level.WARNING, OldValue + "->" + NewValue, e);
}
//
line.add(showNewValue);
line.add(showOldValue);
// UpdatedBy
MUser user = MUser.get(Env.getCtx(), UpdatedBy);
line.add(user.getName());
// Updated
line.add(m_dateFormat.format(Updated));
m_data.add(line);
}
Aggregations