001: package org.tigris.scarab.om;
002:
003: /* ================================================================
004: * Copyright (c) 2000-2005 CollabNet. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions are
008: * met:
009: *
010: * 1. Redistributions of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * 2. Redistributions in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in the
015: * documentation and/or other materials provided with the distribution.
016: *
017: * 3. The end-user documentation included with the redistribution, if
018: * any, must include the following acknowlegement: "This product includes
019: * software developed by Collab.Net <http://www.Collab.Net/>."
020: * Alternately, this acknowlegement may appear in the software itself, if
021: * and wherever such third-party acknowlegements normally appear.
022: *
023: * 4. The hosted project names must not be used to endorse or promote
024: * products derived from this software without prior written
025: * permission. For written permission, please contact info@collab.net.
026: *
027: * 5. Products derived from this software may not use the "Tigris" or
028: * "Scarab" names nor may "Tigris" or "Scarab" appear in their names without
029: * prior written permission of Collab.Net.
030: *
031: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
032: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
033: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
034: * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
035: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
036: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
037: * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
038: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
039: * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
040: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
041: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
042: *
043: * ====================================================================
044: *
045: * This software consists of voluntary contributions made by many
046: * individuals on behalf of Collab.Net.
047: */
048:
049: // Turbine classes
050: import org.apache.torque.TorqueException;
051: import org.apache.torque.om.ObjectKey;
052: import org.apache.torque.util.Criteria;
053: import com.workingdogs.village.Record;
054: import com.workingdogs.village.DataSetException;
055:
056: // Scarab classes
057: import org.tigris.scarab.services.cache.ScarabCache;
058:
059: /**
060: * The skeleton for this class was autogenerated by Torque on:
061: *
062: * [Wed Feb 28 16:36:26 PST 2001]
063: *
064: * You should add additional methods to this class to meet the
065: * application requirements. This class will only be generated as
066: * long as it does not already exist in the output directory.
067: */
068: public class RModuleAttributePeer extends BaseRModuleAttributePeer {
069: private static final String RMODULEATTRIBUTE_PEER = "RModuleAttributePeer";
070: private static final String RETRIEVE_BY_PK = "retrieveByPK";
071:
072: private static final String COUNT = "count(*)";
073:
074: /**
075: * Adds count(*) to the select clause and returns the
076: * number of rows resulting from the given Criteria. If the criteria will
077: * lead to duplicate rows they will be counted.
078: *
079: * @param crit a <code>Criteria</code> value
080: * @return an <code>int</code> value
081: * @exception TorqueException if an error occurs
082: * @exception DataSetException if an error occurs
083: */
084: public static int count(Criteria crit) throws TorqueException,
085: DataSetException {
086: crit.addSelectColumn(COUNT);
087: return ((Record) IssuePeer.doSelectVillageRecords(crit).get(0))
088: .getValue(1).asInt();
089: }
090:
091: /**
092: * Retrieve a single object by pk
093: *
094: * @param pk
095: */
096: public static RModuleAttribute retrieveByPK(ObjectKey pk)
097: throws TorqueException {
098: RModuleAttribute result = null;
099: Object obj = ScarabCache.get(RMODULEATTRIBUTE_PEER,
100: RETRIEVE_BY_PK, pk);
101: if (obj == null) {
102: result = BaseRModuleAttributePeer.retrieveByPK(pk);
103: ScarabCache.put(result, RMODULEATTRIBUTE_PEER,
104: RETRIEVE_BY_PK, pk);
105: } else {
106: result = (RModuleAttribute) obj;
107: }
108: return result;
109: }
110:
111: public static void doDelete(RModuleAttribute rma)
112: throws TorqueException {
113: Criteria crit = new Criteria();
114: crit.add(ConditionPeer.MODULE_ID, rma.getModuleId());
115: crit.add(ConditionPeer.ISSUE_TYPE_ID, rma.getIssueTypeId());
116: crit.add(ConditionPeer.ATTRIBUTE_ID, rma.getAttributeId());
117: ConditionPeer.doDelete(crit);
118: BaseTransitionPeer.doDelete(crit);
119: }
120: }
|