Search in sources :

Example 21 with EpiWeek

use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.

the class ContactsFilterForm method onApplyClick.

private void onApplyClick(EpiWeekAndDateFilterComponent<ContactDateType> weekAndDateFilter) {
    ContactCriteria criteria = getValue();
    DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter().getValue();
    Date fromDate, toDate;
    if (dateFilterOption == DateFilterOption.DATE) {
        Date dateFrom = weekAndDateFilter.getDateFromFilter().getValue();
        fromDate = dateFrom != null ? DateHelper.getStartOfDay(dateFrom) : null;
        Date dateTo = weekAndDateFilter.getDateToFilter().getValue();
        toDate = dateFrom != null ? DateHelper.getEndOfDay(dateTo) : null;
    } else {
        fromDate = DateHelper.getEpiWeekStart((EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue());
        toDate = DateHelper.getEpiWeekEnd((EpiWeek) weekAndDateFilter.getWeekToFilter().getValue());
    }
    if ((fromDate != null && toDate != null) || (fromDate == null && toDate == null)) {
        ContactDateType contactDateType = (ContactDateType) weekAndDateFilter.getDateTypeSelector().getValue();
        if (contactDateType == ContactDateType.LAST_CONTACT_DATE) {
            criteria.lastContactDateBetween(fromDate, toDate);
            criteria.reportDateBetween(null, null);
        } else {
            criteria.reportDateBetween(fromDate, toDate);
            criteria.lastContactDateBetween(null, null);
        }
        criteria.dateFilterOption(dateFilterOption);
    } else {
        weekAndDateFilter.setNotificationsForMissingFilters();
    }
}
Also used : ContactDateType(de.symeda.sormas.api.contact.ContactDateType) DateFilterOption(de.symeda.sormas.api.utils.DateFilterOption) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) Date(java.util.Date) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 22 with EpiWeek

use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.

the class WeeklyReportRegionsGrid method reload.

public void reload(int year, int week) {
    this.week = week;
    this.year = year;
    getContainer().removeAllItems();
    EpiWeek epiWeek = new EpiWeek(year, week);
    List<WeeklyReportRegionSummaryDto> summaryDtos = FacadeProvider.getWeeklyReportFacade().getSummariesPerRegion(epiWeek);
    summaryDtos.forEach(s -> getContainer().addItem(s));
}
Also used : WeeklyReportRegionSummaryDto(de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 23 with EpiWeek

use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.

the class AggregateReportsView method enter.

@Override
public void enter(ViewChangeEvent event) {
    EpiWeek epiWeekFrom = criteria.getEpiWeekFrom();
    EpiWeek epiWeekTo = criteria.getEpiWeekTo();
    String params = event.getParameters().trim();
    if (params.startsWith("?")) {
        params = params.substring(1);
        criteria.fromUrlParams(params);
    }
    if (criteria.getEpiWeekFrom() == null) {
        criteria.setEpiWeekFrom(epiWeekFrom);
    }
    if (criteria.getEpiWeekTo() == null) {
        criteria.setEpiWeekTo(epiWeekTo);
    }
    grid.reload();
}
Also used : EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 24 with EpiWeek

use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.

the class CaseFilterForm method onApplyClick.

private void onApplyClick(EpiWeekAndDateFilterComponent<CriteriaDateType> weekAndDateFilter) {
    DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter().getValue();
    Date fromDate, toDate;
    if (dateFilterOption == DateFilterOption.DATE) {
        Date dateFrom = weekAndDateFilter.getDateFromFilter().getValue();
        fromDate = dateFrom != null ? DateHelper.getStartOfDay(dateFrom) : null;
        Date dateTo = weekAndDateFilter.getDateToFilter().getValue();
        toDate = dateFrom != null ? DateHelper.getEndOfDay(dateTo) : null;
    } else {
        fromDate = DateHelper.getEpiWeekStart((EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue());
        toDate = DateHelper.getEpiWeekEnd((EpiWeek) weekAndDateFilter.getWeekToFilter().getValue());
    }
    if ((fromDate != null && toDate != null) || (fromDate == null && toDate == null)) {
        CaseCriteria criteria = getValue();
        CriteriaDateType newCaseDateType = (CriteriaDateType) weekAndDateFilter.getDateTypeSelector().getValue();
        criteria.newCaseDateBetween(fromDate, toDate, newCaseDateType != null ? newCaseDateType : NewCaseDateType.MOST_RELEVANT);
        criteria.dateFilterOption(dateFilterOption);
    } else {
        weekAndDateFilter.setNotificationsForMissingFilters();
    }
}
Also used : DateFilterOption(de.symeda.sormas.api.utils.DateFilterOption) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) CriteriaDateType(de.symeda.sormas.api.utils.criteria.CriteriaDateType) Date(java.util.Date) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 25 with EpiWeek

use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.

the class WeeklyReportFacadeEjb method saveWeeklyReport.

@Override
@RolesAllowed(UserRight._WEEKLYREPORT_CREATE)
public WeeklyReportDto saveWeeklyReport(@Valid WeeklyReportDto dto) {
    // Don't create a new report if there already is one in the database for the user/epi week combination
    WeeklyReportDto existingReport = getByEpiWeekAndUser(new EpiWeek(dto.getYear(), dto.getEpiWeek()), dto.getReportingUser());
    if (existingReport != null && !dto.getUuid().equals(existingReport.getUuid())) {
        logger.warn("Tried to create a new report for an already existing user/epi week combination (existing UUID: " + existingReport.getUuid() + "); report was not created");
        return null;
    }
    WeeklyReport report = fromDto(dto, true);
    weeklyReportService.ensurePersisted(report);
    return toDto(report);
}
Also used : WeeklyReportDto(de.symeda.sormas.api.report.WeeklyReportDto) EpiWeek(de.symeda.sormas.api.utils.EpiWeek) RolesAllowed(javax.annotation.security.RolesAllowed)

Aggregations

EpiWeek (de.symeda.sormas.api.utils.EpiWeek)34 Date (java.util.Date)24 DateFilterOption (de.symeda.sormas.api.utils.DateFilterOption)9 WeeklyReportOfficerSummaryDto (de.symeda.sormas.api.report.WeeklyReportOfficerSummaryDto)4 Test (org.junit.Test)4 Button (com.vaadin.ui.Button)3 HorizontalLayout (com.vaadin.ui.HorizontalLayout)3 MonthOfYear (de.symeda.sormas.api.MonthOfYear)3 QuarterOfYear (de.symeda.sormas.api.QuarterOfYear)3 WeeklyReportDto (de.symeda.sormas.api.report.WeeklyReportDto)3 WeeklyReportRegionSummaryDto (de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto)3 TaskCriteria (de.symeda.sormas.api.task.TaskCriteria)3 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)3 LocalDate (java.time.LocalDate)3 ArrayList (java.util.ArrayList)3 RolesAllowed (javax.annotation.security.RolesAllowed)3 Month (de.symeda.sormas.api.Month)2 Quarter (de.symeda.sormas.api.Quarter)2 Year (de.symeda.sormas.api.Year)2 EventCriteria (de.symeda.sormas.api.event.EventCriteria)2