diff options
author | desperateCoder <a.dawtjan@gmx.de> | 2018-11-25 00:47:16 +0300 |
---|---|---|
committer | desperateCoder <a.dawtjan@gmx.de> | 2018-11-25 00:47:16 +0300 |
commit | 798c98c72d3ceb6f3f85a0ed88ee8002738fd28c (patch) | |
tree | b8c3ec4fa296bfc2bef2efdee247de65b69db82f /app/src/main/java/it/niedermann/nextcloud/deck/model/User.java | |
parent | d1f71ac7a53a541be4e448094a42292bff65c618 (diff) |
networking... (entity relations). social interactions... ew.
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/model/User.java')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/model/User.java | 118 |
1 files changed, 116 insertions, 2 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/User.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/User.java index 88aca005d..2f17262d8 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/User.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/User.java @@ -1,13 +1,39 @@ package it.niedermann.nextcloud.deck.model; -import java.io.Serializable; +import org.greenrobot.greendao.annotation.Entity; +import org.greenrobot.greendao.annotation.Id; +import org.greenrobot.greendao.annotation.Index; +import org.greenrobot.greendao.annotation.NotNull; +import org.greenrobot.greendao.annotation.ToOne; +import org.greenrobot.greendao.annotation.Generated; +import org.greenrobot.greendao.DaoException; -public class User implements Serializable { +@Entity +public class User { + + @Id + private Long id; + + @NotNull + @Index + @ToOne(joinProperty = "id") + protected Account account; private String primaryKey; private String uid; private String displayname; + /** Used to resolve relations */ + @Generated(hash = 2040040024) + private transient DaoSession daoSession; + + /** Used for active entity operations. */ + @Generated(hash = 1507654846) + private transient UserDao myDao; + + @Generated(hash = 1501133588) + private transient Long account__resolvedKey; + public User() { super(); } @@ -18,6 +44,22 @@ public class User implements Serializable { this.displayname = displayname; } + @Generated(hash = 38411976) + public User(Long id, String primaryKey, String uid, String displayname) { + this.id = id; + this.primaryKey = primaryKey; + this.uid = uid; + this.displayname = displayname; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + public String getPrimaryKey() { return primaryKey; } @@ -41,4 +83,76 @@ public class User implements Serializable { public void setDisplayname(String displayname) { this.displayname = displayname; } + + /** To-one relationship, resolved on first access. */ + @Generated(hash = 2035152785) + public Account getAccount() { + Long __key = this.id; + if (account__resolvedKey == null || !account__resolvedKey.equals(__key)) { + final DaoSession daoSession = this.daoSession; + if (daoSession == null) { + throw new DaoException("Entity is detached from DAO context"); + } + AccountDao targetDao = daoSession.getAccountDao(); + Account accountNew = targetDao.load(__key); + synchronized (this) { + account = accountNew; + account__resolvedKey = __key; + } + } + return account; + } + + /** called by internal mechanisms, do not call yourself. */ + @Generated(hash = 19318331) + public void setAccount(Account account) { + synchronized (this) { + this.account = account; + id = account == null ? null : account.getId(); + account__resolvedKey = id; + } + } + + /** + * 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 = 2059241980) + public void __setDaoSession(DaoSession daoSession) { + this.daoSession = daoSession; + myDao = daoSession != null ? daoSession.getUserDao() : null; + } } |