| 1 |
|
package org.itracker.web.ptos; |
| 2 |
|
|
| 3 |
|
import java.util.Collections; |
| 4 |
|
import java.util.Date; |
| 5 |
|
import java.util.Map; |
| 6 |
|
import java.util.Set; |
| 7 |
|
|
| 8 |
|
import org.apache.commons.lang.builder.ToStringBuilder; |
| 9 |
|
import org.itracker.model.PermissionType; |
| 10 |
|
import org.itracker.model.Project; |
| 11 |
|
import org.itracker.model.Status; |
| 12 |
|
import org.itracker.services.ProjectService; |
| 13 |
|
import org.itracker.services.util.UserUtilities; |
| 14 |
|
import org.itracker.web.util.ServletContextUtils; |
| 15 |
|
|
|
|
|
| 0% |
Uncovered Elements: 83 (83) |
Complexity: 35 |
Complexity Density: 0.81 |
|
| 16 |
|
public class ProjectPTO { |
| 17 |
|
|
| 18 |
|
private final Project project; |
| 19 |
|
|
| 20 |
|
private Long totalOpenIssues = null; |
| 21 |
|
private Long totalResolvedIssues = null; |
| 22 |
|
private Date lastUpdatedIssueDate = null; |
| 23 |
|
private Boolean canCreate = null; |
| 24 |
|
|
| 25 |
|
private final ProjectService projectService; |
| 26 |
|
private final Map<Integer, Set<PermissionType>> permissions; |
| 27 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 28 |
0
|
public ProjectPTO(Project project, Map<Integer, Set<PermissionType>> permissions) {... |
| 29 |
0
|
this(project, ServletContextUtils.getItrackerServices().getProjectService(), permissions); |
| 30 |
|
|
| 31 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 32 |
0
|
public ProjectPTO(Project project, ProjectService projectService, final Map<Integer, Set<PermissionType>> permissions) {... |
| 33 |
0
|
if (null == project) { |
| 34 |
0
|
throw new IllegalArgumentException("Project must not be null"); |
| 35 |
|
} |
| 36 |
0
|
this.project = project; |
| 37 |
0
|
this.projectService = projectService; |
| 38 |
0
|
this.permissions = Collections.unmodifiableMap(permissions); |
| 39 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 40 |
0
|
public Project getProject() {... |
| 41 |
0
|
return project; |
| 42 |
|
} |
| 43 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 44 |
0
|
public Long getTotalNumberIssues() {... |
| 45 |
0
|
return getTotalOpenIssues() + getTotalResolvedIssues(); |
| 46 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 47 |
0
|
public void setTotalNumberIssues(Long totalNumberIssues) {... |
| 48 |
0
|
setTotalOpenIssues(totalNumberIssues); |
| 49 |
0
|
setTotalResolvedIssues(0l); |
| 50 |
|
} |
| 51 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 52 |
0
|
public void setTotalOpenIssues(Long totalOpenIssues) {... |
| 53 |
0
|
this.totalOpenIssues = totalOpenIssues; |
| 54 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 55 |
0
|
public Long getTotalOpenIssues() {... |
| 56 |
0
|
if (null == totalOpenIssues) { |
| 57 |
0
|
setupNumberOfOpenIssues(this, projectService); |
| 58 |
|
} |
| 59 |
0
|
return totalOpenIssues; |
| 60 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 61 |
0
|
public void setTotalResolvedIssues(Long totalResolvedIssues) {... |
| 62 |
0
|
this.totalResolvedIssues = totalResolvedIssues; |
| 63 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 64 |
0
|
public Long getTotalResolvedIssues() {... |
| 65 |
0
|
if (null == totalResolvedIssues) { |
| 66 |
0
|
setupNumberOfResolvedIssues(this, projectService); |
| 67 |
|
} |
| 68 |
0
|
return totalResolvedIssues; |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
@return |
| 73 |
|
@see |
| 74 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 75 |
0
|
public Date getCreateDate() {... |
| 76 |
0
|
return project.getCreateDate(); |
| 77 |
|
} |
| 78 |
|
|
| 79 |
|
@return |
| 80 |
|
@see |
| 81 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 82 |
0
|
public String getDescription() {... |
| 83 |
0
|
return project.getDescription(); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
@return |
| 87 |
|
@see |
| 88 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 89 |
0
|
public Integer getId() {... |
| 90 |
0
|
return project.getId(); |
| 91 |
|
} |
| 92 |
|
|
| 93 |
|
@return |
| 94 |
|
@see |
| 95 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 96 |
0
|
public Date getLastModifiedDate() {... |
| 97 |
0
|
return project.getLastModifiedDate(); |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
@return |
| 101 |
|
@see |
| 102 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 103 |
0
|
public String getName() {... |
| 104 |
0
|
return project.getName(); |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
@return |
| 108 |
|
@see |
| 109 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 110 |
0
|
public Status getStatus() {... |
| 111 |
0
|
return project.getStatus(); |
| 112 |
|
} |
| 113 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 114 |
0
|
public Boolean getActive() {... |
| 115 |
0
|
return getStatus() == Status.ACTIVE; |
| 116 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 117 |
0
|
public Boolean isActive() {... |
| 118 |
0
|
return getActive(); |
| 119 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 120 |
0
|
public Boolean getViewable() {... |
| 121 |
0
|
return getProject().getStatus() == Status.VIEWABLE; |
| 122 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 123 |
0
|
public Boolean isViewable() {... |
| 124 |
0
|
return getViewable(); |
| 125 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 126 |
0
|
public Boolean getCanCreate() {... |
| 127 |
0
|
if (null == this.canCreate) { |
| 128 |
0
|
setupCanCreate(this, permissions); |
| 129 |
|
} |
| 130 |
0
|
return this.canCreate; |
| 131 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 132 |
0
|
public Boolean isCanCreate() {... |
| 133 |
0
|
return getCanCreate(); |
| 134 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 135 |
0
|
public void setCanCreate(Boolean canCreate) {... |
| 136 |
0
|
this.canCreate = canCreate; |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 140 |
0
|
public void setLastUpdatedIssueDate(Date lastUpdatedIssueDate) {... |
| 141 |
0
|
if (null == lastUpdatedIssueDate) { |
| 142 |
0
|
setupLastIssueUpdateDate(this, projectService); |
| 143 |
|
} |
| 144 |
0
|
this.lastUpdatedIssueDate = lastUpdatedIssueDate; |
| 145 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 146 |
0
|
public Date getLastUpdatedIssueDate() {... |
| 147 |
0
|
return lastUpdatedIssueDate; |
| 148 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 149 |
0
|
@Override... |
| 150 |
|
public String toString() { |
| 151 |
0
|
return new ToStringBuilder(this).append("project", getProject()).toString(); |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 156 |
0
|
@SuppressWarnings("unused")... |
| 157 |
|
private static final void setupNumberOfIssues(ProjectPTO pto, |
| 158 |
|
ProjectService service) { |
| 159 |
0
|
pto.setTotalNumberIssues(service.getTotalNumberIssuesByProject(pto |
| 160 |
|
.getId())); |
| 161 |
|
} |
| 162 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 163 |
0
|
private static final void setupNumberOfOpenIssues(ProjectPTO pto,... |
| 164 |
|
ProjectService service) { |
| 165 |
0
|
pto.setTotalOpenIssues(service.getTotalNumberOpenIssuesByProject(pto |
| 166 |
|
.getId())); |
| 167 |
|
} |
| 168 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 169 |
0
|
private static final void setupNumberOfResolvedIssues(ProjectPTO pto,... |
| 170 |
|
ProjectService service) { |
| 171 |
0
|
pto.setTotalResolvedIssues(service |
| 172 |
|
.getTotalNumberResolvedIssuesByProject(pto.getId())); |
| 173 |
|
} |
| 174 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 175 |
0
|
private static final void setupCanCreate(ProjectPTO pto,... |
| 176 |
|
final Map<Integer, Set<PermissionType>> permissions) { |
| 177 |
0
|
pto.setCanCreate(UserUtilities.hasPermission(permissions, pto.getId(), |
| 178 |
|
UserUtilities.PERMISSION_CREATE)); |
| 179 |
|
} |
| 180 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 181 |
0
|
private static final void setupLastIssueUpdateDate(ProjectPTO pto,... |
| 182 |
|
ProjectService service) { |
| 183 |
0
|
pto.setLastUpdatedIssueDate(service |
| 184 |
|
.getLatestIssueUpdatedDateByProjectId(pto.getId())); |
| 185 |
|
} |
| 186 |
|
} |