001: // ================================================================
002: // Copyright (c) 2000-2005 CollabNet. All rights reserved.
003: //
004: // Redistribution and use in source and binary forms, with or without
005: // modification, are permitted provided that the following conditions are
006: // met:
007: //
008: // 1. Redistributions of source code must retain the above copyright
009: // notice, this list of conditions and the following disclaimer.
010: //
011: // 2. Redistributions in binary form must reproduce the above copyright
012: // notice, this list of conditions and the following disclaimer in the
013: // documentation and/or other materials provided with the distribution.
014: //
015: // 3. The end-user documentation included with the redistribution, if
016: // any, must include the following acknowlegement: "This product includes
017: // software developed by Collab.Net <http://www.Collab.Net/>."
018: // Alternately, this acknowlegement may appear in the software itself, if
019: // and wherever such third-party acknowlegements normally appear.
020: //
021: // 4. The hosted project names must not be used to endorse or promote
022: // products derived from this software without prior written
023: // permission. For written permission, please contact info@collab.net.
024: //
025: // 5. Products derived from this software may not use the "Tigris" or
026: // "Scarab" names nor may "Tigris" or "Scarab" appear in their names without
027: // prior written permission of Collab.Net.
028: //
029: // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
030: // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
031: // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
032: // IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
033: // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
034: // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
035: // GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
036: // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
037: // IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
038: // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
039: // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
040: //
041: // ====================================================================
042: //
043: // This software consists of voluntary contributions made by many
044: // individuals on behalf of Collab.Net.
045:
046: package org.tigris.scarab.om;
047:
048: import java.util.List;
049:
050: import org.apache.torque.TorqueException;
051: import org.apache.torque.util.Criteria;
052:
053: /**
054: * This class manages Transition objects.
055: * The skeleton for this class was autogenerated by Torque * You should add additional methods to this class to meet the
056: * application requirements. This class will only be generated as
057: * long as it does not already exist in the output directory.
058: */
059: public class TransitionManager extends BaseTransitionManager {
060: public static final String GET_ALL_TRANSITIONS = "getAllTransitions";
061: public static final String GET_CONDITIONS = "getConditions";
062:
063: /**
064: * Creates a new <code>TransitionManager</code> instance.
065: *
066: * @exception TorqueException if an error occurs
067: */
068: public TransitionManager() throws TorqueException {
069: super ();
070: setRegion(getClassName().replace('.', '_'));
071: }
072:
073: /**
074: * Returns every transition defined for the given Attribute. The list is cached to improve
075: * performance in complex setups.
076: *
077: * @param attribute
078: * @return
079: */
080: public static List getAllTransitions(Attribute attribute) {
081: Object transitions = getMethodResult().get(attribute,
082: GET_ALL_TRANSITIONS, attribute);
083: if (transitions == null) {
084: Integer attribId = attribute.getAttributeId();
085: try {
086: Criteria crit = new Criteria();
087: crit.add(TransitionPeer.ATTRIBUTE_ID, attribId);
088: transitions = TransitionPeer.doSelect(crit);
089: if (transitions != null) {
090: getMethodResult().put(transitions, attribute,
091: "getAllTransitions", attribute);
092: }
093:
094: } catch (TorqueException te) {
095: te.printStackTrace();
096: }
097: }
098: return (List) transitions;
099: }
100:
101: }
|