package com.adins.mss.dao;

import com.adins.mss.dao.DaoSession;
import de.greenrobot.dao.DaoException;

import com.adins.mss.base.util.ExcludeFromGson;
import com.google.gson.annotations.SerializedName;

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

    private long uuid_emergency;
    /** Not-null value. */
     @SerializedName("uuid_user")
    private String uuid_user;
     @SerializedName("longitude")
    private String longitude;
     @SerializedName("latitude")
    private String latitude;
     @SerializedName("dtm_emergency")
    private java.util.Date dtm_emergency;

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

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

    private User user;
    private String user__resolvedKey;


    public Emergency() {
    }

    public Emergency(long uuid_emergency) {
        this.uuid_emergency = uuid_emergency;
    }

    public Emergency(long uuid_emergency, String uuid_user, String longitude, String latitude, java.util.Date dtm_emergency) {
        this.uuid_emergency = uuid_emergency;
        this.uuid_user = uuid_user;
        this.longitude = longitude;
        this.latitude = latitude;
        this.dtm_emergency = dtm_emergency;
    }

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

    public long getUuid_emergency() {
        return uuid_emergency;
    }

    public void setUuid_emergency(long uuid_emergency) {
        this.uuid_emergency = uuid_emergency;
    }

    /** Not-null value. */
    public String getUuid_user() {
        return uuid_user;
    }

    /** Not-null value; ensure this value is available before it is saved to the database. */
    public void setUuid_user(String uuid_user) {
        this.uuid_user = uuid_user;
    }

    public String getLongitude() {
        return longitude;
    }

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

    public String getLatitude() {
        return latitude;
    }

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

    public java.util.Date getDtm_emergency() {
        return dtm_emergency;
    }

    public void setDtm_emergency(java.util.Date dtm_emergency) {
        this.dtm_emergency = dtm_emergency;
    }

    /** To-one relationship, resolved on first access. */
    public User getUser() {
        String __key = this.uuid_user;
        if (user__resolvedKey == null || user__resolvedKey != __key) {
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            UserDao targetDao = daoSession.getUserDao();
            User userNew = targetDao.load(__key);
            synchronized (this) {
                user = userNew;
            	user__resolvedKey = __key;
            }
        }
        return user;
    }

    public void setUser(User user) {
        if (user == null) {
            throw new DaoException("To-one property 'uuid_user' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.user = user;
            uuid_user = user.getUuid_user();
            user__resolvedKey = uuid_user;
        }
    }

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

}
