Clover Coverage Report - itracker
Coverage timestamp: Tue May 1 2012 16:42:12 CEST
36   149   25   2.57
30   100   0.69   7
14     1.79  
2    
 
 
  SystemConfiguration       Line # 33 35 24 70.5% 0.7051282
  SystemConfiguration.SystemConfigurationComparator       Line # 141 1 1 0% 0.0
 
No Tests
 
1    /*
2    * This software was designed and created by Jason Carroll.
3    * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4    * The author can be reached at jcarroll@cowsultants.com
5    * ITracker website: http://www.cowsultants.com
6    * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7    *
8    * This program is free software; you can redistribute it and/or modify
9    * it only under the terms of the GNU General Public License as published by
10    * the Free Software Foundation; either version 2 of the License, or
11    * (at your option) any later version.
12    *
13    * This program is distributed in the hope that it will be useful,
14    * but WITHOUT ANY WARRANTY; without even the implied warranty of
15    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16    * GNU General Public License for more details.
17    */
18   
19    package org.itracker.model;
20   
21    import java.util.ArrayList;
22    import java.util.Arrays;
23    import java.util.Comparator;
24    import java.util.List;
25   
26    import org.apache.commons.lang.builder.CompareToBuilder;
27    import org.apache.commons.lang.builder.ToStringBuilder;
28    import org.itracker.services.util.SystemConfigurationUtilities;
29   
30    /**
31    *
32    */
 
33    public class SystemConfiguration extends AbstractEntity {
34   
35   
36    public static final Comparator<SystemConfiguration> VERSION_COMPARATOR = new SystemConfigurationComparator();
37    /**
38    *
39    */
40    private static final long serialVersionUID = 1L;
41   
42    private String version;
43   
44    private List<CustomField> customFields = new ArrayList<CustomField>();
45   
46    private List<Configuration> resolutions = new ArrayList<Configuration>();
47    private List<Configuration> severities = new ArrayList<Configuration>();
48    private List<Configuration> statuses = new ArrayList<Configuration>();
49   
 
50  8 toggle public SystemConfiguration() {
51    }
52   
 
53  0 toggle public String getVersion() {
54  0 return (version == null ? "" : version);
55    }
56   
 
57  1 toggle public void setVersion(String value) {
58  1 version = value;
59    }
60   
 
61  0 toggle public List<CustomField> getCustomFields() {
62  0 return customFields;
63    }
64   
 
65  2 toggle public void setCustomFields(List<CustomField> value) {
66  2 if (value != null) {
67  2 customFields = value;
68    }
69    }
70   
 
71  3 toggle public List<Configuration> getResolutions() {
72  3 return (resolutions == null ? new ArrayList<Configuration>()
73    : resolutions);
74    }
75   
 
76  1 toggle public void setResolutions(List<Configuration> value) {
77  1 if (value != null) {
78  1 resolutions = value;
79    }
80    }
81   
 
82  3 toggle public List<Configuration> getSeverities() {
83  3 return (severities == null ? new ArrayList<Configuration>()
84    : severities);
85    }
86   
 
87  1 toggle public void setSeverities(List<Configuration> value) {
88  1 if (value != null) {
89  1 severities = value;
90    }
91    }
92   
 
93  3 toggle public List<Configuration> getStatuses() {
94  3 return (statuses == null ? new ArrayList<Configuration>() : statuses);
95    }
96   
 
97  1 toggle public void setStatuses(List<Configuration> value) {
98  1 if (value != null) {
99  1 statuses = value;
100    }
101    }
102   
 
103  3 toggle public void addConfiguration(Configuration configuration) {
104  3 if (configuration != null) {
105  3 Configuration[] newArray;
106   
107  3 if (configuration.getType() == SystemConfigurationUtilities.TYPE_RESOLUTION) {
108  1 newArray = new Configuration[getResolutions().size() + 1];
109  1 if (getResolutions().size() > 0) {
110  0 System.arraycopy((Object) resolutions, 0,
111    (Object) newArray, 0, resolutions.size());
112    }
113  1 newArray[getResolutions().size()] = configuration;
114  1 setResolutions(Arrays.asList(newArray));
115  2 } else if (configuration.getType() == SystemConfigurationUtilities.TYPE_SEVERITY) {
116  1 newArray = new Configuration[getSeverities().size() + 1];
117  1 if (getSeverities().size() > 0) {
118  0 System.arraycopy((Object) severities, 0, (Object) newArray,
119    0, severities.size());
120    }
121  1 newArray[getSeverities().size()] = configuration;
122  1 setSeverities(Arrays.asList(newArray));
123  1 } else if (configuration.getType() == SystemConfigurationUtilities.TYPE_STATUS) {
124  1 newArray = new Configuration[getStatuses().size() + 1];
125  1 if (getStatuses().size() > 0) {
126  0 System.arraycopy((Object) statuses, 0, (Object) newArray,
127    0, statuses.size());
128    }
129  1 newArray[getStatuses().size()] = configuration;
130  1 setStatuses(Arrays.asList(newArray));
131    }
132    }
133    }
134   
 
135  0 toggle public String toString() {
136   
137  0 return new ToStringBuilder(this).append("id", getId()).append("version", getVersion()).toString();
138   
139    }
140   
 
141    private static final class SystemConfigurationComparator implements
142    Comparator<SystemConfiguration> {
 
143  0 toggle public int compare(SystemConfiguration o1, SystemConfiguration o2) {
144  0 return new CompareToBuilder().append(o1.getVersion(),
145    o2.getVersion()).append(o1.getId(), o2.getId())
146    .toComparison();
147    }
148    }
149    }