View Javadoc
1   /**
2    * Copyright 2004-2014 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.kpme.core.position;
17  
18  import org.kuali.kpme.core.api.position.PositionBase;
19  import org.kuali.kpme.core.api.position.PositionBaseContract;
20  import org.kuali.kpme.core.bo.HrKeyedBusinessObject;
21  import org.kuali.kpme.core.groupkey.HrGroupKeyBo;
22  import org.kuali.rice.core.api.mo.ModelObjectUtils;
23  
24  import com.google.common.collect.ImmutableList;
25  import com.google.common.collect.ImmutableMap;
26  
27  public class PositionBaseBo extends HrKeyedBusinessObject implements PositionBaseContract {
28  	
29  	protected static class KeyFields {
30  		public static final String POSITION_NUMBER = "positionNumber";
31  	}
32  
33  	
34  	private static final long serialVersionUID = -3258249005786874634L;
35  	//KPME-2273/1965 Primary Business Keys List.	
36  	public static final ImmutableList<String> BUSINESS_KEYS = new ImmutableList.Builder<String>()
37              .add(KeyFields.POSITION_NUMBER)
38              .build();
39  
40  	
41  	private String hrPositionId;
42  	private String positionNumber;
43  	private String description;
44  
45  	@Override
46  	public ImmutableMap<String, Object> getBusinessKeyValuesMap() {
47      	return  new ImmutableMap.Builder<String, Object>()
48  			.put(KeyFields.POSITION_NUMBER, this.getPositionNumber())
49  			.build();
50  	}
51  	
52  
53  	@Override
54  	public String getId() {
55  		return getHrPositionId();
56  	}
57  
58  	@Override
59  	public void setId(String id) {
60  		setHrPositionId(id);
61  	}
62  	
63  	@Override
64  	public String getUniqueKey() {
65  		return positionNumber;
66  	}
67  
68  	public String getHrPositionId() {
69  		return hrPositionId;
70  	}
71  
72  	public void setHrPositionId(String hrPositionId) {
73  		this.hrPositionId = hrPositionId;
74  	}
75  
76  	public String getPositionNumber() {
77  		return positionNumber;
78  	}
79  
80  	public void setPositionNumber(String positionNumber) {
81  		this.positionNumber = positionNumber;
82  	}
83  
84  	public String getDescription() {
85  		return description;
86  	}
87  
88  	public void setDescription(String description) {
89  		this.description = description;
90  	}
91  	
92  	public static PositionBaseBo from(PositionBase im) {
93  		if (im == null) {
94              return null;
95          }		
96  
97  		PositionBaseBo retVal = new PositionBaseBo();
98  		retVal.setHrPositionId(im.getHrPositionId());
99  		retVal.setPositionNumber(im.getPositionNumber());
100 		retVal.setGroupKeyCode(im.getGroupKeyCode());
101 		retVal.setGroupKey(HrGroupKeyBo.from(im.getGroupKey()));
102 		retVal.setDescription(im.getDescription());
103 		copyCommonFields(retVal, im);
104 
105 		retVal.setId(im.getId());
106 		retVal.setEffectiveLocalDate(im.getEffectiveLocalDate());
107 
108 	    return retVal;
109 	}
110 	
111 	public static PositionBase to(PositionBaseBo bo) {
112 		if (bo == null) {
113 			return null;
114 		}
115 		return PositionBase.Builder.create(bo).build();
116 	}
117 
118 	public static final ModelObjectUtils.Transformer<PositionBaseBo, PositionBase> toImmutable = new ModelObjectUtils.Transformer<PositionBaseBo, PositionBase>() {
119 		public PositionBase transform(PositionBaseBo input) {
120 			return PositionBaseBo.to(input);
121 		};
122 	};
123 
124 	public static final ModelObjectUtils.Transformer<PositionBase, PositionBaseBo> toBo = new ModelObjectUtils.Transformer<PositionBase, PositionBaseBo>() {
125 		public PositionBaseBo transform(PositionBase input) {
126 			return PositionBaseBo.from(input);
127 		};
128 	};
129 	
130 }