001/* 002 * (C) Copyright 2014 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 * <a href="mailto:grenard@nuxeo.com">Guillaume Renard</a> 018 * 019 */ 020 021package org.nuxeo.ecm.platform.routing.core.io; 022 023import java.io.Serializable; 024import java.util.HashMap; 025import java.util.Map; 026 027import org.apache.commons.lang.StringUtils; 028import org.nuxeo.ecm.automation.core.Constants; 029import org.nuxeo.ecm.platform.routing.api.DocumentRoutingConstants; 030import org.nuxeo.ecm.platform.routing.core.impl.GraphNode; 031 032/** 033 * @since 7.2 034 */ 035public class TaskCompletionRequest { 036 037 private String comment; 038 039 private Map<String, Serializable> variables; 040 041 private boolean badJsonFormat; 042 043 public TaskCompletionRequest(String comment, Map<String, Serializable> variables, boolean badJsonFormat) { 044 super(); 045 this.comment = comment; 046 this.variables = variables; 047 this.badJsonFormat = badJsonFormat; 048 } 049 050 public String getComment() { 051 return comment; 052 } 053 054 public Map<String, Object> getDataMap() { 055 Map<String, Object> data = new HashMap<String, Object>(); 056 if (getVariables() != null) { 057 data.put(Constants.VAR_WORKFLOW, getVariables()); 058 data.put(Constants.VAR_WORKFLOW_NODE, getVariables()); 059 } 060 if (badJsonFormat) { 061 data.put(DocumentRoutingConstants._MAP_VAR_FORMAT_JSON, badJsonFormat); 062 } 063 if (StringUtils.isNotBlank(getComment())) { 064 data.put(GraphNode.NODE_VARIABLE_COMMENT, getComment()); 065 } 066 return data; 067 } 068 069 public Map<String, Serializable> getVariables() { 070 return variables; 071 } 072 073}