001/* 002 * (C) Copyright 2010 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Nuxeo - initial API and implementation 016 */ 017package org.nuxeo.ecm.platform.routing.core.impl; 018 019import java.util.List; 020 021import org.nuxeo.ecm.core.api.CoreSession; 022import org.nuxeo.ecm.platform.routing.api.DocumentRouteElement; 023 024/** 025 * Run all its children one after the other and is donen when the last children is done. 026 * 027 * @author <a href="mailto:arussel@nuxeo.com">Alexandre Russel</a> 028 * @deprecated since 5.9.2 - Use only routes of type 'graph' 029 */ 030@Deprecated 031public class SerialRunner extends AbstractRunner implements ElementRunner { 032 033 @Override 034 public void run(CoreSession session, DocumentRouteElement element) { 035 List<DocumentRouteElement> children = getChildrenElement(session, element); 036 if (!element.isRunning()) { 037 element.setRunning(session); 038 } 039 if (children.isEmpty()) { 040 element.setDone(session); 041 return; 042 } 043 // run all the child unless there is a wait state 044 for (DocumentRouteElement child : children) { 045 if (!child.isDone()) { 046 child.run(session); 047 if (!child.isDone()) { 048 return; 049 } 050 } 051 } 052 // all child ran, we're done 053 element.setDone(session); 054 } 055}