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