// get the primary contact for this entity, they are the target
// recipient
String entityid = (String) dynaform.get("selectedEntityId");
ArrayList entityIdCollection = new ArrayList();
entityIdCollection.add(entityid);
Collection contactID = PTRemote.getContactsForEntity(entityIdCollection, true);
Iterator contactIdIterator = contactID.iterator();
HashMap individualIds = new HashMap();
if (contactIdIterator.hasNext()) {
Number individualId = (Number) contactIdIterator.next();
individualIds.put(individualId.toString(), individualId.toString());
}
dynaform.set("toIndividuals", individualIds);
} else if (specificentity.equals("SPECIFICALL") && entitysavedsearch.equals("SPECIFICENTITY")) {
// All individuals associated with the selected entity are
// to be recipients
String entityid = (String) dynaform.get("selectedEntityId");
ArrayList entityIdCollection = new ArrayList();
entityIdCollection.add(entityid);
Collection contactID = PTRemote.getContactsForEntity(entityIdCollection, false);
Iterator contactIdIterator = contactID.iterator();
HashMap individualIds = new HashMap();
while (contactIdIterator.hasNext()) {
Number individualId = (Number) contactIdIterator.next();
individualIds.put(individualId.toString(), individualId.toString());
}
dynaform.set("toIndividuals", individualIds);
} else if (specificentity.equals("SPECIFICCONTACT") && entitysavedsearch.equals("SPECIFICENTITY")) {
// specific
String individualid = (String) dynaform.get("individualId");
HashMap individualIds = new HashMap();
individualIds.put(individualid, individualid);
dynaform.set("toIndividuals", individualIds);
} else if (entitysavedsearch.equals("INDIVIDUAL")) {
String individualSearchId = (String) dynaform.get("individualSearchId");
ArrayList results = new ArrayList();
results.addAll(remoteAdvancedSearch.performSearch(individualID, Integer.parseInt(individualSearchId), "ADVANCE", null));
HashMap individualIds = new HashMap();
for (int i = 0; i < results.size(); i++) {
Number resultId = (Number) results.get(i);
// I stuck the key and value in to this hashmap as the same string
// as that is how the rest of print templates is written and I
// didn't have time to make it more reasonable.
individualIds.put(resultId.toString(), resultId.toString());
}
dynaform.set("toIndividuals", individualIds);
} else if (entitysavedsearch.equals("ENTITY") && savedsearch1.equals("PRIMARY")) {
// this is when an entity saved search is selected, and we need to
// get the individualid's of the primary contacts for the found set
// of entities.
String entitySearchId = (String) dynaform.get("entityId");
ArrayList results = new ArrayList();
results.addAll(remoteAdvancedSearch.performSearch(individualID, Integer.parseInt(entitySearchId), "ADVANCE", null));
// results contains our collection of entity ids.
Collection contactID = PTRemote.getContactsForEntity(results, true);
Iterator contactIdIterator = contactID.iterator();
HashMap individualIds = new HashMap();
while (contactIdIterator.hasNext()) {
Number individualId = (Number) contactIdIterator.next();
individualIds.put(individualId.toString(), individualId.toString());
}
dynaform.set("toIndividuals", individualIds);
} else if (entitysavedsearch.equals("ENTITY") && savedsearch1.equals("ALL")) {
// This is exactly the same as above, except we are getting all
// individuals instead of just primary contacts.
String entitySearchId = (String) dynaform.get("entityId");
ArrayList results = new ArrayList();
results.addAll(remoteAdvancedSearch.performSearch(individualID, Integer.parseInt(entitySearchId), "ADVANCE", null));
// results contains our collection of entity ids.
Collection contactID = PTRemote.getContactsForEntity(results, false);
Iterator contactIdIterator = contactID.iterator();
HashMap individualIds = new HashMap();
while (contactIdIterator.hasNext()) {
Number individualId = (Number) contactIdIterator.next();
individualIds.put(individualId.toString(), individualId.toString());
}
dynaform.set("toIndividuals", individualIds);
} // end else if (entitysavedsearch.equals("ENTITY") &&
request.setAttribute("body", "new");
// now we finished getting the buttload of info.
// So get the templates.
Collection templateList = PTRemote.getallPrintTemplate(individualID, categoryId);
session.setAttribute("mergeType", mergeType);
dynaform.set("templateList", templateList);
PrintTemplateVO ptVO = new PrintTemplateVO();
String id = (String) dynaform.get("id");