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.pm.pstnrptgrpsubcat;
17  
18  import org.kuali.kpme.core.bo.HrKeyedBusinessObject;
19  import org.kuali.kpme.core.groupkey.HrGroupKeyBo;
20  import org.kuali.kpme.pm.api.pstnrptgrpsubcat.PositionReportGroupSubCategory;
21  import org.kuali.kpme.pm.api.pstnrptgrpsubcat.PositionReportGroupSubCategoryContract;
22  
23  import com.google.common.collect.ImmutableList;
24  import com.google.common.collect.ImmutableMap;
25  
26  public class PositionReportGroupSubCategoryBo extends HrKeyedBusinessObject implements PositionReportGroupSubCategoryContract {
27  	
28  	static class KeyFields {
29  		private static final String POSITION_REPORT_GROUP = "positionReportGroup";
30  		private static final String POSITION_REPORT_SUB_CAT = "positionReportSubCat";
31  	}
32  
33  	private static final long serialVersionUID = 1L;
34  	
35  	public static final ImmutableList<String> BUSINESS_KEYS = new ImmutableList.Builder<String>()
36  		     .add(KeyFields.POSITION_REPORT_SUB_CAT)
37  		     .add(KeyFields.POSITION_REPORT_GROUP)
38  		     .build();
39  	
40  	private String pmPstnRptGrpSubCatId;
41  	private String pstnRptGrpSubCat;
42  	private String positionReportGroup;
43  	private String positionReportSubCat;
44  	private String description;
45  	
46  	@Override
47  	public ImmutableMap<String, Object> getBusinessKeyValuesMap() {
48  		return new ImmutableMap.Builder<String, Object>()
49  				.put(KeyFields.POSITION_REPORT_SUB_CAT, this.getPositionReportSubCat())
50  				.put(KeyFields.POSITION_REPORT_GROUP, this.getPositionReportGroup())
51  				.build();
52  	}
53  	
54  	@Override
55  	public String getId() {
56  		return this.getPmPstnRptGrpSubCatId();
57  	}
58  
59  	@Override
60  	public void setId(String id) {
61  		setPmPstnRptGrpSubCatId(id);
62  	}
63  
64  	@Override
65  	protected String getUniqueKey() {
66  		return getPstnRptGrpSubCat() + "_" + getPositionReportGroup() + "_" + getPositionReportSubCat();
67  	}
68  
69  	public String getPmPstnRptGrpSubCatId() {
70  		return pmPstnRptGrpSubCatId;
71  	}
72  
73  	public void setPmPstnRptGrpSubCatId(String pmPstnRptGrpSubCatId) {
74  		this.pmPstnRptGrpSubCatId = pmPstnRptGrpSubCatId;
75  	}
76  
77  	public String getPstnRptGrpSubCat() {
78  		return pstnRptGrpSubCat;
79  	}
80  
81  	public void setPstnRptGrpSubCat(String pstnRptGrpSubCat) {
82  		this.pstnRptGrpSubCat = pstnRptGrpSubCat;
83  	}
84  
85  	public String getPositionReportGroup() {
86  		return positionReportGroup;
87  	}
88  
89  	public void setPositionReportGroup(String positionReportGroup) {
90  		this.positionReportGroup = positionReportGroup;
91  	}
92  
93  	public String getPositionReportSubCat() {
94  		return positionReportSubCat;
95  	}
96  
97  	public void setPositionReportSubCat(String positionReportSubCat) {
98  		this.positionReportSubCat = positionReportSubCat;
99  	}
100 
101 	public String getDescription() {
102 		return description;
103 	}
104 
105 	public void setDescription(String description) {
106 		this.description = description;
107 	}
108 	
109 	public static PositionReportGroupSubCategoryBo from(PositionReportGroupSubCategory im) {
110 		PositionReportGroupSubCategoryBo retVal = new PositionReportGroupSubCategoryBo();
111 		
112 		// copy over BO-specific fields
113 		retVal.setPositionReportGroup(im.getPositionReportGroup());
114 		retVal.setPositionReportSubCat(im.getPositionReportSubCat());
115 		retVal.setPstnRptGrpSubCat(im.getPstnRptGrpSubCat());
116 		retVal.setPmPstnRptGrpSubCatId(im.getPmPstnRptGrpSubCatId());
117 		retVal.setDescription(im.getDescription());
118 		
119 		// fnally copy over fields common to all Hr BOs
120 		copyCommonFields(retVal, im);		
121 		
122 		return retVal;
123 	}
124 	
125 	public static PositionReportGroupSubCategory to(PositionReportGroupSubCategoryBo bo) {
126         if (bo == null) {
127             return null;
128         }
129 
130         return PositionReportGroupSubCategory.Builder.create(bo).build();
131     }
132 
133 
134 }