001// --------------------------------------------------------------------------------
002// Copyright 2002-2024 Echo Three, LLC
003//
004// Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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// Generated File -- DO NOT EDIT BY HAND
017// --------------------------------------------------------------------------------
018
019/**
020 * Person.java
021 */
022
023package com.echothree.model.data.party.server.entity;
024
025import com.echothree.model.data.party.common.pk.PersonPK;
026
027import com.echothree.model.data.party.common.pk.PartyPK;
028import com.echothree.model.data.party.common.pk.PersonalTitlePK;
029import com.echothree.model.data.party.common.pk.NameSuffixPK;
030
031import com.echothree.model.data.party.server.entity.Party;
032import com.echothree.model.data.party.server.entity.PersonalTitle;
033import com.echothree.model.data.party.server.entity.NameSuffix;
034
035import com.echothree.model.data.party.server.factory.PartyFactory;
036import com.echothree.model.data.party.server.factory.PersonalTitleFactory;
037import com.echothree.model.data.party.server.factory.NameSuffixFactory;
038
039import com.echothree.model.data.party.common.pk.PersonPK;
040
041import com.echothree.model.data.party.server.value.PersonValue;
042
043import com.echothree.model.data.party.server.factory.PersonFactory;
044
045import com.echothree.util.common.exception.PersistenceException;
046import com.echothree.util.common.exception.PersistenceDatabaseException;
047import com.echothree.util.common.exception.PersistenceNotNullException;
048import com.echothree.util.common.exception.PersistenceReadOnlyException;
049
050import com.echothree.util.common.persistence.BasePK;
051
052import com.echothree.util.common.persistence.type.ByteArray;
053
054import com.echothree.util.server.persistence.BaseEntity;
055import com.echothree.util.server.persistence.EntityPermission;
056import com.echothree.util.server.persistence.Session;
057import com.echothree.util.server.persistence.ThreadSession;
058
059import java.io.Serializable;
060
061public class Person
062        extends BaseEntity
063        implements Serializable {
064    
065    private PersonPK _pk;
066    private PersonValue _value;
067    
068    /** Creates a new instance of Person */
069    public Person()
070            throws PersistenceException {
071        super();
072    }
073    
074    /** Creates a new instance of Person */
075    public Person(PersonValue value, EntityPermission entityPermission) {
076        super(entityPermission);
077        
078        _value = value;
079        _pk = value.getPrimaryKey();
080    }
081    
082    @Override
083    public PersonFactory getBaseFactoryInstance() {
084        return PersonFactory.getInstance();
085    }
086    
087    @Override
088    public boolean hasBeenModified() {
089        return _value.hasBeenModified();
090    }
091    
092    @Override
093    public int hashCode() {
094        return _pk.hashCode();
095    }
096    
097    @Override
098    public String toString() {
099        return _pk.toString();
100    }
101    
102    @Override
103    public boolean equals(Object other) {
104        if(this == other)
105            return true;
106        
107        if(other instanceof Person) {
108            Person that = (Person)other;
109            
110            PersonValue thatValue = that.getPersonValue();
111            return _value.equals(thatValue);
112        } else {
113            return false;
114        }
115    }
116    
117    @Override
118    public void store(Session session)
119            throws PersistenceDatabaseException {
120        getBaseFactoryInstance().store(session, this);
121    }
122    
123    @Override
124    public void remove(Session session)
125            throws PersistenceDatabaseException {
126        getBaseFactoryInstance().remove(session, this);
127    }
128    
129    @Override
130    public void remove()
131            throws PersistenceDatabaseException {
132        getBaseFactoryInstance().remove(ThreadSession.currentSession(), this);
133    }
134    
135    public PersonValue getPersonValue() {
136        return _value;
137    }
138    
139    public void setPersonValue(PersonValue value)
140            throws PersistenceReadOnlyException {
141        checkReadWrite();
142        _value = value;
143    }
144    
145    @Override
146    public PersonPK getPrimaryKey() {
147        return _pk;
148    }
149    
150    public PartyPK getPartyPK() {
151        return _value.getPartyPK();
152    }
153    
154    public Party getParty(Session session, EntityPermission entityPermission) {
155        return PartyFactory.getInstance().getEntityFromPK(session, entityPermission, getPartyPK());
156    }
157    
158    public Party getParty(EntityPermission entityPermission) {
159        return getParty(ThreadSession.currentSession(), entityPermission);
160    }
161    
162    public Party getParty(Session session) {
163        return getParty(session, EntityPermission.READ_ONLY);
164    }
165    
166    public Party getParty() {
167        return getParty(ThreadSession.currentSession(), EntityPermission.READ_ONLY);
168    }
169    
170    public Party getPartyForUpdate(Session session) {
171        return getParty(session, EntityPermission.READ_WRITE);
172    }
173    
174    public Party getPartyForUpdate() {
175        return getParty(ThreadSession.currentSession(), EntityPermission.READ_WRITE);
176    }
177    
178    public void setPartyPK(PartyPK partyPK)
179            throws PersistenceNotNullException, PersistenceReadOnlyException {
180        checkReadWrite();
181        _value.setPartyPK(partyPK);
182    }
183    
184    public void setParty(Party entity) {
185        setPartyPK(entity == null? null: entity.getPrimaryKey());
186    }
187    
188    public boolean getPartyPKHasBeenModified() {
189        return _value.getPartyPKHasBeenModified();
190    }
191    
192    public PersonalTitlePK getPersonalTitlePK() {
193        return _value.getPersonalTitlePK();
194    }
195    
196    public PersonalTitle getPersonalTitle(Session session, EntityPermission entityPermission) {
197        PersonalTitlePK pk = getPersonalTitlePK();
198        PersonalTitle entity = pk == null? null: PersonalTitleFactory.getInstance().getEntityFromPK(session, entityPermission, pk);
199        
200        return entity;
201    }
202    
203    public PersonalTitle getPersonalTitle(EntityPermission entityPermission) {
204        return getPersonalTitle(ThreadSession.currentSession(), entityPermission);
205    }
206    
207    public PersonalTitle getPersonalTitle(Session session) {
208        return getPersonalTitle(session, EntityPermission.READ_ONLY);
209    }
210    
211    public PersonalTitle getPersonalTitle() {
212        return getPersonalTitle(ThreadSession.currentSession(), EntityPermission.READ_ONLY);
213    }
214    
215    public PersonalTitle getPersonalTitleForUpdate(Session session) {
216        return getPersonalTitle(session, EntityPermission.READ_WRITE);
217    }
218    
219    public PersonalTitle getPersonalTitleForUpdate() {
220        return getPersonalTitle(ThreadSession.currentSession(), EntityPermission.READ_WRITE);
221    }
222    
223    public void setPersonalTitlePK(PersonalTitlePK personalTitlePK)
224            throws PersistenceNotNullException, PersistenceReadOnlyException {
225        checkReadWrite();
226        _value.setPersonalTitlePK(personalTitlePK);
227    }
228    
229    public void setPersonalTitle(PersonalTitle entity) {
230        setPersonalTitlePK(entity == null? null: entity.getPrimaryKey());
231    }
232    
233    public boolean getPersonalTitlePKHasBeenModified() {
234        return _value.getPersonalTitlePKHasBeenModified();
235    }
236    
237    public String getFirstName() {
238        return _value.getFirstName();
239    }
240    
241    public void setFirstName(String firstName)
242            throws PersistenceNotNullException, PersistenceReadOnlyException {
243        checkReadWrite();
244        _value.setFirstName(firstName);
245    }
246    
247    public boolean getFirstNameHasBeenModified() {
248        return _value.getFirstNameHasBeenModified();
249    }
250    
251    public String getFirstNameSdx() {
252        return _value.getFirstNameSdx();
253    }
254    
255    public void setFirstNameSdx(String firstNameSdx)
256            throws PersistenceNotNullException, PersistenceReadOnlyException {
257        checkReadWrite();
258        _value.setFirstNameSdx(firstNameSdx);
259    }
260    
261    public boolean getFirstNameSdxHasBeenModified() {
262        return _value.getFirstNameSdxHasBeenModified();
263    }
264    
265    public String getMiddleName() {
266        return _value.getMiddleName();
267    }
268    
269    public void setMiddleName(String middleName)
270            throws PersistenceNotNullException, PersistenceReadOnlyException {
271        checkReadWrite();
272        _value.setMiddleName(middleName);
273    }
274    
275    public boolean getMiddleNameHasBeenModified() {
276        return _value.getMiddleNameHasBeenModified();
277    }
278    
279    public String getMiddleNameSdx() {
280        return _value.getMiddleNameSdx();
281    }
282    
283    public void setMiddleNameSdx(String middleNameSdx)
284            throws PersistenceNotNullException, PersistenceReadOnlyException {
285        checkReadWrite();
286        _value.setMiddleNameSdx(middleNameSdx);
287    }
288    
289    public boolean getMiddleNameSdxHasBeenModified() {
290        return _value.getMiddleNameSdxHasBeenModified();
291    }
292    
293    public String getLastName() {
294        return _value.getLastName();
295    }
296    
297    public void setLastName(String lastName)
298            throws PersistenceNotNullException, PersistenceReadOnlyException {
299        checkReadWrite();
300        _value.setLastName(lastName);
301    }
302    
303    public boolean getLastNameHasBeenModified() {
304        return _value.getLastNameHasBeenModified();
305    }
306    
307    public String getLastNameSdx() {
308        return _value.getLastNameSdx();
309    }
310    
311    public void setLastNameSdx(String lastNameSdx)
312            throws PersistenceNotNullException, PersistenceReadOnlyException {
313        checkReadWrite();
314        _value.setLastNameSdx(lastNameSdx);
315    }
316    
317    public boolean getLastNameSdxHasBeenModified() {
318        return _value.getLastNameSdxHasBeenModified();
319    }
320    
321    public NameSuffixPK getNameSuffixPK() {
322        return _value.getNameSuffixPK();
323    }
324    
325    public NameSuffix getNameSuffix(Session session, EntityPermission entityPermission) {
326        NameSuffixPK pk = getNameSuffixPK();
327        NameSuffix entity = pk == null? null: NameSuffixFactory.getInstance().getEntityFromPK(session, entityPermission, pk);
328        
329        return entity;
330    }
331    
332    public NameSuffix getNameSuffix(EntityPermission entityPermission) {
333        return getNameSuffix(ThreadSession.currentSession(), entityPermission);
334    }
335    
336    public NameSuffix getNameSuffix(Session session) {
337        return getNameSuffix(session, EntityPermission.READ_ONLY);
338    }
339    
340    public NameSuffix getNameSuffix() {
341        return getNameSuffix(ThreadSession.currentSession(), EntityPermission.READ_ONLY);
342    }
343    
344    public NameSuffix getNameSuffixForUpdate(Session session) {
345        return getNameSuffix(session, EntityPermission.READ_WRITE);
346    }
347    
348    public NameSuffix getNameSuffixForUpdate() {
349        return getNameSuffix(ThreadSession.currentSession(), EntityPermission.READ_WRITE);
350    }
351    
352    public void setNameSuffixPK(NameSuffixPK nameSuffixPK)
353            throws PersistenceNotNullException, PersistenceReadOnlyException {
354        checkReadWrite();
355        _value.setNameSuffixPK(nameSuffixPK);
356    }
357    
358    public void setNameSuffix(NameSuffix entity) {
359        setNameSuffixPK(entity == null? null: entity.getPrimaryKey());
360    }
361    
362    public boolean getNameSuffixPKHasBeenModified() {
363        return _value.getNameSuffixPKHasBeenModified();
364    }
365    
366    public Long getFromTime() {
367        return _value.getFromTime();
368    }
369    
370    public void setFromTime(Long fromTime)
371            throws PersistenceNotNullException, PersistenceReadOnlyException {
372        checkReadWrite();
373        _value.setFromTime(fromTime);
374    }
375    
376    public boolean getFromTimeHasBeenModified() {
377        return _value.getFromTimeHasBeenModified();
378    }
379    
380    public Long getThruTime() {
381        return _value.getThruTime();
382    }
383    
384    public void setThruTime(Long thruTime)
385            throws PersistenceNotNullException, PersistenceReadOnlyException {
386        checkReadWrite();
387        _value.setThruTime(thruTime);
388    }
389    
390    public boolean getThruTimeHasBeenModified() {
391        return _value.getThruTimeHasBeenModified();
392    }
393    
394}