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 its children one after the other and is donen when the last children is 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 SerialRunner extends AbstractRunner implements ElementRunner { 034 035 @Override 036 public void run(CoreSession session, DocumentRouteElement element) { 037 List<DocumentRouteElement> children = getChildrenElement(session, element); 038 if (!element.isRunning()) { 039 element.setRunning(session); 040 } 041 if (children.isEmpty()) { 042 element.setDone(session); 043 return; 044 } 045 // run all the child unless there is a wait state 046 for (DocumentRouteElement child : children) { 047 if (!child.isDone()) { 048 child.run(session); 049 if (!child.isDone()) { 050 return; 051 } 052 } 053 } 054 // all child ran, we're done 055 element.setDone(session); 056 } 057}