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 * SalesOrder.java
021 */
022
023package com.echothree.model.data.sales.server.entity;
024
025import com.echothree.model.data.sales.common.pk.SalesOrderPK;
026
027import com.echothree.model.data.order.common.pk.OrderPK;
028import com.echothree.model.data.offer.common.pk.OfferUsePK;
029import com.echothree.model.data.associate.common.pk.AssociateReferralPK;
030
031import com.echothree.model.data.order.server.entity.Order;
032import com.echothree.model.data.offer.server.entity.OfferUse;
033import com.echothree.model.data.associate.server.entity.AssociateReferral;
034
035import com.echothree.model.data.order.server.factory.OrderFactory;
036import com.echothree.model.data.offer.server.factory.OfferUseFactory;
037import com.echothree.model.data.associate.server.factory.AssociateReferralFactory;
038
039import com.echothree.model.data.sales.common.pk.SalesOrderPK;
040
041import com.echothree.model.data.sales.server.value.SalesOrderValue;
042
043import com.echothree.model.data.sales.server.factory.SalesOrderFactory;
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 SalesOrder
062        extends BaseEntity
063        implements Serializable {
064    
065    private SalesOrderPK _pk;
066    private SalesOrderValue _value;
067    
068    /** Creates a new instance of SalesOrder */
069    public SalesOrder()
070            throws PersistenceException {
071        super();
072    }
073    
074    /** Creates a new instance of SalesOrder */
075    public SalesOrder(SalesOrderValue value, EntityPermission entityPermission) {
076        super(entityPermission);
077        
078        _value = value;
079        _pk = value.getPrimaryKey();
080    }
081    
082    @Override
083    public SalesOrderFactory getBaseFactoryInstance() {
084        return SalesOrderFactory.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 SalesOrder that) {
108            SalesOrderValue thatValue = that.getSalesOrderValue();
109            return _value.equals(thatValue);
110        } else {
111            return false;
112        }
113    }
114    
115    @Override
116    public void store()
117            throws PersistenceDatabaseException {
118        getBaseFactoryInstance().store(this);
119    }
120    
121    @Override
122    public void remove()
123            throws PersistenceDatabaseException {
124        getBaseFactoryInstance().remove(this);
125    }
126    
127    public SalesOrderValue getSalesOrderValue() {
128        return _value;
129    }
130    
131    public void setSalesOrderValue(SalesOrderValue value)
132            throws PersistenceReadOnlyException {
133        checkReadWrite();
134        _value = value;
135    }
136    
137    @Override
138    public SalesOrderPK getPrimaryKey() {
139        return _pk;
140    }
141    
142    public OrderPK getOrderPK() {
143        return _value.getOrderPK();
144    }
145    
146    public Order getOrder(EntityPermission entityPermission) {
147        return OrderFactory.getInstance().getEntityFromPK(entityPermission, getOrderPK());
148    }
149    
150    public Order getOrder() {
151        return getOrder(EntityPermission.READ_ONLY);
152    }
153    
154    public Order getOrderForUpdate() {
155        return getOrder(EntityPermission.READ_WRITE);
156    }
157    
158    public void setOrderPK(OrderPK orderPK)
159            throws PersistenceNotNullException, PersistenceReadOnlyException {
160        checkReadWrite();
161        _value.setOrderPK(orderPK);
162    }
163    
164    public void setOrder(Order entity) {
165        setOrderPK(entity == null? null: entity.getPrimaryKey());
166    }
167    
168    public boolean getOrderPKHasBeenModified() {
169        return _value.getOrderPKHasBeenModified();
170    }
171    
172    public OfferUsePK getOfferUsePK() {
173        return _value.getOfferUsePK();
174    }
175    
176    public OfferUse getOfferUse(EntityPermission entityPermission) {
177        return OfferUseFactory.getInstance().getEntityFromPK(entityPermission, getOfferUsePK());
178    }
179    
180    public OfferUse getOfferUse() {
181        return getOfferUse(EntityPermission.READ_ONLY);
182    }
183    
184    public OfferUse getOfferUseForUpdate() {
185        return getOfferUse(EntityPermission.READ_WRITE);
186    }
187    
188    public void setOfferUsePK(OfferUsePK offerUsePK)
189            throws PersistenceNotNullException, PersistenceReadOnlyException {
190        checkReadWrite();
191        _value.setOfferUsePK(offerUsePK);
192    }
193    
194    public void setOfferUse(OfferUse entity) {
195        setOfferUsePK(entity == null? null: entity.getPrimaryKey());
196    }
197    
198    public boolean getOfferUsePKHasBeenModified() {
199        return _value.getOfferUsePKHasBeenModified();
200    }
201    
202    public AssociateReferralPK getAssociateReferralPK() {
203        return _value.getAssociateReferralPK();
204    }
205    
206    public AssociateReferral getAssociateReferral(EntityPermission entityPermission) {
207        AssociateReferralPK pk = getAssociateReferralPK();
208        AssociateReferral entity = pk == null? null: AssociateReferralFactory.getInstance().getEntityFromPK(entityPermission, pk);
209        
210        return entity;
211    }
212    
213    public AssociateReferral getAssociateReferral() {
214        return getAssociateReferral(EntityPermission.READ_ONLY);
215    }
216    
217    public AssociateReferral getAssociateReferralForUpdate() {
218        return getAssociateReferral(EntityPermission.READ_WRITE);
219    }
220    
221    public void setAssociateReferralPK(AssociateReferralPK associateReferralPK)
222            throws PersistenceNotNullException, PersistenceReadOnlyException {
223        checkReadWrite();
224        _value.setAssociateReferralPK(associateReferralPK);
225    }
226    
227    public void setAssociateReferral(AssociateReferral entity) {
228        setAssociateReferralPK(entity == null? null: entity.getPrimaryKey());
229    }
230    
231    public boolean getAssociateReferralPKHasBeenModified() {
232        return _value.getAssociateReferralPKHasBeenModified();
233    }
234    
235    public Long getFromTime() {
236        return _value.getFromTime();
237    }
238    
239    public void setFromTime(Long fromTime)
240            throws PersistenceNotNullException, PersistenceReadOnlyException {
241        checkReadWrite();
242        _value.setFromTime(fromTime);
243    }
244    
245    public boolean getFromTimeHasBeenModified() {
246        return _value.getFromTimeHasBeenModified();
247    }
248    
249    public Long getThruTime() {
250        return _value.getThruTime();
251    }
252    
253    public void setThruTime(Long thruTime)
254            throws PersistenceNotNullException, PersistenceReadOnlyException {
255        checkReadWrite();
256        _value.setThruTime(thruTime);
257    }
258    
259    public boolean getThruTimeHasBeenModified() {
260        return _value.getThruTimeHasBeenModified();
261    }
262    
263}