View Javadoc
1   /*
2    * Copyright 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  /*
17   * Created on Aug 19, 2004
18   *
19   */
20  package org.kuali.ole.pdp.businessobject;
21  
22  import java.sql.Timestamp;
23  import java.util.HashMap;
24  import java.util.Map;
25  
26  import org.apache.commons.lang.StringUtils;
27  import org.kuali.ole.sys.businessobject.TimestampedBusinessObjectBase;
28  import org.kuali.ole.sys.context.SpringContext;
29  import org.kuali.rice.core.api.util.type.KualiInteger;
30  import org.kuali.rice.kim.api.identity.Person;
31  import org.kuali.rice.krad.service.KualiModuleService;
32  import org.kuali.rice.krad.service.ModuleService;
33  import org.kuali.rice.location.api.LocationConstants;
34  import org.kuali.rice.location.framework.campus.CampusEbo;
35  
36  
37  /**
38   * This class represents a Payment Process.
39   */
40  public class PaymentProcess extends TimestampedBusinessObjectBase {
41      protected KualiInteger id;
42      protected Timestamp processTimestamp;
43      protected String campusCode;
44      protected String processUserId;
45      protected Person processUser;
46      protected boolean extractedInd;
47      protected boolean formattedIndicator;
48  
49      protected CampusEbo campus;
50  
51      /**
52       * Constructs a PaymentProcess.
53       */
54      public PaymentProcess() {
55          super();
56          this.setExtractedInd(false);
57          this.setFormattedIndicator(false);
58      }
59  
60      /**
61       * This method updates the user based on processUserId.
62       * 
63       * @param userService
64       */
65      public void updateUser(org.kuali.rice.kim.api.identity.PersonService userService) {
66          Person u = userService.getPerson(processUserId);
67          setProcessUser(u);
68      }
69  
70      /**
71       * This method gets the campusCode.
72       * 
73       * @return campusCode
74       */
75      public String getCampusCode() {
76          return campusCode;
77      }
78  
79      /**
80       * This method sets the campusCode.
81       * 
82       * @param campusCode
83       */
84      public void setCampusCode(String campusCode) {
85          this.campusCode = campusCode;
86      }
87  
88      /**
89       * This method gets the Id.
90       * 
91       * @return id
92       */
93      public KualiInteger getId() {
94          return id;
95      }
96  
97      /**
98       * This method sets the id.
99       * 
100      * @param id
101      */
102     public void setId(KualiInteger id) {
103         this.id = id;
104     }
105 
106     /**
107      * This method gets the processTimestamp
108      * 
109      * @return processTimestamp
110      */
111     public Timestamp getProcessTimestamp() {
112         return processTimestamp;
113     }
114 
115     /**
116      * This method sets the processTimestamp.
117      * 
118      * @param processTimestamp
119      */
120     public void setProcessTimestamp(Timestamp processTimestamp) {
121         this.processTimestamp = processTimestamp;
122     }
123 
124     /**
125      * This method gets the processUser.
126      * 
127      * @return processUser
128      */
129     public Person getProcessUser() {
130         processUser = SpringContext.getBean(org.kuali.rice.kim.api.identity.PersonService.class).updatePersonIfNecessary(processUserId, processUser);
131         return processUser;
132     }
133 
134     /**
135      * This method sets the processUser.
136      * 
137      * @param processUser
138      */
139     public void setProcessUser(Person processUser) {
140         if (processUser != null) {
141             processUserId = processUser.getPrincipalId();
142         }
143         this.processUser = processUser;
144     }
145 
146     /**
147      * This method gets the processUserId.
148      * 
149      * @return processUserId
150      */
151     public String getProcessUserId() {
152         return processUserId;
153     }
154 
155     /**
156      * This method sets the processUserId.
157      * 
158      * @param processUserId
159      */
160     public void setProcessUserId(String processUserId) {
161         this.processUserId = processUserId;
162     }
163 
164 
165     /**
166      * This method gets the extractedInd.
167      * 
168      * @return extractedInd
169      */
170     public boolean isExtractedInd() {
171         return extractedInd;
172     }
173 
174 
175     /**
176      * This method sets the extractedInd.
177      * 
178      * @param extractedInd
179      */
180     public void setExtractedInd(boolean extractedInd) {
181         this.extractedInd = extractedInd;
182     }
183 
184     /**
185      * This method gets the formattedIndicator.
186      * 
187      * @return formattedIndicator
188      */
189     public boolean isFormattedIndicator() {
190         return formattedIndicator;
191     }
192 
193     /**
194      * This method sets the formattedIndicator.
195      * 
196      * @param formattedIndicator
197      */
198     public void setFormattedIndicator(boolean formattedIndicator) {
199         this.formattedIndicator = formattedIndicator;
200     }
201 
202     /**
203      * This method gets the campus.
204      * 
205      * @return campus
206      */
207     public CampusEbo getCampus() {
208         if ( StringUtils.isBlank(campusCode) ) {
209             campus = null;
210         } else {
211             if ( campus == null || !StringUtils.equals( campus.getCode(),campusCode) ) {
212                 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CampusEbo.class);
213                 if ( moduleService != null ) {
214                     Map<String,Object> keys = new HashMap<String, Object>(1);
215                     keys.put(LocationConstants.PrimaryKeyConstants.CODE, campusCode);
216                     campus = moduleService.getExternalizableBusinessObject(CampusEbo.class, keys);
217                 } else {
218                     throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
219                 }
220             }
221         }
222         return campus;
223     }
224 
225     /**
226      * This method sets the campus.
227      * 
228      * @param campus
229      */
230     public void setCampus(CampusEbo campus) {
231         this.campus = campus;
232     }
233 
234 }