KickJava   Java API By Example, From Geeks To Geeks.

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


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
44 import org.apache.torque.util.Criteria;
45
46 import org.apache.velocity.context.Context;
47
48 import org.campware.cream.om.PrintSubscription;
49 import org.campware.cream.om.PrintSubscriptionPeer;
50 import org.campware.cream.om.ProductPeer;
51 import org.campware.cream.om.ProjectPeer;
52 import org.campware.cream.om.CarrierPeer;
53 import org.campware.cream.om.CustomerPeer;
54 import org.campware.cream.om.SorderPeer;
55
56 /**
57  * To read comments for this class, please see
58  * the ancestor class
59  */

60 public class PrintSubscriptionForm extends CreamForm
61 {
62     protected void initScreen()
63     {
64         setModuleType(DOCUMENT);
65         setModuleName("PRINT_SUBSCRIPTION");
66         setIdName(PrintSubscriptionPeer.PRINT_SUBS_ID);
67         setFormIdName("printsubsid");
68     }
69
70     protected boolean getEntry(Criteria criteria, Context context)
71     {
72         try
73         {
74             PrintSubscription entry = (PrintSubscription) PrintSubscriptionPeer.doSelect(criteria).get(0);
75             context.put("entry", entry);
76
77             Criteria ordcrit = new Criteria();
78             Criteria.Criterion a1 = ordcrit.getNewCriterion(SorderPeer.SORDER_ID, new Integer JavaDoc(1000), Criteria.EQUAL);
79             Criteria.Criterion a2 = ordcrit.getNewCriterion(SorderPeer.SORDER_ID, new Integer JavaDoc(entry.getSorderId()), Criteria.EQUAL);
80             Criteria.Criterion a3 = ordcrit.getNewCriterion(SorderPeer.CUSTOMER_ID, new Integer JavaDoc(entry.getCustomerId()), Criteria.EQUAL);
81             Criteria.Criterion a4 = ordcrit.getNewCriterion(SorderPeer.STATUS, new Integer JavaDoc(30), Criteria.EQUAL);
82             ordcrit.add( a1.or( a2.or(a3.and(a4))));
83             ordcrit.addAscendingOrderByColumn(SorderPeer.SORDER_CODE);
84             context.put("orders", SorderPeer.doSelect(ordcrit));
85
86             return true;
87         }
88         catch (Exception JavaDoc e)
89         {
90             return false;
91         }
92     }
93
94     protected boolean getNew(Context context)
95     {
96         try
97         {
98             PrintSubscription entry = new PrintSubscription();
99             context.put("entry", entry);
100
101             Criteria ordcrit = new Criteria();
102             ordcrit.add(SorderPeer.SORDER_ID, 1000, Criteria.EQUAL);
103             context.put("orders", SorderPeer.doSelect(ordcrit));
104
105             return true;
106         }
107         catch (Exception JavaDoc e)
108         {
109             return false;
110         }
111     }
112
113     protected boolean getLookups(Context context)
114     {
115         try
116         {
117             Criteria prodcrit = new Criteria();
118             Criteria.Criterion a1 = prodcrit.getNewCriterion(ProductPeer.PRODUCT_ID, new Integer JavaDoc(1000), Criteria.EQUAL);
119             Criteria.Criterion a2 = prodcrit.getNewCriterion(ProductPeer.PRODUCT_TYPE, new Integer JavaDoc(40), Criteria.EQUAL);
120             prodcrit.add( a1.or( a2));
121             prodcrit.addAscendingOrderByColumn(ProductPeer.PRODUCT_CODE);
122             context.put("products", ProductPeer.doSelect(prodcrit));
123
124             Criteria projcrit = new Criteria();
125             projcrit.add(ProjectPeer.PROJECT_ID, 999, Criteria.GREATER_THAN);
126             projcrit.addAscendingOrderByColumn(ProjectPeer.PROJECT_NAME);
127             context.put("projects", ProjectPeer.doSelect(projcrit));
128
129             Criteria carrcrit = new Criteria();
130             carrcrit.add(CarrierPeer.CARRIER_ID, 999, Criteria.GREATER_THAN);
131             carrcrit.addAscendingOrderByColumn(CarrierPeer.CARRIER_NAME);
132             context.put("carriers", CarrierPeer.doSelect(carrcrit));
133
134             Criteria custcrit = new Criteria();
135             Criteria.Criterion b1 = custcrit.getNewCriterion(CustomerPeer.CUSTOMER_ID, new Integer JavaDoc(1000), Criteria.EQUAL);
136             Criteria.Criterion b2 = custcrit.getNewCriterion(CustomerPeer.STATUS, new Integer JavaDoc(29), Criteria.GREATER_THAN);
137             custcrit.add( b1.or( b2));
138             custcrit.addAscendingOrderByColumn(CustomerPeer.CUSTOMER_DISPLAY);
139             context.put("customers", CustomerPeer.doSelect(custcrit));
140
141             return true;
142         }
143         catch (Exception JavaDoc e)
144         {
145             return false;
146         }
147     }
148
149
150 }
151
Popular Tags