-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
941 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
app/src/main/java/com/apaza/moises/practicegreendao/database/DaoMaster.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.apaza.moises.practicegreendao.database; | ||
|
||
import android.content.Context; | ||
import android.database.sqlite.SQLiteDatabase; | ||
import android.database.sqlite.SQLiteDatabase.CursorFactory; | ||
import android.database.sqlite.SQLiteOpenHelper; | ||
import android.util.Log; | ||
import de.greenrobot.dao.AbstractDaoMaster; | ||
import de.greenrobot.dao.identityscope.IdentityScopeType; | ||
|
||
import com.apaza.moises.practicegreendao.database.UserDao; | ||
import com.apaza.moises.practicegreendao.database.PlaceDao; | ||
|
||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. | ||
/** | ||
* Master of DAO (schema version 1): knows all DAOs. | ||
*/ | ||
public class DaoMaster extends AbstractDaoMaster { | ||
public static final int SCHEMA_VERSION = 1; | ||
|
||
/** Creates underlying database table using DAOs. */ | ||
public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) { | ||
UserDao.createTable(db, ifNotExists); | ||
PlaceDao.createTable(db, ifNotExists); | ||
} | ||
|
||
/** Drops underlying database table using DAOs. */ | ||
public static void dropAllTables(SQLiteDatabase db, boolean ifExists) { | ||
UserDao.dropTable(db, ifExists); | ||
PlaceDao.dropTable(db, ifExists); | ||
} | ||
|
||
public static abstract class OpenHelper extends SQLiteOpenHelper { | ||
|
||
public OpenHelper(Context context, String name, CursorFactory factory) { | ||
super(context, name, factory, SCHEMA_VERSION); | ||
} | ||
|
||
@Override | ||
public void onCreate(SQLiteDatabase db) { | ||
Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); | ||
createAllTables(db, false); | ||
} | ||
} | ||
|
||
/** WARNING: Drops all table on Upgrade! Use only during development. */ | ||
public static class DevOpenHelper extends OpenHelper { | ||
public DevOpenHelper(Context context, String name, CursorFactory factory) { | ||
super(context, name, factory); | ||
} | ||
|
||
@Override | ||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | ||
Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); | ||
dropAllTables(db, true); | ||
onCreate(db); | ||
} | ||
} | ||
|
||
public DaoMaster(SQLiteDatabase db) { | ||
super(db, SCHEMA_VERSION); | ||
registerDaoClass(UserDao.class); | ||
registerDaoClass(PlaceDao.class); | ||
} | ||
|
||
public DaoSession newSession() { | ||
return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); | ||
} | ||
|
||
public DaoSession newSession(IdentityScopeType type) { | ||
return new DaoSession(db, type, daoConfigMap); | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
app/src/main/java/com/apaza/moises/practicegreendao/database/DaoSession.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.apaza.moises.practicegreendao.database; | ||
|
||
import android.database.sqlite.SQLiteDatabase; | ||
|
||
import java.util.Map; | ||
|
||
import de.greenrobot.dao.AbstractDao; | ||
import de.greenrobot.dao.AbstractDaoSession; | ||
import de.greenrobot.dao.identityscope.IdentityScopeType; | ||
import de.greenrobot.dao.internal.DaoConfig; | ||
|
||
import com.apaza.moises.practicegreendao.database.User; | ||
import com.apaza.moises.practicegreendao.database.Place; | ||
|
||
import com.apaza.moises.practicegreendao.database.UserDao; | ||
import com.apaza.moises.practicegreendao.database.PlaceDao; | ||
|
||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @see de.greenrobot.dao.AbstractDaoSession | ||
*/ | ||
public class DaoSession extends AbstractDaoSession { | ||
|
||
private final DaoConfig userDaoConfig; | ||
private final DaoConfig placeDaoConfig; | ||
|
||
private final UserDao userDao; | ||
private final PlaceDao placeDao; | ||
|
||
public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> | ||
daoConfigMap) { | ||
super(db); | ||
|
||
userDaoConfig = daoConfigMap.get(UserDao.class).clone(); | ||
userDaoConfig.initIdentityScope(type); | ||
|
||
placeDaoConfig = daoConfigMap.get(PlaceDao.class).clone(); | ||
placeDaoConfig.initIdentityScope(type); | ||
|
||
userDao = new UserDao(userDaoConfig, this); | ||
placeDao = new PlaceDao(placeDaoConfig, this); | ||
|
||
registerDao(User.class, userDao); | ||
registerDao(Place.class, placeDao); | ||
} | ||
|
||
public void clear() { | ||
userDaoConfig.getIdentityScope().clear(); | ||
placeDaoConfig.getIdentityScope().clear(); | ||
} | ||
|
||
public UserDao getUserDao() { | ||
return userDao; | ||
} | ||
|
||
public PlaceDao getPlaceDao() { | ||
return placeDao; | ||
} | ||
|
||
} |
164 changes: 164 additions & 0 deletions
164
app/src/main/java/com/apaza/moises/practicegreendao/database/Place.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
package com.apaza.moises.practicegreendao.database; | ||
|
||
import com.apaza.moises.practicegreendao.database.DaoSession; | ||
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 "PLACE". | ||
*/ | ||
public class Place { | ||
|
||
private Long id; | ||
/** Not-null value. */ | ||
private String name; | ||
private Float rating; | ||
private String address; | ||
private String description; | ||
private String pathImage; | ||
private long userId; | ||
|
||
/** Used to resolve relations */ | ||
private transient DaoSession daoSession; | ||
|
||
/** Used for active entity operations. */ | ||
private transient PlaceDao myDao; | ||
|
||
private User user; | ||
private Long user__resolvedKey; | ||
|
||
|
||
public Place() { | ||
} | ||
|
||
public Place(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public Place(Long id, String name, Float rating, String address, String description, String pathImage, long userId) { | ||
this.id = id; | ||
this.name = name; | ||
this.rating = rating; | ||
this.address = address; | ||
this.description = description; | ||
this.pathImage = pathImage; | ||
this.userId = userId; | ||
} | ||
|
||
/** called by internal mechanisms, do not call yourself. */ | ||
public void __setDaoSession(DaoSession daoSession) { | ||
this.daoSession = daoSession; | ||
myDao = daoSession != null ? daoSession.getPlaceDao() : null; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
/** Not-null value. */ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** Not-null value; ensure this value is available before it is saved to the database. */ | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public Float getRating() { | ||
return rating; | ||
} | ||
|
||
public void setRating(Float rating) { | ||
this.rating = rating; | ||
} | ||
|
||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
public void setAddress(String address) { | ||
this.address = address; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public String getPathImage() { | ||
return pathImage; | ||
} | ||
|
||
public void setPathImage(String pathImage) { | ||
this.pathImage = pathImage; | ||
} | ||
|
||
public long getUserId() { | ||
return userId; | ||
} | ||
|
||
public void setUserId(long userId) { | ||
this.userId = userId; | ||
} | ||
|
||
/** To-one relationship, resolved on first access. */ | ||
public User getUser() { | ||
long __key = this.userId; | ||
if (user__resolvedKey == null || !user__resolvedKey.equals(__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 'userId' has not-null constraint; cannot set to-one to null"); | ||
} | ||
synchronized (this) { | ||
this.user = user; | ||
userId = user.getId(); | ||
user__resolvedKey = userId; | ||
} | ||
} | ||
|
||
/** 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); | ||
} | ||
|
||
} |
Oops, something went wrong.