@Override public ValidationAnalysisParams.Builder newParamsBuilder( ValidationRuleGroup validationRuleGroup, OrganisationUnit organisationUnit, Date startDate, Date endDate ) { Collection<ValidationRule> validationRules = validationRuleGroup != null ? validationRuleGroup.getMembers() : validationRuleService.getAllValidationRules(); Collection<Period> periods = periodService.getPeriodsBetweenDates( startDate, endDate ); return new ValidationAnalysisParams.Builder( validationRules, organisationUnit, periods); }
@Override @Transactional public List<DataSetCompletenessResult> getDataSetCompleteness( int periodId, Collection<Integer> organisationUnitIds, int dataSetId, Set<Integer> groupIds ) { final DataSet dataSet = dataSetService.getDataSet( dataSetId ); final Period period = periodService.getPeriod( periodId ); final List<Integer> periodsBetweenDates = getIdentifiers( periodService.getPeriodsBetweenDates( dataSet.getPeriodType(), period.getStartDate(), period.getEndDate() ) ); final Map<Integer, OrganisationUnit> orgUnits = Maps.uniqueIndex( organisationUnitService.getOrganisationUnits( organisationUnitIds ), OrganisationUnit::getId ); final Set<OrganisationUnitGroup> groups = groupIds != null ? Sets.newHashSet( idObjectManager.getObjects( OrganisationUnitGroup.class, groupIds ) ) : null; final List<DataSetCompletenessResult> results = new ArrayList<>(); for ( final Integer unitId : organisationUnitIds ) { final OrganisationUnit unit = orgUnits.get( unitId ); final Set<Integer> children = organisationUnitService.getOrganisationUnitHierarchy().getChildren( unit.getId() ); final Set<Integer> relevantSources = getRelevantSources( dataSet, children, groups ); final DataSetCompletenessResult result = getDataSetCompleteness( period, periodsBetweenDates, unit, relevantSources, dataSet ); if ( result.getSources() > 0 ) { results.add( result ); } } return results; }
Date endDate = DateUtils.getDateAfterAddition( new Date(), monitoringJobParameters.getRelativeEnd() ); periods = periodService.getPeriodsBetweenDates( startDate, endDate );
periodService.getPeriodsBetweenDates( dataSet.getPeriodType(), period.getStartDate(), period.getEndDate() ) );