use of com.ushahidi.android.app.entities.ReportCategory in project Ushahidi_Android by ushahidi.
the class ReportCategoryDao method fetchReportCategoryByReportId.
@Override
public List<ReportCategory> fetchReportCategoryByReportId(int reportId, int status) {
listReportCategories = new ArrayList<ReportCategory>();
final String[] selectionArgs = { String.valueOf(reportId), String.valueOf(status) };
final String selection = REPORT_ID + " =? AND " + STATUS + " =?";
cursor = super.query(TABLE, COLUMNS, selection, selectionArgs, null);
if (cursor != null) {
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
ReportCategory reportCategory = cursorToEntity(cursor);
listReportCategories.add(reportCategory);
cursor.moveToNext();
}
cursor.close();
}
return listReportCategories;
}
use of com.ushahidi.android.app.entities.ReportCategory in project Ushahidi_Android by ushahidi.
the class ReportCategoryDao method fetchReportCategory.
/*
* (non-Javadoc)
*
* @see
* com.ushahidi.android.app.database.IReportCategoryDao#fetchReportCategory
* (long)
*/
@Override
public List<ReportCategory> fetchReportCategory(long id) {
listReportCategories = new ArrayList<ReportCategory>();
final String[] selectionArgs = { String.valueOf(id) };
final String selection = ID + " =?";
cursor = super.query(TABLE, COLUMNS, selection, selectionArgs, null);
if (cursor != null) {
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
ReportCategory reportCategory = cursorToEntity(cursor);
listReportCategories.add(reportCategory);
cursor.moveToNext();
}
cursor.close();
}
return listReportCategories;
}
use of com.ushahidi.android.app.entities.ReportCategory in project Ushahidi_Android by ushahidi.
the class AddReportActivity method setSavedReport.
/**
* Edit existing report
*
* @author henryaddo
*/
private void setSavedReport(int reportId) {
// set text part of reports
ReportEntity report = model.fetchPendingReportById(reportId);
if (report != null) {
view.mIncidentTitle.setText(report.getIncident().getTitle());
view.mIncidentDesc.setText(report.getIncident().getDescription());
view.mLongitude.setText(String.valueOf(report.getIncident().getLongitude()));
view.mLatitude.setText(String.valueOf(report.getIncident().getLatitude()));
view.mIncidentLocation.setText(report.getIncident().getLocationName());
// set date and time
setDateAndTime(report.getIncident().getDate());
}
// set Categories.
mVectorCategories.clear();
for (ReportCategory reportCategory : model.fetchReportCategories(reportId, IReportSchema.PENDING)) {
mVectorCategories.add(reportCategory.getCategoryId());
}
setSelectedCategories(mVectorCategories);
// set the photos
pendingPhoto.refresh(id);
// set news
List<MediaEntity> newsMedia = model.fetchReportNews(reportId);
if (newsMedia != null && newsMedia.size() > 0) {
view.mNews.setText(newsMedia.get(0).getLink());
}
mIsReportEditable = mOgsDao.getReportState(id) != IOpenGeoSmsSchema.STATE_SENT;
if (!mIsReportEditable) {
View[] views = new View[] { view.mBtnAddCategory, view.mIncidentDesc, view.mIncidentLocation, view.mIncidentTitle, view.mLatitude, view.mLongitude, view.mPickDate, view.mPickTime };
for (View v : views) {
v.setEnabled(false);
}
updateMarker(report.getIncident().getLatitude(), report.getIncident().getLongitude(), true);
}
}
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;
}
Aggregations