mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
The jitpack.io build is facing issues. The code required for the code generation is quite small, with a negligible build impact, so import it directly to the repository from the fork and remove the dependency on jitpack completely. - Taken from https://codeberg.org/Freeyourgadget/greenDAO - Original commit: 1998d7cd2d21f662c6044f6ccf3b3a251bbad341
102 lines
3.8 KiB
Plaintext
102 lines
3.8 KiB
Plaintext
<#--
|
|
|
|
Copyright (C) 2011 Markus Junginger, greenrobot (http://greenrobot.de)
|
|
|
|
This file is part of greenDAO Generator.
|
|
|
|
greenDAO Generator is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
greenDAO Generator is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with greenDAO Generator. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
-->
|
|
package ${schema.defaultJavaPackageDao};
|
|
|
|
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;
|
|
|
|
<#list schema.entities as entity>
|
|
import ${entity.javaPackageDao}.${entity.classNameDao};
|
|
</#list>
|
|
|
|
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
|
|
/**
|
|
* Master of DAO (schema version ${schema.version?c}): knows all DAOs.
|
|
*/
|
|
public class DaoMaster extends AbstractDaoMaster {
|
|
public static final int SCHEMA_VERSION = ${schema.version?c};
|
|
|
|
/** Creates underlying database table using DAOs. */
|
|
public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
|
|
<#list schema.entities as entity>
|
|
<#if !entity.skipTableCreation>
|
|
${entity.classNameDao}.createTable(db, ifNotExists);
|
|
</#if>
|
|
</#list>
|
|
}
|
|
|
|
/** Drops underlying database table using DAOs. */
|
|
public static void dropAllTables(SQLiteDatabase db, boolean ifExists) {
|
|
<#list schema.entities as entity>
|
|
<#if !entity.skipTableCreation>
|
|
${entity.classNameDao}.dropTable(db, ifExists);
|
|
</#if>
|
|
</#list>
|
|
}
|
|
|
|
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);
|
|
<#list schema.entities as entity>
|
|
registerDaoClass(${entity.classNameDao}.class);
|
|
</#list>
|
|
}
|
|
|
|
public DaoSession newSession() {
|
|
return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
|
|
}
|
|
|
|
public DaoSession newSession(IdentityScopeType type) {
|
|
return new DaoSession(db, type, daoConfigMap);
|
|
}
|
|
|
|
}
|