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.position;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.apache.commons.lang.builder.EqualsBuilder;
20  import org.kuali.kpme.pm.api.position.PositionQualification;
21  import org.kuali.kpme.pm.api.position.PositionQualificationContract;
22  import org.kuali.kpme.pm.api.pstnqlfrtype.PstnQlfrTypeContract;
23  import org.kuali.kpme.pm.service.base.PmServiceLocator;
24  import org.kuali.rice.core.api.mo.ModelObjectUtils;
25  
26  public class PositionQualificationBo extends PositionDerived implements PositionQualificationContract {
27  	private static final long serialVersionUID = 1L;
28  	
29  	private String pmQualificationId;
30  	private String qualificationType;
31  	@SuppressWarnings("unused")
32  	private String typeValue;		// for GUI only
33  	private String qualifier;
34  	private String qualificationValue;
35  		
36  	public String getQualificationType() {
37  		return qualificationType;
38  	}
39  
40  	public void setQualificationType(String qualificationType) {
41  		this.qualificationType = qualificationType;
42  	}
43  
44  	public String getQualifier() {
45  		return qualifier;
46  	}
47  
48  	public void setQualifier(String qualifier) {
49  		this.qualifier = qualifier;
50  	}
51  
52  	public String getQualificationValue() {
53  		return qualificationValue;
54  	}
55  
56  	public void setQualificationValue(String qualificationValue) {
57  		this.qualificationValue = qualificationValue;
58  	}
59  
60  	public String getTypeValue() {
61  		if(StringUtils.isNotEmpty(this.getQualificationType())) {
62  			PstnQlfrTypeContract aTypeObj = PmServiceLocator.getPstnQlfrTypeService().getPstnQlfrTypeById(this.getQualificationType());
63  			if(aTypeObj != null) {
64  				return aTypeObj.getTypeValue();
65  			}
66  		}
67  		return "";
68  	}
69  
70  	public void setTypeValue(String typeValue) {
71  		this.typeValue = typeValue;
72  	}
73  
74  	public String getPmQualificationId() {
75  		return pmQualificationId;
76  	}
77  
78  	public void setPmQualificationId(String pmQualificationId) {
79  		this.pmQualificationId = pmQualificationId;
80  	}
81  
82      @Override
83      public boolean equals(Object obj) {
84          if (obj == null)
85              return false;
86          if (obj == this)
87              return true;
88          if (obj.getClass() != getClass())
89              return false;
90  
91          PositionQualificationBo rhs = (PositionQualificationBo)obj;
92          return new EqualsBuilder()
93                  .append(pmQualificationId, rhs.getPmQualificationId())
94                  .append(qualificationType, rhs.getQualificationType())
95                  .append(qualifier, rhs.getQualifier())
96                  .append(qualificationValue, rhs.getQualificationValue())
97                  .append(hrPositionId, rhs.getHrPositionId())
98                  .isEquals();
99  
100     }
101     
102 
103 	public static PositionQualificationBo from(PositionQualification im) {
104 
105 		if (im == null) {
106 			return null;
107 		}
108 
109 		PositionQualificationBo positionQualificationBo = new PositionQualificationBo();
110 
111 		positionQualificationBo.setQualifier(im.getQualifier());
112 		positionQualificationBo.setHrPositionId(im.getHrPositionId());
113 		positionQualificationBo.setObjectId(im.getObjectId());
114 		positionQualificationBo.setPmQualificationId(im.getPmQualificationId());
115 		positionQualificationBo.setQualificationType(im.getQualificationType());
116 		positionQualificationBo.setQualificationValue(im.getQualificationValue());
117 		positionQualificationBo.setTypeValue(im.getTypeValue());
118 		positionQualificationBo.setVersionNumber(im.getVersionNumber());
119 		
120 		
121 		return positionQualificationBo;
122 
123 	}
124 
125 	public static PositionQualification to(PositionQualificationBo bo) {
126 		if (bo == null) {
127 			return null;
128 		}
129 		return PositionQualification.Builder.create(bo).build();
130 	}
131 	
132 	public static final ModelObjectUtils.Transformer<PositionQualificationBo, PositionQualification> toImmutable = new ModelObjectUtils.Transformer<PositionQualificationBo, PositionQualification>() {
133 		public PositionQualification transform(PositionQualificationBo input) {
134 			return PositionQualificationBo.to(input);
135 		};
136 	};
137 
138 	public static final ModelObjectUtils.Transformer<PositionQualification, PositionQualificationBo> toBo = new ModelObjectUtils.Transformer<PositionQualification, PositionQualificationBo>() {
139 		public PositionQualificationBo transform(PositionQualification input) {
140 			return PositionQualificationBo.from(input);
141 		};
142 	};
143 
144 	@Override
145 	public String getId() {
146 		return this.getPmQualificationId();
147 	}
148 
149 	@Override
150 	public void setId(String id) {
151 		this.setPmQualificationId(id);
152 	}
153 
154 }