KickJava   Java API By Example, From Geeks To Geeks.

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


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 public class ImportDataModel extends GenericModel {
22     private GenericModel[] dataModels;
23     private boolean[] existingModel;
24
25     private boolean reuseConfig = true;
26     private boolean reuseFields = true;
27     private boolean reuseProjects = true;
28     private boolean reuseUsers = true;
29     private boolean createPasswords = true;
30
31     private int[][] verifyStatistics = new int[7][2];
32
33     public ImportDataModel() {
34     }
35
36     public GenericModel[] getData() {
37         return (dataModels == null ? new GenericModel[0] : dataModels);
38     }
39
40     public boolean[] getExistingModel() {
41         return (existingModel == null ? new boolean[0] : existingModel);
42     }
43
44     public boolean getExistingModel(int i) {
45         return (existingModel != null && i < existingModel.length ? existingModel[i] : false);
46     }
47
48     public void setExistingModel(int i, boolean value) {
49         if(existingModel != null && i < existingModel.length) {
50             existingModel[i] = value;
51         }
52     }
53
54     public void setData(GenericModel[] dataModels, boolean[] existingModel) {
55         if(dataModels != null && existingModel != null && dataModels.length == existingModel.length) {
56             this.dataModels = dataModels;
57             this.existingModel = existingModel;
58             this.verifyStatistics = new int[7][2];
59         }
60     }
61
62     public boolean getReuseConfig() {
63         return reuseConfig;
64     }
65
66     public void setReuseConfig(boolean value) {
67         reuseConfig = value;
68     }
69
70     public void setReuseConfig(Boolean JavaDoc value) {
71         reuseConfig = (value != null ? value.booleanValue() : true);
72     }
73
74     public boolean getReuseFields() {
75         return reuseFields;
76     }
77
78     public void setReuseFields(boolean value) {
79         reuseFields = value;
80     }
81
82     public void setReuseFields(Boolean JavaDoc value) {
83         reuseFields = (value != null ? value.booleanValue() : true);
84     }
85
86     public boolean getReuseProjects() {
87         return reuseProjects;
88     }
89
90     public void setReuseProjects(boolean value) {
91         reuseProjects = value;
92     }
93
94     public void setReuseProjects(Boolean JavaDoc value) {
95         reuseProjects = (value != null ? value.booleanValue() : true);
96     }
97
98     public boolean getReuseUsers() {
99         return reuseUsers;
100     }
101
102     public void setReuseUsers(boolean value) {
103         reuseUsers = value;
104     }
105
106     public void setReuseUsers(Boolean JavaDoc value) {
107         reuseUsers = (value != null ? value.booleanValue() : true);
108     }
109
110     public boolean getCreatePasswords() {
111         return createPasswords;
112     }
113
114     public void setCreatePasswords(boolean value) {
115         createPasswords = value;
116     }
117
118     public void setCreatePasswords(Boolean JavaDoc value) {
119         createPasswords = (value != null ? value.booleanValue() : true);
120     }
121
122     public int[][] getImportStatistics() {
123         return verifyStatistics;
124     }
125
126     public void addVerifyStatistic(int itemType, int category) {
127         try {
128             verifyStatistics[itemType][category]++;
129         } catch(Exception JavaDoc e) {
130         }
131     }
132
133     public String JavaDoc statsToString() {
134         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
135         for(int i = 0; i < verifyStatistics.length; i++) {
136             buf.append(i + ":[" + verifyStatistics[i][0] + ", " + verifyStatistics[i][1] + "] ");
137         }
138         return buf.toString();
139     }
140
141     public String JavaDoc toString() {
142         return "ImportData Num Data Objects: " + getData().length + " Reuse Users: " + getReuseUsers() +
143                " Reuse Projects: " + getReuseProjects() + " Reuse Config: " + getReuseConfig() +
144                " Reuse Fields: " + getReuseFields() + " Create Passwords: " + getCreatePasswords() +
145                " Stats: " + statsToString();
146     }
147 }
148
Popular Tags