1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.itracker.model;
20
21 import org.apache.commons.lang.builder.ToStringBuilder;
22 import org.apache.log4j.Logger;
23
24 public class ImportDataModel extends AbstractEntity {
25
26
27
28
29 private static final long serialVersionUID = 1L;
30 private static final Logger log = Logger.getLogger(ImportDataModel.class);
31 private AbstractEntity[] dataModels;
32 private AbstractEntity[] existingModel;
33
34 private boolean reuseConfig = true;
35 private boolean reuseFields = true;
36 private boolean reuseProjects = true;
37 private boolean reuseUsers = true;
38 private boolean createPasswords = true;
39
40 private int[][] verifyStatistics = new int[7][2];
41
42 public ImportDataModel() {
43 }
44
45 public AbstractEntity[] getData() {
46 return (dataModels == null ? new AbstractEntity[0] : dataModels.clone());
47 }
48
49 public AbstractEntity[] getExistingModel() {
50
51 return (existingModel == null ? new AbstractEntity[0] : existingModel.clone());
52
53 }
54
55 public AbstractEntity getExistingModel(int i) {
56 return (existingModel != null && i < existingModel.length ? existingModel[i]
57 : null);
58 }
59
60 public void setExistingModel(int i, AbstractEntity model) {
61 if (existingModel != null && i < existingModel.length) {
62 existingModel[i] = model;
63 }
64 }
65
66 public void setData(AbstractEntity/itracker/model/AbstractEntity.html#AbstractEntity">AbstractEntity[] dataModels, AbstractEntity[] existingModel) {
67 if (dataModels != null && existingModel != null
68 && dataModels.length == existingModel.length) {
69 this.dataModels = dataModels.clone();
70 this.existingModel = existingModel.clone();
71 this.verifyStatistics = new int[7][2];
72 } else {
73 throw new IllegalArgumentException("Data model must not be null and existing model must not be null nor empty.");
74 }
75 }
76
77 public boolean getReuseConfig() {
78 return reuseConfig;
79 }
80
81 public void setReuseConfig(Boolean value) {
82 reuseConfig = (value != null ? value.booleanValue() : true);
83 }
84
85 public boolean getReuseFields() {
86 return reuseFields;
87 }
88
89 public boolean getReuseProjects() {
90 return reuseProjects;
91 }
92
93 public void setReuseProjects(Boolean value) {
94 reuseProjects = (value != null ? value.booleanValue() : true);
95 }
96
97 public boolean getReuseUsers() {
98 return reuseUsers;
99 }
100
101
102 public void setReuseUsers(Boolean value) {
103 reuseUsers = (value != null ? value.booleanValue() : true);
104 }
105
106 public boolean getCreatePasswords() {
107 return createPasswords;
108 }
109
110 public void setCreatePasswords(Boolean value) {
111 createPasswords = (value != null ? value.booleanValue() : true);
112 }
113
114 public int[][] getImportStatistics() {
115 return verifyStatistics;
116 }
117
118 public void addVerifyStatistic(int itemType, int category) {
119 try {
120 verifyStatistics[itemType][category]++;
121 } catch (RuntimeException e) {
122 throw e;
123 }
124 }
125
126 public String statsToString() {
127 StringBuffer buf = new StringBuffer();
128 for (int i = 0; i < verifyStatistics.length; i++) {
129 buf.append(i + ":[" + verifyStatistics[i][0] + ", "
130 + verifyStatistics[i][1] + "] ");
131 }
132 return buf.toString();
133 }
134
135 public String toString() {
136 return new ToStringBuilder(this).append("id", getId()).append(
137 "dataModels.length", getData().length).append("reuseUsers",
138 getReuseUsers()).append("reuseProjects", getReuseProjects()).append(
139 "reuseFields", getReuseFields()).append("reuseConfig", getReuseConfig())
140 .append("createPasswords", getCreatePasswords()).toString();
141 }
142 }