View Javadoc

1   /*
2    * SymmetricDS is an open source database synchronization solution.
3    *   
4    * Copyright (C) Chris Henson <chenson42@users.sourceforge.net>
5    *
6    * This library is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * version 3 of the License, or (at your option) any later version.
10   *
11   * This library is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   * Lesser General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public
17   * License along with this library; if not, see
18   * <http://www.gnu.org/licenses/>.
19   */
20  
21  package org.jumpmind.symmetric.model;
22  
23  import java.io.Serializable;
24  import java.util.Date;
25  
26  public class OutgoingBatch implements Serializable {
27  
28      private static final long serialVersionUID = 1L;
29  
30      public enum Status {
31          NE, SE, ER, OK;
32      }
33  
34      private long batchId;
35  
36      private String nodeId;
37  
38      private String channelId;
39  
40      private Status status = Status.NE;
41  
42      private BatchType batchType = BatchType.EVENTS;
43  
44      private Date createTime;
45  
46      public OutgoingBatch() {
47      }
48  
49      public OutgoingBatch(Node node, String channelId, BatchType batchType) {
50          this.nodeId = node.getNodeId();
51          this.channelId = channelId;
52          this.status = Status.NE;
53          this.batchType = batchType;
54      }
55  
56      public String getNodeBatchId() {
57          return nodeId + "-" + batchId;
58      }
59  
60      public long getBatchId() {
61          return batchId;
62      }
63  
64      public void setBatchId(long batchId) {
65          this.batchId = batchId;
66      }
67  
68      public Status getStatus() {
69          return status;
70      }
71  
72      public void setStatus(Status status) {
73          this.status = status;
74      }
75  
76      public String getNodeId() {
77          return nodeId;
78      }
79  
80      public void setNodeId(String locationId) {
81          this.nodeId = locationId;
82      }
83  
84      public String getChannelId() {
85          return channelId;
86      }
87  
88      public void setChannelId(String channelId) {
89          this.channelId = channelId;
90      }
91  
92      public void setStatus(String status) {
93          this.status = Status.valueOf(status);
94      }
95  
96      public BatchType getBatchType() {
97          return batchType;
98      }
99  
100     public BatchInfo getBatchInfo() {
101         return new BatchInfo(this.batchId);
102     }
103 
104     public void setBatchType(BatchType batchType) {
105         this.batchType = batchType;
106     }
107 
108     public void setBatchType(String batchType) {
109         if (BatchType.EVENTS.getCode().equals(batchType)) {
110             this.batchType = BatchType.EVENTS;
111         } else if (BatchType.INITIAL_LOAD.getCode().equals(batchType)) {
112             this.batchType = BatchType.INITIAL_LOAD;
113         } else {
114             batchType = null;
115         }
116     }
117 
118     public Date getCreateTime() {
119         return createTime;
120     }
121 
122     public void setCreateTime(Date createTime) {
123         this.createTime = createTime;
124     }
125 
126 }