* wouldn't be secure.
*/
public void doInsert(RunData data, Context context)
throws Exception
{
Dreturn entry = new Dreturn();
data.getParameters().setProperties(entry);
entry.setDreturnCode(getTempCode());
entry.setIssuedDate(parseDate(data.getParameters().getString("issueddate")));
entry.setClosedDate(parseDate(data.getParameters().getString("closeddate")));
entry.setReturnDate(parseDate(data.getParameters().getString("returndate")));
int retStatus= data.getParameters().getInt("status");
entry.setCreatedBy(data.getUser().getUserName());
entry.setCreated(new Date());
entry.setModifiedBy(data.getUser().getUserName());
entry.setModified(new Date());
ParameterParser pp= data.getParameters();
Enumeration paramKeys= pp.keys();
Dorder retDorder= entry.getDorder();
while(paramKeys.hasMoreElements()) {
String paramName = paramKeys.nextElement().toString();
if(paramName.startsWith("locationid")) {
String suffix=paramName.substring(10, paramName.length());
DorderItem entryItem= new DorderItem();
entryItem.setLocationId(pp.getInt("locationid" + suffix));
int itmShippQty= pp.getInt("shippedqty" + suffix);
int itmUnsoldQty= pp.getInt("unsoldqty" + suffix);
int itmLostQty= pp.getInt("lostqty" + suffix);
entryItem.setOrderedQty(itmShippQty);
entryItem.setShippedQty(itmShippQty);
entryItem.setUnsoldQty(itmUnsoldQty);
entryItem.setLostQty(itmLostQty);
retDorder.addDorderItem(entryItem);
}
}
if (retStatus==50){
retDorder.setStatus(50);
}
retDorder.setModified(true);
retDorder.setNew(false);
Criteria crit = new Criteria();
crit.add(DorderItemPeer.DORDER_ID, entry.getDorderId());
Connection conn = Transaction.begin(DreturnPeer.DATABASE_NAME);
boolean success = false;
try {
DorderItemPeer.doDelete(crit, conn);
entry.save(conn);
retDorder.save(conn);
entry.setDreturnCode(getRowCode("SH", entry.getDreturnId()));
entry.save(conn);
Transaction.commit(conn);
success = true;
} finally {
if (!success) Transaction.safeRollback(conn);