001// --------------------------------------------------------------------------------
002// Copyright 2002-2026 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
061import javax.annotation.Nonnull;
062import javax.annotation.Nullable;
063
064public class Event
065        extends BaseEntity
066        implements Serializable {
067    
068    private EventPK _pk;
069    private EventValue _value;
070    
071    /** Creates a new instance of Event */
072    public Event()
073            throws PersistenceException {
074        super();
075    }
076    
077    /** Creates a new instance of Event */
078    public Event(EventValue value, EntityPermission entityPermission) {
079        super(entityPermission);
080        
081        _value = value;
082        _pk = value.getPrimaryKey();
083    }
084    
085    @Override
086    @Nonnull
087    public EventFactory getBaseFactoryInstance() {
088        return EventFactory.getInstance();
089    }
090    
091    @Override
092    public boolean hasBeenModified() {
093        return _value.hasBeenModified();
094    }
095    
096    @Override
097    public int hashCode() {
098        return _pk.hashCode();
099    }
100    
101    @Override
102    @Nonnull
103    public String toString() {
104        return _pk.toString();
105    }
106    
107    @Override
108    public boolean equals(Object other) {
109        if(this == other)
110            return true;
111        
112        if(other instanceof Event that) {
113            EventValue thatValue = that.getEventValue();
114            return _value.equals(thatValue);
115        } else {
116            return false;
117        }
118    }
119    
120    @Override
121    public void store()
122            throws PersistenceDatabaseException {
123        getBaseFactoryInstance().store(this);
124    }
125    
126    @Override
127    public void remove()
128            throws PersistenceDatabaseException {
129        getBaseFactoryInstance().remove(this);
130    }
131    
132    @Nonnull
133    public EventValue getEventValue() {
134        return _value;
135    }
136    
137    public void setEventValue(@Nonnull EventValue value)
138            throws PersistenceReadOnlyException {
139        checkReadWrite();
140        _value = value;
141    }
142    
143    @Override
144    @Nonnull
145    public EventPK getPrimaryKey() {
146        return _pk;
147    }
148    
149    @Nullable
150    public EventGroupPK getEventGroupPK() {
151        return _value.getEventGroupPK();
152    }
153    
154    @Nullable
155    public EventGroup getEventGroup(EntityPermission entityPermission) {
156        EventGroupPK pk = getEventGroupPK();
157        EventGroup entity = pk == null? null: EventGroupFactory.getInstance().getEntityFromPK(entityPermission, pk);
158        
159        return entity;
160    }
161    
162    @Nullable
163    public EventGroup getEventGroup() {
164        return getEventGroup(EntityPermission.READ_ONLY);
165    }
166    
167    @Nullable
168    public EventGroup getEventGroupForUpdate() {
169        return getEventGroup(EntityPermission.READ_WRITE);
170    }
171    
172    public void setEventGroupPK(@Nullable EventGroupPK eventGroupPK)
173            throws PersistenceNotNullException, PersistenceReadOnlyException {
174        checkReadWrite();
175        _value.setEventGroupPK(eventGroupPK);
176    }
177    
178    public void setEventGroup(@Nullable EventGroup entity) {
179        setEventGroupPK(entity == null ? null : entity.getPrimaryKey());
180    }
181    
182    public boolean getEventGroupPKHasBeenModified() {
183        return _value.getEventGroupPKHasBeenModified();
184    }
185    
186    @Nonnull
187    public Long getEventTime() {
188        return _value.getEventTime();
189    }
190    
191    public void setEventTime(@Nonnull Long eventTime)
192            throws PersistenceNotNullException, PersistenceReadOnlyException {
193        checkReadWrite();
194        _value.setEventTime(eventTime);
195    }
196    
197    public boolean getEventTimeHasBeenModified() {
198        return _value.getEventTimeHasBeenModified();
199    }
200    
201    @Nonnull
202    public Integer getEventTimeSequence() {
203        return _value.getEventTimeSequence();
204    }
205    
206    public void setEventTimeSequence(@Nonnull Integer eventTimeSequence)
207            throws PersistenceNotNullException, PersistenceReadOnlyException {
208        checkReadWrite();
209        _value.setEventTimeSequence(eventTimeSequence);
210    }
211    
212    public boolean getEventTimeSequenceHasBeenModified() {
213        return _value.getEventTimeSequenceHasBeenModified();
214    }
215    
216    @Nonnull
217    public EntityInstancePK getEntityInstancePK() {
218        return _value.getEntityInstancePK();
219    }
220    
221    @Nonnull
222    public EntityInstance getEntityInstance(EntityPermission entityPermission) {
223        return EntityInstanceFactory.getInstance().getEntityFromPK(entityPermission, getEntityInstancePK());
224    }
225    
226    @Nonnull
227    public EntityInstance getEntityInstance() {
228        return getEntityInstance(EntityPermission.READ_ONLY);
229    }
230    
231    @Nonnull
232    public EntityInstance getEntityInstanceForUpdate() {
233        return getEntityInstance(EntityPermission.READ_WRITE);
234    }
235    
236    public void setEntityInstancePK(@Nonnull EntityInstancePK entityInstancePK)
237            throws PersistenceNotNullException, PersistenceReadOnlyException {
238        checkReadWrite();
239        _value.setEntityInstancePK(entityInstancePK);
240    }
241    
242    public void setEntityInstance(@Nonnull EntityInstance entity) {
243        setEntityInstancePK(entity == null ? null : entity.getPrimaryKey());
244    }
245    
246    public boolean getEntityInstancePKHasBeenModified() {
247        return _value.getEntityInstancePKHasBeenModified();
248    }
249    
250    @Nonnull
251    public EventTypePK getEventTypePK() {
252        return _value.getEventTypePK();
253    }
254    
255    @Nonnull
256    public EventType getEventType(EntityPermission entityPermission) {
257        return EventTypeFactory.getInstance().getEntityFromPK(entityPermission, getEventTypePK());
258    }
259    
260    @Nonnull
261    public EventType getEventType() {
262        return getEventType(EntityPermission.READ_ONLY);
263    }
264    
265    @Nonnull
266    public EventType getEventTypeForUpdate() {
267        return getEventType(EntityPermission.READ_WRITE);
268    }
269    
270    public void setEventTypePK(@Nonnull EventTypePK eventTypePK)
271            throws PersistenceNotNullException, PersistenceReadOnlyException {
272        checkReadWrite();
273        _value.setEventTypePK(eventTypePK);
274    }
275    
276    public void setEventType(@Nonnull EventType entity) {
277        setEventTypePK(entity == null ? null : entity.getPrimaryKey());
278    }
279    
280    public boolean getEventTypePKHasBeenModified() {
281        return _value.getEventTypePKHasBeenModified();
282    }
283    
284    @Nullable
285    public EntityInstancePK getRelatedEntityInstancePK() {
286        return _value.getRelatedEntityInstancePK();
287    }
288    
289    @Nullable
290    public EntityInstance getRelatedEntityInstance(EntityPermission entityPermission) {
291        EntityInstancePK pk = getRelatedEntityInstancePK();
292        EntityInstance entity = pk == null? null: EntityInstanceFactory.getInstance().getEntityFromPK(entityPermission, pk);
293        
294        return entity;
295    }
296    
297    @Nullable
298    public EntityInstance getRelatedEntityInstance() {
299        return getRelatedEntityInstance(EntityPermission.READ_ONLY);
300    }
301    
302    @Nullable
303    public EntityInstance getRelatedEntityInstanceForUpdate() {
304        return getRelatedEntityInstance(EntityPermission.READ_WRITE);
305    }
306    
307    public void setRelatedEntityInstancePK(@Nullable EntityInstancePK relatedEntityInstancePK)
308            throws PersistenceNotNullException, PersistenceReadOnlyException {
309        checkReadWrite();
310        _value.setRelatedEntityInstancePK(relatedEntityInstancePK);
311    }
312    
313    public void setRelatedEntityInstance(@Nullable EntityInstance entity) {
314        setRelatedEntityInstancePK(entity == null ? null : entity.getPrimaryKey());
315    }
316    
317    public boolean getRelatedEntityInstancePKHasBeenModified() {
318        return _value.getRelatedEntityInstancePKHasBeenModified();
319    }
320    
321    @Nullable
322    public EventTypePK getRelatedEventTypePK() {
323        return _value.getRelatedEventTypePK();
324    }
325    
326    @Nullable
327    public EventType getRelatedEventType(EntityPermission entityPermission) {
328        EventTypePK pk = getRelatedEventTypePK();
329        EventType entity = pk == null? null: EventTypeFactory.getInstance().getEntityFromPK(entityPermission, pk);
330        
331        return entity;
332    }
333    
334    @Nullable
335    public EventType getRelatedEventType() {
336        return getRelatedEventType(EntityPermission.READ_ONLY);
337    }
338    
339    @Nullable
340    public EventType getRelatedEventTypeForUpdate() {
341        return getRelatedEventType(EntityPermission.READ_WRITE);
342    }
343    
344    public void setRelatedEventTypePK(@Nullable EventTypePK relatedEventTypePK)
345            throws PersistenceNotNullException, PersistenceReadOnlyException {
346        checkReadWrite();
347        _value.setRelatedEventTypePK(relatedEventTypePK);
348    }
349    
350    public void setRelatedEventType(@Nullable EventType entity) {
351        setRelatedEventTypePK(entity == null ? null : entity.getPrimaryKey());
352    }
353    
354    public boolean getRelatedEventTypePKHasBeenModified() {
355        return _value.getRelatedEventTypePKHasBeenModified();
356    }
357    
358    @Nullable
359    public EntityInstancePK getCreatedByPK() {
360        return _value.getCreatedByPK();
361    }
362    
363    @Nullable
364    public EntityInstance getCreatedBy(EntityPermission entityPermission) {
365        EntityInstancePK pk = getCreatedByPK();
366        EntityInstance entity = pk == null? null: EntityInstanceFactory.getInstance().getEntityFromPK(entityPermission, pk);
367        
368        return entity;
369    }
370    
371    @Nullable
372    public EntityInstance getCreatedBy() {
373        return getCreatedBy(EntityPermission.READ_ONLY);
374    }
375    
376    @Nullable
377    public EntityInstance getCreatedByForUpdate() {
378        return getCreatedBy(EntityPermission.READ_WRITE);
379    }
380    
381    public void setCreatedByPK(@Nullable EntityInstancePK createdByPK)
382            throws PersistenceNotNullException, PersistenceReadOnlyException {
383        checkReadWrite();
384        _value.setCreatedByPK(createdByPK);
385    }
386    
387    public void setCreatedBy(@Nullable EntityInstance entity) {
388        setCreatedByPK(entity == null ? null : entity.getPrimaryKey());
389    }
390    
391    public boolean getCreatedByPKHasBeenModified() {
392        return _value.getCreatedByPKHasBeenModified();
393    }
394    
395}