01: /*
02: * Bossa Workflow System
03: *
04: * $Id: CloseActivity.java,v 1.12 2004/03/03 20:54:49 gdvieira Exp $
05: *
06: * Copyright (C) 2003,2004 OpenBR Sistemas S/C Ltda.
07: *
08: * This file is part of Bossa.
09: *
10: * Bossa is free software; you can redistribute it and/or modify it
11: * under the terms of version 2 of the GNU General Public License as
12: * published by the Free Software Foundation.
13: *
14: * This program is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: * General Public License for more details.
18: *
19: * You should have received a copy of the GNU General Public
20: * License along with this program; if not, write to the
21: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22: * Boston, MA 02111-1307, USA.
23: */
24:
25: package com.bigbross.bossa.wfnet;
26:
27: import java.util.Map;
28:
29: import com.bigbross.bossa.BossaException;
30:
31: /**
32: * This class implements the close operation of <code>Activity</code>
33: * through the prevalence subsystem. <p>
34: *
35: * @author <a href="http://www.bigbross.com">BigBross Team</a>
36: * @see Activity#close()
37: */
38: class CloseActivity extends WFNetTransaction {
39:
40: private String caseTypeId;
41: private int caseId;
42: private int activityId;
43: private Map attributes;
44:
45: /**
46: * Creates a new close operation. <p>
47: *
48: * @param activity the activity to be closed.
49: * @param attributes an optional attributes map.
50: */
51: CloseActivity(Activity activity, Map attributes) {
52: this .activityId = activity.getId();
53: this .caseId = activity.getCase().getId();
54: this .caseTypeId = activity.getCaseType().getId();
55: this .attributes = attributes;
56: }
57:
58: /**
59: * Executes the operation. <p>
60: *
61: * @exception SetAttributeException if the underlying expression
62: * evaluation system has problems setting an attribute.
63: * @exception EvaluationException if an expression evaluation error
64: * occurs. If this exception is thrown the state of the case
65: * may be left inconsistent.
66: * @see WFNetTransaction#execute(CaseTypeManager)
67: */
68: protected Object execute(CaseTypeManager caseTypeManager)
69: throws BossaException {
70: Case caze = caseTypeManager.getCaseType(caseTypeId).getCase(
71: caseId);
72: Activity activity = caze.getActivity(activityId);
73: return new Boolean(caze.close(activity, attributes));
74: }
75: }
|