KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > tigris > scarab > om > RModuleAttributePeer


1 package org.tigris.scarab.om;
2
3 /* ================================================================
4  * Copyright (c) 2000-2002 CollabNet. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  *
17  * 3. The end-user documentation included with the redistribution, if
18  * any, must include the following acknowlegement: "This product includes
19  * software developed by Collab.Net <http://www.Collab.Net/>."
20  * Alternately, this acknowlegement may appear in the software itself, if
21  * and wherever such third-party acknowlegements normally appear.
22  *
23  * 4. The hosted project names must not be used to endorse or promote
24  * products derived from this software without prior written
25  * permission. For written permission, please contact info@collab.net.
26  *
27  * 5. Products derived from this software may not use the "Tigris" or
28  * "Scarab" names nor may "Tigris" or "Scarab" appear in their names without
29  * prior written permission of Collab.Net.
30  *
31  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
32  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
33  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
34  * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
35  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
37  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
39  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
40  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
41  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42  *
43  * ====================================================================
44  *
45  * This software consists of voluntary contributions made by many
46  * individuals on behalf of Collab.Net.
47  */

48
49 // Turbine classes
50
import org.apache.torque.TorqueException;
51 import org.apache.torque.om.ObjectKey;
52 import org.apache.torque.util.Criteria;
53 import com.workingdogs.village.Record;
54 import com.workingdogs.village.DataSetException;
55
56 // Scarab classes
57
import org.tigris.scarab.services.cache.ScarabCache;
58
59 /**
60   * The skeleton for this class was autogenerated by Torque on:
61   *
62   * [Wed Feb 28 16:36:26 PST 2001]
63   *
64   * You should add additional methods to this class to meet the
65   * application requirements. This class will only be generated as
66   * long as it does not already exist in the output directory.
67   */

68 public class RModuleAttributePeer
69     extends org.tigris.scarab.om.BaseRModuleAttributePeer
70 {
71     private static final String JavaDoc RMODULEATTRIBUTE_PEER =
72         "RModuleAttributePeer";
73     private static final String JavaDoc RETRIEVE_BY_PK =
74         "retrieveByPK";
75
76     private static final String JavaDoc COUNT =
77         "count(*)";
78
79     /**
80      * Adds count(*) to the select clause and returns the
81      * number of rows resulting from the given Criteria. If the criteria will
82      * lead to duplicate rows they will be counted.
83      *
84      * @param crit a <code>Criteria</code> value
85      * @return an <code>int</code> value
86      * @exception TorqueException if an error occurs
87      * @exception DataSetException if an error occurs
88      */

89     public static int count(Criteria crit)
90         throws TorqueException, DataSetException
91     {
92         crit.addSelectColumn(COUNT);
93         return ((Record)IssuePeer.doSelectVillageRecords(crit).get(0))
94             .getValue(1).asInt();
95     }
96
97     /**
98      * Retrieve a single object by pk
99      *
100      * @param pk
101      */

102     public static RModuleAttribute retrieveByPK(ObjectKey pk)
103         throws TorqueException
104     {
105         RModuleAttribute result = null;
106         Object JavaDoc obj = ScarabCache.get(RMODULEATTRIBUTE_PEER, RETRIEVE_BY_PK, pk);
107         if (obj == null)
108         {
109             result = BaseRModuleAttributePeer.retrieveByPK(pk);
110             ScarabCache.put(result, RMODULEATTRIBUTE_PEER, RETRIEVE_BY_PK, pk);
111         }
112         else
113         {
114             result = (RModuleAttribute)obj;
115         }
116         return result;
117     }
118     
119     public static void doDelete(RModuleAttribute rma) throws TorqueException
120     {
121         Criteria crit = new Criteria();
122         crit.add(ConditionPeer.MODULE_ID, rma.getModuleId());
123         crit.add(ConditionPeer.ISSUE_TYPE_ID, rma.getIssueTypeId());
124         crit.add(ConditionPeer.ATTRIBUTE_ID, rma.getAttributeId());
125         ConditionPeer.doDelete(crit);
126         BaseTransitionPeer.doDelete(crit);
127     }
128 }
129
130
Popular Tags