001    /*
002     * Copyright 2011 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.kfs.module.endow.businessobject;
017    
018    import java.sql.Date;
019    import java.util.LinkedHashMap;
020    
021    import org.kuali.kfs.module.endow.EndowPropertyConstants;
022    import org.kuali.kfs.sys.context.SpringContext;
023    import org.kuali.rice.kim.bo.Person;
024    import org.kuali.rice.kim.bo.Role;
025    import org.kuali.rice.kim.service.KIMServiceLocator;
026    import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
027    import org.kuali.rice.kns.util.KualiInteger;
028    
029    public class KemidAuthorizations extends PersistableBusinessObjectBase {
030    
031        private String kemid;
032        private KualiInteger roleSequenceNumber;
033        private String roleId;
034        private String rolePrincipalId;
035        private Date roleTerminationDate;
036        private boolean active;
037    
038        private KEMID kemidObjRef;
039        private Role role;
040        private Person rolePrincipal;
041    
042        /**
043         * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
044         */
045        @Override
046        protected LinkedHashMap toStringMapper() {
047            LinkedHashMap<String, String> m = new LinkedHashMap<String, String>();
048            m.put(EndowPropertyConstants.KEMID, this.kemid);
049            m.put(EndowPropertyConstants.KEMID_AUTHORIZATIONS_ROLE_SEQ_NBR, String.valueOf(this.roleSequenceNumber));
050            m.put(EndowPropertyConstants.KEMID_AUTHORIZATIONS_ROLE_ID, this.roleId);
051            m.put(EndowPropertyConstants.KEMID_AUTHORIZATIONS_ROLE_PRNCPL_ID, rolePrincipalId);
052            return m;
053        }
054    
055        /**
056         * Gets the kemid.
057         * 
058         * @return kemid
059         */
060        public String getKemid() {
061            return kemid;
062        }
063    
064        /**
065         * Sets the kemid.
066         * 
067         * @param kemid
068         */
069        public void setKemid(String kemid) {
070            this.kemid = kemid;
071        }
072    
073        /**
074         * Gets the roleSequenceNumber.
075         * 
076         * @return roleSequenceNumber
077         */
078        public KualiInteger getRoleSequenceNumber() {
079            return roleSequenceNumber;
080        }
081    
082        /**
083         * Sets the roleSequenceNumber.
084         * 
085         * @param roleSequenceNumber
086         */
087        public void setRoleSequenceNumber(KualiInteger roleSequenceNumber) {
088            this.roleSequenceNumber = roleSequenceNumber;
089        }
090    
091        /**
092         * Gets the roleId.
093         * 
094         * @return roleId
095         */
096        public String getRoleId() {
097            return roleId;
098        }
099    
100        /**
101         * Sets the roleId.
102         * 
103         * @param roleId
104         */
105        public void setRoleId(String roleId) {
106            this.roleId = roleId;
107        }
108    
109        /**
110         * Gets the rolePrincipalId.
111         * 
112         * @return rolePrincipalId
113         */
114        public String getRolePrincipalId() {
115            return rolePrincipalId;
116        }
117    
118        /**
119         * Sets the rolePrincipalId.
120         * 
121         * @param rolePrincipalId
122         */
123        public void setRolePrincipalId(String rolePrincipalId) {
124            this.rolePrincipalId = rolePrincipalId;
125        }
126    
127        /**
128         * Gets the roleTerminationDate.
129         * 
130         * @return roleTerminationDate
131         */
132        public Date getRoleTerminationDate() {
133            return roleTerminationDate;
134        }
135    
136        /**
137         * Sets the roleTerminationDate.
138         * 
139         * @param roleTerminationDate
140         */
141        public void setRoleTerminationDate(Date roleTerminationDate) {
142            this.roleTerminationDate = roleTerminationDate;
143        }
144    
145        /**
146         * Gets the active indicator.
147         * 
148         * @return active
149         */
150        public boolean isActive() {
151            return active;
152        }
153    
154        /**
155         * Sets the active indicator.
156         * 
157         * @param active
158         */
159        public void setActive(boolean active) {
160            this.active = active;
161        }
162    
163        /**
164         * Gets the kemidObjRef.
165         * 
166         * @return kemidObjRef
167         */
168        public KEMID getKemidObjRef() {
169            return kemidObjRef;
170        }
171    
172        /**
173         * Sets the kemidObjRef.
174         * 
175         * @param kemidObjRef
176         */
177        public void setKemidObjRef(KEMID kemidObjRef) {
178            this.kemidObjRef = kemidObjRef;
179        }
180    
181        /**
182         * Gets the role.
183         * 
184         * @return role
185         */
186        public Role getRole() {
187            role = KIMServiceLocator.getRoleManagementService().getRole(roleId);
188            return role;
189        }
190    
191        /**
192         * Sets the role.
193         * 
194         * @param role
195         */
196        public void setRole(Role role) {
197            this.role = role;
198        }
199    
200        /**
201         * Gets the rolePrincipal.
202         * 
203         * @return rolePrincipal
204         */
205        public Person getRolePrincipal() {
206            rolePrincipal = SpringContext.getBean(org.kuali.rice.kim.service.PersonService.class).updatePersonIfNecessary(rolePrincipalId, rolePrincipal);
207            return rolePrincipal;
208        }
209    
210        /**
211         * Sets the rolePrincipal.
212         * 
213         * @param rolePrincipal
214         */
215        public void setRolePrincipal(Person rolePrincipal) {
216            this.rolePrincipal = rolePrincipal;
217        }
218    
219        /**
220         * @return Returns the rolePrincipalId.
221         */
222        public String getRolePrincipalIdForSearching() {
223            return getRolePrincipalId();
224        }
225    
226    }