PageRenderTime 63ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/UniwareCore/src/main/java/com/uniware/core/vo/TemplateCustomizationFieldsVO.java

https://bitbucket.org/piyushgd10/bhumi
Java | 638 lines | 461 code | 115 blank | 62 comment | 0 complexity | 4e890e969530ab870c215870de5be4e6 MD5 | raw file
  1. /*
  2. * Copyright 2014 Unicommerce eSolutions (P) Limited . All Rights Reserved.
  3. * UNICOMMERCE ESOLUTIONS PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. *
  5. * @version 1.0, 06/05/14
  6. * @author amit
  7. */
  8. package com.uniware.core.vo;
  9. import java.util.ArrayList;
  10. import java.util.Arrays;
  11. import java.util.List;
  12. import java.util.Map;
  13. import org.springframework.data.annotation.Id;
  14. import org.springframework.data.mongodb.core.mapping.Document;
  15. import com.google.gson.Gson;
  16. /**
  17. * Defines all the customization parameters applicable on a template type. These parameters are grouped into
  18. * {@link com.uniware.core.vo.TemplateCustomizationFieldsVO.CustomizationFieldGroup}.
  19. */
  20. @Document(collection = "templateCustomizationFields")
  21. /*
  22. @CompoundIndexes({
  23. @CompoundIndex(def = "{'templateType' : 1, 'customizationFieldGroupList.displayName': 1}", unique = true),
  24. @CompoundIndex(def = "{'templateType' : 1, 'customizationFieldGroupList.code': 1}", unique = true),
  25. @CompoundIndex(def = "{'templateType' : 1, 'customizationFieldGroupList.fieldList.name': 1}", unique = true) })
  26. */
  27. public class TemplateCustomizationFieldsVO {
  28. @Id
  29. private String id;
  30. private PrintTemplateVO.Type templateType;
  31. private List<CustomizationFieldGroup> customizationFieldGroupList;
  32. public TemplateCustomizationFieldsVO() {
  33. super();
  34. }
  35. public String getId() {
  36. return id;
  37. }
  38. public void setId(String id) {
  39. this.id = id;
  40. }
  41. public PrintTemplateVO.Type getTemplateType() {
  42. return templateType;
  43. }
  44. public void setTemplateType(PrintTemplateVO.Type templateType) {
  45. this.templateType = templateType;
  46. }
  47. public List<CustomizationFieldGroup> getCustomizationFieldGroupList() {
  48. return customizationFieldGroupList;
  49. }
  50. public void setCustomizationFieldGroupList(List<CustomizationFieldGroup> customizationFieldGroupList) {
  51. this.customizationFieldGroupList = customizationFieldGroupList;
  52. }
  53. /**
  54. * Represents a group of fields that show up together.
  55. */
  56. public static class CustomizationFieldGroup {
  57. /**
  58. * Primary key.
  59. */
  60. private String code;
  61. /**
  62. * Order of display of this group
  63. */
  64. private int position;
  65. private String displayName;
  66. private List<CustomizationField> fieldList;
  67. public CustomizationFieldGroup() {
  68. super();
  69. }
  70. public String getCode() {
  71. return code;
  72. }
  73. public void setCode(String code) {
  74. this.code = code;
  75. }
  76. public int getPosition() {
  77. return position;
  78. }
  79. public void setPosition(int position) {
  80. this.position = position;
  81. }
  82. public String getDisplayName() {
  83. return displayName;
  84. }
  85. public void setDisplayName(String displayName) {
  86. this.displayName = displayName;
  87. }
  88. public List<CustomizationField> getFieldList() {
  89. return fieldList;
  90. }
  91. public void setFieldList(List<CustomizationField> fieldList) {
  92. this.fieldList = fieldList;
  93. }
  94. @Override
  95. public String toString() {
  96. return "CustomizationFieldGroup{" + "code='" + code + '\'' + ", position=" + position + ", displayName='" + displayName + '\'' + ", fieldList=" + fieldList + '}';
  97. }
  98. }
  99. public static class CustomizationField {
  100. public enum Type {
  101. CHECKBOX,
  102. TEXT_AREA,
  103. IMAGE,
  104. DROPDOWN
  105. }
  106. /**
  107. * Name as displayed on the page
  108. */
  109. private String name;
  110. /**
  111. * Unique code of each field. Values of these customization parameters are stored in the {@code PrintTemplateVO}
  112. * with this code as key.
  113. */
  114. private String code;
  115. /**
  116. * On which field does this field depend.
  117. */
  118. private String parentFieldCode;
  119. /**
  120. * Is mandatory?
  121. */
  122. private boolean required;
  123. /**
  124. * Type of the field. Checkbox fields are ones whose values are present in the system and client has to give a
  125. * Yes/No answer depending on which the field will show up in the template.
  126. */
  127. private Type type;
  128. /**
  129. * CMS key of the content to be shown on tooltip.
  130. */
  131. private String tooltipKey;
  132. /**
  133. * Additional info for UI
  134. */
  135. private Map<String, Object> uiConfigMetadata;
  136. /**
  137. * List of possible values (mostly used for dropdown type).
  138. */
  139. private List<String> possibleValues;
  140. /**
  141. * List of product types for which this field is applicable
  142. */
  143. private List<String> applicableForProductFeatures;
  144. /**
  145. * Is enabled? Only enabled fields will show up on the UI (and will be visible in the evaluated template)
  146. */
  147. private boolean enabled;
  148. public CustomizationField() {
  149. super();
  150. }
  151. public Type getType() {
  152. return type;
  153. }
  154. public String getName() {
  155. return name;
  156. }
  157. public void setName(String name) {
  158. this.name = name;
  159. }
  160. public String getCode() {
  161. return code;
  162. }
  163. public void setCode(String code) {
  164. this.code = code;
  165. }
  166. public Map<String, Object> getUiConfigMetadata() {
  167. return uiConfigMetadata;
  168. }
  169. public String getParentFieldCode() {
  170. return parentFieldCode;
  171. }
  172. public void setParentFieldCode(String parentFieldCode) {
  173. this.parentFieldCode = parentFieldCode;
  174. }
  175. public Type isType() {
  176. return type;
  177. }
  178. public void setType(Type type) {
  179. this.type = type;
  180. }
  181. public String getTooltipKey() {
  182. return tooltipKey;
  183. }
  184. public void setTooltipKey(String tooltipKey) {
  185. this.tooltipKey = tooltipKey;
  186. }
  187. public boolean isRequired() {
  188. return required;
  189. }
  190. public void setRequired(boolean required) {
  191. this.required = required;
  192. }
  193. public void setUiConfigMetadata(Map<String, Object> uiConfigMetadata) {
  194. this.uiConfigMetadata = uiConfigMetadata;
  195. }
  196. public List<String> getPossibleValues() {
  197. return possibleValues;
  198. }
  199. public void setPossibleValues(List<String> possibleValues) {
  200. this.possibleValues = possibleValues;
  201. }
  202. public boolean isEnabled() {
  203. return enabled;
  204. }
  205. public void setEnabled(boolean enabled) {
  206. this.enabled = enabled;
  207. }
  208. public List<String> getApplicableForProductFeatures() {
  209. return applicableForProductFeatures;
  210. }
  211. public void setApplicableForProductFeatures(List<String> applicableForProductFeatures) {
  212. this.applicableForProductFeatures = applicableForProductFeatures;
  213. }
  214. @Override
  215. public String toString() {
  216. return "CustomizationField{" + "name='" + name + '\'' + ", code='" + code + '\'' + ", required=" + required + ", type=" + type + ", uiConfigMetadata="
  217. + uiConfigMetadata + ", enabled=" + enabled + '}';
  218. }
  219. }
  220. @Override
  221. public String toString() {
  222. return "TemplateCustomizationFieldsVO{" + "id='" + id + '\'' + ", templateType=" + templateType + ", customizationFieldGroupList=" + customizationFieldGroupList + '}';
  223. }
  224. public static void main(String[] args) {
  225. TemplateCustomizationFieldsVO vo = new TemplateCustomizationFieldsVO();
  226. List<CustomizationFieldGroup> customizationFieldGroupList = new ArrayList<>();
  227. // C1
  228. CustomizationFieldGroup c1 = new CustomizationFieldGroup();
  229. c1.setDisplayName("Item Details");
  230. c1.setCode("ITEM_DETAILS");
  231. c1.setPosition(1);
  232. List<CustomizationField> cfl1 = new ArrayList<>();
  233. CustomizationField cf11 = new CustomizationField();
  234. cf11.setCode("DISPLAY_BRAND");
  235. cf11.setName("Brand");
  236. cf11.setEnabled(true);
  237. cf11.setRequired(false);
  238. cf11.setType(CustomizationField.Type.CHECKBOX);
  239. CustomizationField cf12 = new CustomizationField();
  240. cf12.setCode("DISPLAY_PRODUCT_NAME");
  241. cf12.setName("Product Name");
  242. cf12.setEnabled(true);
  243. cf12.setRequired(false);
  244. cf12.setType(CustomizationField.Type.CHECKBOX);
  245. CustomizationField cf13 = new CustomizationField();
  246. cf13.setCode("DISPLAY_PRODUCT_DESCRIPTION");
  247. cf13.setName("Product Description");
  248. cf13.setEnabled(true);
  249. cf13.setRequired(false);
  250. cf13.setType(CustomizationField.Type.CHECKBOX);
  251. CustomizationField cf14 = new CustomizationField();
  252. cf14.setCode("DISPLAY_PRODUCT_SKU_CODE");
  253. cf14.setName("Product SKU Code");
  254. cf14.setEnabled(true);
  255. cf14.setRequired(false);
  256. cf14.setType(CustomizationField.Type.CHECKBOX);
  257. CustomizationField cf15 = new CustomizationField();
  258. cf15.setCode("DISPLAY_CHANNEL_SKU_CODE");
  259. cf15.setName("Channel SKU Code");
  260. cf15.setEnabled(true);
  261. cf15.setRequired(false);
  262. cf15.setType(CustomizationField.Type.CHECKBOX);
  263. CustomizationField cf16 = new CustomizationField();
  264. cf16.setCode("DISPLAY_COLOR");
  265. cf16.setName("Color");
  266. cf16.setEnabled(true);
  267. cf16.setRequired(false);
  268. cf16.setType(CustomizationField.Type.CHECKBOX);
  269. CustomizationField cf17 = new CustomizationField();
  270. cf17.setCode("DISPLAY_SIZE");
  271. cf17.setName("SIZE");
  272. cf17.setEnabled(true);
  273. cf17.setRequired(false);
  274. cf17.setType(CustomizationField.Type.CHECKBOX);
  275. CustomizationField cf18 = new CustomizationField();
  276. cf18.setCode("DISPLAY_MRP");
  277. cf18.setName("MRP");
  278. cf18.setEnabled(true);
  279. cf18.setRequired(false);
  280. cf18.setType(CustomizationField.Type.CHECKBOX);
  281. CustomizationField cf19 = new CustomizationField();
  282. cf19.setCode("DISPLAY_DISCOUNT");
  283. cf19.setName("Discount");
  284. cf19.setEnabled(true);
  285. cf19.setRequired(false);
  286. cf19.setType(CustomizationField.Type.CHECKBOX);
  287. CustomizationField cf110 = new CustomizationField();
  288. cf110.setCode("DISPLAY_TAX");
  289. cf110.setName("Tax");
  290. cf110.setEnabled(true);
  291. cf110.setRequired(false);
  292. cf110.setType(CustomizationField.Type.CHECKBOX);
  293. cfl1.addAll(Arrays.asList(cf11, cf12, cf13, cf14, cf15, cf16, cf17, cf18, cf19, cf110));
  294. c1.setFieldList(cfl1);
  295. customizationFieldGroupList.add(c1);
  296. // C2
  297. CustomizationFieldGroup c2 = new CustomizationFieldGroup();
  298. c2.setDisplayName("Order Details");
  299. c2.setCode("ORDER_DETAILS");
  300. c2.setPosition(2);
  301. List<CustomizationField> cfl2 = new ArrayList<>();
  302. CustomizationField cf21 = new CustomizationField();
  303. cf21.setCode("DISPLAY_SHIP_DATE");
  304. cf21.setName("Ship Date");
  305. cf21.setEnabled(true);
  306. cf21.setRequired(false);
  307. cf21.setType(CustomizationField.Type.CHECKBOX);
  308. CustomizationField cf22 = new CustomizationField();
  309. cf22.setCode("DISPLAY_CARRIER_NAME");
  310. cf22.setName("Carrier Name");
  311. cf22.setEnabled(true);
  312. cf22.setRequired(false);
  313. cf22.setType(CustomizationField.Type.CHECKBOX);
  314. CustomizationField cf23 = new CustomizationField();
  315. cf23.setCode("DISPLAY_AWB_NUM");
  316. cf23.setName("AWB Number");
  317. cf23.setEnabled(true);
  318. cf23.setRequired(false);
  319. cf23.setType(CustomizationField.Type.CHECKBOX);
  320. CustomizationField cf24 = new CustomizationField();
  321. cf24.setCode("DISPLAY_INVOICE_BARCODE");
  322. cf24.setName("Invoice Barcode");
  323. cf24.setEnabled(true);
  324. cf24.setRequired(false);
  325. cf24.setType(CustomizationField.Type.CHECKBOX);
  326. CustomizationField cf25 = new CustomizationField();
  327. cf25.setCode("DISPLAY_ORDER_NUM_BARCODE");
  328. cf25.setName("Order Number Barcode");
  329. cf25.setEnabled(true);
  330. cf25.setRequired(false);
  331. cf25.setType(CustomizationField.Type.CHECKBOX);
  332. CustomizationField cf26 = new CustomizationField();
  333. cf26.setCode("DISPLAY_CHANNEL_NAME");
  334. cf26.setName("Channel Name");
  335. cf26.setEnabled(true);
  336. cf26.setRequired(false);
  337. cf26.setType(CustomizationField.Type.CHECKBOX);
  338. CustomizationField cf27 = new CustomizationField();
  339. cf27.setCode("DISPLAY_SHIPPING_CHARGES");
  340. cf27.setName("Shipping Charges");
  341. cf27.setEnabled(true);
  342. cf27.setRequired(false);
  343. cf27.setType(CustomizationField.Type.CHECKBOX);
  344. CustomizationField cf28 = new CustomizationField();
  345. cf28.setCode("DISPLAY_COD_CHARGES");
  346. cf28.setName("COD Charges");
  347. cf28.setEnabled(true);
  348. cf28.setRequired(false);
  349. cf28.setType(CustomizationField.Type.CHECKBOX);
  350. CustomizationField cf29 = new CustomizationField();
  351. cf29.setCode("DISPLAY_PREPAID_AMOUNT");
  352. cf29.setName("Prepaid Amount");
  353. cf29.setEnabled(true);
  354. cf29.setRequired(false);
  355. cf29.setType(CustomizationField.Type.CHECKBOX);
  356. CustomizationField cf210 = new CustomizationField();
  357. cf210.setCode("DISPLAY_TOTAL_VAT_CST");
  358. cf210.setName("Total VAT/CST On Sale");
  359. cf210.setEnabled(true);
  360. cf210.setRequired(false);
  361. cf210.setType(CustomizationField.Type.CHECKBOX);
  362. CustomizationField cf211 = new CustomizationField();
  363. cf211.setCode("DISPLAY_TRADE_DISCOUNT");
  364. cf211.setName("TRADE_DISCOUNT");
  365. cf211.setEnabled(false);
  366. cf211.setRequired(false);
  367. cf211.setType(CustomizationField.Type.CHECKBOX);
  368. CustomizationField cf212 = new CustomizationField();
  369. cf212.setCode("DISPLAY_ADDITIONAL_DISCOUNT");
  370. cf212.setName("Additional Discount");
  371. cf212.setEnabled(false);
  372. cf212.setRequired(false);
  373. cf212.setType(CustomizationField.Type.CHECKBOX);
  374. CustomizationField cf213 = new CustomizationField();
  375. cf213.setCode("DISPLAY_ADDITIONAL_TAX");
  376. cf213.setName("Additional Tax");
  377. cf213.setEnabled(false);
  378. cf213.setRequired(false);
  379. cf213.setType(CustomizationField.Type.CHECKBOX);
  380. CustomizationField cf214 = new CustomizationField();
  381. cf214.setCode("DISPLAY_AMOUNT_IN_WORDS");
  382. cf214.setName("Amount In Words");
  383. cf214.setEnabled(true);
  384. cf214.setRequired(false);
  385. cf214.setType(CustomizationField.Type.CHECKBOX);
  386. cfl2.addAll(Arrays.asList(cf21, cf22, cf23, cf24, cf25, cf26, cf27, cf28, cf29, cf210, cf211, cf212, cf213, cf214));
  387. c2.setFieldList(cfl2);
  388. customizationFieldGroupList.add(c2);
  389. // C3
  390. CustomizationFieldGroup c3 = new CustomizationFieldGroup();
  391. c3.setDisplayName("Seller-Byer Information");
  392. c3.setCode("SELLER_BUYER_INFORMATION");
  393. c3.setPosition(3);
  394. List<CustomizationField> cfl3 = new ArrayList<>();
  395. CustomizationField cf31 = new CustomizationField();
  396. cf31.setCode("SELLER_LOGO");
  397. cf31.setName("Seller Logo");
  398. cf31.setEnabled(true);
  399. cf31.setRequired(false);
  400. cf31.setType(CustomizationField.Type.IMAGE);
  401. CustomizationField cf32 = new CustomizationField();
  402. cf32.setCode("DISPLAY_SELLER_LOGO");
  403. cf32.setName("Display Seller Logo");
  404. cf32.setEnabled(true);
  405. cf32.setRequired(false);
  406. cf32.setType(CustomizationField.Type.CHECKBOX);
  407. CustomizationField cf33 = new CustomizationField();
  408. cf33.setCode("DISPLAY_CHANNEL_LOGO");
  409. cf33.setName("Channel Logo");
  410. cf33.setEnabled(true);
  411. cf33.setRequired(false);
  412. cf33.setType(CustomizationField.Type.CHECKBOX);
  413. CustomizationField cf34 = new CustomizationField();
  414. cf34.setCode("DISPLAY_WAREHOUSE_NAME");
  415. cf34.setName("Warehouse Name");
  416. cf34.setEnabled(true);
  417. cf34.setRequired(false);
  418. cf34.setType(CustomizationField.Type.CHECKBOX);
  419. CustomizationField cf35 = new CustomizationField();
  420. cf35.setCode("DISPLAY_WAREHOUSE_ADDRESS");
  421. cf35.setName("Warehouse Address");
  422. cf35.setEnabled(true);
  423. cf35.setRequired(false);
  424. cf35.setType(CustomizationField.Type.CHECKBOX);
  425. CustomizationField cf36 = new CustomizationField();
  426. cf36.setCode("DISPLAY_BUYER_VAT_TIN_NUM");
  427. cf36.setName("Buyer VAT TIN Number");
  428. cf36.setEnabled(false);
  429. cf36.setRequired(false);
  430. cf36.setType(CustomizationField.Type.CHECKBOX);
  431. CustomizationField cf37 = new CustomizationField();
  432. cf37.setCode("DISPLAY_BUYER_CST_TIN_NUM");
  433. cf37.setName("Buyer CST TIN Number");
  434. cf37.setEnabled(false);
  435. cf37.setRequired(false);
  436. cf37.setType(CustomizationField.Type.CHECKBOX);
  437. CustomizationField cf38 = new CustomizationField();
  438. cf38.setCode("DISPLAY_BUYER_CIN_NUM");
  439. cf38.setName("Buyer CIN Number");
  440. cf38.setEnabled(false);
  441. cf38.setRequired(false);
  442. cf38.setType(CustomizationField.Type.CHECKBOX);
  443. CustomizationField cf39 = new CustomizationField();
  444. cf39.setCode("DISPLAY_SELLER_VAT_TIN_NUM");
  445. cf39.setName("Seller VAT TIN Number");
  446. cf39.setEnabled(true);
  447. cf39.setRequired(false);
  448. cf39.setType(CustomizationField.Type.CHECKBOX);
  449. CustomizationField cf310 = new CustomizationField();
  450. cf310.setCode("DISPLAY_SELLER_CST_TIN_NUM");
  451. cf310.setName("Seller CST TIN Number");
  452. cf310.setEnabled(true);
  453. cf310.setRequired(false);
  454. cf310.setType(CustomizationField.Type.CHECKBOX);
  455. CustomizationField cf311 = new CustomizationField();
  456. cf311.setCode("DISPLAY_SELLER_CIN_NUM");
  457. cf311.setName("Seller CIN Number");
  458. cf311.setEnabled(false);
  459. cf311.setRequired(false);
  460. cf311.setType(CustomizationField.Type.CHECKBOX);
  461. CustomizationField cf312 = new CustomizationField();
  462. cf312.setCode("DISPLAY_RECIPIENT_VAT_TIN_NUM");
  463. cf312.setName("Recipient VAT TIN Number");
  464. cf312.setEnabled(false);
  465. cf312.setRequired(false);
  466. cf312.setType(CustomizationField.Type.CHECKBOX);
  467. CustomizationField cf313 = new CustomizationField();
  468. cf313.setCode("DISPLAY_RECIPIENT_CST_TIN_NUM");
  469. cf313.setName("Recipient CST TIN Number");
  470. cf313.setEnabled(false);
  471. cf313.setRequired(false);
  472. cf313.setType(CustomizationField.Type.CHECKBOX);
  473. CustomizationField cf314 = new CustomizationField();
  474. cf314.setCode("DISPLAY_RECIPIENT_CIN_NUM");
  475. cf314.setName("Recipient CIN Number");
  476. cf314.setEnabled(false);
  477. cf314.setRequired(false);
  478. cf314.setType(CustomizationField.Type.CHECKBOX);
  479. CustomizationField cf315 = new CustomizationField();
  480. cf315.setCode("DISPLAY_CUSTOMER_CARE_NUM");
  481. cf315.setName("Customer Care Number");
  482. cf315.setEnabled(false);
  483. cf315.setRequired(false);
  484. cf315.setType(CustomizationField.Type.CHECKBOX);
  485. CustomizationField cf316 = new CustomizationField();
  486. cf316.setCode("DISPLAY_CUSTOMER_CARE_EMAIL");
  487. cf316.setName("Customer Care Email");
  488. cf316.setEnabled(false);
  489. cf316.setRequired(false);
  490. cf316.setType(CustomizationField.Type.CHECKBOX);
  491. CustomizationField cf317 = new CustomizationField();
  492. cf317.setCode("NOTES");
  493. cf317.setName("NOTES");
  494. cf317.setEnabled(true);
  495. cf317.setRequired(false);
  496. cf317.setType(CustomizationField.Type.TEXT_AREA);
  497. CustomizationField cf318 = new CustomizationField();
  498. cf318.setCode("DIGITAL_SIGNATURE");
  499. cf318.setName("Digital Signature");
  500. cf318.setPossibleValues(Arrays.asList("A", "B"));
  501. cf318.setEnabled(false);
  502. cf318.setRequired(false);
  503. cf318.setType(CustomizationField.Type.IMAGE);
  504. CustomizationField cf319 = new CustomizationField();
  505. cf319.setCode("SIGNATURE");
  506. cf319.setName("Signature");
  507. cf319.setEnabled(true);
  508. cf319.setRequired(false);
  509. cf319.setType(CustomizationField.Type.TEXT_AREA);
  510. CustomizationField cf320 = new CustomizationField();
  511. cf320.setCode("TERMS_AND_CONDITIONS ");
  512. cf320.setName("Terms And Conditions");
  513. cf320.setEnabled(true);
  514. cf320.setRequired(false);
  515. cf320.setType(CustomizationField.Type.TEXT_AREA);
  516. cfl3.addAll(Arrays.asList(cf31, cf32, cf33, cf34, cf35, cf36, cf37, cf38, cf39, cf310, cf311, cf312, cf313, cf314, cf315, cf316, cf317, cf318, cf319, cf320));
  517. c3.setFieldList(cfl3);
  518. customizationFieldGroupList.add(c3);
  519. //vo.setTemplateType(Type.TAX_INVOICE);
  520. vo.setCustomizationFieldGroupList(customizationFieldGroupList);
  521. System.out.println(new Gson().toJson(vo));
  522. }
  523. }