Search in sources :

Example 1 with ListUtils

use of org.apache.commons.collections15.ListUtils in project dhis2-core by dhis2.

the class MonitoringJob method getPeriods.

private List<Period> getPeriods(MonitoringJobParameters params, Collection<ValidationRule> rules) {
    if (params.getRelativeStart() != 0 && params.getRelativeEnd() != 0) {
        Date startDate = getDateAfterAddition(new Date(), params.getRelativeStart());
        Date endDate = getDateAfterAddition(new Date(), params.getRelativeEnd());
        List<Period> periods = periodService.getPeriodsBetweenDates(startDate, endDate);
        return ListUtils.union(periods, periodService.getIntersectionPeriods(periods));
    }
    return rules.stream().map(ValidationRule::getPeriodType).distinct().map(vr -> asList(vr.createPeriod(), vr.getPreviousPeriod(vr.createPeriod()))).reduce(Lists.newArrayList(), ListUtils::union);
}
Also used : MonitoringJobParameters(org.hisp.dhis.scheduling.parameters.MonitoringJobParameters) Date(java.util.Date) PeriodService(org.hisp.dhis.period.PeriodService) DateUtils.getDateAfterAddition(org.hisp.dhis.util.DateUtils.getDateAfterAddition) MessageService(org.hisp.dhis.message.MessageService) ValidationRuleGroup(org.hisp.dhis.validation.ValidationRuleGroup) ValidationService(org.hisp.dhis.validation.ValidationService) Lists(com.google.common.collect.Lists) Arrays.asList(java.util.Arrays.asList) ValidationRuleService(org.hisp.dhis.validation.ValidationRuleService) ListUtils(org.apache.commons.collections4.ListUtils) JobType(org.hisp.dhis.scheduling.JobType) Job(org.hisp.dhis.scheduling.Job) SetUtils(org.apache.commons.collections4.SetUtils) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) Period(org.hisp.dhis.period.Period) BaseIdentifiableObject(org.hisp.dhis.common.BaseIdentifiableObject) Collection(java.util.Collection) ValidationRule(org.hisp.dhis.validation.ValidationRule) JobProgress(org.hisp.dhis.scheduling.JobProgress) ValidationAnalysisParams(org.hisp.dhis.validation.ValidationAnalysisParams) Collectors.joining(java.util.stream.Collectors.joining) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) List(java.util.List) Component(org.springframework.stereotype.Component) AllArgsConstructor(lombok.AllArgsConstructor) Transactional(org.springframework.transaction.annotation.Transactional) Period(org.hisp.dhis.period.Period) ListUtils(org.apache.commons.collections4.ListUtils) Date(java.util.Date)

Aggregations

Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 Objects (java.util.Objects)1 Collectors.joining (java.util.stream.Collectors.joining)1 AllArgsConstructor (lombok.AllArgsConstructor)1 ListUtils (org.apache.commons.collections4.ListUtils)1 SetUtils (org.apache.commons.collections4.SetUtils)1 BaseIdentifiableObject (org.hisp.dhis.common.BaseIdentifiableObject)1 MessageService (org.hisp.dhis.message.MessageService)1 Period (org.hisp.dhis.period.Period)1 PeriodService (org.hisp.dhis.period.PeriodService)1 Job (org.hisp.dhis.scheduling.Job)1 JobConfiguration (org.hisp.dhis.scheduling.JobConfiguration)1 JobProgress (org.hisp.dhis.scheduling.JobProgress)1 JobType (org.hisp.dhis.scheduling.JobType)1 MonitoringJobParameters (org.hisp.dhis.scheduling.parameters.MonitoringJobParameters)1