01: package org.tigris.scarab.om;
02:
03: import java.util.List;
04: import org.apache.torque.TorqueException;
05:
06: import org.apache.torque.util.Criteria;
07: import org.tigris.scarab.notification.ActivityType;
08:
09: /* ================================================================
10: * Copyright (c) 2000-2005 CollabNet. All rights reserved.
11: *
12: * Redistribution and use in source and binary forms, with or without
13: * modification, are permitted provided that the following conditions are
14: * met:
15: *
16: * 1. Redistributions of source code must retain the above copyright
17: * notice, this list of conditions and the following disclaimer.
18: *
19: * 2. Redistributions in binary form must reproduce the above copyright
20: * notice, this list of conditions and the following disclaimer in the
21: * documentation and/or other materials provided with the distribution.
22: *
23: * 3. The end-user documentation included with the redistribution, if
24: * any, must include the following acknowlegement: "This product includes
25: * software developed by Collab.Net <http://www.Collab.Net/>."
26: * Alternately, this acknowlegement may appear in the software itself, if
27: * and wherever such third-party acknowlegements normally appear.
28: *
29: * 4. The hosted project names must not be used to endorse or promote
30: * products derived from this software without prior written
31: * permission. For written permission, please contact info@collab.net.
32: *
33: * 5. Products derived from this software may not use the "Tigris" or
34: * "Scarab" names nor may "Tigris" or "Scarab" appear in their names without
35: * prior written permission of Collab.Net.
36: *
37: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
39: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
40: * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
41: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
43: * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
44: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
45: * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
46: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
47: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48: *
49: * ====================================================================
50: *
51: * This software consists of voluntary contributions made by many
52: * individuals on behalf of Collab.Net.
53: */
54:
55: /**
56: * Utility methods for the Activity table
57: */
58: public class ActivityPeer extends BaseActivityPeer {
59: /**
60: * Search the activity table for the last occurrence of "issue_moved"
61: * for the five issue, returning the ID of the new value of the ID.
62: * @param issue
63: * @return
64: * @throws TorqueException
65: */
66: public static String getNewIssueUniqueId(Issue issue)
67: throws TorqueException {
68: String id = issue.getUniqueId();
69: Criteria crit = new Criteria();
70: crit.add(ActivityPeer.OLD_VALUE, id);
71: crit.add(ActivityPeer.ACTIVITY_TYPE, ActivityType.ISSUE_MOVED
72: .getCode());
73: crit.addDescendingOrderByColumn(ActivityPeer.ACTIVITY_ID);
74: List list = doSelect(crit);
75: if (list != null && list.size() > 0)
76: id = ((Activity) list.get(0)).getNewValue();
77: return id;
78: }
79: }
|