001/* 002 * (C) Copyright 2010 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 */ 019package org.nuxeo.ecm.platform.routing.core.impl; 020 021import java.util.List; 022 023import org.nuxeo.ecm.core.api.CoreSession; 024import org.nuxeo.ecm.platform.routing.api.DocumentRouteElement; 025 026/** 027 * Run all of its children simultaneous and is done when all the children are done. 028 * 029 * @author <a href="mailto:arussel@nuxeo.com">Alexandre Russel</a> 030 * @deprecated since 5.9.2 - Use only routes of type 'graph' 031 */ 032@Deprecated 033public class ParallelRunner extends AbstractRunner implements ElementRunner { 034 035 @Override 036 public void run(CoreSession session, DocumentRouteElement element) { 037 List<DocumentRouteElement> children = getChildrenElement(session, element); 038 if (children.isEmpty()) { 039 element.setRunning(session); 040 element.setDone(session); 041 return; 042 } 043 if (!element.isRunning()) { 044 element.setRunning(session); 045 boolean someChildrenNotDone = false; 046 for (DocumentRouteElement child : children) { 047 child.run(session); 048 if (!child.isDone()) { 049 someChildrenNotDone = true; 050 } 051 } 052 if (!someChildrenNotDone) { 053 element.setDone(session); 054 } 055 return; 056 } else { 057 boolean someChildrenNotDone = false; 058 for (DocumentRouteElement child : children) { 059 if (!child.isDone()) { 060 child.run(session); 061 if (!child.isDone()) { 062 someChildrenNotDone = true; 063 } 064 } 065 } 066 if (!someChildrenNotDone) { 067 element.setDone(session); 068 } 069 } 070 } 071}