xuekang
2024-05-10 edf3b7fde038fcf3e6d86b8b4b88c2ff6f9014cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*
 *  Copyright 1999-2019 Seata.io Group.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package io.seata.server.console.vo;
 
import io.seata.core.constants.ServerTableColumnsName;
 
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Set;
 
/**
 * GlobalSessionVO
 * @author zhongxiang.wang
 */
public class GlobalSessionVO {
 
    private String xid;
 
    private String transactionId;
 
    private Integer status;
 
    private String applicationId;
 
    private String transactionServiceGroup;
 
    private String transactionName;
 
    private Long timeout;
 
    private Long beginTime;
 
    private String applicationData;
 
    private Long gmtCreate;
 
    private Long gmtModified;
 
    private Set<BranchSessionVO> branchSessionVOs;
 
 
    public GlobalSessionVO() {
 
    }
 
    public GlobalSessionVO(String xid,
                           Long transactionId,
                           Integer status,
                           String applicationId,
                           String transactionServiceGroup,
                           String transactionName,
                           Long timeout,
                           Long beginTime,
                           String applicationData,
                           Set<BranchSessionVO> branchSessionVOs) {
        this.xid = xid;
        this.transactionId = String.valueOf(transactionId);
        this.status = status;
        this.applicationId = applicationId;
        this.transactionServiceGroup = transactionServiceGroup;
        this.transactionName = transactionName;
        this.timeout = timeout;
        this.beginTime = beginTime;
        this.applicationData = applicationData;
        this.branchSessionVOs = branchSessionVOs;
    }
 
    public String getXid() {
        return xid;
    }
 
    public void setXid(String xid) {
        this.xid = xid;
    }
 
    public String getTransactionId() {
        return transactionId;
    }
 
    public void setTransactionId(Long transactionId) {
        this.transactionId = String.valueOf(transactionId);
    }
 
    public Integer getStatus() {
        return status;
    }
 
    public void setStatus(Integer status) {
        this.status = status;
    }
 
    public String getApplicationId() {
        return applicationId;
    }
 
    public void setApplicationId(String applicationId) {
        this.applicationId = applicationId;
    }
 
    public String getTransactionServiceGroup() {
        return transactionServiceGroup;
    }
 
    public void setTransactionServiceGroup(String transactionServiceGroup) {
        this.transactionServiceGroup = transactionServiceGroup;
    }
 
    public String getTransactionName() {
        return transactionName;
    }
 
    public void setTransactionName(String transactionName) {
        this.transactionName = transactionName;
    }
 
    public Long getTimeout() {
        return timeout;
    }
 
    public void setTimeout(Long timeout) {
        this.timeout = timeout;
    }
 
    public Long getBeginTime() {
        return beginTime;
    }
 
    public void setBeginTime(Long beginTime) {
        this.beginTime = beginTime;
    }
 
    public String getApplicationData() {
        return applicationData;
    }
 
    public void setApplicationData(String applicationData) {
        this.applicationData = applicationData;
    }
 
    public Long getGmtCreate() {
        return gmtCreate;
    }
 
    public void setGmtCreate(Long gmtCreate) {
        this.gmtCreate = gmtCreate;
    }
 
    public Long getGmtModified() {
        return gmtModified;
    }
 
    public void setGmtModified(Long gmtModified) {
        this.gmtModified = gmtModified;
    }
 
    public Set<BranchSessionVO> getBranchSessionVOs() {
        return branchSessionVOs;
    }
 
    public void setBranchSessionVOs(Set<BranchSessionVO> branchSessionVOs) {
        this.branchSessionVOs = branchSessionVOs;
    }
 
    public static GlobalSessionVO convert(ResultSet rs) throws SQLException {
        GlobalSessionVO globalSessionVO = new GlobalSessionVO();
        globalSessionVO.setXid(rs.getString(ServerTableColumnsName.GLOBAL_TABLE_XID));
        globalSessionVO.setTransactionId(rs.getLong(ServerTableColumnsName.GLOBAL_TABLE_TRANSACTION_ID));
        globalSessionVO.setStatus(rs.getInt(ServerTableColumnsName.GLOBAL_TABLE_STATUS));
        globalSessionVO.setApplicationId(rs.getString(ServerTableColumnsName.GLOBAL_TABLE_APPLICATION_ID));
        globalSessionVO.setTransactionServiceGroup(rs.getString(ServerTableColumnsName.GLOBAL_TABLE_TRANSACTION_SERVICE_GROUP));
        globalSessionVO.setTransactionName(rs.getString(ServerTableColumnsName.GLOBAL_TABLE_TRANSACTION_NAME));
        globalSessionVO.setTimeout(rs.getLong(ServerTableColumnsName.GLOBAL_TABLE_TIMEOUT));
        globalSessionVO.setBeginTime(rs.getLong(ServerTableColumnsName.GLOBAL_TABLE_BEGIN_TIME));
        globalSessionVO.setApplicationData(rs.getString(ServerTableColumnsName.GLOBAL_TABLE_APPLICATION_DATA));
        Timestamp gmtCreateTimestamp = rs.getTimestamp(ServerTableColumnsName.GLOBAL_TABLE_GMT_CREATE);
        if (gmtCreateTimestamp != null) {
            globalSessionVO.setGmtCreate(gmtCreateTimestamp.getTime());
        }
        Timestamp gmtModifiedTimestamp = rs.getTimestamp(ServerTableColumnsName.GLOBAL_TABLE_GMT_MODIFIED);
        if (gmtModifiedTimestamp != null) {
            globalSessionVO.setGmtModified(gmtModifiedTimestamp.getTime());
        }
        return globalSessionVO;
    }
 
    @Override
    public String toString() {
        return "GlobalSessionVO{" +
                "xid='" + xid + '\'' +
                ", transactionId=" + transactionId +
                ", status=" + status +
                ", applicationId='" + applicationId + '\'' +
                ", transactionServiceGroup='" + transactionServiceGroup + '\'' +
                ", transactionName='" + transactionName + '\'' +
                ", timeout=" + timeout +
                ", beginTime=" + beginTime +
                ", applicationData='" + applicationData + '\'' +
                ", gmtCreate=" + gmtCreate +
                ", gmtModified=" + gmtModified +
                ", branchSessionVOs=" + branchSessionVOs +
                '}';
    }
}