KickJava   Java API By Example, From Geeks To Geeks.

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


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.Iterator JavaDoc;
25 import java.util.List JavaDoc;
26
27 import com.jaspersoft.jasperserver.api.metadata.common.domain.ListOfValues;
28 import com.jaspersoft.jasperserver.api.metadata.common.domain.ListOfValuesItem;
29 import com.jaspersoft.jasperserver.api.metadata.common.domain.Resource;
30 import com.jaspersoft.jasperserver.api.metadata.common.domain.client.ListOfValuesItemImpl;
31 import com.jaspersoft.jasperserver.api.metadata.common.service.ResourceFactory;
32 import com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.ReferenceResolver;
33
34
35 /**
36  * @author Teodor Danciu (teodord@users.sourceforge.net)
37  * @version $Id: RepoQuery.java 2343 2006-03-10 14:54:32Z lucian $
38  *
39  * @hibernate.joined-subclass table="ListOfValues"
40  * @hibernate.joined-subclass-key column="id"
41  */

42 public class RepoListOfValues extends RepoResource
43 {
44
45     /**
46      *
47      */

48     private List JavaDoc values = null;
49
50
51     /**
52      * @hibernate.list table="ListOfValuesItem"
53      * @hibernate.key column="id"
54      * @hibernate.composite-element class="com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.persistent.RepoListOfValuesItem"
55      * @hibernate.list-index
56      */

57     public List JavaDoc getValues()
58     {
59         return values;
60     }
61
62     /**
63      *
64      */

65     public void setValues(List JavaDoc values)
66     {
67         this.values = values;
68     }
69
70     protected Class JavaDoc getClientItf() {
71         return ListOfValues.class;
72     }
73
74     /**
75      *
76      */

77     protected void copyFrom(Resource clientRes, ReferenceResolver referenceResolver)
78     {
79         super.copyFrom(clientRes, referenceResolver);
80         
81         ListOfValues listOfValues = (ListOfValues) clientRes;
82         List JavaDoc repoValues = new ArrayList JavaDoc();
83         if (listOfValues != null)
84         {
85             ListOfValuesItem[] items = listOfValues.getValues();
86             if (items != null && items.length > 0)
87             {
88                 for (int i = 0; i < items.length; i++)
89                 {
90                     ListOfValuesItem item = items[i];
91                     RepoListOfValuesItem value = new RepoListOfValuesItem();
92                     value.setLabel(item.getLabel());
93                     value.setValue(item.getValue());
94                     repoValues.add(value);
95                 }
96             }
97         }
98         setValues(repoValues);
99     }
100
101     /**
102      *
103      */

104     protected void copyTo(Resource clientRes, ResourceFactory resourceFactory) {
105         super.copyTo(clientRes, resourceFactory);
106
107         ListOfValues listOfValues = (ListOfValues) clientRes;
108         for (Iterator JavaDoc it = getValues().iterator(); it.hasNext();)
109         {
110             RepoListOfValuesItem value = (RepoListOfValuesItem)it.next();
111             ListOfValuesItem item = new ListOfValuesItemImpl();
112             item.setLabel(value.getLabel());
113             item.setValue(value.getValue());
114             listOfValues.addValue(item);
115         }
116     }
117
118 }
119
Popular Tags