org.greenrobot.greendao.Property Java Examples

The following examples show how to use org.greenrobot.greendao.Property. 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: MigrationHelper.java    From FimiX8-RE with MIT License 6 votes vote down vote up
private void restoreData(Database db, Class<? extends AbstractDao<?, ?>>... daoClasses) {
    for (Class daoConfig : daoClasses) {
        DaoConfig daoConfig2 = new DaoConfig(db, daoConfig);
        String tableName = daoConfig2.tablename;
        String tempTableName = daoConfig2.tablename.concat("_TEMP");
        ArrayList<String> properties = new ArrayList();
        for (Property property : daoConfig2.properties) {
            String columnName = property.columnName;
            if (getColumns(db, tempTableName).contains(columnName)) {
                properties.add(columnName);
            }
        }
        StringBuilder insertTableStringBuilder = new StringBuilder();
        insertTableStringBuilder.append("INSERT INTO ").append(tableName).append(" (");
        insertTableStringBuilder.append(TextUtils.join(",", properties));
        insertTableStringBuilder.append(") SELECT ");
        insertTableStringBuilder.append(TextUtils.join(",", properties));
        insertTableStringBuilder.append(" FROM ").append(tempTableName).append(";");
        StringBuilder dropTableStringBuilder = new StringBuilder();
        dropTableStringBuilder.append("DROP TABLE ").append(tempTableName);
        db.execSQL(insertTableStringBuilder.toString());
        db.execSQL(dropTableStringBuilder.toString());
    }
}
 
Example #2
Source File: LocalKinoRepository.java    From CineLog with GNU General Public License v3.0 5 votes vote down vote up
private List<LocalKino> queryOrderBy(boolean asc, Property property) {
    QueryBuilder<LocalKino> localKinoQueryBuilder = dao.queryBuilder();

    if (asc) {
        localKinoQueryBuilder = localKinoQueryBuilder
                .orderAsc(property);
    } else {
        localKinoQueryBuilder = localKinoQueryBuilder
                .orderDesc(property);
    }

    return localKinoQueryBuilder.build().list();
}
 
Example #3
Source File: LocalAudioDataSource.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
@Override
public int getMaxIntField(Property property) {
    Cursor cursor = dao.getDatabase().rawQuery(
            new StringBuilder("select max(").append(property.columnName).append(") from ").append(PlayMusicDao.TABLENAME).toString(),
            new String[]{});
    if (cursor != null) {
        try {
            return cursor.getInt(0);
        } finally {
            cursor.close();
        }
    }
    return 0;
}
 
Example #4
Source File: AudioRepository.java    From AssistantBySDK with Apache License 2.0 4 votes vote down vote up
@Override
public int getMaxIntField(Property property) {
    return local.getMaxIntField(property);
}
 
Example #5
Source File: CloudAudioDataSource.java    From AssistantBySDK with Apache License 2.0 4 votes vote down vote up
@Override
public int getMaxIntField(Property property) {
    return 0;
}
 
Example #6
Source File: AudioDataSource.java    From AssistantBySDK with Apache License 2.0 votes vote down vote up
public int getMaxIntField(Property property);