src/main/java/de/uapcore/lightpit/entities/Issue.java

changeset 150
822b7e3d064d
parent 144
7e06b75cf1b9
equal deleted inserted replaced
149:30b840ed8c0e 150:822b7e3d064d
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2018 Mike Becker. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29 package de.uapcore.lightpit.entities;
30
31 import java.sql.Date;
32 import java.sql.Timestamp;
33 import java.time.Instant;
34 import java.util.Collections;
35 import java.util.List;
36 import java.util.Objects;
37
38 public final class Issue {
39
40 private int id;
41 private Project project;
42 private Component component;
43
44 private IssueStatus status;
45 private IssueCategory category;
46
47 private String subject;
48 private String description;
49 private User assignee;
50
51 private List<Version> affectedVersions = Collections.emptyList();
52 private List<Version> resolvedVersions = Collections.emptyList();
53
54 private Timestamp created = Timestamp.from(Instant.now());
55 private Timestamp updated = Timestamp.from(Instant.now());
56 private Date eta;
57
58 public Issue(int id) {
59 this.id = id;
60 }
61
62 public int getId() {
63 return id;
64 }
65
66 /**
67 * Should only be used by a DAO to store the generated ID.
68 * @param id the freshly generated ID returned from the database after insert
69 */
70 public void setId(int id) {
71 this.id = id;
72 }
73
74 public void setProject(Project project) {
75 this.project = project;
76 }
77
78 public Project getProject() {
79 return project;
80 }
81
82 public Component getComponent() {
83 return component;
84 }
85
86 public void setComponent(Component component) {
87 this.component = component;
88 }
89
90 public IssueStatus getStatus() {
91 return status;
92 }
93
94 public void setStatus(IssueStatus status) {
95 this.status = status;
96 }
97
98 public int getPhase() {
99 return this.status.getPhase();
100 }
101
102 public IssueCategory getCategory() {
103 return category;
104 }
105
106 public void setCategory(IssueCategory category) {
107 this.category = category;
108 }
109
110 public String getSubject() {
111 return subject;
112 }
113
114 public void setSubject(String subject) {
115 this.subject = subject;
116 }
117
118 public String getDescription() {
119 return description;
120 }
121
122 public void setDescription(String description) {
123 this.description = description;
124 }
125
126 public User getAssignee() {
127 return assignee;
128 }
129
130 public void setAssignee(User assignee) {
131 this.assignee = assignee;
132 }
133
134 public List<Version> getAffectedVersions() {
135 return affectedVersions;
136 }
137
138 public void setAffectedVersions(List<Version> affectedVersions) {
139 this.affectedVersions = affectedVersions;
140 }
141
142 public List<Version> getResolvedVersions() {
143 return resolvedVersions;
144 }
145
146 public void setResolvedVersions(List<Version> resolvedVersions) {
147 this.resolvedVersions = resolvedVersions;
148 }
149
150 public Timestamp getCreated() {
151 return created;
152 }
153
154 public void setCreated(Timestamp created) {
155 this.created = created;
156 }
157
158 public Timestamp getUpdated() {
159 return updated;
160 }
161
162 public void setUpdated(Timestamp updated) {
163 this.updated = updated;
164 }
165
166 public Date getEta() {
167 return eta;
168 }
169
170 public void setEta(Date eta) {
171 this.eta = eta;
172 }
173
174 /**
175 * An issue is overdue, if it is not done and the ETA is before the current time.
176 * @return true if this issue is overdue, false otherwise
177 */
178 public boolean isOverdue() {
179 return eta != null && status.getPhase() != IssueStatus.PHASE_DONE
180 && eta.before(new Date(System.currentTimeMillis()));
181 }
182
183 @Override
184 public boolean equals(Object o) {
185 if (this == o) return true;
186 if (o == null || getClass() != o.getClass()) return false;
187 Issue issue = (Issue) o;
188 return id == issue.id;
189 }
190
191 @Override
192 public int hashCode() {
193 return Objects.hash(id);
194 }
195 }

mercurial