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 SERVICE.
 */
public class Service {

    private Long id;
    private Long idserviceepp;
    private String name;
    private String locality;
    private Integer type;
    private Double latitude;
    private Double longitude;
    private String startHour;
    private byte[] icon;
    private Boolean available;
    private Boolean activated;
    private Integer serviceMap;
    private long dayId;
    private long excursionId;
    private long alternativeServiceId;
    private long polygonId;

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

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

    private Excursion excursion;
    private Long excursion__resolvedKey;

    private DbPolygon polygon;
    private Long polygon__resolvedKey;

    private List<Service> alternativeServices;
    private List<Detail> details;
    private List<DbLine> lines;

    public Service() {
    }

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

    public Service(Long id, Long idserviceepp, String name, String locality, Integer type, Double latitude, Double longitude, String startHour, byte[] icon, Boolean available, Boolean activated, Integer serviceMap, long dayId, long excursionId, long alternativeServiceId, long polygonId) {
        this.id = id;
        this.idserviceepp = idserviceepp;
        this.name = name;
        this.locality = locality;
        this.type = type;
        this.latitude = latitude;
        this.longitude = longitude;
        this.startHour = startHour;
        this.icon = icon;
        this.available = available;
        this.activated = activated;
        this.serviceMap = serviceMap;
        this.dayId = dayId;
        this.excursionId = excursionId;
        this.alternativeServiceId = alternativeServiceId;
        this.polygonId = polygonId;
    }

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

    public Long getId() {
        return id;
    }

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

    public Long getIdserviceepp() {
        return idserviceepp;
    }

    public void setIdserviceepp(Long idserviceepp) {
        this.idserviceepp = idserviceepp;
    }

    public String getName() {
        return name;
    }

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

    public String getLocality() {
        return locality;
    }

    public void setLocality(String locality) {
        this.locality = locality;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    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 String getStartHour() {
        return startHour;
    }

    public void setStartHour(String startHour) {
        this.startHour = startHour;
    }

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

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

    public Boolean getAvailable() {
        return available;
    }

    public void setAvailable(Boolean available) {
        this.available = available;
    }

    public Boolean getActivated() {
        return activated;
    }

    public void setActivated(Boolean activated) {
        this.activated = activated;
    }

    public Integer getServiceMap() {
        return serviceMap;
    }

    public void setServiceMap(Integer serviceMap) {
        this.serviceMap = serviceMap;
    }

    public long getDayId() {
        return dayId;
    }

    public void setDayId(long dayId) {
        this.dayId = dayId;
    }

    public long getExcursionId() {
        return excursionId;
    }

    public void setExcursionId(long excursionId) {
        this.excursionId = excursionId;
    }

    public long getAlternativeServiceId() {
        return alternativeServiceId;
    }

    public void setAlternativeServiceId(long alternativeServiceId) {
        this.alternativeServiceId = alternativeServiceId;
    }

    public long getPolygonId() {
        return polygonId;
    }

    public void setPolygonId(long polygonId) {
        this.polygonId = polygonId;
    }

    /** To-one relationship, resolved on first access. */
    public Excursion getExcursion() {
        long __key = this.excursionId;
        if (excursion__resolvedKey == null || !excursion__resolvedKey.equals(__key)) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            ExcursionDao targetDao = daoSession.getExcursionDao();
            Excursion excursionNew = targetDao.load(__key);
            synchronized (this) {
                excursion = excursionNew;
            	excursion__resolvedKey = __key;
            }
        }
        return excursion;
    }

    public void setExcursion(Excursion excursion) {
        if (excursion == null) {
            throw new DaoException("To-one property 'excursionId' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.excursion = excursion;
            excursionId = excursion.getId();
            excursion__resolvedKey = excursionId;
        }
    }

    /** To-one relationship, resolved on first access. */
    public DbPolygon getPolygon() {
        long __key = this.polygonId;
        if (polygon__resolvedKey == null || !polygon__resolvedKey.equals(__key)) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            DbPolygonDao targetDao = daoSession.getDbPolygonDao();
            DbPolygon polygonNew = targetDao.load(__key);
            synchronized (this) {
                polygon = polygonNew;
            	polygon__resolvedKey = __key;
            }
        }
        return polygon;
    }

    public void setPolygon(DbPolygon polygon) {
        if (polygon == null) {
            throw new DaoException("To-one property 'polygonId' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.polygon = polygon;
            polygonId = polygon.getId();
            polygon__resolvedKey = polygonId;
        }
    }

    /** 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> getAlternativeServices() {
        if (alternativeServices == null) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            ServiceDao targetDao = daoSession.getServiceDao();
            List<Service> alternativeServicesNew = targetDao._queryService_AlternativeServices(id);
            synchronized (this) {
                if(alternativeServices == null) {
                    alternativeServices = alternativeServicesNew;
                }
            }
        }
        return alternativeServices;
    }

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

    /** 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<Detail> getDetails() {
        if (details == null) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            DetailDao targetDao = daoSession.getDetailDao();
            List<Detail> detailsNew = targetDao._queryService_Details(id);
            synchronized (this) {
                if(details == null) {
                    details = detailsNew;
                }
            }
        }
        return details;
    }

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

    /** 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<DbLine> getLines() {
        if (lines == null) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            DbLineDao targetDao = daoSession.getDbLineDao();
            List<DbLine> linesNew = targetDao._queryService_Lines(id);
            synchronized (this) {
                if(lines == null) {
                    lines = linesNew;
                }
            }
        }
        return lines;
    }

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

}
