View Javadoc

1   /*
2    * Copyright 2005-2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kns.bo;
17  
18  import java.util.LinkedHashMap;
19  import java.util.Map;
20  
21  import javax.persistence.Column;
22  import javax.persistence.Id;
23  import javax.persistence.MappedSuperclass;
24  import javax.persistence.Transient;
25  
26  import org.apache.commons.lang.StringUtils;
27  import org.kuali.rice.kew.util.CodeTranslator;
28  import org.kuali.rice.kew.util.KEWConstants;
29  
30  
31  /**
32   * TODO we should not be referencing kew constants from this class and wedding ourselves to that workflow application Ad Hoc Route
33   * Recipient Business Object
34   */
35  @MappedSuperclass
36  public abstract class AdHocRouteRecipient extends PersistableBusinessObjectBase {
37  
38      private static final long serialVersionUID = -6499610180752232494L;
39      private static Map actionRequestCds = CodeTranslator.arLabels;
40      public static final Integer PERSON_TYPE = new Integer(0);
41      public static final Integer WORKGROUP_TYPE = new Integer(1);
42  
43      @Id
44  	@Column(name="RECIP_TYP_CD")
45  	protected Integer type;
46      @Id
47  	@Column(name="ACTN_RQST_CD")
48  	protected String actionRequested;
49      @Id
50  	@Column(name="ACTN_RQST_RECIP_ID")
51  	protected String id; // can be networkId or group id
52      @Transient
53      protected String name;
54      @Column(name="DOC_HDR_ID")
55  	protected String documentNumber;
56  
57      public AdHocRouteRecipient() {
58          // set some defaults that can be overridden
59          this.actionRequested = KEWConstants.ACTION_REQUEST_APPROVE_REQ;
60          this.versionNumber = new Long(1);
61      }
62  
63      public String getActionRequested() {
64          return actionRequested;
65      }
66  
67      public void setActionRequested(String actionRequested) {
68          this.actionRequested = actionRequested;
69      }
70  
71      public String getId() {
72          return id;
73      }
74  
75      public void setId(String id) {
76          this.id = id;
77      }
78  
79      public abstract String getName();
80  
81      public void setName( String name ) {
82          // do nothing, assume names come from subclasses
83      }
84  
85      public Integer getType() {
86          return type;
87      }
88  
89      public void setType(Integer type) {
90          this.type = type;
91      }
92  
93      public void setdocumentNumber (String documentNumber){
94          this.documentNumber = documentNumber;
95      }
96  
97      public String getdocumentNumber (){
98          return documentNumber;
99      }
100 
101     public String getActionRequestedValue() {
102         String actionRequestedValue = null;
103         if (StringUtils.isNotBlank(getActionRequested())) {
104             actionRequestedValue = (String) actionRequestCds.get(getActionRequested());
105         }
106         return actionRequestedValue;
107     }
108 
109     /**
110      * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
111      */
112     protected LinkedHashMap toStringMapper() {
113         LinkedHashMap m = new LinkedHashMap();
114 
115         m.put("type", getType());
116         m.put("actionRequested", getActionRequested());
117         m.put("id", getId());
118 
119         return m;
120     }
121 }