viraco4a

Suggestion

Mar 13th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. package com.aurora.intelligence.scheduling;
  2.  
  3. import com.fasterxml.jackson.annotation.JsonFormat;
  4. import com.fasterxml.jackson.annotation.JsonIgnore;
  5.  
  6. import java.util.*;
  7.  
  8. public class RedisMessage {
  9.  
  10. @JsonIgnore
  11. private String id;
  12.  
  13. private String requestId = UUID.randomUUID().toString();
  14. private RedisMessageType type;
  15. private RedisMessageStatus status = RedisMessageStatus.PROCESS;
  16. private String creatorServiceId;
  17. private String stage;
  18.  
  19. @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd't'HH:mm:ss.SSSXXX")
  20. private Date dateCreated = new Date();
  21.  
  22. private List<String> refIds;
  23. private Map<String, Object> params;
  24.  
  25. private boolean priority;
  26.  
  27. public RedisMessage() {
  28. this.refIds = new ArrayList<>();
  29. this.params = new HashMap<>();
  30. }
  31.  
  32. public String getRequestId() {
  33. return requestId;
  34. }
  35.  
  36. public void setRequestId(String requestId) {
  37. this.requestId = requestId;
  38. }
  39.  
  40. public RedisMessageType getType() {
  41. return type;
  42. }
  43.  
  44. public void setType(RedisMessageType type) {
  45. this.type = type;
  46. }
  47.  
  48. public RedisMessageStatus getStatus() {
  49. return status;
  50. }
  51.  
  52. public void setStatus(RedisMessageStatus status) {
  53. this.status = status;
  54. }
  55.  
  56. public String getCreatorServiceId() {
  57. return creatorServiceId;
  58. }
  59.  
  60. public void setCreatorServiceId(String creatorServiceId) {
  61. this.creatorServiceId = creatorServiceId;
  62. }
  63.  
  64. public String getStage() {
  65. return stage;
  66. }
  67.  
  68. public void setStage(String stage) {
  69. this.stage = stage;
  70. }
  71.  
  72. public Date getDateCreated() {
  73. return dateCreated;
  74. }
  75.  
  76. public void setDateCreated(Date dateCreated) {
  77. this.dateCreated = dateCreated;
  78. }
  79.  
  80. public List<String> getRefIds() {
  81. return refIds;
  82. }
  83.  
  84. public void setRefIds(List<String> refIds) {
  85. this.refIds = refIds;
  86. }
  87.  
  88. public Map<String, Object> getParams() {
  89. return params;
  90. }
  91.  
  92. public void setParams(Map<String, Object> params) {
  93. this.params = params;
  94. }
  95.  
  96. public boolean isPriority() {
  97. return priority;
  98. }
  99.  
  100. public void setPriority(boolean priority) {
  101. this.priority = priority;
  102. }
  103.  
  104. public String getId() {
  105. if (this.refIds.size() > 0) {
  106. return refIds.get(0);
  107. } else {
  108. return null;
  109. }
  110. }
  111.  
  112. public void addRefId(String refId) {
  113. this.refIds.add(refId);
  114. }
  115.  
  116. public void insertRefId(String refId) {
  117. this.refIds.add(0, refId);
  118. }
  119.  
  120. public String resetRequestId() {
  121. String id = UUID.randomUUID().toString();
  122. this.setRequestId(id);
  123. return id;
  124. }
  125.  
  126. public String insertDataObject(RedisMessageDataObject dataObject) {
  127. this.setType(dataObject.messageType());
  128. String id = dataObject.getClass().getSimpleName() + "-" + UUID.randomUUID().toString();
  129. this.insertRefId(id);
  130. return id;
  131. }
  132. }
Add Comment
Please, Sign In to add comment