EventQueryParams extends DataQueryParams { public boolean timeFieldIsValid() { if ( timeField == null ) { return true; } if ( TimeField.fieldIsValid( timeField ) ) { return true; } if ( program.getTrackedEntityAttributes().stream() .anyMatch( at -> at.getValueType().isDate() && timeField.equals( at.getUid() ) ) ) { return true; } if ( program.getDataElements().stream() .anyMatch( de -> de.getValueType().isDate() && timeField.equals( de.getUid() ) ) ) { return true; } return false; } 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 testIsTimeFieldValid() { QueryItem iA = new QueryItem( createDataElement( 'A', new CategoryCombo() ) ); EventQueryParams params = new EventQueryParams.Builder() .withProgram( prA ) .withTimeField( deC.getUid() ) .addItem( iA ).build(); assertTrue( params.timeFieldIsValid() ); params = new EventQueryParams.Builder() .withProgram( prA ) .withTimeField( TimeField.DUE_DATE.name() ) .addItem( iA ).build(); assertTrue( params.timeFieldIsValid() ); params = new EventQueryParams.Builder() .withProgram( prA ) .withTimeField( "someInvalidTimeField" ) .addItem( iA ).build(); assertFalse( params.timeFieldIsValid() ); }