PageRenderTime 56ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/Common_Classes/lwt/src/za/co/ucs/accsys/webmodule/WebProcess_EmployeeContact.java

https://gitlab.com/accsys/netbeansprojects
Java | 549 lines | 427 code | 40 blank | 82 comment | 88 complexity | f0c879f1e3a17342ec6ecd5d2a4e8428 MD5 | raw file
  1. package za.co.ucs.accsys.webmodule;
  2. import java.sql.Connection;
  3. import java.sql.ResultSet;
  4. import java.sql.SQLException;
  5. import za.co.ucs.accsys.peopleware.Contact;
  6. import za.co.ucs.accsys.peopleware.Employee;
  7. import static za.co.ucs.accsys.webmodule.WebProcess.et_INITIAL;
  8. import za.co.ucs.lwt.db.DatabaseObject;
  9. /**
  10. * <p>
  11. * A WebProcess_EmployeeContact is an extension of WebProcess that specializes
  12. * in change in Contact Information
  13. * </p>
  14. */
  15. public final class WebProcess_EmployeeContact extends WebProcess {
  16. /**
  17. * To change Contact information, WebProcess_EmployeeContact requires
  18. *
  19. * @param processDefinition - details of reporting structure, etc
  20. * @param owner - who created/is responsible for this process?
  21. * @param employee - which employee is requesting changes to contact
  22. * information?
  23. * @param contact - Contact class that replaces the current contact
  24. * information of this employee
  25. */
  26. public WebProcess_EmployeeContact(WebProcessDefinition processDefinition, Employee owner, Employee employee, Contact aNewContact, Employee aNewEmployee) {
  27. super(processDefinition, owner, employee);
  28. this.newContact = aNewContact;
  29. this.newEmployee = aNewEmployee;
  30. // Is this a valid leave request?
  31. ValidationResult valid = validate();
  32. if (!valid.isValid()) {
  33. this.cancelProcess(valid.getInvalidReason());
  34. } else {
  35. this.escalateProcess(et_INITIAL, "");
  36. }
  37. }
  38. /**
  39. * This method should be implemented by each and every descendent of
  40. * WebProcess. It returns an instance of ValidationResult which contains
  41. * both the isValid() property as well as a reason in case of a non-valid
  42. * result.
  43. */
  44. @Override
  45. public ValidationResult validate() {
  46. if (isActive()) {
  47. // Does the employee still exist?
  48. Connection con = null;
  49. try {
  50. con = DatabaseObject.getNewConnectionFromPool();
  51. ResultSet rs1 = DatabaseObject.openSQL(getEmployeeExistsStatement(), con);
  52. if (rs1.next()) {
  53. if (rs1.getInt(1) <= 0) {
  54. rs1.close();
  55. DatabaseObject.releaseConnection(con);
  56. return (new ValidationResult(false, "Employee (employee_id=" + this.getEmployee().getEmployeeID() + ") does not exist in database."));
  57. }
  58. }
  59. rs1.close();
  60. } catch (SQLException e) {
  61. e.printStackTrace();
  62. } finally {
  63. DatabaseObject.releaseConnection(con);
  64. }
  65. }
  66. return (new ValidationResult(true, ""));
  67. }
  68. @Override
  69. public String toString() {
  70. StringBuilder result = new StringBuilder();
  71. result.append("Change contact information: ").append(getEmployee().getSurname()).append(", ").append(getEmployee().getFirstName());
  72. return result.toString();
  73. }
  74. // Explanation of process in HTML format
  75. @Override
  76. public String toHTMLString() {
  77. StringBuilder result = new StringBuilder();
  78. result.append("Process Number: [").append(this.hashCode()).append("]<br>");
  79. // Explanation of what changes were requested
  80. String detail = getChanges(this.getEmployee().getContact(), this.getEmployee(), this.newContact, this.newEmployee, true);
  81. result.append("Change contact information: ").append(getEmployee().getSurname()).append(", ").append(getEmployee().getFirstName()).append(detail);
  82. return result.toString();
  83. }
  84. /**
  85. * SQL Statement to be used to check weather the process is still valid.
  86. * These statements contain replacement characters that will be 'replaced'
  87. * before being fed to the DatabaseComponent.
  88. *
  89. * @COMPANY_ID,
  90. * @EMPLOYEE_ID, etc.
  91. */
  92. private String getEmployeeExistsStatement() {
  93. return prepareStatement(getEmployeeExistsCONSTANTStatement());
  94. }
  95. /**
  96. * Returns a String representation of the differences between the instance
  97. * of Family and the current properties in this WebProcess
  98. */
  99. private String getChanges(Contact oldContact, Employee oldEmployee, Contact newContact, Employee newEmployee, boolean formatInHTML) {
  100. StringBuffer result = new StringBuffer();
  101. if (formatInHTML) {
  102. if (this.didUpdateChanges && changesHTML.equalsIgnoreCase("<table class=process_detail><font size='-3'></font></table>") == false) {
  103. return changesHTML;
  104. } else {
  105. try {
  106. result.append("<table class=process_detail><font size='-3'>");
  107. // Personal
  108. if (isDifferent(newEmployee.getFirstName(), oldEmployee.getFirstName())) {
  109. result.append("<tr><td>Firstname:</td><td>From '").append(oldEmployee.getFirstName()).append("'</td><td>To '").append(newEmployee.getFirstName()).append("'</td></tr>");
  110. }
  111. if (isDifferent(newEmployee.getSecondName(), oldEmployee.getSecondName())) {
  112. result.append("<tr><td>Second Name:</td><td>From '").append(oldEmployee.getSecondName()).append("'</td><td>To '").append(newEmployee.getSecondName()).append("'</td></tr>");
  113. }
  114. if (isDifferent(newEmployee.getSurname(), oldEmployee.getSurname())) {
  115. result.append("<tr><td>Surname:</td><td>From '").append(oldEmployee.getSurname()).append("'</td><td>To '").append(newEmployee.getSurname()).append("'</td></tr>");
  116. }
  117. if (isDifferent(newEmployee.getPreferredName(), oldEmployee.getPreferredName())) {
  118. result.append("<tr><td>Preferred Name:</td><td>From '").append(oldEmployee.getPreferredName()).append("'</td><td>To '").append(newEmployee.getPreferredName()).append("'</td></tr>");
  119. }
  120. if (isDifferent(newEmployee.getInitials(), oldEmployee.getInitials())) {
  121. result.append("<tr><td>Initials:</td><td>From '").append(oldEmployee.getInitials()).append("'</td><td>To '").append(newEmployee.getInitials()).append("'</td></tr>");
  122. }
  123. if (isDifferent(DatabaseObject.formatDate(newEmployee.getBirthDate()), DatabaseObject.formatDate(oldEmployee.getBirthDate()))) {
  124. result.append("<tr><td>Birth Date:</td><td>From '").append(DatabaseObject.formatDate(oldEmployee.getBirthDate())).append("'</td><td>To '").append(DatabaseObject.formatDate(newEmployee.getBirthDate())).append("'</td></tr>");
  125. }
  126. // Race
  127. if (isDifferent(newEmployee.getRace(), oldEmployee.getRace())) {
  128. result.append("<tr><td>Race:</td><td>From '").append(oldEmployee.getRace()).append("'</td><td>To '").append(newEmployee.getRace()).append("'</td></tr>");
  129. }
  130. // Gender
  131. if (isDifferent(newEmployee.getGender(), oldEmployee.getGender())) {
  132. result.append("<tr><td>Gender:</td><td>From '").append(oldEmployee.getGender()).append("'</td><td>To '").append(newEmployee.getGender()).append("'</td></tr>");
  133. }
  134. // Gender
  135. if (isDifferent(newEmployee.getTaxNumber(), oldEmployee.getTaxNumber())) {
  136. result.append("<tr><td>Tax Number:</td><td>From '").append(oldEmployee.getTaxNumber()).append("'</td><td>To '").append(newEmployee.getTaxNumber()).append("'</td></tr>");
  137. }
  138. // Numbers
  139. if (isDifferent(newContact.getCellNo(), oldContact.getCellNo())) {
  140. result.append("<tr><td>CellNo:</td><td>From '").append(oldContact.getCellNo()).append("'</td><td>To '").append(newContact.getCellNo()).append("'</td></tr>");
  141. }
  142. if (isDifferent(newContact.getEMail(), oldContact.getEMail())) {
  143. result.append("<tr><td>E-Mail:</td><td>From '").append(oldContact.getEMail()).append("'</td><td>To '").append(newContact.getEMail()).append("'</td></tr>");
  144. }
  145. if (isDifferent(newContact.getFaxHome(), oldContact.getFaxHome())) {
  146. result.append("<tr><td>Home Fax:</td><td>From '").append(oldContact.getFaxHome()).append("'</td><td>To '").append(newContact.getFaxHome()).append("'</td></tr>");
  147. }
  148. if (isDifferent(newContact.getFaxWork(), oldContact.getFaxWork())) {
  149. result.append("<tr><td>Office Fax:</td><td>From '").append(oldContact.getFaxWork()).append("'</td><td>To '").append(newContact.getFaxWork()).append("'</td></tr>");
  150. }
  151. if (isDifferent(newContact.getTelHome(), oldContact.getTelHome())) {
  152. result.append("<tr><td>Home Tel:</td><td>From '").append(oldContact.getTelHome()).append("'</td><td>To '").append(newContact.getTelHome()).append("'</td></tr>");
  153. }
  154. if (isDifferent(newContact.getTelWork(), oldContact.getTelWork())) {
  155. result.append("<tr><td>Office Tel:</td><td>From '").append(oldContact.getTelWork()).append("'</td><td>To '").append(newContact.getTelWork()).append("'</td></tr>");
  156. }
  157. // Home Postal
  158. if (isDifferent(newContact.getHomePostal1(), oldContact.getHomePostal1())) {
  159. result.append("<tr><td>Home Postal 1:</td><td>From '").append(oldContact.getHomePostal1()).append("'</td><td>To '").append(newContact.getHomePostal1()).append("'</td></tr>");
  160. }
  161. if (isDifferent(newContact.getHomePostal2(), oldContact.getHomePostal2())) {
  162. result.append("<tr><td>Home Postal 2:</td><td>From '").append(oldContact.getHomePostal2()).append("'</td><td>To '").append(newContact.getHomePostal2()).append("'</td></tr>");
  163. }
  164. if (isDifferent(newContact.getHomePostal3(), oldContact.getHomePostal3())) {
  165. result.append("<tr><td>Home Postal 3:</td><td>From '").append(oldContact.getHomePostal3()).append("'</td><td>To '").append(newContact.getHomePostal3()).append("'</td></tr>");
  166. }
  167. if (isDifferent(newContact.getHomePostal4(), oldContact.getHomePostal4())) {
  168. result.append("<tr><td>Home Postal 4:</td><td>From '").append(oldContact.getHomePostal4()).append("'</td><td>To '").append(newContact.getHomePostal4()).append("'");
  169. }
  170. if (isDifferent(newContact.getHomePostalCode(), oldContact.getHomePostalCode())) {
  171. result.append("<tr><td>Home Postal Code:</td><td>From '").append(oldContact.getHomePostalCode()).append("'</td><td>To '").append(newContact.getHomePostalCode()).append("'");
  172. }
  173. if (isDifferent(newContact.getPhys_HOME_UNITNO(), oldContact.getPhys_HOME_UNITNO())) {
  174. result.append("<tr><td>Unit Number:</td><td>From '").append(oldContact.getPhys_HOME_UNITNO()).append("'</td><td>To '").append(newContact.getPhys_HOME_UNITNO()).append("'</td></tr>");
  175. }
  176. if (isDifferent(newContact.getPhys_HOME_COMPLEX(), oldContact.getPhys_HOME_COMPLEX())) {
  177. result.append("<tr><td>Complex Name:</td><td>From '").append(oldContact.getPhys_HOME_COMPLEX()).append("'</td><td>To '").append(newContact.getPhys_HOME_COMPLEX()).append("'</td></tr>");
  178. }
  179. if (isDifferent(newContact.getPhys_HOME_STREETNO(), oldContact.getPhys_HOME_STREETNO())) {
  180. result.append("<tr><td>Street Number:</td><td>From '").append(oldContact.getPhys_HOME_STREETNO()).append("'</td><td>To '").append(newContact.getPhys_HOME_STREETNO()).append("'</td></tr>");
  181. }
  182. if (isDifferent(newContact.getPhys_HOME_STREET(), oldContact.getPhys_HOME_STREET())) {
  183. result.append("<tr><td>Street Name:</td><td>From '").append(oldContact.getPhys_HOME_STREET()).append("'</td><td>To '").append(newContact.getPhys_HOME_STREET()).append("'</td></tr>");
  184. }
  185. if (isDifferent(newContact.getPhys_HOME_SUBURB(), oldContact.getPhys_HOME_SUBURB())) {
  186. result.append("<tr><td>Suburb:</td><td>From '").append(oldContact.getPhys_HOME_SUBURB()).append("'</td><td>To '").append(newContact.getPhys_HOME_SUBURB()).append("'</td></tr>");
  187. }
  188. if (isDifferent(newContact.getPhys_HOME_CITY(), oldContact.getPhys_HOME_CITY())) {
  189. result.append("<tr><td>Residential City:</td><td>From '").append(oldContact.getPhys_HOME_CITY()).append("'</td><td>To '").append(newContact.getPhys_HOME_CITY()).append("'</td></tr>");
  190. }
  191. if (isDifferent(newContact.getPhys_HOME_CODE(), oldContact.getPhys_HOME_CODE())) {
  192. result.append("<tr><td>Residential Code:</td><td>From '").append(oldContact.getPhys_HOME_CODE()).append("'</td><td>To '").append(newContact.getPhys_HOME_CODE()).append("'</td></tr>");
  193. }
  194. if (isDifferent(newContact.getPhys_HOME_PROVINCE(), oldContact.getPhys_HOME_PROVINCE())) {
  195. result.append("<tr><td>Province:</td><td>From '").append(oldContact.getPhys_HOME_PROVINCE()).append("'</td><td>To '").append(newContact.getPhys_HOME_PROVINCE()).append("'</td></tr>");
  196. }
  197. if (isDifferent(newContact.getPhys_HOME_COUNTRY(), oldContact.getPhys_HOME_COUNTRY())) {
  198. result.append("<tr><td>Country:</td><td>From '").append(oldContact.getPhys_HOME_COUNTRY()).append("'</td><td>To '").append(newContact.getPhys_HOME_COUNTRY()).append("'</td></tr>");
  199. }
  200. //Passport details
  201. if (isDifferent(newEmployee.getPassportNumber(), oldEmployee.getPassportNumber())) {
  202. result.append("<tr><td>Passport Number:</td><td>From '").append(oldEmployee.getPassportNumber()).append("'</td><td>To '").append(newEmployee.getPassportNumber()).append("'</td></tr>");
  203. }
  204. if (isDifferent(newEmployee.getCountryOfIssue(), oldEmployee.getCountryOfIssue())) {
  205. result.append("<tr><td>Country of Issue:</td><td>From '").append(oldEmployee.getCountryOfIssue()).append("'</td><td>To '").append(newEmployee.getCountryOfIssue()).append("'</td></tr>");
  206. }
  207. //emergency details
  208. if (isDifferent(newEmployee.getDoctor(), oldEmployee.getDoctor())) {
  209. result.append("<tr><td>Doctor:</td><td>From '").append(oldEmployee.getDoctor()).append("'</td><td>To '").append(newEmployee.getDoctor()).append("'</td></tr>");
  210. }
  211. if (isDifferent(newEmployee.getPhone(), oldEmployee.getPhone())) {
  212. result.append("<tr><td>Phone:</td><td>From '").append(oldEmployee.getPhone()).append("'</td><td>To '").append(newEmployee.getPhone()).append("'</td></tr>");
  213. }
  214. if (isDifferent(newEmployee.getKnownConditions(), oldEmployee.getKnownConditions())) {
  215. result.append("<tr><td>Known Conditions:</td><td>From '").append(oldEmployee.getKnownConditions()).append("'</td><td>To '").append(newEmployee.getKnownConditions()).append("'</td></tr>");
  216. }
  217. if (isDifferent(newEmployee.getAllergies(), oldEmployee.getAllergies())) {
  218. result.append("<tr><td>Allergies:</td><td>From '").append(oldEmployee.getAllergies()).append("'</td><td>To '").append(newEmployee.getAllergies()).append("'</td></tr>");
  219. }
  220. result.append("</font></table>");
  221. } catch (java.lang.NullPointerException e) {
  222. result = new StringBuffer("<table class=process_detail><font size='-3'>");
  223. result.append("<tr><td>The system is unable to determine the detail of this process.</td></tr>");
  224. result.append("</font></table>");
  225. }
  226. // Persist changes for future reference and set didUpdateChanges
  227. this.didUpdateChanges = true;
  228. changesHTML = result.toString();
  229. return changesHTML;
  230. }
  231. } else {
  232. // Non HTML
  233. if (didUpdateChanges) {
  234. return changesPlain;
  235. } else {
  236. try {
  237. String lineBreak = "\n";
  238. // Personal
  239. if (isDifferent(newEmployee.getFirstName(), oldEmployee.getFirstName())) {
  240. result.append(lineBreak).append("Firstname: From '").append(oldEmployee.getFirstName()).append("' To '").append(newEmployee.getFirstName()).append("'");
  241. }
  242. if (isDifferent(newEmployee.getSecondName(), oldEmployee.getSecondName())) {
  243. result.append(lineBreak).append("SecondName: From '").append(oldEmployee.getSecondName()).append("' To '").append(newEmployee.getSecondName()).append("'");
  244. }
  245. if (isDifferent(newEmployee.getSurname(), oldEmployee.getSurname())) {
  246. result.append(lineBreak).append("Surname: From '").append(oldEmployee.getSurname()).append("' To '").append(newEmployee.getSurname()).append("'");
  247. }
  248. if (isDifferent(newEmployee.getPreferredName(), oldEmployee.getPreferredName())) {
  249. result.append(lineBreak).append("Preferred Name: From '").append(oldEmployee.getPreferredName()).append("' To '").append(newEmployee.getPreferredName()).append("'");
  250. }
  251. if (isDifferent(newEmployee.getInitials(), oldEmployee.getInitials())) {
  252. result.append(lineBreak).append("Initials: From '").append(oldEmployee.getInitials()).append("' To '").append(newEmployee.getInitials()).append("'");
  253. }
  254. if (isDifferent(DatabaseObject.formatDate(newEmployee.getBirthDate()), DatabaseObject.formatDate(oldEmployee.getBirthDate()))) {
  255. result.append(lineBreak).append("Birthdate: From '").append(DatabaseObject.formatDate(oldEmployee.getBirthDate())).append("' To '").append(DatabaseObject.formatDate(newEmployee.getBirthDate())).append("'");
  256. }
  257. // Race
  258. if (isDifferent(newEmployee.getRace(), oldEmployee.getRace())) {
  259. result.append(lineBreak).append("Race: From '").append(oldEmployee.getRace()).append("' To '").append(newEmployee.getRace()).append("'");
  260. }
  261. // Gender
  262. if (isDifferent(newEmployee.getGender(), oldEmployee.getGender())) {
  263. result.append(lineBreak).append("Gender: From '").append(oldEmployee.getGender()).append("' To '").append(newEmployee.getGender()).append("'");
  264. }
  265. //Numbers
  266. if (isDifferent(newContact.getCellNo(), oldContact.getCellNo())) {
  267. result.append(lineBreak).append("CellNo: From '").append(oldContact.getCellNo()).append("' To '").append(newContact.getCellNo()).append("'");
  268. }
  269. if (isDifferent(newContact.getEMail(), oldContact.getEMail())) {
  270. result.append(lineBreak).append("E-Mail: From '").append(oldContact.getEMail()).append("' To '").append(newContact.getEMail()).append("'");
  271. }
  272. if (isDifferent(newContact.getFaxHome(), oldContact.getFaxHome())) {
  273. result.append(lineBreak).append("Home Fax: From '").append(oldContact.getFaxHome()).append("' To '").append(newContact.getFaxHome()).append("'");
  274. }
  275. if (isDifferent(newContact.getFaxWork(), oldContact.getFaxWork())) {
  276. result.append(lineBreak).append("Office Fax: From '").append(oldContact.getFaxWork()).append("' To '").append(newContact.getFaxWork()).append("'");
  277. }
  278. if (isDifferent(newContact.getTelHome(), oldContact.getTelHome())) {
  279. result.append(lineBreak).append("Home Tel: From '").append(oldContact.getTelHome()).append("' To '").append(newContact.getTelHome()).append("'");
  280. }
  281. if (isDifferent(newContact.getTelWork(), oldContact.getTelWork())) {
  282. result.append(lineBreak).append("Office Tel: From '").append(oldContact.getTelWork()).append("' To '").append(newContact.getTelWork()).append("'");
  283. }
  284. // Home Postal
  285. if (isDifferent(newContact.getHomePostal1(), oldContact.getHomePostal1())) {
  286. result.append(lineBreak).append("Home Postal 1: From '").append(oldContact.getHomePostal1()).append("' To '").append(newContact.getHomePostal1()).append("'");
  287. }
  288. if (isDifferent(newContact.getHomePostal2(), oldContact.getHomePostal2())) {
  289. result.append(lineBreak).append("Home Postal 2: From '").append(oldContact.getHomePostal2()).append("' To '").append(newContact.getHomePostal2()).append("'");
  290. }
  291. if (isDifferent(newContact.getHomePostal3(), oldContact.getHomePostal3())) {
  292. result.append(lineBreak).append("Home Postal 3: From '").append(oldContact.getHomePostal3()).append("' To '").append(newContact.getHomePostal3()).append("'");
  293. }
  294. if (isDifferent(newContact.getHomePostal4(), oldContact.getHomePostal4())) {
  295. result.append(lineBreak).append("Home Postal 4: From '").append(oldContact.getHomePostal4()).append("' To '").append(newContact.getHomePostal4()).append("'");
  296. }
  297. if (isDifferent(newContact.getHomePostalCode(), oldContact.getHomePostalCode())) {
  298. result.append(lineBreak).append("Home Postal Code: From '").append(oldContact.getHomePostalCode()).append("' To '").append(newContact.getHomePostalCode()).append("'");
  299. }
  300. // Home Street
  301. if (isDifferent(newContact.getHomeStreet1(), oldContact.getHomeStreet1())) {
  302. result.append(lineBreak).append("Home Street 1: From '").append(oldContact.getHomeStreet1()).append("' To '").append(newContact.getHomeStreet1()).append("'");
  303. }
  304. if (isDifferent(newContact.getHomeStreet2(), oldContact.getHomeStreet2())) {
  305. result.append(lineBreak).append("Home Street 2: From '").append(oldContact.getHomeStreet2()).append("' To '").append(newContact.getHomeStreet2()).append("'");
  306. }
  307. if (isDifferent(newContact.getHomeStreet3(), oldContact.getHomeStreet3())) {
  308. result.append(lineBreak).append("Home Street 3: From '").append(oldContact.getHomeStreet3()).append("' To '").append(newContact.getHomeStreet3()).append("'");
  309. }
  310. if (isDifferent(newContact.getHomeStreet4(), oldContact.getHomeStreet4())) {
  311. result.append(lineBreak).append("Home Street 4: From '").append(oldContact.getHomeStreet4()).append("' To '").append(newContact.getHomeStreet4()).append("'");
  312. }
  313. if (isDifferent(newContact.getHomeStreetCode(), oldContact.getHomeStreetCode())) {
  314. result.append(lineBreak).append("Home Street Code: From '").append(oldContact.getHomeStreetCode()).append("' To '").append(newContact.getHomeStreetCode()).append("'");
  315. }
  316. if (isDifferent(newContact.getPhys_HOME_UNITNO(), oldContact.getPhys_HOME_UNITNO())) {
  317. result.append(lineBreak).append("Unit Number: From '").append(oldContact.getPhys_HOME_UNITNO()).append("' To '").append(newContact.getPhys_HOME_UNITNO()).append("'");
  318. }
  319. if (isDifferent(newContact.getPhys_HOME_COMPLEX(), oldContact.getPhys_HOME_COMPLEX())) {
  320. result.append(lineBreak).append("Complex Name: From '").append(oldContact.getPhys_HOME_COMPLEX()).append("' To '").append(newContact.getPhys_HOME_COMPLEX()).append("'");
  321. }
  322. if (isDifferent(newContact.getPhys_HOME_STREETNO(), oldContact.getPhys_HOME_STREETNO())) {
  323. result.append(lineBreak).append("Street Number: From '").append(oldContact.getPhys_HOME_STREETNO()).append("' To '").append(newContact.getPhys_HOME_STREETNO()).append("'");
  324. }
  325. if (isDifferent(newContact.getPhys_HOME_STREET(), oldContact.getPhys_HOME_STREET())) {
  326. result.append(lineBreak).append("Street Name: From '").append(oldContact.getPhys_HOME_STREET()).append("' To '").append(newContact.getPhys_HOME_STREET()).append("'");
  327. }
  328. if (isDifferent(newContact.getPhys_HOME_SUBURB(), oldContact.getPhys_HOME_SUBURB())) {
  329. result.append(lineBreak).append("Suburb: From '").append(oldContact.getPhys_HOME_SUBURB()).append("' To '").append(newContact.getPhys_HOME_SUBURB()).append("'");
  330. }
  331. if (isDifferent(newContact.getPhys_HOME_CITY(), oldContact.getPhys_HOME_CITY())) {
  332. result.append(lineBreak).append("Residential City: From '").append(oldContact.getPhys_HOME_CITY()).append("' To '").append(newContact.getPhys_HOME_CITY()).append("'");
  333. }
  334. if (isDifferent(newContact.getPhys_HOME_CODE(), oldContact.getPhys_HOME_CODE())) {
  335. result.append(lineBreak).append("Residential Code: From '").append(oldContact.getPhys_HOME_CODE()).append("' To '").append(newContact.getPhys_HOME_CODE()).append("'");
  336. }
  337. if (isDifferent(newContact.getPhys_HOME_PROVINCE(), oldContact.getPhys_HOME_PROVINCE())) {
  338. result.append(lineBreak).append("Province: From '").append(oldContact.getPhys_HOME_PROVINCE()).append("' To '").append(newContact.getPhys_HOME_PROVINCE()).append("'");
  339. }
  340. if (isDifferent(newContact.getPhys_HOME_COUNTRY(), oldContact.getPhys_HOME_COUNTRY())) {
  341. result.append(lineBreak).append("Country: From '").append(oldContact.getPhys_HOME_COUNTRY()).append("' To '").append(newContact.getPhys_HOME_COUNTRY()).append("'");
  342. }
  343. //Passport
  344. if (isDifferent(newEmployee.getPassportNumber(), oldEmployee.getPassportNumber())) {
  345. result.append(lineBreak).append("Passport Number: From '").append(oldEmployee.getPassportNumber()).append("' To '").append(newEmployee.getPassportNumber()).append("'");
  346. }
  347. if (isDifferent(newEmployee.getCountryOfIssue(), oldEmployee.getCountryOfIssue())) {
  348. result.append(lineBreak).append("Country of Issue: From '").append(oldEmployee.getCountryOfIssue()).append("' To '").append(newEmployee.getCountryOfIssue()).append("'");
  349. }
  350. //Emergency
  351. if (isDifferent(newEmployee.getDoctor(), oldEmployee.getDoctor())) {
  352. result.append(lineBreak).append("Doctor: From '").append(oldEmployee.getDoctor()).append("' To '").append(newEmployee.getDoctor()).append("'");
  353. }
  354. if (isDifferent(newEmployee.getPhone(), oldEmployee.getPhone())) {
  355. result.append(lineBreak).append("Phone: From '").append(oldEmployee.getPhone()).append("' To '").append(newEmployee.getPhone()).append("'");
  356. }
  357. if (isDifferent(newEmployee.getKnownConditions(), oldEmployee.getKnownConditions())) {
  358. result.append(lineBreak).append("Known Conditions: From '").append(oldEmployee.getKnownConditions()).append("' To '").append(newEmployee.getKnownConditions()).append("'");
  359. }
  360. if (isDifferent(newEmployee.getAllergies(), oldEmployee.getAllergies())) {
  361. result.append(lineBreak).append("Allergies: From '").append(oldEmployee.getAllergies()).append("' To '").append(newEmployee.getAllergies()).append("'");
  362. }
  363. } catch (java.lang.NullPointerException e) {
  364. result = new StringBuffer("< The system is unable to determine the detail of this process. >");
  365. }
  366. // Persist non-HTML changes for future reference and set didUpdateChanges
  367. didUpdateChanges = true;
  368. changesPlain = result.toString();
  369. return changesPlain;
  370. }
  371. }
  372. }
  373. /**
  374. * This statement gets executed when the process is to be written to the
  375. * database.
  376. */
  377. @Override
  378. String getCommitStatement() {
  379. String sqlString = "";
  380. sqlString = getCommitCONSTANTStatement();
  381. return (prepareStatement(sqlString));
  382. }
  383. /**
  384. * Internal method to perform parameter replacements
  385. */
  386. private String prepareStatement(String aStatementWithParameters) {
  387. String sqlString = aStatementWithParameters;
  388. sqlString = sqlString.replaceAll(":companyID", getEmployee().getCompany().getCompanyID().toString());
  389. sqlString = sqlString.replaceAll(":employeeID", getEmployee().getEmployeeID().toString());
  390. return sqlString;
  391. }
  392. private String getEmployeeExistsCONSTANTStatement() {
  393. return ("select count(*) from e_master with (NOLOCK) where company_id=:companyID "
  394. + "and employee_id=:employeeID");
  395. }
  396. private String getCommitCONSTANTStatement() {
  397. StringBuilder result = new StringBuilder();
  398. // E_MASTER
  399. result.append("update e_master set ");
  400. result.append("SURNAME='").append(newEmployee.getSurname()).append("', ");
  401. result.append("FIRSTNAME='").append(newEmployee.getFirstName()).append("', ");
  402. result.append("SECONDNAME='").append(newEmployee.getSecondName()).append("', ");
  403. result.append("PREFERRED_NAME='").append(newEmployee.getPreferredName()).append("', ");
  404. result.append("INITIALS='").append(newEmployee.getInitials()).append("', ");
  405. result.append("BIRTHDATE='").append(DatabaseObject.formatDate(newEmployee.getBirthDate())).append("' ");
  406. result.append("where company_id=:companyID and employee_id=:employeeID; commit;");
  407. // E_CONTACT
  408. result.append("update e_contact set ");
  409. result.append("TEL_HOME='").append(newContact.getTelHome()).append("', ");
  410. result.append("TEL_WORK='").append(newContact.getTelWork()).append("', ");
  411. result.append("FAX_HOME='").append(newContact.getFaxHome()).append("', ");
  412. result.append("FAX_WORK='").append(newContact.getFaxWork()).append("', ");
  413. result.append("TEL_CELL='").append(newContact.getCellNo()).append("', ");
  414. result.append("E_MAIL='").append(newContact.getEMail()).append("' ");
  415. result.append("where company_id=:companyID and employee_id=:employeeID; commit;");
  416. // E_ADDRESS
  417. result.append("update e_address set ");
  418. result.append("HOME_STREET1='").append(newContact.getHomeStreet1()).append("', ");
  419. result.append("HOME_STREET2='").append(newContact.getHomeStreet2()).append("', ");
  420. result.append("HOME_STREET3='").append(newContact.getHomeStreet3()).append("', ");
  421. result.append("HOME_STREET4='").append(newContact.getHomeStreet4()).append("', ");
  422. result.append("HOME_STREET_CODE='").append(newContact.getHomeStreetCode()).append("', ");
  423. result.append("HOME_POSTAL1='").append(newContact.getHomePostal1()).append("', ");
  424. result.append("HOME_POSTAL2='").append(newContact.getHomePostal2()).append("', ");
  425. result.append("HOME_POSTAL3='").append(newContact.getHomePostal3()).append("', ");
  426. result.append("HOME_POSTAL4='").append(newContact.getHomePostal4()).append("', ");
  427. result.append("HOME_POSTAL_CODE='").append(newContact.getHomePostalCode()).append("', ");
  428. result.append("PHYS_HOME_UNITNO='").append(newContact.getPhys_HOME_UNITNO()).append("', ");
  429. result.append("PHYS_HOME_COMPLEX='").append(newContact.getPhys_HOME_COMPLEX()).append("', ");
  430. result.append("PHYS_HOME_STREETNO='").append(newContact.getPhys_HOME_STREETNO()).append("', ");
  431. result.append("PHYS_HOME_STREET='").append(newContact.getPhys_HOME_STREET()).append("', ");
  432. result.append("PHYS_HOME_SUBURB='").append(newContact.getPhys_HOME_SUBURB()).append("', ");
  433. result.append("PHYS_HOME_CITY='").append(newContact.getPhys_HOME_CITY()).append("', ");
  434. result.append("PHYS_HOME_CODE='").append(newContact.getPhys_HOME_CODE()).append("', ");
  435. result.append("PHYS_HOME_PROVINCE='").append(newContact.getPhys_HOME_PROVINCE()).append("', ");
  436. result.append("PHYS_HOME_COUNTRY='").append(newContact.getPhys_HOME_COUNTRY()).append("' ");
  437. result.append("where company_id=:companyID and employee_id=:employeeID; commit;");
  438. // E_NUMBER
  439. result.append("update e_number set ");
  440. result.append("TAX_NUMBER='").append(newEmployee.getTaxNumber()).append("' ");
  441. result.append("where company_id=:companyID and employee_id=:employeeID; commit;");
  442. // Race
  443. result.append("delete from e_group where company_id=:companyID and employee_id=:employeeID and group_id=2; ");
  444. result.append(" insert into e_group (company_id, employee_id, group_id, subgroup1_id) ");
  445. result.append(" values (:companyID,:employeeID, 2, ");
  446. result.append(" (select group_id from c_group where parent_group_id=2 ");
  447. result.append(" and trim(upper(description))=trim(upper('").append(newEmployee.getRace().trim()).append("')))); commit;");
  448. // Gender
  449. result.append("delete from e_group where company_id=:companyID and employee_id=:employeeID and group_id=1; ");
  450. result.append(" insert into e_group (company_id, employee_id, group_id, subgroup1_id) ");
  451. result.append(" values (:companyID,:employeeID, 1, ");
  452. result.append(" (select group_id from c_group where parent_group_id=1 ");
  453. result.append(" and trim(upper(description))=trim(upper('").append(newEmployee.getGender().trim()).append("')))); commit;");
  454. //E_PASSPORT
  455. result.append("INSERT INTO E_PASSPORT (COMPANY_ID, EMPLOYEE_ID, PASSPORT_NUMBER, PASSPORT_HELD)");
  456. result.append("ON EXISTING UPDATE VALUES('");
  457. result.append(newEmployee.getCompany().getCompanyID()).append("','");
  458. result.append(newEmployee.getEmployeeID()).append("','");
  459. result.append(newEmployee.getPassportNumber()).append("','");
  460. result.append(newEmployee.getCountryOfIssue()).append("');");
  461. result.append("commit;");
  462. //E-EMERGENCY
  463. result.append("INSERT INTO E_EMERGENCY (COMPANY_ID, EMPLOYEE_ID, DOCTOR, PHONE, KNOWN_CONDITIONS, ALLERGIES)");
  464. result.append("ON EXISTING UPDATE VALUES('");
  465. result.append(newEmployee.getCompany().getCompanyID()).append("', '");
  466. result.append(newEmployee.getEmployeeID()).append("', '");
  467. result.append(newEmployee.getDoctor()).append("', '");
  468. result.append(newEmployee.getPhone()).append("', '");
  469. result.append(newEmployee.getKnownConditions()).append("', '");
  470. result.append(newEmployee.getAllergies()).append("');");
  471. result.append("commit;");
  472. return (result.toString());
  473. }
  474. private String getCountryList(String countryList) {
  475. // Establish LeaveType ID
  476. String aCountryList = " ";
  477. //int aLeaveTypeID = -1;
  478. Connection con = null;
  479. try {
  480. con = DatabaseObject.getNewConnectionFromPool();
  481. ResultSet rs = DatabaseObject.openSQL("select COUNTRY from A_PASSPORT_COUNTRYLIST with (nolock) where", con);
  482. if (rs.next()) {
  483. aCountryList = rs.getString("COUNTRY");
  484. }
  485. rs.close();
  486. } catch (SQLException e) {
  487. e.printStackTrace();
  488. } finally {
  489. DatabaseObject.releaseConnection(con);
  490. }
  491. return aCountryList;
  492. }
  493. @Override
  494. public String getProcessName() {
  495. return "Employee Contact Information";
  496. }
  497. // Fingerprint of previously compatible version
  498. /* In order to extract this UID, run the following command in the
  499. * folder where the current jwt.jar file resides BEFORE changing
  500. * the contents of the class.
  501. C:\Apache5\shared\lib>c:\j2sdk1.4.2_03\bin\serialver -classpath lwt.jar za.co.ucs.accsys.webmodule.WebProcess_EmployeeContact
  502. za.co.ucs.accsys.webmodule.WebProcess_EmployeeContact: static final long serialVersionUID = -1459535708782221840L;
  503. */
  504. private static final long serialVersionUID = -1459535708782221840L;
  505. private Contact newContact = null;
  506. private Employee newEmployee = null;
  507. private EmployeeSelection initialEmployeeSelection;
  508. } // end LeaveRequisitionProcess