001/**
002 * Copyright 2005-2015 The Kuali Foundation
003 *
004 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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 */
016package org.kuali.rice.kew.api.action;
017
018import java.util.Collection;
019
020import javax.xml.bind.annotation.XmlAccessType;
021import javax.xml.bind.annotation.XmlAccessorType;
022import javax.xml.bind.annotation.XmlAnyElement;
023import javax.xml.bind.annotation.XmlElement;
024import javax.xml.bind.annotation.XmlRootElement;
025import javax.xml.bind.annotation.XmlType;
026
027import org.kuali.rice.core.api.CoreConstants;
028import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
029import org.kuali.rice.kew.api.document.Document;
030import org.w3c.dom.Element;
031
032@XmlRootElement(name = DocumentActionResult.Constants.ROOT_ELEMENT_NAME)
033@XmlAccessorType(XmlAccessType.NONE)
034@XmlType(name = DocumentActionResult.Constants.TYPE_NAME, propOrder = {
035                DocumentActionResult.Elements.DOCUMENT,
036                DocumentActionResult.Elements.VALID_ACTIONS,
037                DocumentActionResult.Elements.REQUESTED_ACTIONS,
038                CoreConstants.CommonElements.FUTURE_ELEMENTS
039})
040public final class DocumentActionResult extends AbstractDataTransferObject {
041    
042        private static final long serialVersionUID = -3916503634900791018L;
043
044        @XmlElement(name = Elements.DOCUMENT, required = true)
045    private final Document document;
046        
047        @XmlElement(name = Elements.VALID_ACTIONS, required = false)
048        private final ValidActions validActions;
049        
050        @XmlElement(name = Elements.REQUESTED_ACTIONS, required = false)
051        private final RequestedActions requestedActions;
052            
053    @SuppressWarnings("unused")
054    @XmlAnyElement
055    private final Collection<Element> _futureElements = null;
056
057    private DocumentActionResult() {
058        this.document = null;
059        this.validActions = null;
060        this.requestedActions = null;
061    }
062    
063    private DocumentActionResult(Document document, ValidActions validActions, RequestedActions requestedActions) {
064        if (document == null) {
065                throw new IllegalArgumentException("document was null");
066        }
067        this.document = document;
068        this.validActions = validActions;
069        this.requestedActions = requestedActions;
070    }
071    
072    public static DocumentActionResult create(Document document, ValidActions validActions, RequestedActions requestedActions) {
073        return new DocumentActionResult(document, validActions, requestedActions);
074    }
075    
076    public Document getDocument() {
077        return document;
078    }
079    
080    public ValidActions getValidActions() {
081        return validActions;
082    }
083    
084    public RequestedActions getRequestedActions() {
085        return requestedActions;
086    }
087    
088    /**
089     * Defines some internal constants used on this class.
090     */
091    static class Constants {
092        final static String ROOT_ELEMENT_NAME = "documentActionResult";
093        final static String TYPE_NAME = "DocumentActionResultType";
094    }
095    
096    /**
097     * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
098     */
099    static class Elements {
100        final static String DOCUMENT = "document";
101        final static String VALID_ACTIONS = "validActions";
102        final static String REQUESTED_ACTIONS = "requestedActions";
103    }
104
105}