Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. public abstract class XmlBaseChild {
  2. protected Integer value;
  3. protected String text;
  4.  
  5. @Autowired
  6. transient protected MasterCodeService masterCodeService;
  7.  
  8.  
  9.  
  10. public XmlBaseChild(Integer value) {
  11. setValue(value);
  12. }
  13.  
  14. /**
  15. * Set the Numeric value of the ChildView.
  16. * This code is common for all childViews and handles a null value.
  17. * @param value Numeric value of the ChildView
  18. */
  19. @JsonProperty(value="id")
  20. public void setValue(Integer value) {
  21. if (value == null) {
  22. this.value = null;
  23. this.text = null;
  24. return;
  25. }
  26. setConcreteValue(value);
  27. }
  28.  
  29. /**
  30. * Set the Numeric value of the ChildView.
  31. * This code must be overridden by the concrete childViews.
  32. * @param value Numeric value of the ChildView
  33. */
  34. protected void setConcreteValue(Integer value){
  35. boolean keyNotFound = true;
  36. if (value != null && value > -1) {
  37. this.value = value;
  38. String messageKey = getValueFromMap(value, GetMasterCodeMapForChildView());
  39. if (messageKey != null) {
  40. this.text = LocalizeString(messageKey, null, getLocale);
  41. keyNotFound = false;
  42. }
  43. }
  44. if (keyNotFound){
  45. throw new NotFoundException();
  46. }
  47. }
  48.  
  49. protected abstract Map<String, MasterCodeView> GetMasterCodeMapForChildView();
  50. }
  51.  
  52. @Component
  53. @XmlRootElement(name=XmlDeployTool.VIEW_NAME)
  54. public class XmlDeployTool extends XmlBaseChild {
  55.  
  56. public static Map<String, MasterCodeView> toolTypeCodes = new HashMap<String, MasterCodeView>();
  57.  
  58.  
  59. /**
  60. * Constructor for creating this object and preparing for marchalling (from java objects to xml/json).
  61. * @param value Numeric value of the ChildView
  62. * @param request HttpServletRequest
  63. * @param includeSelf Include SELF link
  64. * @param includeUP Include UP link
  65. */
  66. public XmlDeployTool(Integer value) {
  67. super(value);
  68. }
  69.  
  70. /**
  71. * Initialize the Tool Type codes after the component is wired (postconstruct),
  72. * so that they are available in the constructor when an XmlDeploy object is created.
  73. */
  74. @PostConstruct
  75. protected void initializeDeployToolTypeCodes() {
  76. toolTypeCodes = convertListToMap(masterCodeService.getToolTypeCodes());
  77. }
  78. @Override
  79. protected Map<String, MasterCodeView> GetMasterCodeMapForChildView() {
  80. return toolTypeCodes;
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement