From 4a362a08c67f0c2402f7080ee080ecfd45d7158e Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 21 Aug 2008 18:05:44 +0000 Subject: [PATCH] Fix [ 1890616 ] Workflow infinate loop (fix attached) Thanks to Kostadin --- base/src/org/compiere/wf/MWorkflow.java | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/base/src/org/compiere/wf/MWorkflow.java b/base/src/org/compiere/wf/MWorkflow.java index f89fef5f93..dcf6ffc7b8 100644 --- a/base/src/org/compiere/wf/MWorkflow.java +++ b/base/src/org/compiere/wf/MWorkflow.java @@ -1,5 +1,5 @@ /****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * + * Product: Adempiere ERP & CRM Smart Business Solution * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * @@ -283,6 +283,8 @@ public class MWorkflow extends X_AD_Workflow for (int i = 0; i < m_nodes.size(); i++) { MWFNode node = m_nodes.get(i); + if (!node.isActive()) + continue; if (node.getAD_Client_ID() == 0 || node.getAD_Client_ID() == AD_Client_ID) list.add(node); } @@ -359,6 +361,8 @@ public class MWorkflow extends X_AD_Workflow for (int n = 0; n < m_nodes.size(); n++) { MWFNode node = (MWFNode)m_nodes.get(n); + if (!node.isActive()) + continue; if (node.getAD_Client_ID() == 0 || node.getAD_Client_ID() == AD_Client_ID) { boolean found = false; @@ -400,7 +404,10 @@ public class MWorkflow extends X_AD_Workflow // Get Dependent MWFNodeNext[] nexts = node.getTransitions(AD_Client_ID); for (int i = 0; i < nexts.length; i++) - addNodesDF (list, nexts[i].getAD_WF_Next_ID(), AD_Client_ID); + { + if (nexts[i].isActive()) + addNodesDF (list, nexts[i].getAD_WF_Next_ID(), AD_Client_ID); + } } } // addNodesDF @@ -412,6 +419,7 @@ public class MWorkflow extends X_AD_Workflow */ private void addNodesSF (ArrayList list, int AD_WF_Node_ID, int AD_Client_ID) { + ArrayList tmplist = new ArrayList (); MWFNode node = getNode (AD_WF_Node_ID); if (node != null && (node.getAD_Client_ID() == 0 || node.getAD_Client_ID() == AD_Client_ID)) @@ -422,16 +430,20 @@ public class MWorkflow extends X_AD_Workflow for (int i = 0; i < nexts.length; i++) { MWFNode child = getNode (nexts[i].getAD_WF_Next_ID()); + if (!child.isActive()) + continue; if (child.getAD_Client_ID() == 0 || child.getAD_Client_ID() == AD_Client_ID) { - if (!list.contains(child)) + if (!list.contains(child)){ list.add(child); + tmplist.add(child); + } } } - // Remainder Nodes not conncetd - for (int i = 0; i < nexts.length; i++) - addNodesSF (list, nexts[i].getAD_WF_Next_ID(), AD_Client_ID); + // Remainder Nodes not connected + for (int i = 0; i < tmplist.size(); i++) + addNodesSF (list, tmplist.get(i).get_ID(), AD_Client_ID); } } // addNodesSF