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: import java.util.HashMap;
050:
051: import org.apache.torque.TorqueException;
052: import org.apache.torque.om.Persistent;
053: import org.apache.torque.om.ComboKey;
054: import org.apache.torque.om.SimpleKey;
055: import org.apache.torque.om.NumberKey;
056:
057: /**
058: * This class manages RModuleOption objects.
059: * The skeleton for this class was autogenerated by Torque * You should add additional methods to this class to meet the
060: * application requirements. This class will only be generated as
061: * long as it does not already exist in the output directory.
062: */
063: public class RModuleOptionManager extends BaseRModuleOptionManager {
064: /**
065: * Creates a new <code>RModuleOptionManager</code> instance.
066: *
067: * @exception TorqueException if an error occurs
068: */
069: public RModuleOptionManager() throws TorqueException {
070: super ();
071: validFields = new HashMap();
072: validFields.put(RModuleOptionPeer.MODULE_ID, null);
073: }
074:
075: protected Persistent putInstanceImpl(Persistent om)
076: throws TorqueException {
077: Persistent oldOm = super .putInstanceImpl(om);
078: List listeners = (List) listenersMap
079: .get(RModuleOptionPeer.MODULE_ID);
080: notifyListeners(listeners, oldOm, om);
081: return oldOm;
082: }
083:
084: public static final RModuleOption getInstance(Integer moduleId,
085: Integer issueTypeId, Integer optionId)
086: throws TorqueException {
087: SimpleKey[] keys = { new NumberKey(moduleId.toString()),
088: new NumberKey(issueTypeId.toString()),
089: new NumberKey(optionId.toString()) };
090: return getInstance(new ComboKey(keys));
091: }
092:
093: public static final RModuleOption getInstance(Module module,
094: IssueType issueType, AttributeOption option)
095: throws TorqueException {
096: SimpleKey[] keys = { SimpleKey.keyFor(module.getModuleId()),
097: SimpleKey.keyFor(issueType.getIssueTypeId()),
098: SimpleKey.keyFor(option.getOptionId()) };
099: return getInstance(new ComboKey(keys));
100: }
101: }
|