01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: /*
06: * Created by IntelliJ IDEA.
07: * User: plightbo
08: * Date: Apr 29, 2002
09: * 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;
22:
23: /**
24: * Ofbiz aware workflow implementation
25: */
26: public class OfbizWorkflow extends AbstractWorkflow {
27: //~ Static fields/initializers /////////////////////////////////////////////
28:
29: private static final Log log = LogFactory
30: .getLog(OfbizWorkflow.class);
31:
32: //~ Constructors ///////////////////////////////////////////////////////////
33:
34: public OfbizWorkflow(String caller) {
35: super .context = new OfbizWorkflowContext(caller);
36: }
37:
38: //~ Methods ////////////////////////////////////////////////////////////////
39:
40: public void changeEntryState(long id, int newState)
41: throws WorkflowException {
42: try {
43: TransactionUtil.begin();
44: } catch (GenericTransactionException e) {
45: throw new WorkflowException(e);
46: }
47:
48: super .changeEntryState(id, newState);
49:
50: try {
51: TransactionUtil.commit();
52: } catch (GenericTransactionException e) {
53: throw new WorkflowException(e);
54: }
55: }
56:
57: public void doAction(long id, int actionId, Map inputs)
58: throws WorkflowException {
59: try {
60: TransactionUtil.begin();
61: } catch (GenericTransactionException e) {
62: throw new WorkflowException(e);
63: }
64:
65: super .doAction(id, actionId, inputs);
66:
67: try {
68: TransactionUtil.commit();
69: } catch (GenericTransactionException e) {
70: throw new WorkflowException(e);
71: }
72: }
73:
74: public long initialize(String workflowName, int initialState,
75: Map 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: }
|