001// --------------------------------------------------------------------------------
002// Copyright 2002-2025 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 * UserSession.java
021 */
022
023package com.echothree.model.data.user.server.entity;
024
025import com.echothree.model.data.user.common.pk.UserSessionPK;
026
027import com.echothree.model.data.user.common.pk.UserVisitPK;
028import com.echothree.model.data.party.common.pk.PartyPK;
029import com.echothree.model.data.party.common.pk.PartyRelationshipPK;
030
031import com.echothree.model.data.user.server.entity.UserVisit;
032import com.echothree.model.data.party.server.entity.Party;
033import com.echothree.model.data.party.server.entity.PartyRelationship;
034
035import com.echothree.model.data.user.server.factory.UserVisitFactory;
036import com.echothree.model.data.party.server.factory.PartyFactory;
037import com.echothree.model.data.party.server.factory.PartyRelationshipFactory;
038
039import com.echothree.model.data.user.common.pk.UserSessionPK;
040
041import com.echothree.model.data.user.server.value.UserSessionValue;
042
043import com.echothree.model.data.user.server.factory.UserSessionFactory;
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 UserSession
062        extends BaseEntity
063        implements Serializable {
064    
065    private UserSessionPK _pk;
066    private UserSessionValue _value;
067    
068    /** Creates a new instance of UserSession */
069    public UserSession()
070            throws PersistenceException {
071        super();
072    }
073    
074    /** Creates a new instance of UserSession */
075    public UserSession(UserSessionValue value, EntityPermission entityPermission) {
076        super(entityPermission);
077        
078        _value = value;
079        _pk = value.getPrimaryKey();
080    }
081    
082    @Override
083    public UserSessionFactory getBaseFactoryInstance() {
084        return UserSessionFactory.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 UserSession that) {
108            UserSessionValue thatValue = that.getUserSessionValue();
109            return _value.equals(thatValue);
110        } else {
111            return false;
112        }
113    }
114    
115    @Override
116    public void store(Session session)
117            throws PersistenceDatabaseException {
118        getBaseFactoryInstance().store(session, this);
119    }
120    
121    @Override
122    public void remove(Session session)
123            throws PersistenceDatabaseException {
124        getBaseFactoryInstance().remove(session, this);
125    }
126    
127    @Override
128    public void remove()
129            throws PersistenceDatabaseException {
130        getBaseFactoryInstance().remove(ThreadSession.currentSession(), this);
131    }
132    
133    public UserSessionValue getUserSessionValue() {
134        return _value;
135    }
136    
137    public void setUserSessionValue(UserSessionValue value)
138            throws PersistenceReadOnlyException {
139        checkReadWrite();
140        _value = value;
141    }
142    
143    @Override
144    public UserSessionPK getPrimaryKey() {
145        return _pk;
146    }
147    
148    public UserVisitPK getUserVisitPK() {
149        return _value.getUserVisitPK();
150    }
151    
152    public UserVisit getUserVisit(Session session, EntityPermission entityPermission) {
153        return UserVisitFactory.getInstance().getEntityFromPK(session, entityPermission, getUserVisitPK());
154    }
155    
156    public UserVisit getUserVisit(EntityPermission entityPermission) {
157        return getUserVisit(ThreadSession.currentSession(), entityPermission);
158    }
159    
160    public UserVisit getUserVisit(Session session) {
161        return getUserVisit(session, EntityPermission.READ_ONLY);
162    }
163    
164    public UserVisit getUserVisit() {
165        return getUserVisit(ThreadSession.currentSession(), EntityPermission.READ_ONLY);
166    }
167    
168    public UserVisit getUserVisitForUpdate(Session session) {
169        return getUserVisit(session, EntityPermission.READ_WRITE);
170    }
171    
172    public UserVisit getUserVisitForUpdate() {
173        return getUserVisit(ThreadSession.currentSession(), EntityPermission.READ_WRITE);
174    }
175    
176    public void setUserVisitPK(UserVisitPK userVisitPK)
177            throws PersistenceNotNullException, PersistenceReadOnlyException {
178        checkReadWrite();
179        _value.setUserVisitPK(userVisitPK);
180    }
181    
182    public void setUserVisit(UserVisit entity) {
183        setUserVisitPK(entity == null? null: entity.getPrimaryKey());
184    }
185    
186    public boolean getUserVisitPKHasBeenModified() {
187        return _value.getUserVisitPKHasBeenModified();
188    }
189    
190    public PartyPK getPartyPK() {
191        return _value.getPartyPK();
192    }
193    
194    public Party getParty(Session session, EntityPermission entityPermission) {
195        return PartyFactory.getInstance().getEntityFromPK(session, entityPermission, getPartyPK());
196    }
197    
198    public Party getParty(EntityPermission entityPermission) {
199        return getParty(ThreadSession.currentSession(), entityPermission);
200    }
201    
202    public Party getParty(Session session) {
203        return getParty(session, EntityPermission.READ_ONLY);
204    }
205    
206    public Party getParty() {
207        return getParty(ThreadSession.currentSession(), EntityPermission.READ_ONLY);
208    }
209    
210    public Party getPartyForUpdate(Session session) {
211        return getParty(session, EntityPermission.READ_WRITE);
212    }
213    
214    public Party getPartyForUpdate() {
215        return getParty(ThreadSession.currentSession(), EntityPermission.READ_WRITE);
216    }
217    
218    public void setPartyPK(PartyPK partyPK)
219            throws PersistenceNotNullException, PersistenceReadOnlyException {
220        checkReadWrite();
221        _value.setPartyPK(partyPK);
222    }
223    
224    public void setParty(Party entity) {
225        setPartyPK(entity == null? null: entity.getPrimaryKey());
226    }
227    
228    public boolean getPartyPKHasBeenModified() {
229        return _value.getPartyPKHasBeenModified();
230    }
231    
232    public PartyRelationshipPK getPartyRelationshipPK() {
233        return _value.getPartyRelationshipPK();
234    }
235    
236    public PartyRelationship getPartyRelationship(Session session, EntityPermission entityPermission) {
237        PartyRelationshipPK pk = getPartyRelationshipPK();
238        PartyRelationship entity = pk == null? null: PartyRelationshipFactory.getInstance().getEntityFromPK(session, entityPermission, pk);
239        
240        return entity;
241    }
242    
243    public PartyRelationship getPartyRelationship(EntityPermission entityPermission) {
244        return getPartyRelationship(ThreadSession.currentSession(), entityPermission);
245    }
246    
247    public PartyRelationship getPartyRelationship(Session session) {
248        return getPartyRelationship(session, EntityPermission.READ_ONLY);
249    }
250    
251    public PartyRelationship getPartyRelationship() {
252        return getPartyRelationship(ThreadSession.currentSession(), EntityPermission.READ_ONLY);
253    }
254    
255    public PartyRelationship getPartyRelationshipForUpdate(Session session) {
256        return getPartyRelationship(session, EntityPermission.READ_WRITE);
257    }
258    
259    public PartyRelationship getPartyRelationshipForUpdate() {
260        return getPartyRelationship(ThreadSession.currentSession(), EntityPermission.READ_WRITE);
261    }
262    
263    public void setPartyRelationshipPK(PartyRelationshipPK partyRelationshipPK)
264            throws PersistenceNotNullException, PersistenceReadOnlyException {
265        checkReadWrite();
266        _value.setPartyRelationshipPK(partyRelationshipPK);
267    }
268    
269    public void setPartyRelationship(PartyRelationship entity) {
270        setPartyRelationshipPK(entity == null? null: entity.getPrimaryKey());
271    }
272    
273    public boolean getPartyRelationshipPKHasBeenModified() {
274        return _value.getPartyRelationshipPKHasBeenModified();
275    }
276    
277    public Long getIdentityVerifiedTime() {
278        return _value.getIdentityVerifiedTime();
279    }
280    
281    public void setIdentityVerifiedTime(Long identityVerifiedTime)
282            throws PersistenceNotNullException, PersistenceReadOnlyException {
283        checkReadWrite();
284        _value.setIdentityVerifiedTime(identityVerifiedTime);
285    }
286    
287    public boolean getIdentityVerifiedTimeHasBeenModified() {
288        return _value.getIdentityVerifiedTimeHasBeenModified();
289    }
290    
291    public Long getFromTime() {
292        return _value.getFromTime();
293    }
294    
295    public void setFromTime(Long fromTime)
296            throws PersistenceNotNullException, PersistenceReadOnlyException {
297        checkReadWrite();
298        _value.setFromTime(fromTime);
299    }
300    
301    public boolean getFromTimeHasBeenModified() {
302        return _value.getFromTimeHasBeenModified();
303    }
304    
305    public Long getThruTime() {
306        return _value.getThruTime();
307    }
308    
309    public void setThruTime(Long thruTime)
310            throws PersistenceNotNullException, PersistenceReadOnlyException {
311        checkReadWrite();
312        _value.setThruTime(thruTime);
313    }
314    
315    public boolean getThruTimeHasBeenModified() {
316        return _value.getThruTimeHasBeenModified();
317    }
318    
319}