KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > ofbiz > OfbizWorkflow


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 /*
6  * Created by IntelliJ IDEA.
7  * User: plightbo
8  * Date: Apr 29, 2002
9  * Time: 11:22:48 PM
10  */

11 package com.opensymphony.workflow.ofbiz;
12
13 import com.opensymphony.workflow.*;
14
15 import org.apache.commons.logging.Log;
16 import org.apache.commons.logging.LogFactory;
17
18 import org.ofbiz.core.entity.GenericTransactionException;
19 import org.ofbiz.core.entity.TransactionUtil;
20
21 import java.util.Map JavaDoc;
22
23
24 /**
25  * DOCUMENT ME!
26  *
27  * @author $author$
28  * @version $Revision: 1.5 $
29  */

30 public class OfbizWorkflow extends AbstractWorkflow {
31     //~ Static fields/initializers /////////////////////////////////////////////
32

33     private static final Log log = LogFactory.getLog(OfbizWorkflow.class);
34
35     //~ Constructors ///////////////////////////////////////////////////////////
36

37     public OfbizWorkflow(String JavaDoc caller) {
38         super.context = new OfbizWorkflowContext(caller);
39     }
40
41     //~ Methods ////////////////////////////////////////////////////////////////
42

43     public void changeEntryState(long id, int newState) throws WorkflowException {
44         try {
45             TransactionUtil.begin();
46         } catch (GenericTransactionException e) {
47             throw new WorkflowException(e);
48         }
49
50         super.changeEntryState(id, newState);
51
52         try {
53             TransactionUtil.commit();
54         } catch (GenericTransactionException e) {
55             throw new WorkflowException(e);
56         }
57     }
58
59     public void doAction(long id, int actionId, Map JavaDoc inputs) throws WorkflowException {
60         try {
61             TransactionUtil.begin();
62         } catch (GenericTransactionException e) {
63             throw new WorkflowException(e);
64         }
65
66         super.doAction(id, actionId, inputs);
67
68         try {
69             TransactionUtil.commit();
70         } catch (GenericTransactionException e) {
71             throw new WorkflowException(e);
72         }
73     }
74
75     public long initialize(String JavaDoc workflowName, int initialState, Map JavaDoc inputs) throws WorkflowException {
76         try {
77             TransactionUtil.begin();
78         } catch (GenericTransactionException e) {
79             throw new WorkflowException(e);
80         }
81
82         long id = super.initialize(workflowName, initialState, inputs);
83
84         try {
85             TransactionUtil.commit();
86
87             return id;
88         } catch (GenericTransactionException e) {
89             throw new WorkflowException(e);
90         }
91     }
92 }
93
Popular Tags