001/**
002 * Copyright 2005-2017 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.doctype;
017
018import org.kuali.rice.kew.doctype.bo.DocumentType;
019import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
020
021import javax.persistence.Column;
022import javax.persistence.EmbeddedId;
023import javax.persistence.Entity;
024import javax.persistence.JoinColumn;
025import javax.persistence.JoinColumns;
026import javax.persistence.ManyToOne;
027import javax.persistence.MapsId;
028import javax.persistence.PrimaryKeyJoinColumn;
029import javax.persistence.Table;
030import javax.persistence.Transient;
031
032/**
033 * Model bean representing the valid application document statuses for a document type
034 * An instance of this class represents a single valid status for a given document type.
035 *
036 * The purpose of the Application Document Status is to provide an alternative to the
037 * KEW Route Status. Some documents may have a variety of statuses relating to where they are
038 * in their lifecycle.  The application document status provides a means to for a document type to have its
039 * own set of statuses.
040 *
041 * A policy defined in the document type definition for a document determines if the Application
042 * Document Status is to be used.  In the document definition, a list of valid application statuses
043 * for the document may also be defined.  If the list of valid statuses are not defined, then any status
044 * value may be assigned by the client.
045 *
046 * @author Dan Seibert
047 */
048@Entity
049@Table(name = "KREW_DOC_TYP_APP_DOC_STAT_T")
050public class ApplicationDocumentStatus extends PersistableBusinessObjectBase {
051
052    private static final long serialVersionUID = -2212481684546954746L;
053
054    @EmbeddedId
055    private ApplicationDocumentStatusId applicationDocumentStatusId;
056
057    @Column(name = "SEQ_NO")
058    private Integer sequenceNumber;
059
060    @ManyToOne
061    @JoinColumns( {
062            @JoinColumn(name = "CAT_NM", referencedColumnName = "CAT_NM"),
063            @JoinColumn(name = "DOC_TYP_ID", referencedColumnName = "DOC_TYP_ID", updatable = false, insertable = false)
064    })
065    private ApplicationDocumentStatusCategory category;
066
067    @MapsId("documentTypeId")
068    @ManyToOne
069    @JoinColumn(name = "DOC_TYP_ID")
070    private DocumentType documentType;
071
072    /**
073     * Just here to keep OJB happy for now.
074     */
075    @Deprecated
076    @Transient
077    private String categoryName;
078
079    @Deprecated
080    @Transient
081    private String documentTypeId;
082
083    @Deprecated
084    @Transient
085    private String statusName;
086
087    public ApplicationDocumentStatusId getApplicationDocumentStatusId() {
088        if (this.applicationDocumentStatusId == null) {
089            this.applicationDocumentStatusId = new ApplicationDocumentStatusId();
090        }
091        return this.applicationDocumentStatusId;
092    }
093
094    public void setApplicationDocumentStatusId(ApplicationDocumentStatusId documentStatusId) {
095        this.applicationDocumentStatusId = documentStatusId;
096    }
097
098    public String getDocumentTypeId() {
099        return this.getDocumentType() != null ? getDocumentType().getDocumentTypeId() : "";
100    }
101
102    public void setDocumentTypeId(String documentTypeId) {
103        this.getApplicationDocumentStatusId().setDocumentTypeId(documentTypeId);
104    }
105
106    public String getStatusName() {
107        return this.getApplicationDocumentStatusId().getStatusName();
108    }
109
110    public void setStatusName(String statusName) {
111        this.getApplicationDocumentStatusId().setStatusName(statusName);
112    }
113
114    public Integer getSequenceNumber() {
115        return sequenceNumber;
116    }
117
118    public void setSequenceNumber(Integer sequenceNumber) {
119        this.sequenceNumber = sequenceNumber;
120    }
121
122    public String getCategoryName() {
123        if (getCategory() == null) {
124            return null;
125        }
126        return getCategory().getApplicationDocumentStatusCategoryId().getCategoryName();
127    }
128
129    public DocumentType getDocumentType() {
130        return documentType;
131    }
132
133    public void setDocumentType(DocumentType documentType) {
134        this.documentType = documentType;
135    }
136
137    public ApplicationDocumentStatusCategory getCategory() {
138        return category;
139    }
140
141    public void setCategory(ApplicationDocumentStatusCategory category) {
142        this.category = category;
143    }
144}