EventQueryParams extends DataQueryParams { private void replacePeriodsWithStartEndDates() { List<Period> periods = asTypedList( getDimensionOrFilterItems( PERIOD_DIM_ID ) ); for ( Period period : periods ) { Date start = period.getStartDate(); Date end = period.getEndDate(); if ( startDate == null || ( start != null && start.before( startDate ) ) ) { startDate = start; } if ( endDate == null || ( end != null && end.after( endDate ) ) ) { endDate = end; } } removeDimensionOrFilter( PERIOD_DIM_ID ); } private  EventQueryParams(); static EventQueryParams fromDataQueryParams( DataQueryParams dataQueryParams ); @Override String getKey(); List<QueryItem> getDuplicateQueryItems(); List<QueryItem> getItemsAndItemFilters(); Set<DimensionalItemObject> getDimensionalObjectItems(); Set<Legend> getItemLegends(); Set<Option> getItemOptions(); boolean timeFieldIsValid(); boolean orgUnitFieldIsValid(); ProgramStatus getProgramStatus(); EventQueryParams removeProgramIndicatorItems(); AnalyticsAggregationType getAggregationTypeFallback(); @Override boolean isAggregationType( AggregationType type ); boolean isOrganisationUnitMode( OrganisationUnitSelectionMode mode ); boolean hasItemsOrItemFilters(); boolean isLastPeriodAggregationType(); boolean isFirstPeriodAggregationType(); boolean isFirstOrLastPeriodAggregationType(); boolean hasNonDefaultBoundaries(); boolean hasAnalyticsVariables(); boolean useIndividualQuery(); Set<OrganisationUnit> getOrganisationUnitChildren(); boolean isSorting(); boolean isPaging(); int getPageWithDefault(); int getPageSizeWithDefault(); int getOffset(); boolean hasSortOrder(); boolean hasLimit(); boolean hasEventStatus(); boolean hasValueDimension(); @Override boolean hasProgramIndicatorDimension(); boolean hasEventProgramIndicatorDimension(); boolean hasEnrollmentProgramIndicatorDimension(); boolean hasSinglePeriod(); boolean hasFilterPeriods(); boolean isProgramRegistration(); boolean hasClusterSize(); boolean hasProgramStatus(); boolean hasBbox(); boolean hasDataIdScheme(); int getSortOrderAsInt(); @Override String toString(); List<QueryItem> getItems(); List<QueryItem> getItemFilters(); DimensionalItemObject getValue(); List<ProgramIndicator> getItemProgramIndicators(); ProgramIndicator getProgramIndicator(); List<DimensionalItemObject> getAsc(); @Override List<DimensionalObject> getDimensions(); List<DimensionalItemObject> getDesc(); OrganisationUnitSelectionMode getOrganisationUnitMode(); Integer getPage(); Integer getPageSize(); SortOrder getSortOrder(); Integer getLimit(); EventOutputType getOutputType(); EventStatus getEventStatus(); boolean isCollapseDataDimensions(); boolean isCoordinatesOnly(); boolean isGeometryOnly(); boolean isAggregateData(); Long getClusterSize(); String getCoordinateField(); String getBbox(); boolean isIncludeClusterPoints(); @Override boolean isIncludeMetadataDetails(); IdScheme getDataIdScheme(); static final String EVENT_COORDINATE_FIELD; static final String ENROLLMENT_COORDINATE_FIELD; }
@Test public void testReplacePeriodsWithStartEndDates() { EventQueryParams params = new EventQueryParams.Builder() .addDimension( new BaseDimensionalObject( PERIOD_DIM_ID, DimensionType.PERIOD, Lists.newArrayList( peA, peB, peC ) ) ) .build(); assertNull( params.getStartDate() ); assertNull( params.getEndDate() ); params = new EventQueryParams.Builder( params ) .withStartEndDatesForPeriods().build(); assertEquals( new DateTime( 2014, 4, 1, 0, 0 ).toDate(), params.getStartDate() ); assertEquals( new DateTime( 2014, 6, 30, 0, 0 ).toDate(), params.getEndDate() ); }