use of com.ushahidi.android.app.entities.ReportCategory in project Ushahidi_Android by ushahidi.
the class ReportCategoryDao method cursorToEntity.
/*
* (non-Javadoc)
*
* @see
* com.ushahidi.android.app.database.DbContentProvider#cursorToEntity(android
* .database.Cursor)
*/
@SuppressWarnings("unchecked")
@Override
protected ReportCategory cursorToEntity(Cursor cursor) {
ReportCategory reportCategory = new ReportCategory();
int idIndex;
int reportIdIndex;
int categoryIdIndex;
int statusIndex;
if (cursor != null) {
if (cursor.getColumnIndex(ID) != -1) {
idIndex = cursor.getColumnIndexOrThrow(ID);
reportCategory.setDbId(cursor.getInt(idIndex));
}
if (cursor.getColumnIndex(REPORT_ID) != -1) {
reportIdIndex = cursor.getColumnIndexOrThrow(REPORT_ID);
reportCategory.setReportId(cursor.getInt(reportIdIndex));
}
if (cursor.getColumnIndex(CATEGORY_ID) != -1) {
categoryIdIndex = cursor.getColumnIndexOrThrow(CATEGORY_ID);
reportCategory.setCategoryId(cursor.getInt(categoryIdIndex));
}
if (cursor.getColumnIndex(STATUS) != -1) {
statusIndex = cursor.getColumnIndexOrThrow(STATUS);
reportCategory.setStatus(cursor.getInt(statusIndex));
}
}
return reportCategory;
}
use of com.ushahidi.android.app.entities.ReportCategory in project Ushahidi_Android by ushahidi.
the class ReportCategoryDao method addReportCategories.
/*
* (non-Javadoc)
*
* @see
* com.ushahidi.android.app.database.IReportCategoryDao#addReportCategories
* (java.util.List)
*/
@Override
public boolean addReportCategories(List<ReportCategory> reportCategories) {
try {
mDb.beginTransaction();
for (ReportCategory reportCategory : reportCategories) {
addReportCategory(reportCategory);
}
mDb.setTransactionSuccessful();
} finally {
mDb.endTransaction();
}
return true;
}
use of com.ushahidi.android.app.entities.ReportCategory in project Ushahidi_Android by ushahidi.
the class ReportsApi method saveCategories.
/**
* Save details of categories to the database
*
* @param categoryId The ID of the category
* @param reportId The ID of the report
* @return void
*/
private void saveCategories(int categoryId, int reportId) {
ReportCategory reportCategory = new ReportCategory();
reportCategory.setCategoryId(categoryId);
reportCategory.setReportId(reportId);
reportCategory.setStatus(IReportSchema.FETCHED);
List<ReportCategory> reportCategories = new ArrayList<ReportCategory>();
reportCategories.add(reportCategory);
// save new data
Database.mReportCategoryDao.addReportCategories(reportCategories);
}
Aggregations