aboutsummaryrefslogtreecommitdiffstats
path: root/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java
blob: d6fe4f9a9f6ef9ebe9513b9cd44ca7c4f90a685f (plain)
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
/*
 * Copyright © 2017-2018 AT&T Intellectual Property.
 * Modifications Copyright © 2018 IBM.
 * 
 * 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.
 * 
 * 
 * Unless otherwise specified, all documentation contained herein is licensed
 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 * you may not use this documentation except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *         https://creativecommons.org/licenses/by/4.0/
 * 
 * Unless required by applicable law or agreed to in writing, documentation
 * 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 org.onap.optf.cmso.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.joda.time.format.ISODateTimeFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;

/**
 * The persistent class for the schedules database table.
 * 
 */
@Entity
@Table(name = "SCHEDULES")
@NamedQuery(name = "Schedule.findAll", query = "SELECT s FROM Schedule s")
public class Schedule implements Serializable {
    private static final long serialVersionUID = 1L;

    @JsonIgnore
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer id;

    @JsonIgnore
    @Column(name = "create_date_time")
    private Long createDateTimeMillis;

    @ApiModelProperty(value = "Date/time schedule was created.")
    @JsonProperty
    @Transient
    private String createDateTime;

    @ApiModelProperty(value = "Date/time optimizer was invoked.")
    @JsonIgnore
    @Column(name = "optimizer_date_time")
    private Long optimizerDateTimeMillis;

    @JsonProperty
    @Transient
    private String optimizerDateTime;

    @Lob
    @Column(name = "optimizer_message")
    private String optimizerMessage;

    @Column(name = "optimizer_status")
    private String optimizerStatus;

    @JsonIgnore
    @Column(name = "optimizer_attempts_to_schedule")
    private Integer optimizerAttemptsToSchedule;

    @JsonIgnore
    @Column(name = "optimizer_return_date_time")
    private Long optimizerReturnDateTimeMillis;

    @JsonProperty
    @Transient
    private String optimizerReturnDateTime;

    @Column(name = "optimizer_transaction_id")
    private String optimizerTransactionId;

    @Lob
    @Column(name = "schedule")
    private String schedule;

    @JsonIgnore
    @Column(name = "schedule_id")
    private String scheduleId;

    @Column(name = "schedule_name")
    private String scheduleName;

    @Lob
    @Column(name = "schedule_info")
    private String scheduleInfo;

    @Column(name = "status")
    private String status;

    @Column(name = "user_id")
    private String userId;

    @Column(name = "domain")
    private String domain;

    @JsonIgnore
    @Column(name = "delete_date_time")
    private Long deleteDateTimeMillis;

