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 * Event.java
021 */
022
023package com.echothree.model.data.core.server.entity;
024
025import com.echothree.model.data.core.common.pk.EventPK;
026
027import com.echothree.model.data.core.common.pk.EventGroupPK;
028import com.echothree.model.data.core.common.pk.EntityInstancePK;
029import com.echothree.model.data.core.common.pk.EventTypePK;
030
031import com.echothree.model.data.core.server.entity.EventGroup;
032import com.echothree.model.data.core.server.entity.EntityInstance;
033import com.echothree.model.data.core.server.entity.EventType;
034
035import com.echothree.model.data.core.server.factory.EventGroupFactory;
036import com.echothree.model.data.core.server.factory.EntityInstanceFactory;
037import com.echothree.model.data.core.server.factory.EventTypeFactory;
038
039import com.echothree.model.data.core.common.pk.EventPK;
040
041import com.echothree.model.data.core.server.value.EventValue;
042
043import com.echothree.model.data.core.server.factory.EventFactory;
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 Event
062        extends BaseEntity
063        implements Serializable {
064    
065    private EventPK _pk;
066    private EventValue _value;
067    
068    /** Creates a new instance of Event */
069    public Event()
070            throws PersistenceException {
071        super();
072    }
073    
074    /** Creates a new instance of Event */
075    public Event(EventValue value, EntityPermission entityPermission) {
076        super(entityPermission);
077        
078        _value = value;
079        _pk = value.getPrimaryKey();
080    }
081    
082    @Override
083    public EventFactory getBaseFactoryInstance() {
084        return EventFactory.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 Event) {
108            Event that = (Event)other;
109            
110            EventValue thatValue = that.getEventValue();
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 EventValue getEventValue() {
136        return _value;
137    }
138    
139    public void setEventValue(EventValue value)
140            throws PersistenceReadOnlyException {
141        checkReadWrite();
142        _value = value;
143    }
144    
145    @Override
146    public EventPK getPrimaryKey() {
147        return _pk;
148    }
149    
150    public EventGroupPK getEventGroupPK() {
151        return _value.getEventGroupPK();
152    }
153    
154    public EventGroup getEventGroup(Session session, EntityPermission entityPermission) {
155        EventGroupPK pk = getEventGroupPK();
156        EventGroup entity = pk == null? null: EventGroupFactory.getInstance().getEntityFromPK(session, entityPermission, pk);
157        
158        return entity;
159    }
160    
161    public EventGroup getEventGroup(EntityPermission entityPermission) {
162        return getEventGroup(ThreadSession.currentSession(), entityPermission);
163    }
164    
165    public EventGroup getEventGroup(Session session) {
166        return getEventGroup(session, EntityPermission.READ_ONLY);
167    }
168    
169    public EventGroup getEventGroup() {
170        return getEventGroup(ThreadSession.currentSession(), EntityPermission.READ_ONLY);
171    }
172    
173    public EventGroup getEventGroupForUpdate(Session session) {
174        return getEventGroup(session, EntityPermission.READ_WRITE);
175    }
176    
177    public EventGroup getEventGroupForUpdate() {
178        return getEventGroup(ThreadSession.currentSession(), EntityPermission.READ_WRITE);
179    }
180    
181    public void setEventGroupPK(EventGroupPK eventGroupPK)
182            throws PersistenceNotNullException, PersistenceReadOnlyException {
183        checkReadWrite();
184        _value.setEventGroupPK(eventGroupPK);
185    }
186    
187    public void setEventGroup(EventGroup entity) {
188        setEventGroupPK(entity == null? null: entity.getPrimaryKey());
189    }
190    
191    public boolean getEventGroupPKHasBeenModified() {
192        return _value.getEventGroupPKHasBeenModified();
193    }
194    
195    public Long getEventTime() {
196        return _value.getEventTime();
197    }
198    
199    public void setEventTime(Long eventTime)
200            throws PersistenceNotNullException, PersistenceReadOnlyException {
201        checkReadWrite();
202        _value.setEventTime(eventTime);
203    }
204    
205    public boolean getEventTimeHasBeenModified() {
206        return _value.getEventTimeHasBeenModified();
207    }
208    
209    public Integer getEventTimeSequence() {
210        return _value.getEventTimeSequence();
211    }
212    
213    public void setEventTimeSequence(Integer eventTimeSequence)
214            throws PersistenceNotNullException, PersistenceReadOnlyException {
215        checkReadWrite();
216        _value.setEventTimeSequence(eventTimeSequence);
217    }
218    
219    public boolean getEventTimeSequenceHasBeenModified() {
220        return _value.getEventTimeSequenceHasBeenModified();
221    }
222    
223    public EntityInstancePK getEntityInstancePK() {
224        return _value.getEntityInstancePK();
225    }
226    
227    public EntityInstance getEntityInstance(Session session, EntityPermission entityPermission) {
228        return EntityInstanceFactory.getInstance().getEntityFromPK(session, entityPermission, getEntityInstancePK());
229    }
230    
231    public EntityInstance getEntityInstance(EntityPermission entityPermission) {
232        return getEntityInstance(ThreadSession.currentSession(), entityPermission);
233    }
234    
235    public EntityInstance getEntityInstance(Session session) {
236        return getEntityInstance(session, EntityPermission.READ_ONLY);
237    }
238    
239    public EntityInstance getEntityInstance() {
240        return getEntityInstance(ThreadSession.currentSession(), EntityPermission.READ_ONLY);
241    }
242    
243    public EntityInstance getEntityInstanceForUpdate(Session session) {
244        return getEntityInstance(session, EntityPermission.READ_WRITE);
245    }
246    
247    public EntityInstance getEntityInstanceForUpdate() {
248        return getEntityInstance(ThreadSession.currentSession(), EntityPermission.READ_WRITE);
249    }
250    
251    public void setEntityInstancePK(EntityInstancePK entityInstancePK)
252            throws PersistenceNotNullException, PersistenceReadOnlyException {
253        checkReadWrite();
254        _value.setEntityInstancePK(entityInstancePK);
255    }
256    
257    public void setEntityInstance(EntityInstance entity) {
258        setEntityInstancePK(entity == null? null: entity.getPrimaryKey());
259    }
260    
261    public boolean getEntityInstancePKHasBeenModified() {
262        return _value.getEntityInstancePKHasBeenModified();
263    }
264    
265    public EventTypePK getEventTypePK() {
266        return _value.getEventTypePK();
267    }
268    
269    public EventType getEventType(Session session, EntityPermission entityPermission) {
270        return EventTypeFactory.getInstance().getEntityFromPK(session, entityPermission, getEventTypePK());
271    }
272    
273    public EventType getEventType(EntityPermission entityPermission) {
274        return getEventType(ThreadSession.currentSession(), entityPermission);
275    }
276    
277    public EventType getEventType(Session session) {
278        return getEventType(session, EntityPermission.READ_ONLY);
279    }
280    
281    public EventType getEventType() {
282        return getEventType(ThreadSession.currentSession(), EntityPermission.READ_ONLY);
283    }
284    
285    public EventType getEventTypeForUpdate(Session session) {
286        return getEventType(session, EntityPermission.READ_WRITE);
287    }
288    
289    public EventType getEventTypeForUpdate() {
290        return getEventType(ThreadSession.currentSession(), EntityPermission.READ_WRITE);
291    }
292    
293    public void setEventTypePK(EventTypePK eventTypePK)
294            throws PersistenceNotNullException, PersistenceReadOnlyException {
295        checkReadWrite();
296        _value.setEventTypePK(eventTypePK);
297    }
298    
299    public void setEventType(EventType entity) {
300        setEventTypePK(entity == null? null: entity.getPrimaryKey());
301    }
302    
303    public boolean getEventTypePKHasBeenModified() {
304        return _value.getEventTypePKHasBeenModified();
305    }
306    
307    public EntityInstancePK getRelatedEntityInstancePK() {
308        return _value.getRelatedEntityInstancePK();
309    }
310    
311    public EntityInstance getRelatedEntityInstance(Session session, EntityPermission entityPermission) {
312        EntityInstancePK pk = getRelatedEntityInstancePK();
313        EntityInstance entity = pk == null? null: EntityInstanceFactory.getInstance().getEntityFromPK(session, entityPermission, pk);
314        
315        return entity;
316    }
317    
318    public EntityInstance getRelatedEntityInstance(EntityPermission entityPermission) {
319        return getRelatedEntityInstance(ThreadSession.currentSession(), entityPermission);
320    }
321    
322    public EntityInstance getRelatedEntityInstance(Session session) {
323        return getRelatedEntityInstance(session, EntityPermission.READ_ONLY);
324    }
325    
326    public EntityInstance getRelatedEntityInstance() {
327        return getRelatedEntityInstance(ThreadSession.currentSession(), EntityPermission.READ_ONLY);
328    }
329    
330    public EntityInstance getRelatedEntityInstanceForUpdate(Session session) {
331        return getRelatedEntityInstance(session, EntityPermission.READ_WRITE);
332    }
333    
334    public EntityInstance getRelatedEntityInstanceForUpdate() {
335        return getRelatedEntityInstance(ThreadSession.currentSession(), EntityPermission.READ_WRITE);
336    }
337    
338    public void setRelatedEntityInstancePK(EntityInstancePK relatedEntityInstancePK)
339            throws PersistenceNotNullException, PersistenceReadOnlyException {
340        checkReadWrite();
341        _value.setRelatedEntityInstancePK(relatedEntityInstancePK);
342    }
343    
344    public void setRelatedEntityInstance(EntityInstance entity) {
345        setRelatedEntityInstancePK(entity == null? null: entity.getPrimaryKey());
346    }
347    
348    public boolean getRelatedEntityInstancePKHasBeenModified() {
349        return _value.getRelatedEntityInstancePKHasBeenModified();
350    }
351    
352    public EventTypePK getRelatedEventTypePK() {
353        return _value.getRelatedEventTypePK();
354    }
355    
356    public EventType getRelatedEventType(Session session, EntityPermission entityPermission) {
357        EventTypePK pk = getRelatedEventTypePK();
358        EventType entity = pk == null? null: EventTypeFactory.getInstance().getEntityFromPK(session, entityPermission, pk);
359        
360        return entity;
361    }
362    
363    public EventType getRelatedEventType(EntityPermission entityPermission) {
364        return getRelatedEventType(ThreadSession.currentSession(), entityPermission);
365    }
366    
367    public EventType getRelatedEventType(Session session) {
368        return getRelatedEventType(session, EntityPermission.READ_ONLY);
369    }
370    
371    public EventType getRelatedEventType() {
372        return getRelatedEventType(ThreadSession.currentSession(), EntityPermission.READ_ONLY);
373    }
374    
375    public EventType getRelatedEventTypeForUpdate(Session session) {
376        return getRelatedEventType(session, EntityPermission.READ_WRITE);
377    }
378    
379    public EventType getRelatedEventTypeForUpdate() {
380        return getRelatedEventType(ThreadSession.currentSession(), EntityPermission.READ_WRITE);
381    }
382    
383    public void setRelatedEventTypePK(EventTypePK relatedEventTypePK)
384            throws PersistenceNotNullException, PersistenceReadOnlyException {
385        checkReadWrite();
386        _value.setRelatedEventTypePK(relatedEventTypePK);
387    }
388    
389    public void setRelatedEventType(EventType entity) {
390        setRelatedEventTypePK(entity == null? null: entity.getPrimaryKey());
391    }
392    
393    public boolean getRelatedEventTypePKHasBeenModified() {
394        return _value.getRelatedEventTypePKHasBeenModified();
395    }
396    
397    public EntityInstancePK getCreatedByPK() {
398        return _value.getCreatedByPK();
399    }
400    
401    public EntityInstance getCreatedBy(Session session, EntityPermission entityPermission) {
402        EntityInstancePK pk = getCreatedByPK();
403        EntityInstance entity = pk == null? null: EntityInstanceFactory.getInstance().getEntityFromPK(session, entityPermission, pk);
404        
405        return entity;
406    }
407    
408    public EntityInstance getCreatedBy(EntityPermission entityPermission) {
409        return getCreatedBy(ThreadSession.currentSession(), entityPermission);
410    }
411    
412    public EntityInstance getCreatedBy(Session session) {
413        return getCreatedBy(session, EntityPermission.READ_ONLY);
414    }
415    
416    public EntityInstance getCreatedBy() {
417        return getCreatedBy(ThreadSession.currentSession(), EntityPermission.READ_ONLY);
418    }
419    
420    public EntityInstance getCreatedByForUpdate(Session session) {
421        return getCreatedBy(session, EntityPermission.READ_WRITE);
422    }
423    
424    public EntityInstance getCreatedByForUpdate() {
425        return getCreatedBy(ThreadSession.currentSession(), EntityPermission.READ_WRITE);
426    }
427    
428    public void setCreatedByPK(EntityInstancePK createdByPK)
429            throws PersistenceNotNullException, PersistenceReadOnlyException {
430        checkReadWrite();
431        _value.setCreatedByPK(createdByPK);
432    }
433    
434    public void setCreatedBy(EntityInstance entity) {
435        setCreatedByPK(entity == null? null: entity.getPrimaryKey());
436    }
437    
438    public boolean getCreatedByPKHasBeenModified() {
439        return _value.getCreatedByPKHasBeenModified();
440    }
441    
442}