int individualId = ((UserObject)session.getAttribute("userobject")).getIndividualID();
SupportFacadeHome sfh = (SupportFacadeHome)CVUtility.getHomeObject("com.centraview.support.supportfacade.SupportFacadeHome", "SupportFacade");
SupportFacade remote = (SupportFacade)sfh.create();
remote.setDataSource(dataSource);
ThreadVO tVO = null;
if (request.getParameter("rowId") != null) {
tVO = remote.getThread(individualId, Integer.parseInt(request.getParameter("rowId")));
} else {
tVO = remote.getThread(individualId, Integer.parseInt(request.getAttribute("rowId").toString()));
}
if (tVO != null) {
TicketVO ticketVO = remote.getTicketBasicRelations(individualId, tVO.getTicketId());
if (ticketVO != null) {
TicketForm ticketForm = new TicketForm();
ticketForm.setSubject(ticketVO.getTitle());
ticketForm.setDetail(ticketVO.getDetail());
ticketForm.setId(new Integer(ticketVO.getId()).toString());
ticketForm.setEntityid(new Integer(ticketVO.getRefEntityId()).toString());
ticketForm.setContactid(new Integer(ticketVO.getRefIndividualId()).toString());
ticketForm.setContact(ticketVO.getRefIndividualName());
EntityVO entityVO = ticketVO.getEntityVO();
if (entityVO != null) {
String entityName = entityVO.getName();
ticketForm.setEntityname(entityName);
AddressVO primaryAdd = entityVO.getPrimaryAddress();
if (primaryAdd != null) {
String address = "";
if (primaryAdd.getStreet1() != null && !primaryAdd.getStreet1().equals("")) {
address += primaryAdd.getStreet1();
}
if (primaryAdd.getStreet2() != null && !primaryAdd.getStreet2().equals("")) {
address +=", "+ primaryAdd.getStreet2()+"\n";
} else {
address += "\n";
}
if (primaryAdd.getCity() != null && !primaryAdd.getCity().equals("")) {
address += primaryAdd.getCity();
}
if (primaryAdd.getStateName() != null && !primaryAdd.getStateName().equals("")) {
address += ", "+ primaryAdd.getStateName();
}
if (primaryAdd.getZip() != null && !primaryAdd.getZip().equals("")) {
address += " "+ primaryAdd.getZip();
}
if (primaryAdd.getCountryName() != null && !primaryAdd.getCountryName().equals("")) {
address += ", "+ primaryAdd.getCountryName();
}
ticketForm.setAddress(address);
if (primaryAdd.getWebsite() != null) {
ticketForm.setWebsite(primaryAdd.getWebsite());
}
}
Collection mocList = entityVO.getMOC();
Iterator iterator = mocList.iterator();
while (iterator.hasNext()) {
MethodOfContactVO moc = (MethodOfContactVO) iterator.next();
if (moc.getMocType() == 1 && moc.getIsPrimary().equalsIgnoreCase("YES")) {
ticketForm.setEmail(moc.getContent());
} else if (moc.getMocType() == 4) {
ticketForm.setPhone(moc.getContent());
}
}
}
request.setAttribute("ticketform", ticketForm);
DynaActionForm dynaForm = (DynaActionForm)form;
if (tVO != null) {
dynaForm.set("threadid", new Integer(tVO.getId()).toString());
dynaForm.set("ticketnumber", new Integer(ticketVO.getId()).toString());
dynaForm.set("title", tVO.getTitle());
dynaForm.set("threaddetail", tVO.getDetail());
dynaForm.set("priority", new Integer(tVO.getPriorityId()).toString());
if (tVO.getCreatedByVO() != null) {
dynaForm.set("createdby", tVO.getCreatedByVO().getFirstName() + " " + tVO.getCreatedByVO().getLastName());
}
dynaForm.set("createdbyid", new Integer(tVO.getCreatedBy()).toString());
dynaForm.set("createddate", tVO.getCreatedOn().toString());
if (tVO.getModifiedOn() != null) {
dynaForm.set("modifieddate", tVO.getModifiedOn().toString());
}
}
request.setAttribute(SupportConstantKeys.TYPEOFSUBMODULE, "Ticket");
FORWARD_final = FORWARD_vieweditthread;
}