KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jaspersoft > jasperserver > api > metadata > common > service > impl > hibernate > persistent > RepoInputControl


1 /*
2  * Copyright (C) 2006 JasperSoft http://www.jaspersoft.com
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed WITHOUT ANY WARRANTY; and without the
10  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
15  * or write to:
16  *
17  * Free Software Foundation, Inc.,
18  * 59 Temple Place - Suite 330,
19  * Boston, MA USA 02111-1307
20  */

21 package com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.persistent;
22
23 import java.util.ArrayList JavaDoc;
24 import java.util.List JavaDoc;
25
26 import com.jaspersoft.jasperserver.api.metadata.common.domain.InputControl;
27 import com.jaspersoft.jasperserver.api.metadata.common.domain.Resource;
28 import com.jaspersoft.jasperserver.api.metadata.common.service.ResourceFactory;
29 import com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.ReferenceResolver;
30
31
32 /**
33  * @author Teodor Danciu (teodord@users.sourceforge.net)
34  * @version $Id: RepoInputControl.java 4472 2006-09-08 14:16:36Z lucian $
35  *
36  * @hibernate.joined-subclass table="InputControl"
37  * @hibernate.joined-subclass-key column="id"
38  */

39 public class RepoInputControl extends RepoResource
40 {
41
42     /**
43      *
44      */

45     private byte type = InputControl.TYPE_SINGLE_VALUE;
46     private boolean isMandatory = false;
47     private boolean isReadOnly = false;
48     private RepoDataType dataType = null;
49     private RepoListOfValues listOfValues = null;
50     private RepoQuery query = null;
51     private List JavaDoc queryVisibleColumns = new ArrayList JavaDoc();
52     private String JavaDoc queryValueColumn = null;
53     private Object JavaDoc defaultValue = null;
54     private List JavaDoc defaultValues = null;
55
56
57     /**
58      * @hibernate.property
59      */

60     public byte getType()
61     {
62         return type;
63     }
64
65     /**
66      *
67      */

68     public void setType(byte type)
69     {
70         this.type = type;
71     }
72
73     /**
74      * @hibernate.property
75      */

76     public boolean isMandatory()
77     {
78         return isMandatory;
79     }
80
81     /**
82      *
83      */

84     public void setMandatory(boolean isMandatory)
85     {
86         this.isMandatory = isMandatory;
87     }
88
89     /**
90      * @hibernate.property
91      */

92     public boolean isReadOnly()
93     {
94         return isReadOnly;
95     }
96
97     /**
98      *
99      */

100     public void setReadOnly(boolean isReadOnly)
101     {
102         this.isReadOnly = isReadOnly;
103     }
104
105     /**
106      * @hibernate.many-to-one
107      * column="data_type"
108      */

109     public RepoDataType getDataType()
110     {
111         return dataType;
112     }
113
114     /**
115      *
116      */

117     public void setDataType(RepoDataType dataType)
118     {
119         this.dataType = dataType;
120     }
121
122     /**
123      * @hibernate.many-to-one
124      * column="list_of_values"
125      */

126     public RepoListOfValues getListOfValues()
127     {
128         return listOfValues;
129     }
130
131     /**
132      *
133      */

134     public void setListOfValues(RepoListOfValues values)
135     {
136         this.listOfValues = values;
137     }
138
139     /**
140      * @hibernate.many-to-one
141      * column="list_query"
142      */

143     public RepoQuery getQuery()
144     {
145         return query;
146     }
147
148     /**
149      *
150      */

151     public void setQuery(RepoQuery query)
152     {
153         this.query = query;
154     }
155
156     /**
157      * @hibernate.list table="InputControlQueryColumn"
158      * @hibernate.key column="input_control_id"
159      * @hibernate.element column="query_column" type="string" length="40" not-null="true"
160      * @hibernate.list-index column="column_index"
161      */

162     public List JavaDoc getQueryVisibleColumns()
163     {
164         return queryVisibleColumns;
165     }
166
167     /**
168      *
169      */

170     public void setQueryVisibleColumns(List JavaDoc queryVisibleColumns)
171     {
172         this.queryVisibleColumns = queryVisibleColumns;
173     }
174
175     /**
176      * @hibernate.property
177      * column="query_value_column" type="string" length="40"
178      */

179     public String JavaDoc getQueryValueColumn()
180     {
181         return queryValueColumn;
182     }
183
184     /**
185      *
186      */

187     public void setQueryValueColumn(String JavaDoc column)
188     {
189         this.queryValueColumn = column;
190     }
191
192     /**
193      * @hibernate.property type="serializable"
194      */

195     public Object JavaDoc getDefaultValue()
196     {
197         return defaultValue;
198     }
199
200     /**
201      *
202      */

203     public void setDefaultValue(Object JavaDoc value)
204     {
205         this.defaultValue = value;
206     }
207
208     /**
209      *
210      */

211     public List JavaDoc getDefaultValues() //FIXME persist this
212
{
213         return defaultValues;
214     }
215
216     /**
217      *
218      */

219     public void setDefaultValues(List JavaDoc values)
220     {
221         this.defaultValues = values;
222     }
223
224     protected Class JavaDoc getClientItf() {
225         return InputControl.class;
226     }
227
228     protected void copyTo(Resource clientRes, ResourceFactory resourceFactory) {
229         super.copyTo(clientRes, resourceFactory);
230
231         InputControl control = (InputControl) clientRes;
232         
233         control.setType(getType());
234         control.setMandatory(isMandatory());
235         control.setReadOnly(isReadOnly());
236         
237         control.setDataType(getClientReference(getDataType(), resourceFactory));
238         control.setListOfValues(getClientReference(getListOfValues(), resourceFactory));
239         control.setQuery(getClientReference(getQuery(), resourceFactory));
240
241         control.setQueryValueColumn(getQueryValueColumn());
242         for (int i = 0; i < queryVisibleColumns.size(); i++)
243             control.addQueryVisibleColumn((String JavaDoc) queryVisibleColumns.get(i));
244
245         control.setDefaultValue(getDefaultValue());
246         //FIXME defaultValues
247
}
248
249     /**
250      *
251      */

252     protected void copyFrom(Resource clientRes, ReferenceResolver referenceResolver)
253     {
254         super.copyFrom(clientRes, referenceResolver);
255         
256         InputControl control = (InputControl) clientRes;
257         
258         setType(control.getType());
259         setMandatory(control.isMandatory());
260         setReadOnly(control.isReadOnly());
261
262         switch(control.getType()) {
263             case InputControl.TYPE_BOOLEAN:
264                 setDataType(null);
265                 setListOfValues(null);
266                 setQuery(null);
267                 break;
268             case InputControl.TYPE_SINGLE_VALUE:
269             case InputControl.TYPE_MULTI_VALUE:
270                 setDataType((RepoDataType) getReference(control.getDataType(), RepoDataType.class, referenceResolver));
271                 setListOfValues(null);
272                 setQuery(null);
273                 break;
274             case InputControl.TYPE_SINGLE_SELECT_LIST_OF_VALUES:
275             case InputControl.TYPE_MULTI_SELECT_LIST_OF_VALUES:
276             case InputControl.TYPE_SINGLE_SELECT_LIST_OF_VALUES_RADIO:
277             case InputControl.TYPE_MULTI_SELECT_LIST_OF_VALUES_CHECKBOX:
278                 setListOfValues((RepoListOfValues) getReference(control.getListOfValues(), RepoListOfValues.class, referenceResolver));
279                 setDataType(null);
280                 setQuery(null);
281                 break;
282             case InputControl.TYPE_SINGLE_SELECT_QUERY:
283             case InputControl.TYPE_MULTI_SELECT_QUERY:
284             case InputControl.TYPE_SINGLE_SELECT_QUERY_RADIO:
285             case InputControl.TYPE_MULTI_SELECT_QUERY_CHECKBOX:
286                 setQuery((RepoQuery) getReference(control.getQuery(), RepoQuery.class, referenceResolver));
287                 setDataType(null);
288                 setListOfValues(null);
289                 break;
290         }
291
292         setQueryValueColumn(control.getQueryValueColumn());
293         setQueryVisibleColumns(control.getQueryVisibleColumnsAsList());
294         setDefaultValue(control.getDefaultValue());
295         //FIXME defaultValues
296
}
297
298 }
299
Popular Tags