private void addValueToDataMap( int orgUnitId, String aocUid, DimensionalItemObject dimItemObject, Double value, Period p, MapMapMap<Integer, String, DimensionalItemObject, Long> checkForDuplicates ) { double existingValue = ObjectUtils.firstNonNull( dataMap.getValue( orgUnitId, aocUid, dimItemObject ), 0.0 ); long periodInterval = p.getEndDate().getTime() - p.getStartDate().getTime(); Long existingPeriodInterval = checkForDuplicates.getValue( orgUnitId, aocUid, dimItemObject ); if ( existingPeriodInterval != null ) { if ( existingPeriodInterval < periodInterval ) { return; // Do not overwrite the previous value if for a shorter interval } else if ( existingPeriodInterval > periodInterval ) { existingValue = 0.0; // Overwrite previous value if for a longer interval } } dataMap.putEntry( orgUnitId, aocUid, dimItemObject, value + existingValue ); checkForDuplicates.putEntry( orgUnitId, aocUid, dimItemObject, periodInterval ); }
public void putMap( MapMapMap<S, T, U, V> map ) { for ( Entry<S, MapMap<T, U, V>> entry : map.entrySet() ) { this.putEntries( entry.getKey(), entry.getValue() ); } }
Set<String> defaultOptionComboAsSet = Sets.newHashSet( categoryService.getDefaultCategoryOptionCombo().getUid() ); Map4<OrganisationUnit, Period, String, DimensionalItemObject, Double> emptyMap4 = new Map4<>(); MapMapMap<Period, String, DimensionalItemObject, Double> emptyMapMapMap = new MapMapMap<>(); boolean usingAttributeOptions = hasAttributeOptions( aggregateDimensionItems ) || hasAttributeOptions( nonAggregateDimensionItems ); nonAggregateDataMap.get( period ), new MapMap<>() );
/** * Gets aggregated event data for the given parameters. * * @param hasAttributeOptions whether the event data has attribute options. */ private MapMapMap<Integer, String, DimensionalItemObject, Double> getEventMap( boolean hasAttributeOptions, Set<DimensionalItemObject> eventItems ) { if ( eventItems.isEmpty() ) { return new MapMapMap<>(); } DataQueryParams.Builder paramsBuilder = DataQueryParams.newBuilder() .withDataDimensionItems( Lists.newArrayList( eventItems ) ) .withAttributeOptionCombos( Lists.newArrayList() ) .withFilterPeriods( Lists.newArrayList( period ) ) .withOrganisationUnits( orgUnits ); if ( hasAttributeOptions ) { paramsBuilder.withAttributeOptionCombos( Lists.newArrayList() ); } return getEventData( paramsBuilder.build(), hasAttributeOptions ); }
/** * Evaluates the skip test expression for any sample periods in which * skip test data occurs. For any combination of period and attribute * option combo where the skip test is true, removes all sample data with * that combination of period and attribute option combo. * * @param dataMap all data values (both skip and aggregate). * @param skipTest the skip test expression. * @param constantMap constants to use in skip expression if needed. */ private void applySkipTest( MapMapMap<Period, String, DimensionalItemObject, Double> dataMap, Expression skipTest, Map<String, Double> constantMap ) { if ( skipTest != null && dataMap != null ) { for ( Period period : dataMap.keySet() ) { MapMap<String, DimensionalItemObject, Double> periodData = dataMap.get( period ); for ( String aoc : periodData.keySet() ) { Double testValue = expressionService.getExpressionValue( skipTest, periodData.get( aoc ), constantMap, null, period.getDaysInPeriod() ); if ( testValue != null && !MathUtils.isZero( testValue ) ) { periodData.remove( aoc ); } } } } }
public V getValue( R key1, S key2, T key3, U key4 ) { return this.get( key1 ) == null ? null : this.get( key1 ).getValue( key2, key3, key4 ); }
/** * Gets the data we will need for this task. */ private void getData() { getDataMap(); slidingWindowEventMap = getEventMapForSlidingWindow( true, periodTypeX.getEventItems() ); slidingWindowEventMap .putMap( getEventMapForSlidingWindow( false, periodTypeX.getEventItemsWithoutAttributeOptions() ) ); slidingWindowEventMap.putMap( dataMap ); eventMap = getEventMap( true, periodTypeX.getEventItems() ); eventMap.putMap( getEventMap( false, periodTypeX.getEventItemsWithoutAttributeOptions() ) ); dataMap.putMap( eventMap ); }
return new MapMapMap<>();
public boolean skipValidationOfTuple( OrganisationUnit organisationUnit, ValidationRule validationRule, Period period, String attributeOptionCombo, int dayInPeriod ) { List<ValidationResult> validationResultList = initialValidationResults .getValue( organisationUnit, validationRule, period ); if ( validationResultList != null ) { for ( ValidationResult vr : validationResultList ) { if ( vr.getAttributeOptionCombo().getUid().equals( attributeOptionCombo ) && vr.getDayInPeriod() == dayInPeriod ) { return true; } } } return false; }
public Builder withInitialResults( Collection<ValidationResult> results ) { this.context.validationResults.addAll( results ); results.forEach( validationResult -> { List<ValidationResult> res = context.initialValidationResults .getValue( validationResult.getOrganisationUnit(), validationResult.getValidationRule(), validationResult.getPeriod() ); if ( res == null ) { res = new ArrayList<>(); } res.add( validationResult ); context.initialValidationResults .putEntry( validationResult.getOrganisationUnit(), validationResult.getValidationRule(), validationResult.getPeriod(), res ); } ); return this; } }
MapMap<String, DimensionalItemObject, Double> periodValues = dataMap.get( period );