001/* 002 * (C) Copyright 2012 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 * Florent Guillaume 016 */ 017package org.nuxeo.ecm.platform.routing.core.impl; 018 019import java.io.Serializable; 020import java.util.Collection; 021import java.util.List; 022import java.util.Map; 023 024import org.nuxeo.ecm.core.api.CoreSession; 025import org.nuxeo.ecm.core.api.DocumentModelList; 026import org.nuxeo.ecm.platform.routing.api.DocumentRoute; 027import org.nuxeo.ecm.platform.routing.api.exception.DocumentRouteException; 028 029/** 030 * A route graph, defining a workflow with arbitrarily complex transitions between nodes. 031 * 032 * @since 5.6 033 */ 034public interface GraphRoute extends DocumentRoute { 035 036 String PROP_VARIABLES_FACET = "docri:variablesFacet"; 037 038 String PROP_AVAILABILITY_FILTER = "docri:availabilityFilter"; 039 040 /** 041 * The id of the parent route instance from which this route was started. 042 * 043 * @since 5.7.2 044 */ 045 String PROP_PARENT_ROUTE = "docri:parentRouteInstanceId"; 046 047 /** 048 * The id of the node in the parent route from which this route was started. 049 * 050 * @since 5.7.2 051 */ 052 String PROP_PARENT_NODE = "docri:parentRouteNodeId"; 053 054 /** 055 * Gets the start node for this graph. 056 * 057 * @return the start node 058 */ 059 GraphNode getStartNode() throws DocumentRouteException; 060 061 /** 062 * Gets the attached documents. 063 * 064 * @return a list of document 065 */ 066 DocumentModelList getAttachedDocumentModels(); 067 068 /** 069 * Gets the graph variables. 070 * 071 * @return the map of variables 072 */ 073 Map<String, Serializable> getVariables(); 074 075 /** 076 * Gets the Json formatted graph variables. 077 * 078 * @return the map of variables 079 * @since 7.2 080 */ 081 Map<String, Serializable> getJsonVariables(); 082 083 /** 084 * Sets the graph variables. 085 * 086 * @param map the map of variables 087 */ 088 void setVariables(Map<String, Serializable> map); 089 090 /** 091 * Sets the variables of the workflow based on their JSON representation (especially for scalar lists). Eg. 092 * Map<String, String> map = new HashMap<String, String>(); 093 * map.put("contributors","[\"John Doe\", \"John Smith\"]"); map.put("title","Test Title"); 094 * 095 * @param map the map of variables 096 * @since 5.9.3, 5.8.0-HF10 097 */ 098 void setJSONVariables(Map<String, String> map); 099 100 /** 101 * Gets the node with the given id. 102 * 103 * @param id 104 * @return the node 105 * @throws IllegalArgumentException if there is no such node 106 */ 107 GraphNode getNode(String id) throws IllegalArgumentException; 108 109 /** 110 * Gets a collection of the route nodes 111 * 112 * @return 113 */ 114 Collection<GraphNode> getNodes(); 115 116 /** 117 * Returns the availability filter name for this graph. 118 */ 119 String getAvailabilityFilter(); 120 121 /** 122 * Checks if this graph instance has been started from another graph. 123 * 124 * @return {@code true} if this is a sub-route instance 125 * @since 5.7.2 126 */ 127 boolean hasParentRoute(); 128 129 /** 130 * Resumes execution of the parent route from which this graph was started. 131 * 132 * @param session the session 133 * @since 5.7.2 134 */ 135 void resumeParentRoute(CoreSession session); 136 137 /** 138 * Get the list of nodes of which the State is suspended. 139 * 140 * @since 7.4 141 */ 142 List<GraphNode> getSuspendedNodes(); 143 144}