001/**
002 * Copyright 2005-2016 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.EmbeddedId;
022import javax.persistence.Entity;
023import javax.persistence.FetchType;
024import javax.persistence.JoinColumn;
025import javax.persistence.ManyToOne;
026import javax.persistence.MapsId;
027import javax.persistence.Table;
028import javax.persistence.Transient;
029import java.util.ArrayList;
030import java.util.List;
031
032/**
033 * <p>Model bean representing a grouping of valid application document statuses for a document type
034 * An instance of this class represents a subset of the valid status for a given document type.
035 * </p>
036 * <p>The purpose of the Application Document Status Category is to provide a grouping mechanism
037 * for Application Document Status that can be used to not only label a set of statuses as having some common
038 * characteristic, but to allow users to search on all the grouped statuses by selecting the category name.
039 * </p>
040 * <p>The (optional) valid application statuses element within a document type definition may (again, optionally) contain
041 * category elements which define these groupings of valid statuses.
042 * </p>
043 * @author Peter Giles
044 *
045 */
046@Entity
047@Table(name="KREW_DOC_TYP_APP_STAT_CAT_T")
048public class ApplicationDocumentStatusCategory extends PersistableBusinessObjectBase {
049        private static final long serialVersionUID = -2212481684546954746L;
050
051        @EmbeddedId
052        private ApplicationDocumentStatusCategoryId applicationDocumentStatusCategoryId;
053
054        @MapsId("documentTypeId")
055        @ManyToOne(fetch=FetchType.EAGER)
056        @JoinColumn(name="DOC_TYP_ID")
057        private DocumentType documentType;
058
059        @Transient
060        private String documentTypeId;
061        @Transient
062        private String categoryName;
063
064    /**
065     * Gets the composite identifier, a {@link org.kuali.rice.kew.doctype.ApplicationDocumentStatusCategoryId}
066     * @return the application document status category id
067     */
068    public ApplicationDocumentStatusCategoryId getApplicationDocumentStatusCategoryId() {
069        if (this.applicationDocumentStatusCategoryId == null) {
070                this.applicationDocumentStatusCategoryId = new ApplicationDocumentStatusCategoryId();
071        }
072                return this.applicationDocumentStatusCategoryId;
073        }
074
075    /**
076     * Sets the composition identifier
077     * @param categoryId the composite identifier to set
078     */
079        public void setApplicationDocumentStatusCategoryId(ApplicationDocumentStatusCategoryId categoryId) {
080                this.applicationDocumentStatusCategoryId = categoryId;
081        }
082
083    /**
084     * Get the document type id for this category
085     * @return the document type id
086     */
087        public String getDocumentTypeId() {
088                if (this.getApplicationDocumentStatusCategoryId().getDocumentTypeId() != null) {
089            return this.getApplicationDocumentStatusCategoryId().getDocumentTypeId();
090        } else {
091            return this.documentTypeId;
092        }
093        }
094
095    /**
096     * Set the document type id for this category
097     * @param documentTypeId the document type id to set
098     */
099        public void setDocumentTypeId(String documentTypeId) {
100                this.documentTypeId = documentTypeId;
101                this.getApplicationDocumentStatusCategoryId().setDocumentTypeId(documentTypeId);
102        }
103
104    /**
105     * The name for this category
106     * @return the category name
107     */
108        public String getCategoryName() {
109        if (this.getApplicationDocumentStatusCategoryId().getCategoryName() != null) {
110            return this.getApplicationDocumentStatusCategoryId().getCategoryName();
111        } else {
112            return this.categoryName;
113        }
114        }
115
116    /**
117     * Set the name for this category
118     * @param statusName the category name to set
119     */
120        public void setCategoryName(String statusName) {
121                this.categoryName = statusName;
122                this.getApplicationDocumentStatusCategoryId().setCategoryName(statusName);
123        }
124
125    /**
126     * Get the document type that this category is associated with
127     * @return the document type for this category
128     */
129        public DocumentType getDocumentType() {
130                return this.documentType;
131        }
132
133    /**
134     * Set the document type that this category is associated with
135     * @param documentType the document type to set
136     */
137        public void setDocumentType(DocumentType documentType) {
138                this.documentType = documentType;
139        }
140
141}