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.restapi.server.jaxrs.routing.model;
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    protected String comment;
038
039    protected Map<String, Serializable> variables;
040
041    public TaskCompletionRequest() {
042        super();
043    }
044
045    public String getComment() {
046        return comment;
047    }
048
049    public Map<String, Object> getDataMap() {
050        Map<String, Object> data = new HashMap<String, Object>();
051        if (getVariables() != null) {
052            data.put(Constants.VAR_WORKFLOW, getVariables());
053            data.put(Constants.VAR_WORKFLOW_NODE, getVariables());
054        }
055        data.put(DocumentRoutingConstants._MAP_VAR_FORMAT_JSON, Boolean.TRUE);
056        if (StringUtils.isNotBlank(getComment())) {
057            data.put(GraphNode.NODE_VARIABLE_COMMENT, getComment());
058        }
059        return data;
060    }
061
062    public Map<String, Serializable> getVariables() {
063        return variables;
064    }
065
066    public void setComment(String comment) {
067        this.comment = comment;
068    }
069
070    public void setVariables(Map<String, Serializable> nodeVariables) {
071        this.variables = nodeVariables;
072    }
073
074}