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 MapMapMap<S, T, U, V> putEntry( R key1, S key2, T key3, U key4, V value ) { MapMapMap<S, T, U, V> map = this.get( key1 ); map = map == null ? new MapMapMap<>() : map; map.putEntry( key2, key3, key4, value ); return this.put( key1, map ); }
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; } }
DimensionalItemObject eventItem = dxLookup.get( dx ); map.putEntry( orgUnit.getId(), ao, eventItem, vl );
dataPresent.putEntry( dv.getSourceId(), dv.getDataElementId(), dv.getCategoryOptionComboId(), true );