001    /**
002     * Copyright 2005-2014 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.kim.ldap;
017    
018    import org.kuali.rice.core.api.util.type.KualiDecimal;
019    import org.kuali.rice.kim.api.identity.CodedAttribute;
020    import org.kuali.rice.kim.api.identity.employment.EntityEmployment;
021    import org.springframework.ldap.core.DirContextOperations;
022    
023    /**
024     * 
025     * @author Kuali Rice Team (rice.collab@kuali.org)
026     */
027    public class EntityEmploymentMapper extends BaseMapper<EntityEmployment> {
028    
029        @Override
030        EntityEmployment mapDtoFromContext(DirContextOperations context) {
031            EntityEmployment.Builder builder = mapBuilderFromContext(context);
032            return builder != null ? builder.build() : null;
033        }
034    
035        EntityEmployment.Builder mapBuilderFromContext(DirContextOperations context) {
036            final String departmentCode = context.getStringAttribute(getConstants().getDepartmentLdapProperty());
037            
038            if (departmentCode == null) {
039                return null;
040            }
041    
042            final EntityEmployment.Builder employee = EntityEmployment.Builder.create();
043            employee.setId(context.getStringAttribute(getConstants().getEmployeeIdProperty()));
044            employee.setEmployeeStatus(
045                    CodedAttribute.Builder.create(context.getStringAttribute(getConstants().getEmployeeStatusProperty())));
046            //employee.setEmployeeTypeCode(context.getStringAttribute(getConstants().getEmployeeTypeProperty()));
047            employee.setEmployeeType(CodedAttribute.Builder.create("P"));
048            employee.setBaseSalaryAmount(KualiDecimal.ZERO);
049            
050            employee.setActive(true);
051            return employee;
052        }
053        
054    }