All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.cq.testing.client.workflow.InboxItem Maven / Gradle / Ivy

There is a newer version: 1.2.8
Show newest version
/*
 * Copyright 2017 Adobe Systems Incorporated
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.adobe.cq.testing.client.workflow;

import org.codehaus.jackson.JsonNode;

import java.util.Date;

/**
 * Simple wrapper for the return JSON representing a work item in a users inbox.
 */
public class InboxItem {

    private JsonNode rootNode = null;

    /**
     * The only Constructor.
     *
     * @param rootNode the JSON node containing the data.
     */
    public InboxItem(JsonNode rootNode){
        this.rootNode = rootNode;
    }

    /**
     * returns the URI of this work item
     *
     * @return the URI of the work item
     */
    public String getUri() {
        if (rootNode.get("uri") == null)return null;
        return rootNode.get("uri").getValueAsText();
    }

    /**
     * returns the current assignee for this work item.
     * @return  current assignee
     */
    public String  getCurrentAssignee(){
        if (rootNode.get("currentAssignee") == null)return null;
        return rootNode.get("currentAssignee").getValueAsText();
    }

    /**
     * The start date when this work item was started
     *
     * @return   the start date
     */
    public Date getStartTime(){
        if (rootNode.get("startTime") == null)return null;
        Date startTime = new Date();
        startTime.setTime(Long.parseLong(rootNode.get("startTime").getValueAsText()));
        return startTime;
    }

    /**
     * the end date when this work item was completed
     *
     * @return the end date
     */
    public Date getEndTime(){
        if (rootNode.get("endTime") == null)return null;
        Date endTime = new Date();
        endTime.setTime(Long.parseLong(rootNode.get("endTime").getValueAsText()));
        return endTime;
    }

    /**
     * the payload type, either URL or JCR_PATH.
     *
     * @return the type of payload reference
     */
    public String getPayloadType(){
        if (rootNode.get("payloadType") == null)return null;
        return rootNode.get("payloadType").getValueAsText();
    }

    /**
     * the reference to the payload
     * @return payload reference
     */
    public String getPayload(){
        if (rootNode.get("payload") == null)return null;
        return rootNode.get("payload").getValueAsText();
    }

    /**
     * the comment set for this work item
     * @return the comment
     */
    public String getComment(){
        if (rootNode.get("comment") == null)return null;
        return rootNode.get("comment").getValueAsText();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy