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