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 DB_POLYGON.
 */
public class DbPolygon {

    private Long id;
    private long floraId;
    private long faunaId;
    private long heritageId;
    private long parkInfoRestrictedId;
    private long parkInfoAccommodationId;

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

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

    private List<DbPoint> points;

    public DbPolygon() {
    }

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

    public DbPolygon(Long id, long floraId, long faunaId, long heritageId, long parkInfoRestrictedId, long parkInfoAccommodationId) {
        this.id = id;
        this.floraId = floraId;
        this.faunaId = faunaId;
        this.heritageId = heritageId;
        this.parkInfoRestrictedId = parkInfoRestrictedId;
        this.parkInfoAccommodationId = parkInfoAccommodationId;
    }

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

    public Long getId() {
        return id;
    }

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

    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;
    }

    public long getParkInfoRestrictedId() {
        return parkInfoRestrictedId;
    }

    public void setParkInfoRestrictedId(long parkInfoRestrictedId) {
        this.parkInfoRestrictedId = parkInfoRestrictedId;
    }

    public long getParkInfoAccommodationId() {
        return parkInfoAccommodationId;
    }

    public void setParkInfoAccommodationId(long parkInfoAccommodationId) {
        this.parkInfoAccommodationId = parkInfoAccommodationId;
    }

    /** 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<DbPoint> getPoints() {
        if (points == null) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            DbPointDao targetDao = daoSession.getDbPointDao();
            List<DbPoint> pointsNew = targetDao._queryDbPolygon_Points(id);
            synchronized (this) {
                if(points == null) {
                    points = pointsNew;
                }
            }
        }
        return points;
    }

    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    public synchronized void resetPoints() {
        points = 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);
    }

}
