package com.cc.infosur.greendao;

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 DETAIL.
 */
public class Detail {

    private Long id;
    private String fulldescr;
    private byte[] picture;
    private Integer detailOrder;
    private long serviceId;
    private long stepId;
    private long floraId;
    private long faunaId;
    private long heritageId;

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

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

    private Service service;
    private Long service__resolvedKey;

    private Step step;
    private Long step__resolvedKey;

    private Flora flora;
    private Long flora__resolvedKey;

    private Fauna fauna;
    private Long fauna__resolvedKey;

    private Heritage heritage;
    private Long heritage__resolvedKey;


    public Detail() {
    }

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

    public Detail(Long id, String fulldescr, byte[] picture, Integer detailOrder, long serviceId, long stepId, long floraId, long faunaId, long heritageId) {
        this.id = id;
        this.fulldescr = fulldescr;
        this.picture = picture;
        this.detailOrder = detailOrder;
        this.serviceId = serviceId;
        this.stepId = stepId;
        this.floraId = floraId;
        this.faunaId = faunaId;
        this.heritageId = heritageId;
    }

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

    public Long getId() {
        return id;
    }

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

    public String getFulldescr() {
        return fulldescr;
    }

    public void setFulldescr(String fulldescr) {
        this.fulldescr = fulldescr;
    }

    public byte[] getPicture() {
        return picture;
    }

    public void setPicture(byte[] picture) {
        this.picture = picture;
    }

    public Integer getDetailOrder() {
        return detailOrder;
    }

    public void setDetailOrder(Integer detailOrder) {
        this.detailOrder = detailOrder;
    }

    public long getServiceId() {
        return serviceId;
    }

    public void setServiceId(long serviceId) {
        this.serviceId = serviceId;
    }

    public long getStepId() {
        return stepId;
    }

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

    public long getFloraId() {
        return floraId;
    }

    public void setFloraId(long floraId) {
        this.floraId = floraId;
    }

    public long getFaunaId() {
        return faunaId;
    }

    public void setFaunaId(long faunaId) {
        this.faunaId = faunaId;
    }

    public long getHeritageId() {
        return heritageId;
    }

    public void setHeritageId(long heritageId) {
        this.heritageId = heritageId;
    }

    /** To-one relationship, resolved on first access. */
    public Service getService() {
        long __key = this.serviceId;
        if (service__resolvedKey == null || !service__resolvedKey.equals(__key)) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            ServiceDao targetDao = daoSession.getServiceDao();
            Service serviceNew = targetDao.load(__key);
            synchronized (this) {
                service = serviceNew;
            	service__resolvedKey = __key;
            }
        }
        return service;
    }

    public void setService(Service service) {
        if (service == null) {
            throw new DaoException("To-one property 'serviceId' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.service = service;
            serviceId = service.getId();
            service__resolvedKey = serviceId;
        }
    }

    /** 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-one relationship, resolved on first access. */
    public Flora getFlora() {
        long __key = this.floraId;
        if (flora__resolvedKey == null || !flora__resolvedKey.equals(__key)) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            FloraDao targetDao = daoSession.getFloraDao();
            Flora floraNew = targetDao.load(__key);
            synchronized (this) {
                flora = floraNew;
            	flora__resolvedKey = __key;
            }
        }
        return flora;
    }

    public void setFlora(Flora flora) {
        if (flora == null) {
            throw new DaoException("To-one property 'floraId' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.flora = flora;
            floraId = flora.getId();
            flora__resolvedKey = floraId;
        }
    }

    /** To-one relationship, resolved on first access. */
    public Fauna getFauna() {
        long __key = this.faunaId;
        if (fauna__resolvedKey == null || !fauna__resolvedKey.equals(__key)) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            FaunaDao targetDao = daoSession.getFaunaDao();
            Fauna faunaNew = targetDao.load(__key);
            synchronized (this) {
                fauna = faunaNew;
            	fauna__resolvedKey = __key;
            }
        }
        return fauna;
    }

    public void setFauna(Fauna fauna) {
        if (fauna == null) {
            throw new DaoException("To-one property 'faunaId' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.fauna = fauna;
            faunaId = fauna.getId();
            fauna__resolvedKey = faunaId;
        }
    }

    /** To-one relationship, resolved on first access. */
    public Heritage getHeritage() {
        long __key = this.heritageId;
        if (heritage__resolvedKey == null || !heritage__resolvedKey.equals(__key)) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            HeritageDao targetDao = daoSession.getHeritageDao();
            Heritage heritageNew = targetDao.load(__key);
            synchronized (this) {
                heritage = heritageNew;
            	heritage__resolvedKey = __key;
            }
        }
        return heritage;
    }

    public void setHeritage(Heritage heritage) {
        if (heritage == null) {
            throw new DaoException("To-one property 'heritageId' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.heritage = heritage;
            heritageId = heritage.getId();
            heritage__resolvedKey = heritageId;
        }
    }

    /** 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);
    }

}
