de.greenrobot.daogenerator.Schema Java Examples
The following examples show how to use
de.greenrobot.daogenerator.Schema.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EhDaoGenerator.java From MHViewer with Apache License 2.0 | 6 votes |
public static void generate() throws Exception { Utilities.deleteContents(new File(DELETE_DIR)); File outDir = new File(OUT_DIR); outDir.delete(); outDir.mkdirs(); Schema schema = new Schema(VERSION, PACKAGE); addReadingRecord(schema); addDownloads(schema); addDownloadLabel(schema); addDownloadDirname(schema); addHistoryInfo(schema); addQuickSearch(schema); addLocalFavorites(schema); addBookmarks(schema); addFilter(schema); new DaoGenerator().generateAll(schema, OUT_DIR); adjustDownloadInfo(); adjustHistoryInfo(); adjustQuickSearch(); adjustLocalFavoriteInfo(); adjustBookmarkInfo(); adjustFilter(); }
Example #2
Source File: EhDaoGenerator.java From MHViewer with Apache License 2.0 | 6 votes |
private static void addQuickSearch(Schema schema) { Entity entity = schema.addEntity("QuickSearch"); entity.setTableName("QUICK_SEARCH"); entity.setClassNameDao("QuickSearchDao"); entity.addIdProperty(); entity.addStringProperty("name"); entity.addIntProperty("mode").notNull(); entity.addIntProperty("category").notNull(); entity.addStringProperty("keyword"); entity.addIntProperty("advanceSearch").notNull(); entity.addIntProperty("minRating").notNull(); // Since 4 entity.addIntProperty("pageFrom").notNull(); // Since 4 entity.addIntProperty("pageTo").notNull(); entity.addLongProperty("time").notNull(); }
Example #3
Source File: EhDaoGenerator.java From MHViewer with Apache License 2.0 | 6 votes |
private static void addLocalFavorites(Schema schema) { Entity entity = schema.addEntity("LocalFavoriteInfo"); entity.setTableName("LOCAL_FAVORITES"); entity.setClassNameDao("LocalFavoritesDao"); entity.setSuperclass("GalleryInfo"); // GalleryInfo data entity.addStringProperty("gid").notNull(); entity.addStringProperty("token"); entity.addStringProperty("title"); entity.addStringProperty("titleJpn"); entity.addStringProperty("thumb"); entity.addIntProperty("category").notNull(); entity.addStringProperty("posted"); entity.addStringProperty("uploader"); entity.addFloatProperty("rating").notNull(); entity.addStringProperty("simpleLanguage"); // LocalFavoriteInfo data entity.addLongProperty("time").notNull(); entity.addStringProperty("id").primaryKey().notNull(); }
Example #4
Source File: EhDaoGenerator.java From MHViewer with Apache License 2.0 | 6 votes |
private static void addBookmarks(Schema schema) { Entity entity = schema.addEntity("BookmarkInfo"); entity.setTableName("BOOKMARKS"); entity.setClassNameDao("BookmarksBao"); entity.setSuperclass("GalleryInfo"); // GalleryInfo data entity.addStringProperty("gid").primaryKey().notNull(); entity.addStringProperty("token"); entity.addStringProperty("title"); entity.addStringProperty("titleJpn"); entity.addStringProperty("thumb"); entity.addIntProperty("category").notNull(); entity.addStringProperty("posted"); entity.addStringProperty("uploader"); entity.addFloatProperty("rating").notNull(); entity.addStringProperty("simpleLanguage"); // Bookmark data entity.addIntProperty("page").notNull(); entity.addLongProperty("time").notNull(); }
Example #5
Source File: EhDaoGenerator.java From MHViewer with Apache License 2.0 | 6 votes |
private static void addDownloads(Schema schema) { Entity entity = schema.addEntity("DownloadInfo"); entity.setTableName("DOWNLOADS"); entity.setClassNameDao("DownloadsDao"); entity.setSuperclass("GalleryInfo"); // GalleryInfo data entity.addStringProperty("gid").primaryKey().notNull(); entity.addStringProperty("token"); entity.addStringProperty("title"); entity.addStringProperty("titleJpn"); entity.addStringProperty("thumb"); entity.addIntProperty("category").notNull(); entity.addStringProperty("posted"); entity.addStringProperty("uploader"); entity.addFloatProperty("rating").notNull(); entity.addStringProperty("simpleLanguage"); // DownloadInfo data entity.addIntProperty("state").notNull(); entity.addIntProperty("legacy").notNull(); entity.addLongProperty("time").notNull(); entity.addStringProperty("label"); }
Example #6
Source File: EhDaoGenerator.java From MHViewer with Apache License 2.0 | 6 votes |
private static void addHistoryInfo(Schema schema) { Entity entity = schema.addEntity("HistoryInfo"); entity.setTableName("HISTORY"); entity.setClassNameDao("HistoryDao"); entity.setSuperclass("GalleryInfo"); // GalleryInfo data entity.addStringProperty("gid").notNull(); entity.addStringProperty("token"); entity.addStringProperty("title"); entity.addStringProperty("titleJpn"); entity.addStringProperty("thumb"); entity.addIntProperty("category").notNull(); entity.addStringProperty("posted"); entity.addStringProperty("uploader"); entity.addFloatProperty("rating").notNull(); entity.addStringProperty("simpleLanguage"); // HistoryInfo data entity.addIntProperty("mode").notNull(); entity.addLongProperty("time").notNull(); entity.addStringProperty("id").primaryKey().notNull(); }
Example #7
Source File: GreenDaoGen.java From iBeebo with GNU General Public License v3.0 | 6 votes |
private static void addAccountTable(Schema schema) { Entity table = schema.addEntity("Green_AccountBean"); table.setHasKeepSections(true); table.setTableName(AccountTable.ACCOUNT_TABLE); table.implementsSerializable(); table.addLongProperty(AccountTable.UID).primaryKey(); table.addStringProperty(AccountTable.USER_NAME); table.addStringProperty(AccountTable.USER_PWD); table.addStringProperty(AccountTable.COOKIE); table.addStringProperty(AccountTable.OAUTH_TOKEN); table.addLongProperty(AccountTable.OAUTH_TOKEN_EXPIRES_TIME); table.addStringProperty(AccountTable.ACCESS_TOKEN_HACK); table.addLongProperty(AccountTable.ACCESS_TOKEN_HACK_EXPIRES_TIME); table.addStringProperty(AccountTable.G_SID); table.addIntProperty(AccountTable.NAVIGATION_POSITION); table.addStringProperty(AccountTable.USER_INFO_JSON); }
Example #8
Source File: GreenDaoGenerator.java From DMusic with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { // 正如你所见的,你创建了一个用于添加实体(Entity)的模式(Schema)对象。 // 两个参数分别代表:数据库版本号与自动生成代码的包路径。 // Schema schema = new Schema(1, "com.d.music.data.database.greendao.music"); // 当然,如果你愿意,你也可以分别指定生成的 Bean 与 DAO 类所在的目录,只要如下所示: Schema schema = new Schema(1, "com.d.music.data.database.greendao.bean"); schema.setDefaultJavaPackageDao("com.d.music.data.database.greendao.dao"); // 模式(Schema)同时也拥有两个默认的 flags,分别用来标示 entity 是否是 activie 以及是否使用 keep sections。 // schema2.enableActiveEntitiesByDefault(); // schema2.enableKeepSectionsByDefault(); // 一旦你拥有了一个 Schema 对象后,你便可以使用它添加实体(Entities)了。 addMusic(schema); addLocalAllMusic(schema); addCollectionMusic(schema); addCustomList(schema); addCustomMusics(schema); addTransferModel(schema); // 最后我们将使用 DAOGenerator 类的 generateAll() 方法自动生成代码,此处你需要根据自己的情况更改输出目录。 // 其实,输出目录的路径可以在 build.gradle 中设置,有兴趣的朋友可以自行搜索,这里就不再详解。 // 重新运行GreenDaoGenerator时,将此路径更改为本地src路径 new DaoGenerator().generateAll(schema, "D:\\AndroidStudioProjects\\DMusic\\app\\src\\main\\java"); }
Example #9
Source File: GreenDaoGenerator.java From sctalk with Apache License 2.0 | 6 votes |
private static void addDepartment(Schema schema){ Entity department = schema.addEntity("DepartmentEntity"); department.setTableName("Department"); department.setClassNameDao("DepartmentDao"); department.setJavaPackage(entityPath); department.addIdProperty().autoincrement(); department.addIntProperty("departId").unique().notNull().index(); department.addStringProperty("departName").unique().notNull().index(); department.addIntProperty("priority").notNull(); department.addIntProperty("status").notNull(); department.addIntProperty("created").notNull(); department.addIntProperty("updated").notNull(); department.setHasKeepSections(true); }
Example #10
Source File: GreenDaoGenerator.java From sctalk with Apache License 2.0 | 6 votes |
private static void addGroupInfo(Schema schema) { Entity groupInfo = schema.addEntity("GroupEntity"); groupInfo.setTableName("GroupInfo"); groupInfo.setClassNameDao("GroupDao"); groupInfo.setJavaPackage(entityPath); groupInfo.addIdProperty().autoincrement(); groupInfo.addIntProperty("peerId").unique().notNull(); groupInfo.addIntProperty("groupType").notNull(); groupInfo.addStringProperty("mainName").notNull(); groupInfo.addStringProperty("avatar").notNull(); groupInfo.addIntProperty("creatorId").notNull(); groupInfo.addIntProperty("userCnt").notNull(); groupInfo.addStringProperty("userList").notNull(); groupInfo.addIntProperty("version").notNull(); groupInfo.addIntProperty("status").notNull(); groupInfo.addIntProperty("created").notNull(); groupInfo.addIntProperty("updated").notNull(); groupInfo.setHasKeepSections(true); }
Example #11
Source File: GreenDaoGenerator.java From sctalk with Apache License 2.0 | 6 votes |
private static void addSessionInfo(Schema schema){ Entity sessionInfo = schema.addEntity("SessionEntity"); sessionInfo.setTableName("Session"); sessionInfo.setClassNameDao("SessionDao"); sessionInfo.setJavaPackage(entityPath); //point to userId/groupId need sessionType 区分 sessionInfo.addIdProperty().autoincrement(); sessionInfo.addStringProperty("sessionKey").unique().notNull(); //.unique() sessionInfo.addIntProperty("peerId").notNull(); sessionInfo.addIntProperty("peerType").notNull(); sessionInfo.addIntProperty("latestMsgType").notNull(); sessionInfo.addIntProperty("latestMsgId").notNull(); sessionInfo.addStringProperty("latestMsgData").notNull(); sessionInfo.addIntProperty("talkId").notNull(); sessionInfo.addIntProperty("created").notNull(); sessionInfo.addIntProperty("updated").notNull(); sessionInfo.setHasKeepSections(true); }
Example #12
Source File: Generator.java From AndroidDatabaseLibraryComparison with MIT License | 6 votes |
public static void main(String[] args) { Schema schema = new Schema(1, "com.raizlabs.android.databasecomparison.greendao.gen"); Entity simpleAddressItem = getAddressItemEntity(schema, "SimpleAddressItem"); Entity addressItem = getAddressItemEntity(schema, "AddressItem"); Entity contactItem = getContactItemEntity(schema); Entity addressBook = getAddressBookEntity(schema); addressItem.addToOne(addressBook, addressItem.getProperties().get(0)); contactItem.addToOne(addressBook, contactItem.getProperties().get(0)); addressBook.addToMany(addressItem, addressItem.getProperties().get(0)); addressBook.addToMany(contactItem, contactItem.getProperties().get(0)); try { new DaoGenerator().generateAll(schema, "../app/src/main/java"); } catch (Exception e) { e.printStackTrace(); } }
Example #13
Source File: NMBDaoGenerator.java From Nimingban with Apache License 2.0 | 6 votes |
private static void addACForum(Schema schema) { Entity entity = schema.addEntity("ACForumRaw"); entity.setTableName("AC_FORUM"); entity.setClassNameDao("ACForumDao"); entity.addIdProperty(); entity.addStringProperty("forumid"); entity.addStringProperty("displayname"); entity.addIntProperty("priority"); entity.addBooleanProperty("visibility"); // @since 4 entity.addStringProperty("msg"); // @since 5 entity.addBooleanProperty("official"); // @since 6 entity.addIntProperty("frequency"); }
Example #14
Source File: HttpCookieDaoGenerator.java From Nimingban with Apache License 2.0 | 6 votes |
private static void addHttpCookie(Schema schema) { Entity entity = schema.addEntity("HttpCookieRaw"); entity.setTableName("HTTP_COOKIE"); entity.setClassNameDao("HttpCookieDao"); entity.addIdProperty(); entity.addStringProperty("name"); entity.addStringProperty("value"); entity.addStringProperty("comment"); entity.addStringProperty("commentURL"); entity.addBooleanProperty("discard"); entity.addStringProperty("domain"); entity.addLongProperty("maxAge"); entity.addStringProperty("path"); entity.addStringProperty("portList"); entity.addBooleanProperty("secure"); entity.addIntProperty("version"); entity.addStringProperty("url"); entity.addLongProperty("whenCreated"); }
Example #15
Source File: PrinterDaoGenerator.java From octoandroid with GNU General Public License v3.0 | 6 votes |
private static Entity addPrinter(Schema schema) { Entity printer = schema.addEntity("PrinterDbEntity"); printer.setTableName("PRINTER"); printer.addIdProperty().primaryKey().unique(); printer.addStringProperty("name").notNull().unique(); printer.addStringProperty("apiKey").columnName("api_key").notNull(); printer.addStringProperty("scheme").notNull(); printer.addStringProperty("host").notNull(); printer.addIntProperty("port").notNull(); printer.addStringProperty("websocketPath").columnName("websocket_path").notNull(); printer.addStringProperty("webcamPathQuery").columnName("webcam_path_query").notNull(); printer.addStringProperty("uploadLocation").columnName("upload_location").notNull(); printer.addStringProperty("versionJson").columnName("version_json"); printer.addStringProperty("connectionJson").columnName("connection_json"); printer.addStringProperty("printerStateJson").columnName("printer_state_json"); printer.addStringProperty("filesJson").columnName("files_json"); return printer; }
Example #16
Source File: DBClass.java From MeiZiNews with MIT License | 6 votes |
private static void addHtml(Schema schema) { // 实体类 Entity mHtmlEntity = schema.addEntity("HtmlEntity");//表名 //列名 mHtmlEntity.addIdProperty();//主键id mHtmlEntity.addStringProperty("url");//连接 mHtmlEntity.addStringProperty("type");//类型 mHtmlEntity.addStringProperty("title");//标题 mHtmlEntity.addStringProperty("html");//html mHtmlEntity.addStringProperty("summary");//总结 mHtmlEntity.addStringProperty("collect");//是否收藏 mHtmlEntity.addDateProperty("hireDate"); // 收藏实体类 Entity mCollectEntity = schema.addEntity("CollectEntity");//表名 mCollectEntity.addIdProperty();//主键id Property htmlID = mCollectEntity.addLongProperty("html_id").getProperty();//收藏的id mCollectEntity.addStringProperty("collect");//是否收藏 mCollectEntity.addToOne(mHtmlEntity, htmlID); }
Example #17
Source File: MyDaoGenerator.java From JianDan_OkHttpWithVolley with Apache License 2.0 | 5 votes |
/** * 添加不同的缓存表 * @param schema * @param tableName */ private static void addCache(Schema schema, String tableName) { Entity joke = schema.addEntity(tableName); //主键id自增长 joke.addIdProperty().primaryKey().autoincrement(); //请求结果 joke.addStringProperty("result"); //页数 joke.addIntProperty("page"); //插入时间,暂时无用 joke.addLongProperty("time"); }
Example #18
Source File: NMBDaoGenerator.java From Nimingban with Apache License 2.0 | 5 votes |
public static void generate() throws Exception { Utilities.deleteContents(new File(DELETE_DIR)); File outDir = new File(OUT_DIR); outDir.delete(); outDir.mkdirs(); Schema schema = new Schema(VERSION, PACKAGE); addACForum(schema); addDraft(schema); addACRecord(schema); addACCommonPost(schema); new DaoGenerator().generateAll(schema, OUT_DIR); }
Example #19
Source File: MyDaoGenerator.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
/** * 添加不同的缓存表 * @param schema * @param tableName */ private static void addCache(Schema schema, String tableName) { Entity joke = schema.addEntity(tableName); //主键id自增长 joke.addIdProperty().primaryKey().autoincrement(); //请求结果 joke.addStringProperty("result"); //页数 joke.addIntProperty("page"); //插入时间,暂时无用 joke.addLongProperty("time"); }
Example #20
Source File: HttpCookieDaoGenerator.java From Nimingban with Apache License 2.0 | 5 votes |
public static void generate() throws Exception { Utilities.deleteContents(new File(DELETE_DIR)); File outDir = new File(OUT_DIR); outDir.delete(); outDir.mkdirs(); Schema schema = new Schema(1, PACKAGE); addHttpCookie(schema); new DaoGenerator().generateAll(schema, OUT_DIR); }
Example #21
Source File: MyDaoGenerator.java From MyWeather with Apache License 2.0 | 5 votes |
private static void addAlarms(Schema schema) { Entity weekForeCast = schema.addEntity("Alarms"); weekForeCast.implementsSerializable(); weekForeCast.addStringProperty("alarmContent"); weekForeCast.addStringProperty("alarmId"); weekForeCast.addStringProperty("alarmLevelNo"); weekForeCast.addStringProperty("alarmLevelNoDesc"); weekForeCast.addStringProperty("alarmType"); weekForeCast.addStringProperty("alarmTypeDesc"); weekForeCast.addStringProperty("publishTime"); weekForeCast.addStringProperty("areaid"); weekForeCast.addStringProperty("areaName"); }
Example #22
Source File: MyDaoGenerator.java From MyWeather with Apache License 2.0 | 5 votes |
private static void addUseArea(Schema schema) { Entity weekForeCast = schema.addEntity("UseArea"); weekForeCast.addStringProperty("areaid"); weekForeCast.addStringProperty("areaid2345"); weekForeCast.addStringProperty("areaName"); weekForeCast.addBooleanProperty("main"); }
Example #23
Source File: MyDaoGenerator.java From MyWeather with Apache License 2.0 | 5 votes |
private static void addZhishu(Schema schema) { Entity weekForeCast = schema.addEntity("Zhishu"); weekForeCast.addStringProperty("areaid"); weekForeCast.addStringProperty("name"); weekForeCast.addStringProperty("level"); weekForeCast.addStringProperty("text"); weekForeCast.addStringProperty("detail"); }
Example #24
Source File: MyDaoGenerator.java From MyWeather with Apache License 2.0 | 5 votes |
private static void addAqi(Schema schema) { Entity weekForeCast = schema.addEntity("Aqi"); weekForeCast.addStringProperty("areaid"); weekForeCast.addIntProperty("aqi"); weekForeCast.addStringProperty("quality"); weekForeCast.addIntProperty("pm2_5"); weekForeCast.addIntProperty("pm10"); weekForeCast.addIntProperty("so2"); weekForeCast.addIntProperty("no2"); }
Example #25
Source File: MyDaoGenerator.java From MyWeather with Apache License 2.0 | 5 votes |
private static void addHourForeCast(Schema schema) { Entity weekForeCast = schema.addEntity("HourForeCast"); weekForeCast.addStringProperty("areaid"); weekForeCast.addStringProperty("hour"); weekForeCast.addStringProperty("weatherCondition"); weekForeCast.addIntProperty("temp"); }
Example #26
Source File: MyDaoGenerator.java From MyWeather with Apache License 2.0 | 5 votes |
private static void addForeCast(Schema schema) { Entity weekForeCast = schema.addEntity("WeekForeCast"); weekForeCast.addStringProperty("areaid"); weekForeCast.addDateProperty("weatherDate"); weekForeCast.addStringProperty("weatherConditionStart"); weekForeCast.addStringProperty("weatherConditionEnd"); weekForeCast.addIntProperty("tempH"); weekForeCast.addIntProperty("tempL"); weekForeCast.addStringProperty("fx"); weekForeCast.addStringProperty("fj"); weekForeCast.addIntProperty("rainPerCent"); }
Example #27
Source File: MyDaoGenerator.java From MyWeather with Apache License 2.0 | 5 votes |
private static void addRealWeather(Schema schema) { Entity realWeather = schema.addEntity("RealWeather"); realWeather.addStringProperty("areaid"); realWeather.addStringProperty("areaName"); realWeather.addStringProperty("weatherCondition"); realWeather.addStringProperty("fx"); realWeather.addStringProperty("fj"); realWeather.addIntProperty("temp"); realWeather.addIntProperty("feeltemp"); realWeather.addIntProperty("shidu"); realWeather.addStringProperty("sunrise"); realWeather.addStringProperty("sundown"); realWeather.addDateProperty("lastUpdate"); }
Example #28
Source File: MyDaoGenerator.java From MyWeather with Apache License 2.0 | 5 votes |
public static void main(String args[]) throws Exception { Schema schema = new Schema(2, "suda.sudamodweather.dao.greendao"); addForeCast(schema); addRealWeather(schema); addHourForeCast(schema); addAqi(schema); addZhishu(schema); addUseArea(schema); addAlarms(schema); new DaoGenerator().generateAll(schema, "app/src/main/java"); }
Example #29
Source File: DBClass.java From MeiZiNews with MIT License | 5 votes |
private static void addCollect(Schema schema) { // // 实体类 // Entity mCollectEntity = schema.addEntity("CollectEntity");//表名 // mCollectEntity.addIdProperty();//主键id // mCollectEntity.addStringProperty("html_id");//收藏的id // mCollectEntity.addStringProperty("collect");//是否收藏 // mCollectEntity.addDateProperty("hireDate"); }
Example #30
Source File: NMBDaoGenerator.java From Nimingban with Apache License 2.0 | 5 votes |
/** * @since 2 */ private static void addACRecord(Schema schema) { Entity entity = schema.addEntity("ACRecordRaw"); entity.setTableName("AC_RECORD"); entity.setClassNameDao("ACRecordDao"); entity.addIdProperty(); entity.addIntProperty("type"); entity.addStringProperty("recordid"); entity.addStringProperty("postid"); entity.addStringProperty("content"); entity.addStringProperty("image"); entity.addLongProperty("time"); }