* into the database.
*/
public void doUpdate(RunData data, Context context)
throws Exception
{
Dcontract entry = new Dcontract();
data.getParameters().setProperties(entry);
entry.setIssuedDate(parseDate(data.getParameters().getString("issueddate")));
entry.setClosedDate(parseDate(data.getParameters().getString("closeddate")));
entry.setStartDate(parseDate(data.getParameters().getString("startdate")));
entry.setEndDate(parseDate(data.getParameters().getString("enddate")));
entry.setCreated(parseDateTime(data.getParameters().getString("created")));
entry.setModifiedBy(data.getUser().getUserName());
entry.setModified(new Date());
ParameterParser pp= data.getParameters();
Enumeration paramKeys= pp.keys();
while(paramKeys.hasMoreElements()) {
String paramName = paramKeys.nextElement().toString();
if(paramName.startsWith("costtypeid")) {
String suffix=paramName.substring(10, paramName.length());
DcontractItem entryItem= new DcontractItem();
entryItem.setCostTypeId(pp.getInt("costtypeid" + suffix));
entryItem.setCostFunction(pp.getInt("costfunction" + suffix));
BigDecimal itmCostAmount= pp.getBigDecimal("costamount" + suffix);
entryItem.setCostAmount(itmCostAmount);
entry.addDcontractItem(entryItem);
}
}
entry.setModified(true);
entry.setNew(false);
Criteria crit = new Criteria();
crit.add(DcontractItemPeer.DCONTRACT_ID, entry.getDcontractId());
Connection conn = Transaction.begin(DcontractPeer.DATABASE_NAME);
boolean success = false;
try {
DcontractItemPeer.doDelete(crit, conn);
entry.save(conn);
Transaction.commit(conn);
success = true;
} finally {
if (!success) Transaction.safeRollback(conn);