    @JsonProperty
    @Transient
    private String deleteDateTime;

    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "schedule")
    @LazyCollection(value = LazyCollectionOption.FALSE)
    // @JoinColumn(name="schedules_id")
    private List<DomainData> domainData;
    //
    // //uni-directional many-to-one association to ScheduleApproval
    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "schedule")
    @LazyCollection(value = LazyCollectionOption.FALSE)
    private List<ScheduleApproval> scheduleApprovals;
    //
    // //bi-directional many-to-one association to Domain
    // @ManyToOne
    // @JoinColumn(name="domain")
    // private Domain domainBean;

    @JsonProperty
    @Transient
    List<ChangeManagementGroup> groups;

    public Schedule() {}

    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCreateDateTime() {
        if (createDateTimeMillis != null)
            return ISODateTimeFormat.dateTimeNoMillis().print(this.createDateTimeMillis);
        return null;
    }

    public void setCreateDateTime(String datetime) {
        // only set time via setCreateDateTimeMillis
    }

    public void setCreateDateTimeMillis(Long millis) {
        this.createDateTimeMillis = millis;
    }

    public long getCreateDateTimeMillis() {
        return this.createDateTimeMillis;
    }

    public Long getDeleteDateTimeMillis() {
        return deleteDateTimeMillis;
    }

    public void setDeleteDateTimeMillis(Long deleteDateTimeMillis) {
        this.deleteDateTimeMillis = deleteDateTimeMillis;
    }

    public String getDeleteDateTime() {
        if (deleteDateTimeMillis != null)
            return ISODateTimeFormat.dateTimeNoMillis().print(this.deleteDateTimeMillis);
        return null;
    }

    public void setDeleteDateTime(String deleteDateTime) {}

    public String getOptimizerDateTime() {
        if (optimizerDateTimeMillis != null)
            return ISODateTimeFormat.dateTimeNoMillis().print(this.optimizerDateTimeMillis);
        return null;
    }

    public void setOptimizerDateTime(String optimizerDateTime) {}

    public String getOptimizerMessage() {
        return this.optimizerMessage;
    }

    public void setOptimizerMessage(String optimizerMessage) {
        this.optimizerMessage = optimizerMessage;
    }

    public String getOptimizerStatus() {
        return this.optimizerStatus;
    }

    public void setOptimizerStatus(String optimizerStatus) {
        this.optimizerStatus = optimizerStatus;
    }

    public String getSchedule() {
        return this.schedule;
    }

    public void setSchedule(String schedule) {
        this.schedule = schedule;
    }

    public String getScheduleId() {
        return this.scheduleId;
    }

    public void setScheduleId(String scheduleId) {
        this.scheduleId = scheduleId;
    }

    public String getScheduleName() {
        return this.scheduleName;
    }

    public void setScheduleName(String scheduleName) {
        this.scheduleName = scheduleName;
    }

    public String getScheduleInfo() {
        return this.scheduleInfo;
    }

    public void setScheduleInfo(String scheduleInfo) {
        this.scheduleInfo = scheduleInfo;
    }

    public String getStatus() {
        return this.status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getUserId() {
        return this.userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getDomain() {
        return domain;
    }

    public void setDomain(String domain) {
        this.domain = domain;
    }

    public List<DomainData> getDomainData() {
        return domainData;
    }

    public List<ScheduleApproval> getScheduleApprovals() {
        return scheduleApprovals;
    }

    public DomainData addDomainData(DomainData domainData) {
        List<DomainData> list = getDomainData();
        if (list == null)
            list = new ArrayList<DomainData>();
        list.add(domainData);
        domainData.setSchedule(this);
        return domainData;
    }

    public ScheduleApproval addScheduleApproval(ScheduleApproval sa) {
        List<ScheduleApproval> list = getScheduleApprovals();
        if (list == null)
            list = new ArrayList<ScheduleApproval>();
        list.add(sa);
        sa.setSchedule(this);
        return sa;
    }

    public Integer getOptimizerAttemptsToSchedule() {
        return optimizerAttemptsToSchedule;
    }

    public void setOptimizerAttemptsToSchedule(Integer optimizerAttemptsToSchedule) {
        this.optimizerAttemptsToSchedule = optimizerAttemptsToSchedule;
    }

    public String getOptimizerReturnDateTime() {
        if (optimizerReturnDateTimeMillis != null)
            return ISODateTimeFormat.dateTimeNoMillis().print(this.optimizerReturnDateTimeMillis);
        return null;
    }

    public void setOptimizerReturnDateTime(String optimizerReturnDateTime) {

    }

    public String getOptimizerTransactionId() {
        return optimizerTransactionId;
    }

    public void setOptimizerTransactionId(String optimizerTransactionId) {
        this.optimizerTransactionId = optimizerTransactionId;
    }

    public Long getOptimizerDateTimeMillis() {
        return optimizerDateTimeMillis;
    }

    public void setOptimizerDateTimeMillis(Long optimizerDateTimeMillis) {
        this.optimizerDateTimeMillis = optimizerDateTimeMillis;
    }

    public Long getOptimizerReturnDateTimeMillis() {
        return optimizerReturnDateTimeMillis;
    }

    public void setOptimizerReturnDateTimeMillis(Long optimizerReturnDateTimeMillis) {
        this.optimizerReturnDateTimeMillis = optimizerReturnDateTimeMillis;
    }

    public List<ChangeManagementGroup> getGroups() {
        return groups;
    }

    public void setGroups(List<ChangeManagementGroup> groups) {
        this.groups = groups;
    }

}