View Javadoc

1   /**
2    * Copyright 2005-2011 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.kim.ldap;
17  
18  import org.springframework.ldap.core.DirContextOperations;
19  import org.springframework.ldap.core.support.AbstractContextMapper;
20  
21  import org.kuali.rice.kim.api.identity.CodedAttribute;
22  import org.kuali.rice.kim.api.identity.employment.EntityEmployment;
23  import org.kuali.rice.kim.util.Constants;
24  
25  import org.kuali.rice.core.api.util.type.KualiDecimal;
26  
27  /**
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class EntityEmploymentMapper extends AbstractContextMapper {
32      private Constants constants;
33      
34      
35      public EntityEmployment.Builder mapFromContext(DirContextOperations context) {
36          return (EntityEmployment.Builder) doMapFromContext(context);
37      }
38  
39      public Object doMapFromContext(DirContextOperations context) {
40          final String departmentCode = context.getStringAttribute(getConstants().getDepartmentLdapProperty());
41          
42          if (departmentCode == null) {
43              return null;
44          }
45  
46          final EntityEmployment.Builder employee = EntityEmployment.Builder.create();
47          employee.setId(context.getStringAttribute(getConstants().getEmployeeIdProperty()));
48          employee.setEmployeeStatus(
49                  CodedAttribute.Builder.create(context.getStringAttribute(getConstants().getEmployeeStatusProperty())));
50          //employee.setEmployeeTypeCode(context.getStringAttribute(getConstants().getEmployeeTypeProperty()));
51          employee.setEmployeeType(CodedAttribute.Builder.create("P"));
52          employee.setBaseSalaryAmount(KualiDecimal.ZERO);
53          
54          employee.setActive(true);
55          return employee;
56      }
57      
58      /**
59       * Gets the value of constants
60       *
61       * @return the value of constants
62       */
63      public final Constants getConstants() {
64          return this.constants;
65      }
66  
67      /**
68       * Sets the value of constants
69       *
70       * @param argConstants Value to assign to this.constants
71       */
72      public final void setConstants(final Constants argConstants) {
73          this.constants = argConstants;
74      }
75  }