// Setting the Custom Fields..
String customFields = "";
TreeMap map = new TreeMap();
map = CustomFieldData.getCustomField("Ticket", ticketID, dataSource);
Set set = map.keySet();
Iterator it = set.iterator();
while (it.hasNext()) {
String str = (String) it.next();
CustomFieldVO field = (CustomFieldVO) map.get(str);
if (field == null) {
continue;
}// end if (field == null)
String fieldType = field.getFieldType();
String fieldValue = field.getValue();
String fieldLabel = field.getLabel();
if (fieldValue == null) {
fieldValue = "";
}// end of if (fieldValue == null)
if (fieldType == null) {
fieldType = "SCALAR";
}// end of if (fieldType == null)
if (fieldType.equals("SCALAR")) {
customFields += "<TR>\n";
customFields += "<TD class=\"popupTableText\">" + fieldLabel + "</TD>";
customFields += "<TD class=\"popupTableText\">" + fieldValue + "</TD>";
customFields += "</TR>";
}// end of if (fieldType.equals("SCALAR"))
else {
fieldValue = fieldValue.trim();
if (fieldValue.equals("")) {
customFields += "<TR>\n";
customFields += "<TD class=\"popupTableText\">" + fieldLabel + "</TD>";
customFields += "<TD class=\"popupTableText\">" + fieldValue + "</TD>";
customFields += "</TR>";
fieldValue = "0";
}// end of if(fieldValue.equals(""))
Vector vec = field.getOptionValues();
if (vec != null) {
for (int j = 0; j < vec.size(); j++) {
DDNameValue ddName = (DDNameValue) vec.get(j);
int compId = Integer.parseInt(fieldValue);
if (ddName.getId() == compId) {
customFields += "<TR>\n";
customFields += "<TD class=\"popupTableText\">" + fieldLabel + "</TD>";
customFields += "<TD class=\"popupTableText\">" + ddName.getName() + "</TD>";
customFields += "</TR>";
}
}
} // end if (vec != null)
} // end if (fieldType.equals("SCALAR"))
} // end while (it.hasNext())
// Setting the Values in the Values Map
TreeMap Values = new TreeMap();
Values.put("--TicketNumber--", new Integer(tVO.getId()).toString());
GlobalMasterLists gml = GlobalMasterLists.getGlobalMasterLists(dataSource);
Vector statusVec = gml.getAllStatus();
if (statusVec != null) {
for (int j = 0; j < statusVec.size(); j++) {
DDNameValue ddName = (DDNameValue) statusVec.get(j);
int compId = tVO.getStatusId();
if (ddName.getId() == compId) {
Values.put("--Status--", ddName.getName());
}
}
} // end if (vec != null)
Vector priorityVec = gml.getAllPriorities();
if (priorityVec != null) {
for (int j = 0; j < priorityVec.size(); j++) {
DDNameValue ddName = (DDNameValue) priorityVec.get(j);
int compId = tVO.getPriorityId();
if (ddName.getId() == compId) {
Values.put("--Priority--", ddName.getName());
}
}
} // end if (priorityVec != null)
Values.put("--Subject--", tVO.getTitle());
String detail = tVO.getDetail();
detail = detail.replaceAll("\n", "<br>");
Values.put("--Details--", detail);
Values.put("--Contact--", tVO.getRefIndividualName());
Values.put("--Manager--", tVO.getManagerName());
Values.put("--AssignedTo--", tVO.getAssignedToName());
SupportFacadeHome supFacade = (SupportFacadeHome) CVUtility.getHomeObject(
"com.centraview.support.supportfacade.SupportFacadeHome", "SupportFacade");
SupportFacade remote = supFacade.create();
remote.setDataSource(dataSource);
ThreadList threadList = remote.getThreadList(individualID, tVO.getId());
String threadValues = this.setLinksfunction(threadList);
EntityVO entityVO = tVO.getEntityVO();
if (entityVO != null) {
String entityName = entityVO.getName();
Values.put("--Name--", entityName);
AddressVO primaryAdd = entityVO.getPrimaryAddress();
String address = "";
if (primaryAdd != null) {
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();
}
address = address.replaceAll("\n", "<br>");
} // end if (primaryAdd != null)
Values.put("--Address--", address);
Collection mocList = entityVO.getMOC();
Iterator iterator = mocList.iterator();
String emailAddress = "";
String phoneNumber = "";
while (iterator.hasNext()) {
MethodOfContactVO moc = (MethodOfContactVO) iterator.next();
if (moc.getMocType() == 1 && moc.getIsPrimary().equalsIgnoreCase("YES")) // this
// is
// for
// email
{
emailAddress = moc.getContent();
} // end of if statement (moc.getMocType() == 1)
else if (moc.getMocType() == 4) {
phoneNumber = moc.getContent();
} // end of else statement (moc.getMocType() == 1)
}// end of while
Values.put("--Email--", emailAddress);
Values.put("--Phone--", phoneNumber);
}
PrintTemplateHome PTHome = (PrintTemplateHome) CVUtility.getHomeObject(
"com.centraview.printtemplate.PrintTemplateHome", "Printtemplate");
PrintTemplate PTRemote = PTHome.create();
PTRemote.setDataSource(dataSource);
PrintTemplateVO ptVO = PTRemote.getPrintTemplate(3);
String ticketTemplate = ptVO.getPtData();
Set listkey = Values.keySet();
Iterator it1 = listkey.iterator();
while (it1.hasNext()) {
String str = (String) it1.next();
String valueString = (String) Values.get(str);
try {
ticketTemplate = ticketTemplate.replaceAll(str, valueString);