KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cowsultants > itracker > ejb > client > models > SystemConfigurationModel


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 cowsultants.itracker.ejb.client.models;
20
21 import java.io.Serializable JavaDoc;
22
23 import cowsultants.itracker.ejb.client.util.SystemConfigurationUtilities;
24
25 public class SystemConfigurationModel extends GenericModel {
26     private String JavaDoc version;
27
28     private CustomFieldModel[] customFields = new CustomFieldModel[0];
29
30     private ConfigurationModel[] resolutions = new ConfigurationModel[0];
31     private ConfigurationModel[] severities = new ConfigurationModel[0];
32     private ConfigurationModel[] statuses = new ConfigurationModel[0];
33
34     public SystemConfigurationModel() {
35     }
36
37     public String JavaDoc getVersion() {
38         return (version == null ? "" : version);
39     }
40
41     public void setVersion(String JavaDoc value) {
42         version = value;
43     }
44
45     public CustomFieldModel[] getCustomFields() {
46         return customFields;
47     }
48
49     public void setCustomFields(CustomFieldModel[] value) {
50         if(value != null) {
51             customFields = value;
52         }
53     }
54
55     public ConfigurationModel[] getResolutions() {
56         return (resolutions == null ? new ConfigurationModel[0] : resolutions);
57     }
58
59     public void setResolutions(ConfigurationModel[] value) {
60         if(value != null) {
61             resolutions = value;
62         }
63     }
64
65     public ConfigurationModel[] getSeverities() {
66         return (severities == null ? new ConfigurationModel[0] : severities);
67     }
68
69     public void setSeverities(ConfigurationModel[] value) {
70         if(value != null) {
71             severities = value;
72         }
73     }
74
75     public ConfigurationModel[] getStatuses() {
76         return (statuses == null ? new ConfigurationModel[0] : statuses);
77     }
78
79     public void setStatuses(ConfigurationModel[] value) {
80         if(value != null) {
81             statuses = value;
82         }
83     }
84
85     public void addConfiguration(ConfigurationModel model) {
86         if(model != null) {
87             ConfigurationModel[] newArray;
88
89             if(model.getType() == SystemConfigurationUtilities.TYPE_RESOLUTION) {
90                 newArray = new ConfigurationModel[getResolutions().length + 1];
91                 if(getResolutions().length > 0) {
92                     System.arraycopy((Object JavaDoc) resolutions, 0, (Object JavaDoc) newArray, 0, resolutions.length);
93                 }
94                 newArray[getResolutions().length] = model;
95                 setResolutions(newArray);
96             } else if(model.getType() == SystemConfigurationUtilities.TYPE_SEVERITY) {
97                 newArray = new ConfigurationModel[getSeverities().length + 1];
98                 if(getSeverities().length > 0) {
99                     System.arraycopy((Object JavaDoc) severities, 0, (Object JavaDoc) newArray, 0, severities.length);
100                 }
101                 newArray[getSeverities().length] = model;
102                 setSeverities(newArray);
103             } else if(model.getType() == SystemConfigurationUtilities.TYPE_STATUS) {
104                 newArray = new ConfigurationModel[getStatuses().length + 1];
105                 if(getStatuses().length > 0) {
106                     System.arraycopy((Object JavaDoc) statuses, 0, (Object JavaDoc) newArray, 0, statuses.length);
107                 }
108                 newArray[getStatuses().length] = model;
109                 setStatuses(newArray);
110             }
111         }
112     }
113
114     public String JavaDoc toString() {
115         StringBuffer JavaDoc buf = new StringBuffer JavaDoc("SystemConfiguration Version: " + getVersion() + "\n");
116         buf.append(" Resolutions:");
117         for(int i = 0; i < resolutions.length; i++) {
118             buf.append(" " + resolutions[i].getName() + "(" + resolutions[i].getValue() + ")");
119         }
120         buf.append("\n");
121         buf.append(" Severities:");
122         for(int i = 0; i < severities.length; i++) {
123             buf.append(" " + severities[i].getName() + "(" + severities[i].getValue() + ")");
124         }
125         buf.append("\n");
126         buf.append(" Statuses:");
127         for(int i = 0; i < statuses.length; i++) {
128             buf.append(" " + statuses[i].getName() + "(" + statuses[i].getValue() + ")");
129         }
130         buf.append("\n");
131
132         return buf.toString();
133     }
134 }
135
Popular Tags