Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.67 KB | None | 0 0
  1. package gauss.com.cesting.models;
  2.  
  3. import android.database.sqlite.SQLiteException;
  4.  
  5. import org.greenrobot.greendao.DaoException;
  6. import org.greenrobot.greendao.annotation.Entity;
  7. import org.greenrobot.greendao.annotation.Generated;
  8. import org.greenrobot.greendao.annotation.Id;
  9. import org.greenrobot.greendao.annotation.JoinEntity;
  10. import org.greenrobot.greendao.annotation.NotNull;
  11. import org.greenrobot.greendao.annotation.ToMany;
  12. import org.greenrobot.greendao.annotation.ToOne;
  13.  
  14. import java.util.ArrayList;
  15. import java.util.List;
  16.  
  17. import gauss.com.cesting.Cesting;
  18.  
  19. /**
  20. * Created by vedran on 26.05.17..
  21. */
  22. @Entity
  23. public class SaveWorkorderRequest {
  24.  
  25. //region PARAMS
  26. @Id
  27. private Long Id;
  28. private String adDate;
  29. private String travelEndTime;
  30. private String travelStartTime;
  31. private String acKey;
  32. private String worker;
  33. private String regOznaka;
  34. private String acStatus;
  35. private boolean active;
  36. @ToMany(referencedJoinProperty = "eventsJoinId")
  37. private List<EventsCombinedModel> events;
  38. @ToMany(referencedJoinProperty = "usedServicesId")
  39. private List<UsedServicesModel> usedServices;
  40. @ToMany(referencedJoinProperty = "accidentLargeModelId")
  41. private List<AccidentLargeModel> prometna;
  42. /**
  43. * Used to resolve relations
  44. */
  45. @Generated(hash = 2040040024)
  46. private transient DaoSession daoSession;
  47. /**
  48. * Used for active entity operations.
  49. */
  50. @Generated(hash = 1045882519)
  51. private transient SaveWorkorderRequestDao myDao;
  52.  
  53.  
  54. //endregion
  55.  
  56. //region CONSTRUCTOR
  57.  
  58. public SaveWorkorderRequest(boolean isActive, String acKey) {
  59. this.active = isActive;
  60. this.acKey = acKey;
  61. }
  62.  
  63. public SaveWorkorderRequest(String adDate, String travelEndTime, String travelStartTime, String acKey, String worker, String regOznaka, String acStatus, List<EventsCombinedModel> events, List<UsedServicesModel> usedServices, List<AccidentLargeModel> prometna) {
  64. this.adDate = adDate;
  65. this.travelEndTime = travelEndTime;
  66. this.travelStartTime = travelStartTime;
  67. this.acKey = acKey;
  68. this.worker = worker;
  69. this.regOznaka = regOznaka;
  70. this.acStatus = acStatus;
  71. this.events = events;
  72. this.usedServices = usedServices;
  73. this.prometna = prometna;
  74. }
  75.  
  76. @Generated(hash = 1753560489)
  77. public SaveWorkorderRequest(Long Id, String adDate, String travelEndTime, String travelStartTime, String acKey, String worker, String regOznaka, String acStatus, boolean active) {
  78. this.Id = Id;
  79. this.adDate = adDate;
  80. this.travelEndTime = travelEndTime;
  81. this.travelStartTime = travelStartTime;
  82. this.acKey = acKey;
  83. this.worker = worker;
  84. this.regOznaka = regOznaka;
  85. this.acStatus = acStatus;
  86. this.active = active;
  87. }
  88.  
  89. @Generated(hash = 1470173319)
  90. public SaveWorkorderRequest() {
  91. }
  92.  
  93. //endregion
  94.  
  95. //region GETTERS AND SETTERS
  96.  
  97. public String getAdDate() {
  98. return adDate;
  99. }
  100.  
  101. public void setAdDate(String adDate) {
  102. this.adDate = adDate;
  103. }
  104.  
  105. public String getTravelEndTime() {
  106. return travelEndTime;
  107. }
  108.  
  109. public void setTravelEndTime(String travelEndTime) {
  110. this.travelEndTime = travelEndTime;
  111. }
  112.  
  113. public String getTravelStartTime() {
  114. return travelStartTime;
  115. }
  116.  
  117. public void setTravelStartTime(String travelStartTime) {
  118. this.travelStartTime = travelStartTime;
  119. }
  120.  
  121. public String getAcKey() {
  122. return acKey;
  123. }
  124.  
  125. public void setAcKey(String acKey) {
  126. this.acKey = acKey;
  127. }
  128.  
  129. public String getWorker() {
  130. return worker;
  131. }
  132.  
  133. public void setWorker(String worker) {
  134. this.worker = worker;
  135. }
  136.  
  137. public String getRegOznaka() {
  138. return regOznaka;
  139. }
  140.  
  141. public void setRegOznaka(String regOznaka) {
  142. this.regOznaka = regOznaka;
  143. }
  144.  
  145. public String getAcStatus() {
  146. return acStatus;
  147. }
  148.  
  149. public void setAcStatus(String acStatus) {
  150. this.acStatus = acStatus;
  151. }
  152.  
  153. public Long getId() {
  154. return this.Id;
  155. }
  156.  
  157. public void setId(Long Id) {
  158. this.Id = Id;
  159. }
  160.  
  161. public boolean isActive() {
  162. return active;
  163. }
  164.  
  165. public void setActive(boolean active) {
  166. this.active = active;
  167. }
  168.  
  169. public static List<SaveWorkorderRequest> listAllModels() {
  170. return Cesting.getInstance().getDaoSession().getSaveWorkorderRequestDao().queryBuilder().list();
  171. }
  172.  
  173. public static List<SaveWorkorderRequest> getActiveWorkOrder() {
  174. try {
  175. return Cesting.getInstance().getDaoSession().getSaveWorkorderRequestDao().queryBuilder().where(SaveWorkorderRequestDao.Properties.Active.eq(true)).list();
  176. } catch (SQLiteException ex) {
  177. return new ArrayList<>();
  178. }
  179. }
  180.  
  181.  
  182. /**
  183. * To-many relationship, resolved on first access (and after reset).
  184. * Changes to to-many relations are not persisted, make changes to the target entity.
  185. */
  186. @Generated(hash = 1174941244)
  187. public List<EventsCombinedModel> getEvents() {
  188. if (events == null) {
  189. final DaoSession daoSession = this.daoSession;
  190. if (daoSession == null) {
  191. throw new DaoException("Entity is detached from DAO context");
  192. }
  193. EventsCombinedModelDao targetDao = daoSession.getEventsCombinedModelDao();
  194. List<EventsCombinedModel> eventsNew = targetDao._querySaveWorkorderRequest_Events(Id);
  195. synchronized (this) {
  196. if (events == null) {
  197. events = eventsNew;
  198. }
  199. }
  200. }
  201. return events;
  202. }
  203.  
  204. /**
  205. * To-many relationship, resolved on first access (and after reset).
  206. * Changes to to-many relations are not persisted, make changes to the target entity.
  207. */
  208. @Generated(hash = 7599493)
  209. public List<UsedServicesModel> getUsedServices() {
  210. if (usedServices == null) {
  211. final DaoSession daoSession = this.daoSession;
  212. if (daoSession == null) {
  213. throw new DaoException("Entity is detached from DAO context");
  214. }
  215. UsedServicesModelDao targetDao = daoSession.getUsedServicesModelDao();
  216. List<UsedServicesModel> usedServicesNew = targetDao._querySaveWorkorderRequest_UsedServices(Id);
  217. synchronized (this) {
  218. if (usedServices == null) {
  219. usedServices = usedServicesNew;
  220. }
  221. }
  222. }
  223. return usedServices;
  224. }
  225.  
  226. /**
  227. * Resets a to-many relationship, making the next get call to query for a fresh result.
  228. */
  229. @Generated(hash = 1009978459)
  230. public synchronized void resetUsedServices() {
  231. usedServices = null;
  232. }
  233.  
  234. /**
  235. * To-many relationship, resolved on first access (and after reset).
  236. * Changes to to-many relations are not persisted, make changes to the target entity.
  237. */
  238. @Generated(hash = 92949840)
  239. public List<AccidentLargeModel> getPrometna() {
  240. if (prometna == null) {
  241. final DaoSession daoSession = this.daoSession;
  242. if (daoSession == null) {
  243. throw new DaoException("Entity is detached from DAO context");
  244. }
  245. AccidentLargeModelDao targetDao = daoSession.getAccidentLargeModelDao();
  246. List<AccidentLargeModel> prometnaNew = targetDao._querySaveWorkorderRequest_Prometna(Id);
  247. synchronized (this) {
  248. if (prometna == null) {
  249. prometna = prometnaNew;
  250. }
  251. }
  252. }
  253. return prometna;
  254. }
  255.  
  256. /**
  257. * Resets a to-many relationship, making the next get call to query for a fresh result.
  258. */
  259. @Generated(hash = 109329087)
  260. public synchronized void resetPrometna() {
  261. prometna = null;
  262. }
  263.  
  264. /**
  265. * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
  266. * Entity must attached to an entity context.
  267. */
  268. @Generated(hash = 128553479)
  269. public void delete() {
  270. if (myDao == null) {
  271. throw new DaoException("Entity is detached from DAO context");
  272. }
  273. myDao.delete(this);
  274. }
  275.  
  276. /**
  277. * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
  278. * Entity must attached to an entity context.
  279. */
  280. @Generated(hash = 1942392019)
  281. public void refresh() {
  282. if (myDao == null) {
  283. throw new DaoException("Entity is detached from DAO context");
  284. }
  285. myDao.refresh(this);
  286. }
  287.  
  288. /**
  289. * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
  290. * Entity must attached to an entity context.
  291. */
  292. @Generated(hash = 713229351)
  293. public void update() {
  294. if (myDao == null) {
  295. throw new DaoException("Entity is detached from DAO context");
  296. }
  297. myDao.update(this);
  298. }
  299.  
  300. public static Long insertModelToDb(SaveWorkorderRequest model) {
  301. return Cesting.getInstance().getDaoSession().getSaveWorkorderRequestDao().insertOrReplace(model);
  302. }
  303. //endregion
  304.  
  305. public boolean getActive() {
  306. return this.active;
  307. }
  308.  
  309. /** Resets a to-many relationship, making the next get call to query for a fresh result. */
  310. @Generated(hash = 1830105409)
  311. public synchronized void resetEvents() {
  312. events = null;
  313. }
  314.  
  315. /** called by internal mechanisms, do not call yourself. */
  316. @Generated(hash = 274751260)
  317. public void __setDaoSession(DaoSession daoSession) {
  318. this.daoSession = daoSession;
  319. myDao = daoSession != null ? daoSession.getSaveWorkorderRequestDao() : null;
  320. }
  321.  
  322.  
  323. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement