package com.tofly.ghrq_route.module.plan.domain;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToMany;

import java.util.List;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;
import com.tofly.data.sql.dao.DaoSession;
import com.tofly.data.sql.dao.OfflinePathBeanDao;
import com.tofly.data.sql.dao.OfflinePointLineBeanDao;

/**
 * Created by Amu on 2017/7/28.
 */
@Entity(nameInDb = "DB_OFFLINE_POINTLINE")
public class OfflinePointLineBean {
    /**
     * temp_id : 90EDF71F81B64733A48CFF5759B2808B
     * plan_id : 585B6D5C28404855BBEFA504CFB7E529
     * isover : 0
     * lat : null
     * lng : null
     * geometry : {"paths":[[[106.51768476199999,29.577656531000002],[106.51768599299999,29.577655156999981]]]}
     * path : [{"id":"5F2F54459B684C619B2D97FAFD288B0C","temp_id":"90EDF71F81B64733A48CFF5759B2808B","point_id":"PIPESECTIONLP-P487456","lat":29.577655157,"lng":106.517685993,"isover":0},{"id":"ED8B96F8CB234A2D9542FCA25666F509","temp_id":"90EDF71F81B64733A48CFF5759B2808B","point_id":"PIPESECTIONLP-P487456","lat":29.577656531,"lng":106.517684762,"isover":0}]
     */

    @Id
    private String temp_id;
    private String plan_id;
    private int isover = 0;
    private int isupload = 0;
    private int ispast = 0;
    private double lat;
    private double lng;
    private String geometry;
    @ToMany(referencedJoinProperty = "temp_id")
    private List<OfflinePathBean> path;
    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    /** Used for active entity operations. */
    @Generated(hash = 613690093)
    private transient OfflinePointLineBeanDao myDao;

    @Generated(hash = 1261106357)
    public OfflinePointLineBean(String temp_id, String plan_id, int isover, int isupload, int ispast, double lat, double lng, String geometry) {
        this.temp_id = temp_id;
        this.plan_id = plan_id;
        this.isover = isover;
        this.isupload = isupload;
        this.ispast = ispast;
        this.lat = lat;
        this.lng = lng;
        this.geometry = geometry;
    }

    @Generated(hash = 725246871)
    public OfflinePointLineBean() {
    }

    public String getTemp_id() {
        return temp_id;
    }

    public void setTemp_id(String temp_id) {
        this.temp_id = temp_id;
    }

    public String getPlan_id() {
        return plan_id;
    }

    public void setPlan_id(String plan_id) {
        this.plan_id = plan_id;
    }

    public int getIsover() {
        return isover;
    }

    public void setIsover(int isover) {
        this.isover = isover;
    }

    public double getLat() {
        return lat;
    }

    public void setLat(double lat) {
        this.lat = lat;
    }

    public double getLng() {
        return lng;
    }

    public void setLng(double lng) {
        this.lng = lng;
    }

    public String getGeometry() {
        return geometry;
    }

    public void setGeometry(String geometry) {
        this.geometry = geometry;
    }

    public int getIsupload() {
        return this.isupload;
    }

    public void setIsupload(int isupload) {
        this.isupload = isupload;
    }

    public int getIspast() {
        return this.ispast;
    }

    public void setIspast(int ispast) {
        this.ispast = ispast;
    }

    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 648156709)
    public List<OfflinePathBean> getPath() {
        if (path == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            OfflinePathBeanDao targetDao = daoSession.getOfflinePathBeanDao();
            List<OfflinePathBean> pathNew = targetDao._queryOfflinePointLineBean_Path(temp_id);
            synchronized (this) {
                if (path == null) {
                    path = pathNew;
                }
            }
        }
        return path;
    }

    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 588079533)
    public synchronized void resetPath() {
        path = null;
    }

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

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

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

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