001/**
002 * Copyright 2004-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 */
016package org.kuali.kpme.pm.api.position;
017
018import java.io.Serializable;
019import java.math.BigDecimal;
020import java.util.Collection;
021import javax.xml.bind.annotation.XmlAccessType;
022import javax.xml.bind.annotation.XmlAccessorType;
023import javax.xml.bind.annotation.XmlAnyElement;
024import javax.xml.bind.annotation.XmlElement;
025import javax.xml.bind.annotation.XmlRootElement;
026import javax.xml.bind.annotation.XmlType;
027import org.joda.time.LocalDate;
028import org.kuali.rice.core.api.CoreConstants;
029import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
030import org.kuali.rice.core.api.mo.ModelBuilder;
031import org.w3c.dom.Element;
032
033@XmlRootElement(name = PositionDuty.Constants.ROOT_ELEMENT_NAME)
034@XmlAccessorType(XmlAccessType.NONE)
035@XmlType(name = PositionDuty.Constants.TYPE_NAME, propOrder = {
036    PositionDuty.Elements.NAME,
037    PositionDuty.Elements.DESCRIPTION,
038    PositionDuty.Elements.PERCENTAGE,
039    PositionDuty.Elements.PM_DUTY_ID,
040    PositionDuty.Elements.HR_POSITION_ID,
041    PositionDuty.Elements.EFFECTIVE_LOCAL_DATE_OF_OWNER,
042    CoreConstants.CommonElements.VERSION_NUMBER,
043    CoreConstants.CommonElements.OBJECT_ID,
044    CoreConstants.CommonElements.FUTURE_ELEMENTS
045})
046public final class PositionDuty extends AbstractDataTransferObject implements PositionDutyContract {
047
048        private static final long serialVersionUID = -5750874869253559360L;
049        
050        @XmlElement(name = Elements.NAME, required = false)
051    private final String name;
052    @XmlElement(name = Elements.DESCRIPTION, required = false)
053    private final String description;
054    @XmlElement(name = Elements.PERCENTAGE, required = false)
055    private final BigDecimal percentage;
056    @XmlElement(name = Elements.PM_DUTY_ID, required = false)
057    private final String pmDutyId;
058    @XmlElement(name = Elements.HR_POSITION_ID, required = false)
059    private final String hrPositionId;
060    @XmlElement(name = Elements.EFFECTIVE_LOCAL_DATE_OF_OWNER, required = false)
061    private final LocalDate effectiveLocalDateOfOwner;
062    @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
063    private final Long versionNumber;
064    @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
065    private final String objectId;
066    @XmlAnyElement
067    private final Collection<Element> _futureElements = null;
068
069    /**
070     * Private constructor used only by JAXB.
071     * 
072     */
073    private PositionDuty() {
074        this.name = null;
075        this.description = null;
076        this.percentage = null;
077        this.pmDutyId = null;
078        this.hrPositionId = null;
079        this.effectiveLocalDateOfOwner = null;
080        this.versionNumber = null;
081        this.objectId = null;
082    }
083
084    private PositionDuty(Builder builder) {
085        this.name = builder.getName();
086        this.description = builder.getDescription();
087        this.percentage = builder.getPercentage();
088        this.pmDutyId = builder.getPmDutyId();
089        this.hrPositionId = builder.getHrPositionId();
090        this.effectiveLocalDateOfOwner = builder.getEffectiveLocalDateOfOwner();
091        this.versionNumber = builder.getVersionNumber();
092        this.objectId = builder.getObjectId();
093    }
094
095    @Override
096    public String getName() {
097        return this.name;
098    }
099
100    @Override
101    public String getDescription() {
102        return this.description;
103    }
104
105    @Override
106    public BigDecimal getPercentage() {
107        return this.percentage;
108    }
109
110    @Override
111    public String getPmDutyId() {
112        return this.pmDutyId;
113    }
114    
115    @Override
116    public String getHrPositionId() {
117        return this.hrPositionId;
118    }
119
120    @Override
121    public LocalDate getEffectiveLocalDateOfOwner() {
122        return this.effectiveLocalDateOfOwner;
123    }
124
125    @Override
126    public Long getVersionNumber() {
127        return this.versionNumber;
128    }
129
130    @Override
131    public String getObjectId() {
132        return this.objectId;
133    }
134
135
136    /**
137     * A builder which can be used to construct {@link PositionDuty} instances.  Enforces the constraints of the {@link PositionDutyContract}.
138     * 
139     */
140    public final static class Builder implements Serializable, PositionDutyContract, ModelBuilder {
141
142                private static final long serialVersionUID = -529812836523277483L;
143                private String name;
144        private String description;
145        private BigDecimal percentage;
146        private String pmDutyId;
147        private String hrPositionId;
148        private LocalDate effectiveLocalDateOfOwner;
149        private Long versionNumber;
150        private String objectId;
151
152        private Builder() {
153            // TODO modify this constructor as needed to pass any required values and invoke the appropriate 'setter' methods
154        }
155
156        public static Builder create() {
157
158            return new Builder();
159        }
160
161        public static Builder create(PositionDutyContract contract) {
162            if (contract == null) {
163                throw new IllegalArgumentException("contract was null");
164            }
165
166            Builder builder = create();
167            builder.setName(contract.getName());
168            builder.setDescription(contract.getDescription());
169            builder.setPercentage(contract.getPercentage());
170            builder.setPmDutyId(contract.getPmDutyId());
171            builder.setHrPositionId(contract.getHrPositionId());
172            builder.setEffectiveLocalDateOfOwner(contract.getEffectiveLocalDateOfOwner());
173            builder.setVersionNumber(contract.getVersionNumber());
174            builder.setObjectId(contract.getObjectId());
175            return builder;
176        }
177
178        public PositionDuty build() {
179            return new PositionDuty(this);
180        }
181
182        @Override
183        public String getName() {
184            return this.name;
185        }
186
187        @Override
188        public String getDescription() {
189            return this.description;
190        }
191
192        @Override
193        public BigDecimal getPercentage() {
194            return this.percentage;
195        }
196
197        @Override
198        public String getPmDutyId() {
199            return this.pmDutyId;
200        }
201        
202
203        @Override
204        public String getHrPositionId() {
205            return this.hrPositionId;
206        }
207
208        @Override
209        public LocalDate getEffectiveLocalDateOfOwner() {
210            return this.effectiveLocalDateOfOwner;
211        }
212
213        @Override
214        public Long getVersionNumber() {
215            return this.versionNumber;
216        }
217
218        @Override
219        public String getObjectId() {
220            return this.objectId;
221        }
222
223        public void setName(String name) {
224
225            this.name = name;
226        }
227
228        public void setDescription(String description) {
229
230            this.description = description;
231        }
232
233        public void setPercentage(BigDecimal percentage) {
234
235            this.percentage = percentage;
236        }
237
238        public void setPmDutyId(String pmDutyId) {
239
240            this.pmDutyId = pmDutyId;
241        }
242        
243        public void setHrPositionId(String hrPositionId) {
244
245            this.hrPositionId = hrPositionId;
246        }
247
248        public void setEffectiveLocalDateOfOwner(LocalDate effectiveLocalDateOfOwner) {
249
250            this.effectiveLocalDateOfOwner = effectiveLocalDateOfOwner;
251        }
252
253        public void setVersionNumber(Long versionNumber) {
254
255            this.versionNumber = versionNumber;
256        }
257
258        public void setObjectId(String objectId) {
259
260            this.objectId = objectId;
261        }
262
263    }
264
265
266    /**
267     * Defines some internal constants used on this class.
268     * 
269     */
270    static class Constants {
271
272        final static String ROOT_ELEMENT_NAME = "positionDuty";
273        final static String TYPE_NAME = "PositionDutyType";
274
275    }
276
277
278    /**
279     * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
280     * 
281     */
282    static class Elements {
283
284        final static String NAME = "name";
285        final static String DESCRIPTION = "description";
286        final static String PERCENTAGE = "percentage";
287        final static String PM_DUTY_ID = "pmDutyId";
288        final static String HR_POSITION_ID = "hrPositionId";
289        final static String EFFECTIVE_LOCAL_DATE_OF_OWNER = "effectiveLocalDateOfOwner";
290
291    }
292
293}
294