1 5 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 30 public class OfbizWorkflow extends AbstractWorkflow { 31 33 private static final Log log = LogFactory.getLog(OfbizWorkflow.class); 34 35 37 public OfbizWorkflow(String caller) { 38 super.context = new OfbizWorkflowContext(caller); 39 } 40 41 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 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 workflowName, int initialState, 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 } 93 | Popular Tags |