View Javadoc
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 org.apache.commons.lang.builder.CompareToBuilder;
22  import org.apache.commons.lang.builder.ToStringBuilder;
23  
24  import java.util.ArrayList;
25  import java.util.Comparator;
26  import java.util.List;
27  
28  /**
29   *
30   */
31  public class SystemConfiguration extends AbstractEntity {
32  
33  
34      public static final Comparator<SystemConfiguration> VERSION_COMPARATOR = new SystemConfigurationComparator();
35      /**
36       *
37       */
38      private static final long serialVersionUID = 1L;
39  
40      private String version;
41  
42      private List<CustomField> customFields = new ArrayList<CustomField>();
43  
44      private List<Configuration> resolutions = new ArrayList<Configuration>();
45      private List<Configuration> severities = new ArrayList<Configuration>();
46      private List<Configuration> statuses = new ArrayList<Configuration>();
47  
48      public SystemConfiguration() {
49      }
50  
51      public String getVersion() {
52          return (version == null ? "" : version);
53      }
54  
55      public void setVersion(String value) {
56          version = value;
57      }
58  
59      public List<CustomField> getCustomFields() {
60          return customFields;
61      }
62  
63      public void setCustomFields(List<CustomField> value) {
64          if (value != null) {
65              customFields = value;
66          }
67      }
68  
69      public List<Configuration> getResolutions() {
70          return (resolutions == null ? new ArrayList<Configuration>()
71                  : resolutions);
72      }
73  
74      public void setResolutions(List<Configuration> value) {
75          if (value != null) {
76              resolutions = value;
77          }
78      }
79  
80      public List<Configuration> getSeverities() {
81          return (severities == null ? new ArrayList<Configuration>()
82                  : severities);
83      }
84  
85      public void setSeverities(List<Configuration> value) {
86          if (value != null) {
87              severities = value;
88          }
89      }
90  
91      public List<Configuration> getStatuses() {
92          return (statuses == null ? new ArrayList<Configuration>() : statuses);
93      }
94  
95      public void setStatuses(List<Configuration> value) {
96          if (value != null) {
97              statuses = value;
98          }
99      }
100 
101     public void addConfiguration(Configuration configuration) {
102         if (configuration != null) {
103             switch (configuration.getType()) {
104                 case resolution:
105                     resolutions.add(configuration);
106                     break;
107                 case severity:
108                     severities.add(configuration);
109                     break;
110                 case status:
111                     statuses.add(configuration);
112                     break;
113                 default:
114                     return;
115             }
116         }
117     }
118 
119     public String toString() {
120 
121         return new ToStringBuilder(this).append("id", getId()).append("version", getVersion()).toString();
122 
123     }
124 
125     private static final class SystemConfigurationComparator implements
126             Comparator<SystemConfiguration> {
127         public int compare(SystemConfiguration./org/itracker/model/SystemConfiguration.html#SystemConfiguration">SystemConfiguration o1, SystemConfiguration o2) {
128             return new CompareToBuilder().append(o1.getVersion(),
129                     o2.getVersion()).append(o1.getId(), o2.getId())
130                     .toComparison();
131         }
132     }
133 }