private void addAggregateDataValue( Map4<OrganisationUnit, Period, String, DimensionalItemObject, Double> dataValues, OrganisationUnit orgUnit, Period p, CategoryOptionCombo attributeOptionCombo, DimensionalItemObject dimensionItem, String stringValue ) { Double value; try { value = Double.parseDouble( stringValue ); } catch ( NumberFormatException e ) { return; // Ignore any non-numeric values. } Double valueSoFar = dataValues.getValue( orgUnit, p, attributeOptionCombo.getUid(), dimensionItem ); if ( valueSoFar != null ) { value += valueSoFar; } dataValues.putEntry( orgUnit, p, attributeOptionCombo.getUid(), dimensionItem, value ); }
@Override public String toString() { return "[Data element: " + dataElement.getUid() + ", period: " + period.getUid() + ", source: " + source.getUid() + ", category option combo: " + categoryOptionCombo.getUid() + ", attribute option combo: " + attributeOptionCombo.getUid() + ", value: " + value + ", deleted: " + deleted + "]"; }
@Override public String toString() { return "{" + "\"class\":\"" + getClass() + "\", " + "\"id\":\"" + getId() + "\", " + "\"uid\":\"" + getUid() + "\", " + "\"code\":\"" + getCode() + "\", " + "\"categoryCombo\":" + categoryCombo + ", " + "\"categoryOptions\":" + categoryOptions + "}"; }
private void addToAocCache( CategoryOptionCombo aoc ) { context.getAocIdMap().put( aoc.getId(), aoc ); context.getAocUidMap().put( aoc.getUid(), aoc ); }
/** * Builds the actual ValidationRunContext object configured with the builder * * @return a new ValidationParam based on the builders configuration */ public ValidationRunContext build() { Validate .notNull( this.context.periodTypeXs, "Missing required property 'periodTypeXs'" ); Validate.notNull( this.context.constantMap, "Missing required property 'constantMap'" ); Validate.notNull( this.context.orgUnits, "Missing required property 'orgUnits'" ); Validate.notNull( this.context.defaultAttributeCombo, "Missing required property 'defaultAttributeCombo'" ); // Preload the caches: context.aocIdMap.put( context.defaultAttributeCombo.getId(), context.defaultAttributeCombo ); context.aocUidMap.put( context.defaultAttributeCombo.getUid(), context.defaultAttributeCombo ); for ( PeriodTypeExtended periodTypeX : context.periodTypeXs ) { for ( Period p : periodTypeX.getPeriods() ) { context.periodIdMap.putIfAbsent( p.getId(), p ); } } return this.context; }
@Override public String getUid() { String uid = null; if ( dataElement != null ) { uid = dataElement.getUid(); } if ( categoryOptionCombo != null && !categoryOptionCombo.isDefault() ) { uid += SEPARATOR + categoryOptionCombo.getUid(); } return uid; }
/** * Returns a mapping between the category option combo identifiers and names * for the given query. * * @param params the data query parameters. * @return a mapping between identifiers and names. */ public static Map<String, String> getCocNameMap( DataQueryParams params ) { Map<String, String> metaData = new HashMap<>(); List<DimensionalItemObject> des = params.getAllDataElements(); if ( !des.isEmpty() ) { for ( DimensionalItemObject de : des ) { DataElement dataElement = (DataElement) de; for ( CategoryOptionCombo coc : dataElement.getCategoryOptionCombos() ) { metaData.put( coc.getUid(), coc.getName() ); } } } return metaData; }
@Override public List<String> canWriteCached( User user, CategoryOptionCombo optionCombo ) { String cacheKey = user.getUid() + "-" + optionCombo.getUid(); return CAN_DATA_WRITE_COC_CACHE.get( cacheKey, key -> canWrite( user, optionCombo ) ); }
replacement += "." + coc.getUid();
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 String getCacheKey() { return dataApprovalLevel.getUid() + "-" + workflow.getUid() + "-" + period.getUid() + "-" + organisationUnit.getUid() + "-" + attributeOptionCombo.getUid(); }
/** * Makes sure that an attribute option combo is valid for a workflow. * * @param attributeOptionCombo attribute option combo to test. * @param workflow workflow to check against. */ private void validAttributeOptionCombo( CategoryOptionCombo attributeOptionCombo, DataApprovalWorkflow workflow ) { for ( DataSet ds : workflow.getDataSets() ) { if ( ds.getCategoryCombo().getOptionCombos().contains( attributeOptionCombo ) ) { return; } } log.info( "validateAttributeOptionCombos: attribuetOptionCombo " + attributeOptionCombo.getUid() + " not valid for workflow " + workflow.getUid() ); throw new DataMayNotBeApprovedException(); }
/** * Returns a key consisting of statusKey + attributeOptionCombo. * This can identify a particular DataApproval object in the return * set of statuses. */ private String daKey ( DataApproval da ) { return daKey( da, da.getOrganisationUnit().getUid(), da.getAttributeOptionCombo() == null ? "null" : da.getAttributeOptionCombo().getUid() ); }
@Override public Collection<ValidationRule> getValidationRulesForDataSet( DataSet dataSet ) { Set<String> elementsAndOptionCombos = new HashSet<>(); for ( DataSetElement dataSetElement : dataSet.getDataSetElements() ) { DataElement dataElement = dataSetElement.getDataElement(); elementsAndOptionCombos.add( dataElement.getUid() ); CategoryCombo catCombo = dataSetElement.hasCategoryCombo() ? dataSetElement.getCategoryCombo() : dataElement.getCategoryCombo(); for ( CategoryOptionCombo optionCombo : catCombo.getOptionCombos() ) { elementsAndOptionCombos.add( dataElement.getUid() + Expression.SEPARATOR + optionCombo.getUid() ); } } Set<ValidationRule> rulesForDataSet = new HashSet<>(); for ( ValidationRule rule : getAllFormValidationRules() ) { if ( !Sets.intersection( expressionService.getElementsAndOptionCombosInExpression( rule.getLeftSide().getExpression() ), elementsAndOptionCombos ).isEmpty() || !Sets.intersection( expressionService.getElementsAndOptionCombosInExpression( rule.getRightSide().getExpression() ), elementsAndOptionCombos ).isEmpty() ) { rulesForDataSet.add( rule ); } } return rulesForDataSet; }
public MetaDataProperties initMetaDataProperties( org.hisp.dhis.dxf2.dataset.CompleteDataSetRegistration cdsr, MetaDataCallables callables, MetaDataCaches cache ) { String ds = StringUtils.trimToNull( cdsr.getDataSet() ); String pe = StringUtils.trimToNull( cdsr.getPeriod() ); String ou = StringUtils.trimToNull( cdsr.getOrganisationUnit() ); String aoc = StringUtils.trimToNull( cdsr.getAttributeOptionCombo() ); if ( aoc == null ) { CategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( cdsr.getCc(), cdsr.getCp(), false ); aoc = attributeOptionCombo != null ? attributeOptionCombo.getUid() : aoc; } return new MetaDataProperties( cache.dataSets.get( ds, callables.dataSetCallable.setId( ds ) ), cache.periods.get( pe, callables.periodCallable.setId( pe ) ), cache.orgUnits.get( ou, callables.orgUnitCallable.setId( ou ) ), cache.attrOptionCombos.get( aoc, callables.optionComboCallable.setId( aoc ) ) ); }
aocValues.putEntries( context.getDefaultAttributeCombo().getUid(), nonAocValues );
/** * Returns a key for a data approval object, consisting of the UIDs * of all the approval object dimensions that uniquely define it. * * @param da the data approval object. * @return a key for the object. */ private String approvalKey( DataApproval da ) { return da.getDataApprovalLevel().getUid() + da.getWorkflow().getUid() + da.getPeriod().getCode() + da.getOrganisationUnit().getUid() + da.getAttributeOptionCombo().getUid(); }
Period p = getPeriod( dv.getPeriodId() ); int orgUnitId = dv.getSourceId(); String attributeOptionComboUid = getAttributeOptionCombo( dv.getAttributeOptionComboId() ).getUid(); String valueString = dv.getValue(); Double value;
SimpleNode simpleNode = complexNode.addChild( new SimpleNode( "categoryOptionCombo", categoryOptionCombo.getUid() ) ); simpleNode.setAttribute( true );