PageRenderTime 34ms CodeModel.GetById 2ms RepoModel.GetById 0ms app.codeStats 0ms

/hcms-rest-api/src/main/java/com/abminvestama/hcms/rest/api/dto/response/IT0022ResponseWrapper.java

https://gitlab.com/baihaki/hcms-sap
Java | 517 lines | 312 code | 64 blank | 141 comment | 23 complexity | 980783aef4210df55109acf84b28c0c2 MD5 | raw file
  1. package com.abminvestama.hcms.rest.api.dto.response;
  2. import java.util.Date;
  3. import java.util.Optional;
  4. import org.apache.commons.lang3.StringUtils;
  5. import org.json.JSONException;
  6. import org.springframework.beans.BeanUtils;
  7. import org.springframework.hateoas.ResourceSupport;
  8. import com.abminvestama.hcms.core.model.constant.DocumentStatus;
  9. import com.abminvestama.hcms.core.model.entity.IT0022;
  10. import com.abminvestama.hcms.core.model.entity.T005T;
  11. import com.abminvestama.hcms.core.model.entity.T517T;
  12. import com.abminvestama.hcms.core.model.entity.T517X;
  13. import com.abminvestama.hcms.core.model.entity.T518B;
  14. import com.abminvestama.hcms.core.model.entity.T519T;
  15. import com.abminvestama.hcms.core.model.entity.T538T;
  16. import com.abminvestama.hcms.core.service.api.CommonServiceFactory;
  17. import com.fasterxml.jackson.annotation.JsonInclude;
  18. import com.fasterxml.jackson.annotation.JsonInclude.Include;
  19. import com.fasterxml.jackson.annotation.JsonProperty;
  20. /**
  21. *
  22. * @since 1.0.0
  23. * @version 1.0.4
  24. * @author yauri (yauritux@gmail.com)<br>anasuya (anasuyahirai@gmail.com)<br>baihaki (baihaki.pru@gmail.com)
  25. * <br><br>
  26. * <table>
  27. * <tr><td><b>Version</td><td><b>Author</td><td><b>Description</td></tr>
  28. * <tr><td>1.0.4</td><td>Baihaki</td><td>Fix getUpdatedFields bug: Update the current referred fields i.e. text fields</td></tr>
  29. * <tr><td>1.0.3</td><td>Baihaki</td><td>Add Constructor of Read from EventData -> IT0022ResponseWrapper(IT0022, String, CommonServiceFactory)</td></tr>
  30. * <tr><td>1.0.2</td><td>Baihaki</td><td>Add attachmentType, attachmentTypeText, attachmentPath field</td></tr>
  31. * <tr><td>1.0.1</td><td>Anasuya</td><td>Add status (DocumentStatus) field</td></tr>
  32. * <tr><td>1.0.0</td><td>Yauri</td><td>Development release</td></tr>
  33. * </table>
  34. *
  35. */
  36. @JsonInclude(Include.NON_NULL)
  37. public class IT0022ResponseWrapper extends ResourceSupport {
  38. private long pernr;
  39. private String subty;
  40. private Date endda;
  41. private Date begda;
  42. private String subtyText;
  43. private String slart;
  44. private String slartText;
  45. private String insti;
  46. private String sland;
  47. private String slandText;
  48. private long ausbi;
  49. private String ausbiText;
  50. private String slabs;
  51. private String slabsText;
  52. private double anzkl;
  53. private String anzeh;
  54. private String anzehText;
  55. private String sltp1;
  56. private String sltp1Text;
  57. private String sltp2;
  58. private String sltp2Text;
  59. private String documentStatus;
  60. private String emark;
  61. private String attachmentType;
  62. private String attachmentTypeText;
  63. private String attachmentPath;
  64. private IT0022ResponseWrapper() {}
  65. public IT0022ResponseWrapper(IT0022 it0022) {
  66. if (it0022 == null) {
  67. new IT0022ResponseWrapper();
  68. } else {
  69. this
  70. .setPernr(it0022.getId().getPernr())
  71. .setSubty(it0022.getSubty() != null ?
  72. StringUtils.defaultString(it0022.getSubty().getId() != null ? it0022.getSubty().getId().getSubty() : StringUtils.EMPTY,
  73. StringUtils.EMPTY)
  74. : it0022.getId().getSubty())
  75. .setEndda(it0022.getId().getEndda()).setBegda(it0022.getId().getBegda())
  76. .setSubtyText(it0022.getSubty() != null ? StringUtils.defaultString(it0022.getSubty().getStext(), StringUtils.EMPTY) : it0022.getId().getSubty())
  77. .setSlart(it0022.getSlart() != null ? StringUtils.defaultString(it0022.getSlart().getSlart(), StringUtils.EMPTY) : StringUtils.EMPTY)
  78. .setSlartText(it0022.getSlart() != null ? StringUtils.defaultString(it0022.getSlart().getStext(), StringUtils.EMPTY) : StringUtils.EMPTY)
  79. .setInsti(StringUtils.defaultString(it0022.getInsti(), StringUtils.EMPTY))
  80. .setSland(it0022.getSland() != null ? StringUtils.defaultString(it0022.getSland().getLand1(), StringUtils.EMPTY) : StringUtils.EMPTY)
  81. .setSlandText(it0022.getSland() != null ? StringUtils.defaultString(it0022.getSland().getLandx(), StringUtils.EMPTY) : StringUtils.EMPTY)
  82. .setAusbi(it0022.getAusbi() != null ? it0022.getAusbi().getAusbi().longValue() : 0)
  83. .setAusbiText(StringUtils.defaultString(it0022.getAusbi() != null ? it0022.getAusbi().getAtext() : StringUtils.EMPTY, StringUtils.EMPTY))
  84. .setSlabs(StringUtils.defaultString(it0022.getSlabs() != null ? it0022.getSlabs().getSlabs() : StringUtils.EMPTY, StringUtils.EMPTY))
  85. .setSlabsText(StringUtils.defaultString(it0022.getSlabs() != null ? it0022.getSlabs().getStext() : StringUtils.EMPTY, StringUtils.EMPTY))
  86. .setAnzkl(it0022.getAnzkl() != null ? it0022.getAnzkl().doubleValue() : 0.0)
  87. .setAnzeh(StringUtils.defaultString(it0022.getAnzeh() != null ? it0022.getAnzeh().getZeinh() : StringUtils.EMPTY, StringUtils.EMPTY))
  88. .setAnzehText(StringUtils.defaultString(it0022.getAnzeh() != null ? it0022.getAnzeh().getEtext() : StringUtils.EMPTY, StringUtils.EMPTY))
  89. .setSltp1(StringUtils.defaultString(it0022.getSltp1() != null ? it0022.getSltp1().getFaart() : StringUtils.EMPTY, StringUtils.EMPTY))
  90. .setSltp1Text(StringUtils.defaultString(it0022.getSltp1() != null ? it0022.getSltp1().getFtext() : StringUtils.EMPTY, StringUtils.EMPTY))
  91. .setSltp2(StringUtils.defaultString(it0022.getSltp2() != null ? it0022.getSltp2().getFaart() : StringUtils.EMPTY, StringUtils.EMPTY))
  92. .setSltp2Text(StringUtils.defaultString(it0022.getSltp2() != null ? it0022.getSltp2().getFtext() : StringUtils.EMPTY, StringUtils.EMPTY))
  93. .setAttachmentType(it0022.getAttachment() != null ? StringUtils.defaultString(it0022.getAttachment().getId().getSubty(), StringUtils.EMPTY) : StringUtils.EMPTY)
  94. .setAttachmentTypeText(it0022.getAttachment() != null ? StringUtils.defaultString(it0022.getAttachment().getStext(), StringUtils.EMPTY) : StringUtils.EMPTY)
  95. .setAttachmentPath(StringUtils.defaultString(it0022.getAttachmentPath(), StringUtils.EMPTY))
  96. .setDocumentStatus(it0022.getStatus())
  97. .setEmark(StringUtils.defaultString(it0022.getEmark(), StringUtils.EMPTY));
  98. }
  99. }
  100. public IT0022ResponseWrapper(IT0022 currentData, String eventData, CommonServiceFactory serviceFactory) throws JSONException, Exception {
  101. this(currentData);
  102. IT0022ResponseWrapper itWrapper = (IT0022ResponseWrapper) new EventDataWrapper(eventData, this).getItWrapper();
  103. String[] ignoreProperties = EventDataWrapper.getNullPropertyNames(itWrapper);
  104. BeanUtils.copyProperties(itWrapper, this, ignoreProperties);
  105. // Update the current referred fields i.e. text fields
  106. Optional<T517T> slartObject = serviceFactory.getT517TQueryService().findById(Optional.ofNullable(slart));
  107. slartText = slartObject.isPresent() ? slartObject.get().getStext() : StringUtils.EMPTY;
  108. Optional<T005T> slandObject = serviceFactory.getT005TQueryService().findById(Optional.ofNullable(sland));
  109. slandText = slandObject.isPresent() ? slandObject.get().getLandx() : StringUtils.EMPTY;
  110. Optional<T518B> ausbiObject = serviceFactory.getT518BQueryService().findById(Optional.ofNullable(ausbi));
  111. ausbiText = ausbiObject.isPresent() ? ausbiObject.get().getAtext() : StringUtils.EMPTY;
  112. Optional<T519T> slabsObject = serviceFactory.getT519TQueryService().findById(Optional.ofNullable(slabs));
  113. slabsText = slabsObject.isPresent() ? slabsObject.get().getStext() : StringUtils.EMPTY;
  114. Optional<T538T> anzehObject = serviceFactory.getT538TQueryService().findById(Optional.ofNullable(anzeh));
  115. anzehText = anzehObject.isPresent() ? anzehObject.get().getEtext() : StringUtils.EMPTY;
  116. Optional<T517X> sltp1Object = serviceFactory.getT517XQueryService().findById(Optional.ofNullable(sltp1));
  117. sltp1Text = sltp1Object.isPresent() ? sltp1Object.get().getFtext() : StringUtils.EMPTY;
  118. Optional<T517X> sltp2Object = serviceFactory.getT517XQueryService().findById(Optional.ofNullable(sltp2));
  119. sltp2Text = sltp2Object.isPresent() ? sltp2Object.get().getFtext() : StringUtils.EMPTY;
  120. }
  121. /**
  122. * GET Employee SSN.
  123. *
  124. * @return
  125. */
  126. @JsonProperty("ssn")
  127. public long getPernr() {
  128. return pernr;
  129. }
  130. public IT0022ResponseWrapper setPernr(long pernr) {
  131. this.pernr = pernr;
  132. return this;
  133. }
  134. /**
  135. * GET Subtype.
  136. *
  137. * @return
  138. */
  139. @JsonProperty("subtype")
  140. public String getSubty() {
  141. return subty;
  142. }
  143. public IT0022ResponseWrapper setSubty(String subty) {
  144. this.subty = subty;
  145. return this;
  146. }
  147. /**
  148. * GET End Date.
  149. *
  150. * @return
  151. */
  152. @JsonProperty("end_date")
  153. public Date getEndda() {
  154. return endda;
  155. }
  156. public IT0022ResponseWrapper setEndda(Date endda) {
  157. this.endda = endda;
  158. return this;
  159. }
  160. /**
  161. * GET Begin Date.
  162. *
  163. * @return
  164. */
  165. @JsonProperty("begin_date")
  166. public Date getBegda() {
  167. return begda;
  168. }
  169. public IT0022ResponseWrapper setBegda(Date begda) {
  170. this.begda = begda;
  171. return this;
  172. }
  173. /**
  174. * GET Subtype Text.
  175. *
  176. * @return
  177. */
  178. @JsonProperty("subtype_text")
  179. public String getSubtyText() {
  180. return subtyText;
  181. }
  182. public IT0022ResponseWrapper setSubtyText(String subtyText) {
  183. this.subtyText = subtyText;
  184. return this;
  185. }
  186. @JsonProperty("emark")
  187. public String getEmark() {
  188. return emark;
  189. }
  190. public IT0022ResponseWrapper setEmark(String emark) {
  191. this.emark = emark;
  192. return this;
  193. }
  194. /**
  195. * GET Education Est. Code.
  196. *
  197. * @return
  198. */
  199. @JsonProperty("education_est_code")
  200. public String getSlart() {
  201. return slart;
  202. }
  203. public IT0022ResponseWrapper setSlart(String slart) {
  204. this.slart = slart;
  205. return this;
  206. }
  207. /**
  208. * GET Education Est.Text
  209. *
  210. * @return
  211. */
  212. @JsonProperty("education_est_text")
  213. public String getSlartText() {
  214. return slartText;
  215. }
  216. public IT0022ResponseWrapper setSlartText(String slartText) {
  217. this.slartText = slartText;
  218. return this;
  219. }
  220. /**
  221. * GET Institute /Location.
  222. *
  223. * @return
  224. */
  225. @JsonProperty("institute")
  226. public String getInsti() {
  227. return insti;
  228. }
  229. public IT0022ResponseWrapper setInsti(String insti) {
  230. this.insti = insti;
  231. return this;
  232. }
  233. /**
  234. * GET Country Key.
  235. *
  236. * @return
  237. */
  238. @JsonProperty("country_key")
  239. public String getSland() {
  240. return sland;
  241. }
  242. public IT0022ResponseWrapper setSland(String sland) {
  243. this.sland = sland;
  244. return this;
  245. }
  246. /**
  247. * GET Country Name.
  248. *
  249. * @return
  250. */
  251. @JsonProperty("country_name")
  252. public String getSlandText() {
  253. return slandText;
  254. }
  255. public IT0022ResponseWrapper setSlandText(String slandText) {
  256. this.slandText = slandText;
  257. return this;
  258. }
  259. /**
  260. * GET Education/Training Code.
  261. *
  262. * @return
  263. */
  264. @JsonProperty("edu_or_training_code")
  265. public long getAusbi() {
  266. return ausbi;
  267. }
  268. public IT0022ResponseWrapper setAusbi(long ausbi) {
  269. this.ausbi = ausbi;
  270. return this;
  271. }
  272. /**
  273. * GET Education/Training Text.
  274. *
  275. * @return
  276. */
  277. @JsonProperty("edu_or_training_text")
  278. public String getAusbiText() {
  279. return ausbiText;
  280. }
  281. public IT0022ResponseWrapper setAusbiText(String ausbiText) {
  282. this.ausbiText = ausbiText;
  283. return this;
  284. }
  285. /**
  286. * GET Certificate.
  287. *
  288. * @return
  289. */
  290. @JsonProperty("certificate_code")
  291. public String getSlabs() {
  292. return slabs;
  293. }
  294. public IT0022ResponseWrapper setSlabs(String slabs) {
  295. this.slabs = slabs;
  296. return this;
  297. }
  298. /**
  299. * GET Certificate Name/Description.
  300. *
  301. * @return
  302. */
  303. @JsonProperty("certificate_name")
  304. public String getSlabsText() {
  305. return slabsText;
  306. }
  307. public IT0022ResponseWrapper setSlabsText(String slabsText) {
  308. this.slabsText = slabsText;
  309. return this;
  310. }
  311. /**
  312. * GET Duration of Courses.
  313. *
  314. * @return
  315. */
  316. @JsonProperty("duration_of_courses")
  317. public double getAnzkl() {
  318. return anzkl;
  319. }
  320. public IT0022ResponseWrapper setAnzkl(double anzkl) {
  321. this.anzkl = anzkl;
  322. return this;
  323. }
  324. /**
  325. * GET Unit of Time/Meas.
  326. *
  327. * @return
  328. */
  329. @JsonProperty("unit_of_time_code")
  330. public String getAnzeh() {
  331. return anzeh;
  332. }
  333. public IT0022ResponseWrapper setAnzeh(String anzeh) {
  334. this.anzeh = anzeh;
  335. return this;
  336. }
  337. /**
  338. * GET Unit of Time/Meas. Description Text.
  339. *
  340. * @return
  341. */
  342. @JsonProperty("unit_of_time_name")
  343. public String getAnzehText() {
  344. return anzehText;
  345. }
  346. public IT0022ResponseWrapper setAnzehText(String anzehText) {
  347. this.anzehText = anzehText;
  348. return this;
  349. }
  350. /**
  351. * GET Branch of Study 1 Code.
  352. *
  353. * @return
  354. */
  355. @JsonProperty("branch_study1_code")
  356. public String getSltp1() {
  357. return sltp1;
  358. }
  359. public IT0022ResponseWrapper setSltp1(String sltp1) {
  360. this.sltp1 = sltp1;
  361. return this;
  362. }
  363. /**
  364. * GET Branch of Study 1 Name/Description.
  365. *
  366. * @return
  367. */
  368. @JsonProperty("branch_study1_name")
  369. public String getSltp1Text() {
  370. return sltp1Text;
  371. }
  372. public IT0022ResponseWrapper setSltp1Text(String sltp1Text) {
  373. this.sltp1Text = sltp1Text;
  374. return this;
  375. }
  376. /**
  377. * GET Branch of Study 2 Code.
  378. * @return
  379. */
  380. @JsonProperty("branch_study2_code")
  381. public String getSltp2() {
  382. return sltp2;
  383. }
  384. public IT0022ResponseWrapper setSltp2(String sltp2) {
  385. this.sltp2 = sltp2;
  386. return this;
  387. }
  388. /**
  389. * GET Branch of Study 2 Name/Description.
  390. *
  391. * @return
  392. */
  393. @JsonProperty("branch_study2_name")
  394. public String getSltp2Text() {
  395. return sltp2Text;
  396. }
  397. public IT0022ResponseWrapper setSltp2Text(String sltp2Text) {
  398. this.sltp2Text = sltp2Text;
  399. return this;
  400. }
  401. /**
  402. * GET Document Status.
  403. *
  404. * @return
  405. */
  406. @JsonProperty("document_status")
  407. public String getDocumentStatus() {
  408. return documentStatus;
  409. }
  410. public IT0022ResponseWrapper setDocumentStatus(DocumentStatus documentStatus) {
  411. this.documentStatus = documentStatus.name();
  412. return this;
  413. }
  414. /**
  415. * GET Attachment Type.
  416. *
  417. * @return
  418. */
  419. @JsonProperty("attachment1_type")
  420. public String getAttachmentType() {
  421. return attachmentType;
  422. }
  423. public IT0022ResponseWrapper setAttachmentType(String attachmentType) {
  424. this.attachmentType = attachmentType;
  425. return this;
  426. }
  427. /**
  428. * GET Attachment Type Text.
  429. *
  430. * @return
  431. */
  432. @JsonProperty("attachment1_type_text")
  433. public String getAttachmentTypeText() {
  434. return attachmentTypeText;
  435. }
  436. public IT0022ResponseWrapper setAttachmentTypeText(String attachmentTypeText) {
  437. this.attachmentTypeText = attachmentTypeText;
  438. return this;
  439. }
  440. /**
  441. * GET Attachment Type.
  442. *
  443. * @return
  444. */
  445. @JsonProperty("attachment1_path")
  446. public String getAttachmentPath() {
  447. return attachmentPath;
  448. }
  449. public IT0022ResponseWrapper setAttachmentPath(String attachmentPath) {
  450. this.attachmentPath = attachmentPath;
  451. return this;
  452. }
  453. }