package com.cc.infosur.greendao;

import java.util.List;
import de.greenrobot.dao.DaoException;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 
/**
 * Entity mapped to table EXCURSION.
 */
public class Excursion {

    private Long id;
    private Integer excursionOrder;
    private String name;
    private String region;
    private Double latitude;
    private Double longitude;
    private byte[] icon;
    private String description;
    private long stepId;

    /** Used to resolve relations */
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    private transient ExcursionDao myDao;

    private Step step;
    private Long step__resolvedKey;

    private List<Service> services;

    public Excursion() {
    }

    public Excursion(Long id) {
        this.id = id;
    }

    public Excursion(Long id, Integer excursionOrder, String name, String region, Double latitude, Double longitude, byte[] icon, String description, long stepId) {
        this.id = id;
        this.excursionOrder = excursionOrder;
        this.name = name;
        this.region = region;
        this.latitude = latitude;
        this.longitude = longitude;
        this.icon = icon;
        this.description = description;
        this.stepId = stepId;
    }

    /** called by internal mechanisms, do not call yourself. */
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getExcursionDao() : null;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getExcursionOrder() {
        return excursionOrder;
    }

    public void setExcursionOrder(Integer excursionOrder) {
        this.excursionOrder = excursionOrder;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRegion() {
        return region;
    }

    public void setRegion(String region) {
        this.region = region;
    }

    public Double getLatitude() {
        return latitude;
    }

    public void setLatitude(Double latitude) {
        this.latitude = latitude;
    }

    public Double getLongitude() {
        return longitude;
    }

    public void setLongitude(Double longitude) {
        this.longitude = longitude;
    }

    public byte[] getIcon() {
        return icon;
    }

    public void setIcon(byte[] icon) {
        this.icon = icon;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public long getStepId() {
        return stepId;
    }

    public void setStepId(long stepId) {
        this.stepId = stepId;
    }

    /** To-one relationship, resolved on first access. */
    public Step getStep() {
        long __key = this.stepId;
        if (step__resolvedKey == null || !step__resolvedKey.equals(__key)) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            StepDao targetDao = daoSession.getStepDao();
            Step stepNew = targetDao.load(__key);
            synchronized (this) {
                step = stepNew;
                step__resolvedKey = __key;
            }
        }
        return step;
    }

    public void setStep(Step step) {
        if (step == null) {
            throw new DaoException("To-one property 'stepId' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.step = step;
            stepId = step.getId();
            step__resolvedKey = stepId;
        }
    }

    /** To-many relationship, resolved on first access (and after reset). Changes to to-many relations are not persisted, make changes to the target entity. */
    public List<Service> getServices() {
        if (services == null) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            ServiceDao targetDao = daoSession.getServiceDao();
            List<Service> servicesNew = targetDao._queryExcursion_Services(id);
            synchronized (this) {
                if(services == null) {
                    services = servicesNew;
                }
            }
        }
        return services;
    }

    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    public synchronized void resetServices() {
        services = null;
    }

    /** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

}
