Fri, 22 May 2020 21:23:57 +0200
adds the ability to create and edit issues
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;
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;
38 public final class Issue {
40 private int id;
41 private final Project project;
43 private IssueStatus status;
44 private IssueCategory category;
46 private String subject;
47 private String description;
48 private User assignee;
50 private List<Version> affectedVersions = Collections.emptyList();
51 private List<Version> scheduledVersions = Collections.emptyList();
52 private List<Version> resolvedVersions = Collections.emptyList();
54 private Timestamp created = Timestamp.from(Instant.now());
55 private Timestamp updated = Timestamp.from(Instant.now());
56 private Date eta;
58 public Issue(int id, Project project) {
59 this.id = id;
60 this.project = project;
61 }
63 public int getId() {
64 return id;
65 }
67 /**
68 * Should only be used by a DAO to store the generated ID.
69 * @param id the freshly generated ID returned from the database after insert
70 */
71 public void setId(int id) {
72 this.id = id;
73 }
75 public Project getProject() {
76 return project;
77 }
79 public IssueStatus getStatus() {
80 return status;
81 }
83 public void setStatus(IssueStatus status) {
84 this.status = status;
85 }
87 public IssueCategory getCategory() {
88 return category;
89 }
91 public void setCategory(IssueCategory category) {
92 this.category = category;
93 }
95 public String getSubject() {
96 return subject;
97 }
99 public void setSubject(String subject) {
100 this.subject = subject;
101 }
103 public String getDescription() {
104 return description;
105 }
107 public void setDescription(String description) {
108 this.description = description;
109 }
111 public User getAssignee() {
112 return assignee;
113 }
115 public void setAssignee(User assignee) {
116 this.assignee = assignee;
117 }
119 public List<Version> getAffectedVersions() {
120 return affectedVersions;
121 }
123 public void setAffectedVersions(List<Version> affectedVersions) {
124 this.affectedVersions = affectedVersions;
125 }
127 public List<Version> getScheduledVersions() {
128 return scheduledVersions;
129 }
131 public void setScheduledVersions(List<Version> scheduledVersions) {
132 this.scheduledVersions = scheduledVersions;
133 }
135 public List<Version> getResolvedVersions() {
136 return resolvedVersions;
137 }
139 public void setResolvedVersions(List<Version> resolvedVersions) {
140 this.resolvedVersions = resolvedVersions;
141 }
143 public Timestamp getCreated() {
144 return created;
145 }
147 public void setCreated(Timestamp created) {
148 this.created = created;
149 }
151 public Timestamp getUpdated() {
152 return updated;
153 }
155 public void setUpdated(Timestamp updated) {
156 this.updated = updated;
157 }
159 public Date getEta() {
160 return eta;
161 }
163 public void setEta(Date eta) {
164 this.eta = eta;
165 }
167 @Override
168 public boolean equals(Object o) {
169 if (this == o) return true;
170 if (o == null || getClass() != o.getClass()) return false;
171 Issue issue = (Issue) o;
172 return id == issue.id;
173 }
175 @Override
176 public int hashCode() {
177 return Objects.hash(id);
178 }
179 }