use of de.symeda.sormas.app.backend.report.WeeklyReport in project SORMAS-Project by hzi-braunschweig.
the class WeeklyReportBackendTest method shouldCreateReportWithCases.
@Test
public void shouldCreateReportWithCases() {
TestEntityCreator.createCase();
WeeklyReport report = TestEntityCreator.createWeeklyReport(DateHelper.getEpiWeek(new Date()));
// Assure that the weekly report has an entry
assertThat(report.getTotalNumberOfCases(), is(1));
}
use of de.symeda.sormas.app.backend.report.WeeklyReport in project SORMAS-Project by hzi-braunschweig.
the class TestEntityCreator method createWeeklyReport.
public static WeeklyReport createWeeklyReport(EpiWeek epiWeek) {
WeeklyReport weeklyReport;
try {
weeklyReport = DatabaseHelper.getWeeklyReportDao().build(epiWeek);
DatabaseHelper.getWeeklyReportDao().saveAndSnapshot(weeklyReport);
} catch (DaoException e) {
throw new RuntimeException(e);
}
return DatabaseHelper.getWeeklyReportDao().queryForIdWithEmbedded(weeklyReport.getId());
}
use of de.symeda.sormas.app.backend.report.WeeklyReport in project SORMAS-Project by hzi-braunschweig.
the class TaskNotificationService method doWeeklyReportNotification.
private static void doWeeklyReportNotification(Context context, Date notificationRangeStart, Date notificationRangeEnd) {
if (ConfigProvider.hasUserRight(UserRight.WEEKLYREPORT_CREATE) && !DatabaseHelper.getFeatureConfigurationDao().isFeatureDisabled(FeatureType.WEEKLY_REPORTING)) {
// notify at 6:00
Date notificationPoint = DateHelper.addSeconds(DateHelper.getStartOfDay(new Date()), 60 * 60 * 6);
if (DateHelper.isBetween(notificationPoint, notificationRangeStart, notificationRangeEnd)) {
WeeklyReport weeklyReport = DatabaseHelper.getWeeklyReportDao().queryByEpiWeekAndUser(DateHelper.getPreviousEpiWeek(notificationPoint), ConfigProvider.getUser());
if (weeklyReport == null) {
int notificationId = (int) notificationPoint.getTime();
Intent notificationIntent = new Intent(context, ReportActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, notificationId, notificationIntent, 0);
String title = context.getResources().getString(R.string.action_submit_report);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, NotificationHelper.NOTIFICATION_CHANNEL_TASKS_ID).setTicker(title).setSmallIcon(R.mipmap.ic_launcher_foreground).setContentTitle(title).setContentText(context.getResources().getString(R.string.hint_weekly_report_confirmation_required)).setContentIntent(pi).setAutoCancel(true).setContentIntent(pi);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(notificationId, notificationBuilder.build());
}
}
}
}
use of de.symeda.sormas.app.backend.report.WeeklyReport in project SORMAS-Project by hzi-braunschweig.
the class ReportFragment method showSubmitReportConfirmationDialog.
private void showSubmitReportConfirmationDialog() {
final ConfirmationDialog confirmationDialog = new ConfirmationDialog(getActivity(), R.string.heading_confirmation_dialog, R.string.info_add_cases_before_report_submit, R.string.action_submit_report, R.string.action_cancel);
confirmationDialog.setPositiveCallback(() -> {
confirmReportTask = new DefaultAsyncTask(getContext()) {
@Override
public void onPreExecute() {
getBaseActivity().showPreloader();
}
@Override
public void doInBackground(TaskResultHolder resultHolder) throws DaoException {
WeeklyReport weeklyReport = DatabaseHelper.getWeeklyReportDao().build(getEpiWeek());
DatabaseHelper.getWeeklyReportDao().saveAndSnapshot(weeklyReport);
}
@Override
protected void onPostExecute(AsyncTaskResult<TaskResultHolder> taskResult) {
super.onPostExecute(taskResult);
getBaseActivity().hidePreloader();
Intent intent = new Intent(getContext(), ReportActivity.class);
getContext().startActivity(intent);
if (!taskResult.getResultStatus().isSuccess()) {
NotificationHelper.showNotification((NotificationContext) getActivity(), NotificationType.ERROR, taskResult.getResultStatus().getMessage());
return;
}
NotificationHelper.showNotification((NotificationContext) getActivity(), NotificationType.SUCCESS, R.string.message_weekly_report_submitted);
}
}.executeOnThreadPool();
});
confirmationDialog.show();
}
use of de.symeda.sormas.app.backend.report.WeeklyReport in project SORMAS-Project by hzi-braunschweig.
the class ReportFragment method showReportData.
protected void showReportData() {
User user = ConfigProvider.getUser();
EpiWeek epiWeek = getEpiWeek();
EpiWeekFilterOption filterOption = getEpiWeekFilterOption();
if (epiWeek == null || !ConfigProvider.hasUserRight(UserRight.WEEKLYREPORT_CREATE)) {
setVisibilityForNoData();
} else {
WeeklyReport weeklyReport = DatabaseHelper.getWeeklyReportDao().queryByEpiWeekAndUser(epiWeek, user);
if (EpiWeekFilterOption.THIS_WEEK.equals(filterOption)) {
// table is shown if the report for the last week has been confirmed; no buttons
reportDate = getResources().getString(R.string.hint_report_not_submitted);
setVisibilityForTable(false);
showPendingReport();
} else if (EpiWeekFilterOption.LAST_WEEK.equals(filterOption)) {
// table is shown, buttons are shown if the report has not been confirmed yet
if (weeklyReport == null) {
setVisibilityForTable(true);
reportDate = getResources().getString(R.string.hint_report_not_submitted);
showPendingReport();
} else {
setVisibilityForTable(false);
reportDate = DateFormatHelper.formatLocalDate(weeklyReport.getReportDateTime());
showWeeklyReport(weeklyReport);
}
} else {
// any other week;
if (weeklyReport == null) {
if (DateHelper.isEpiWeekAfter(DateHelper.getEpiWeek(new Date()), epiWeek)) {
// 'no data' hint is shown for dates in the future
setVisibilityForNoData();
reportDate = "";
showNoReport();
} else {
// table is shown for dates in the past
setVisibilityForTable(true);
reportDate = getResources().getString(R.string.hint_report_not_submitted);
showPendingReport();
}
} else {
setVisibilityForTable(false);
reportDate = DateFormatHelper.formatLocalDate(weeklyReport.getReportDateTime());
showWeeklyReport(weeklyReport);
}
}
}
}
Aggregations