try {
PromotionDetailListForm promotionDetailListForm;
promotionDetailListForm = (PromotionDetailListForm)form;
promotionDetailListForm.convertItemLines();
PromotionVO promotionVO = new PromotionVO();
promotionVO.setName(promotionDetailListForm.getPname());
promotionVO.setDescription(promotionDetailListForm.getPdescription());
promotionVO.setStatus(promotionDetailListForm.getPstatus());
promotionVO.setNotes(promotionDetailListForm.getNotes());
promotionVO.setItemlines(promotionDetailListForm.getItemLines());
promotionVO.setNotes(promotionDetailListForm.getNotes());
if ((promotionDetailListForm.getStartmonth() != null)
&& (promotionDetailListForm.getStartday() != null)
&& (promotionDetailListForm.getStartyear() != null)) {
String startmonth = promotionDetailListForm.getStartmonth();
String startday = promotionDetailListForm.getStartday();
String startyear = promotionDetailListForm.getStartyear();
try {
Timestamp start = DateUtility.createTimestamp(startyear, startmonth, startday);
promotionVO.setStartdate(start);
} catch (Exception e) {
logger.error("[execute]: Exception", e);
}
}
if ((promotionDetailListForm.getEndmonth() != null)
&& (promotionDetailListForm.getEndday() != null)
&& (promotionDetailListForm.getEndyear() != null)) {
String endmonth = promotionDetailListForm.getEndmonth();
String endday = promotionDetailListForm.getEndday();
String endyear = promotionDetailListForm.getEndyear();
try {
Timestamp end = DateUtility.createTimestamp(endyear, endmonth, endday);
promotionVO.setEnddate(end);
} catch (Exception e) {
logger.error("[execute]: Exception", e);
}
}
Vector vec = new Vector();
int total = 0;
String Total = request.getParameter("TotalCustomFields");
if (Total != null) {
try {
total = Integer.parseInt(Total);
} catch (Exception e) {
logger.error("[execute]: Exception", e);
total = 0;
}
}
for (int i = 1; i <= total; i++) // starting from 1...
{
String fieldid = request.getParameter("fieldid" + i);
String fieldType = request.getParameter("fieldType" + i);
String textValue = request.getParameter("text" + i);
if (fieldid == null)
fieldid = "0";
int intfieldId = Integer.parseInt(fieldid);
CustomFieldVO cfvo = new CustomFieldVO();
cfvo.setFieldID(intfieldId);
cfvo.setFieldType(fieldType);
cfvo.setValue(textValue);
if (intfieldId != 0)
vec.add(cfvo);
}
promotionVO.setCustomfield(vec);
HttpSession session = request.getSession();
int individualId = ((UserObject)session.getAttribute("userobject")).getIndividualID();
HashMap mapPromotion = new HashMap();
String promotionid = "";
if (request.getParameter("promotionid") != null) {
promotionid = request.getParameter("promotionid");
mapPromotion.put("PromotionID", promotionid);
}
MarketingFacadeHome mfh = (MarketingFacadeHome)CVUtility.getHomeObject(
"com.centraview.marketing.marketingfacade.MarketingFacadeHome", "MarketingFacade");
MarketingFacade remote = mfh.create();
remote.setDataSource(dataSource);
if (request.getParameter("operation") != null) {
if (request.getParameter("operation").equals("Add")) {
mapPromotion.put("PromotionVo", promotionVO);
promotionid = remote.addPromotion(individualId, mapPromotion);
promotionDetailListForm.setPromotionid(promotionid);
request.setAttribute("promotionid", promotionid);
} else if (request.getParameter("operation").equals("Edit")) {
promotionVO.setPromotionid(Integer.parseInt(promotionid));
mapPromotion.put("PromotionVo", promotionVO);
remote.updatePromotion(individualId, mapPromotion);
}
}