001    /**
002     * Copyright 2005-2012 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     */
016    package org.kuali.rice.kew.routeheader;
017    
018    import org.bouncycastle.ocsp.OCSPReqGenerator;
019    import org.hibernate.annotations.GenericGenerator;
020    import org.hibernate.annotations.Parameter;
021    import org.joda.time.DateTime;
022    import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
023    
024    import javax.persistence.*;
025    import java.sql.Timestamp;
026    
027    
028    /**
029     * Model bean representing the valid application document statuses for a document type
030     * 
031     * @author Kuali Rice Team (kuali-rice@googlegroups.com)
032     *
033     */
034    @Entity
035    @Table(name="KREW_APP_DOC_STAT_TRAN_T")
036    public class DocumentStatusTransition extends PersistableBusinessObjectBase {
037            private static final long serialVersionUID = -2212481684546954746L;
038    
039            @Id
040            @GeneratedValue(generator="KREW_DOC_HDR_S")
041            @GenericGenerator(name="KREW_DOC_HDR_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
042                            @Parameter(name="sequence_name",value="KREW_DOC_HDR_S"),
043                            @Parameter(name="value_column",value="id")
044            })
045            @Column(name="APP_DOC_STAT_TRAN_ID")
046            private String statusTransitionId;
047            
048            @Column(name="DOC_HDR_ID")
049            private String documentId;
050            
051            @Column(name="APP_DOC_STAT_FROM")
052            private String oldAppDocStatus;
053            
054            @Column(name="APP_DOC_STAT_TO")
055            private String newAppDocStatus;
056            
057            @Column(name="STAT_TRANS_DATE")
058            private java.sql.Timestamp statusTransitionDate;
059            
060        public DocumentStatusTransition() {
061        }
062    
063        public DocumentStatusTransition(String documentId, String oldStatus, String newStatus) {
064            this.documentId = documentId;
065            this.oldAppDocStatus = oldStatus;
066            this.newAppDocStatus = newStatus;
067            this.statusTransitionDate = new Timestamp(System.currentTimeMillis());
068        }
069    
070            public String getStatusTransitionId() {
071                    return this.statusTransitionId;
072            }
073    
074            public void setStatusTransitionId(String statusTransitionId) {
075                    this.statusTransitionId = statusTransitionId;
076            }
077    
078            public String getDocumentId() {
079                    return this.documentId;
080            }
081    
082            public void setDocumentId(String documentId) {
083                    this.documentId = documentId;
084            }
085    
086            public String getOldAppDocStatus() {
087                    return this.oldAppDocStatus;
088            }
089    
090            public void setOldAppDocStatus(String oldAppDocStatus) {
091                    this.oldAppDocStatus = oldAppDocStatus;
092            }
093    
094            public String getNewAppDocStatus() {
095                    return this.newAppDocStatus;
096            }
097    
098            public void setNewAppDocStatus(String newAppDocStatus) {
099                    this.newAppDocStatus = newAppDocStatus;
100            }
101    
102            public java.sql.Timestamp getStatusTransitionDate() {
103                    return this.statusTransitionDate;
104            }
105    
106            public void setStatusTransitionDate(java.sql.Timestamp statusTransitionDate) {
107                    this.statusTransitionDate = statusTransitionDate;
108            }
109    
110        public static DocumentStatusTransition from(org.kuali.rice.kew.api.document.DocumentStatusTransition im) {
111            if (im == null) {
112                return null;
113            }
114            DocumentStatusTransition transition = new DocumentStatusTransition(im.getDocumentId(), im.getOldStatus(), im.getNewStatus());
115            transition.setStatusTransitionId(im.getId());
116            if (im.getStatusTransitionDate() != null) {
117                transition.setStatusTransitionDate(new Timestamp(im.getStatusTransitionDate().getMillis()));
118            }
119            return transition;
120        }
121    
122        public static org.kuali.rice.kew.api.document.DocumentStatusTransition to(DocumentStatusTransition bo) {
123            if (bo == null) {
124                return null;
125            }
126    
127            org.kuali.rice.kew.api.document.DocumentStatusTransition.Builder builder = org.kuali.rice.kew.api.document.DocumentStatusTransition.Builder.create(bo.getDocumentId(), bo.getOldAppDocStatus(), bo.getNewAppDocStatus());
128            builder.setId(bo.getStatusTransitionId());
129            if (bo.getStatusTransitionDate() != null) {
130                builder.setStatusTransitionDate(new DateTime(bo.getStatusTransitionDate().getTime()));
131            }
132            return builder.build();
133        }
134    }