KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > campware > cream > modules > screens > UserForm


1 package org.campware.cream.modules.screens;
2
3 /* ====================================================================
4  * Copyright (C) 2003 Media Development Loan Fund
5  *
6  * Contact: contact@campware.org - http://www.campware.org
7  * Campware encourages further development. Please let us know.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
27  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  * ====================================================================
36  *
37  * This software consists of voluntary contributions made by many
38  * individuals on behalf of the Apache Software Foundation. For more
39  * information on the Apache Software Foundation, please see
40  * <http://www.apache.org/>.
41  */

42
43 import org.apache.torque.util.Criteria;
44
45 import org.apache.velocity.context.Context;
46
47 import org.campware.cream.om.TurbineUser;
48 import org.campware.cream.om.TurbineUserPeer;
49 import org.campware.cream.om.TurbineRolePeer;
50 import org.campware.cream.om.CreamUser;
51 import org.campware.cream.om.CreamUserPeer;
52
53 /**
54  * To read comments for this class, please see
55  * the ancestor class
56  */

57 public class UserForm extends CreamForm
58 {
59     protected void initScreen()
60     {
61         setModuleType(LOOKUP);
62         setModuleName("TURBINE_USER");
63         setIdName(TurbineUserPeer.USER_ID);
64         setFormIdName("userid");
65     }
66
67     protected boolean getEntry(Criteria criteria, Context context)
68     {
69         try
70         {
71             TurbineUser entry = (TurbineUser) TurbineUserPeer.doSelect(criteria).get(0);
72
73             Criteria prefcrit= new Criteria();
74             prefcrit.add(CreamUserPeer.LOGIN_NAME, entry.getUserName());
75             CreamUser prefs = (CreamUser) CreamUserPeer.doSelect(prefcrit).get(0);
76             
77             context.put("entry", entry);
78             context.put("entryitems", entry.getTurbineUserGroupRoles());
79             context.put("prefs", prefs);
80             return true;
81         }
82         catch (Exception JavaDoc e)
83         {
84             return false;
85         }
86     }
87     
88     protected boolean getNew(Context context)
89     {
90         try
91         {
92             TurbineUser entry = new TurbineUser();
93             CreamUser prefs = new CreamUser();
94             context.put("entry", entry);
95             context.put("prefs", prefs);
96
97             return true;
98         }
99         catch (Exception JavaDoc e)
100         {
101             return false;
102         }
103     }
104
105     protected boolean getLookups(Context context)
106     {
107         try
108         {
109             Criteria rolecrit = new Criteria();
110             rolecrit.add(TurbineRolePeer.ROLE_ID, 999, Criteria.GREATER_THAN);
111             rolecrit.addAscendingOrderByColumn(TurbineRolePeer.ROLE_NAME);
112             context.put("roles", TurbineRolePeer.doSelect(rolecrit));
113
114             return true;
115         }
116         catch (Exception JavaDoc e)
117         {
118             return false;
119         }
120     }
121
122     
123 }
124
Popular Tags