/** * Retrieves the encrypted value if the attribute is confidential. If the * value is not confidential, returns old value. Should be null unless it was * confidential at an earlier stage. * * @return String with decrypted value or null. */ @JsonIgnore public String getEncryptedValue() { return (getAttribute().getConfidential() && this.value != null ? this.value : this.encryptedValue); }
public TrackedEntityAttributeValueAudit( TrackedEntityAttributeValue trackedEntityAttributeValue, String value, String modifiedBy, AuditType auditType ) { this.attribute = trackedEntityAttributeValue.getAttribute(); this.entityInstance = trackedEntityAttributeValue.getEntityInstance(); this.created = new Date(); this.value = value; this.modifiedBy = modifiedBy; this.auditType = auditType; }
public void setEncryptedValue( String encryptedValue ) { this.encryptedValue = encryptedValue; if ( getAttribute().getConfidential() ) { auditValue = encryptedValue; auditValueIsSet = true; } }
/** * Retrieves the plain-text value is the attribute isn't confidential. If * the value is confidential, this value should be null, unless it was * non-confidential at an earlier stage. * * @return String with plain-text value or null. */ @JsonIgnore public String getPlainValue() { return (!getAttribute().getConfidential() && this.value != null ? this.value : this.plainValue); }
public void setPlainValue( String plainValue ) { this.plainValue = plainValue; if ( !getAttribute().getConfidential() ) { auditValue = plainValue; auditValueIsSet = true; } }
private Map<String, TrackedEntityAttributeValue> getTeiAttributeValueMap( List<TrackedEntityAttributeValue> teiAttributeValues ) { return teiAttributeValues.stream().collect( Collectors.toMap( tav -> tav.getAttribute().getUid(), tav -> tav ) ); }
@Override public int compare( TrackedEntityAttributeValue value0, TrackedEntityAttributeValue value1 ) { if ( value0 == null || value1 == null || value0.getAttribute() == null || value1.getAttribute() == null ) { return 0; } if ( value0.getAttribute().getSortOrderInListNoProgram() == null || value0.getAttribute().getSortOrderInListNoProgram() == 0 ) { return value0.getAttribute().getName().compareTo( value1.getAttribute().getName() ); } if ( value1.getAttribute().getSortOrderInListNoProgram() == null || value1.getAttribute().getSortOrderInListNoProgram() == 0 ) { return value0.getAttribute().getName().compareTo( value1.getAttribute().getName() ); } return value0.getAttribute().getSortOrderInListNoProgram() - value1.getAttribute().getSortOrderInListNoProgram(); } }
@Override protected Map<String, String> resolveTrackedEntityAttributeValues( Set<String> attributeKeys, ProgramInstance entity ) { if ( attributeKeys.isEmpty() ) { return Maps.newHashMap(); } return entity.getEntityInstance().getTrackedEntityAttributeValues().stream() .filter( av -> attributeKeys.contains( av.getAttribute().getUid() ) ) .collect( Collectors.toMap( av -> av.getAttribute().getUid(), ProgramNotificationMessageRenderer::filterValue ) ); }
@Override protected Map<String, String> resolveTrackedEntityAttributeValues( Set<String> attributeKeys, ProgramStageInstance entity ) { if ( attributeKeys.isEmpty() ) { return Maps.newHashMap(); } return entity.getProgramInstance().getEntityInstance().getTrackedEntityAttributeValues().stream() .filter( av -> attributeKeys.contains( av.getAttribute().getUid() ) ) .collect( Collectors.toMap( av -> av.getAttribute().getUid(), ProgramStageNotificationMessageRenderer::filterValue ) ); }
private static String filterValue( TrackedEntityAttributeValue av ) { String value = av.getPlainValue(); if ( value == null ) { return CONFIDENTIAL_VALUE_REPLACEMENT; } // If the AV has an OptionSet -> substitute value with the name of the Option if ( av.getAttribute().hasOptionSet() ) { value = av.getAttribute().getOptionSet().getOptionByCode( value ).getName(); } return value != null ? value : MISSING_VALUE_REPLACEMENT; } }
private static String filterValue( TrackedEntityAttributeValue av ) { String value = av.getPlainValue(); if ( value == null ) { return CONFIDENTIAL_VALUE_REPLACEMENT; } // If the AV has an OptionSet -> substitute value with the name of the Option if ( av.getAttribute().hasOptionSet() ) { value = av.getAttribute().getOptionSet().getOptionByCode( value ).getName(); } return value != null ? value : MISSING_VALUE_REPLACEMENT; }
/** * Returns the encrypted or the plain-text value based on the confidential * state of the attribute. * * @return String with value, either plain-text or decrypted. */ @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public String getValue() { return (getAttribute().getConfidential() ? this.getEncryptedValue() : this.getPlainValue()); }
@Override public void addTrackedEntityAttributeValue( TrackedEntityAttributeValue attributeValue ) if ( attributeValue == null || attributeValue.getAttribute() == null || attributeValue.getAttribute().getValueType() == null ) if ( attributeValue.getAttribute().isConfidentialBool() && !dhisConfigurationProvider.getEncryptionStatus().isOk() ) String result = dataValueIsValid( attributeValue.getValue(), attributeValue.getAttribute().getValueType() ); if ( attributeValue.getAttribute().getValueType().isFile() && !addFileValue( attributeValue ) ) if ( attributeValue.getAttribute().isGenerated() && attributeValue.getAttribute().getTextPattern() != null ) .useReservedValue( attributeValue.getAttribute().getTextPattern(), attributeValue.getValue() );
public String getTrackedEntityInstanceRecipient( TrackedEntityInstance tei, ValueType type ) { Set<TrackedEntityAttributeValue> attributeValues = tei.getTrackedEntityAttributeValues(); for ( TrackedEntityAttributeValue value : attributeValues ) { if ( value != null && value.getAttribute().getValueType().equals( type ) && value.getPlainValue() != null && !value.getPlainValue().trim().isEmpty() ) { return value.getPlainValue(); } } throw new IllegalQueryException( "Tracked entity does not have any attribute of value type: " + type.toString() ); }
filter( value -> attributeValueMap.containsKey( value.getAttribute().getUid() ) ). forEach( value -> String newValue = attributeValueMap.get( value.getAttribute().getUid() ); value.setValue( newValue ); attributeValueMap.remove( value.getAttribute().getUid() ); } );
.filter( av -> template.getRecipientProgramAttribute().getUid().equals( av.getAttribute().getUid() ) ) .map( TrackedEntityAttributeValue::getPlainValue ) .collect( Collectors.toList() );
if ( attributeValue == null || attributeValue.getAttribute() == null || attributeValue.getAttribute().getValueType() == null ) String result = dataValueIsValid( attributeValue.getValue(), attributeValue.getAttribute().getValueType() ); attributeValueStore.update( attributeValue ); if ( attributeValue.getAttribute().isGenerated() && attributeValue.getAttribute().getTextPattern() != null ) .useReservedValue( attributeValue.getAttribute().getTextPattern(), attributeValue.getValue() );
@Override public RuleEnrollment toMappedRuleEnrollment( ProgramInstance enrollment ) { if( enrollment == null ) { return null; } return RuleEnrollment.create( enrollment.getUid(), enrollment.getIncidentDate(), enrollment.getEnrollmentDate(), RuleEnrollment.Status.valueOf( enrollment.getStatus().toString() ), enrollment.getOrganisationUnit() != null ? enrollment.getOrganisationUnit().getUid() : "", enrollment.getEntityInstance().getTrackedEntityAttributeValues().stream().filter( Objects::nonNull ) .map( attr -> RuleAttributeValue.create( attr.getAttribute().getUid(), getTrackedEntityAttributeValue( attr ) ) ) .collect( Collectors.toList() ), enrollment.getProgram().getName() ); }
private void deleteFileValue( TrackedEntityAttributeValue value ) { if ( !value.getAttribute().getValueType().isFile() || fileResourceService.getFileResource( value.getValue() ) == null ) { return; } FileResource fileResource = fileResourceService.getFileResource( value.getValue() ); fileResource.setAssigned( false ); fileResourceService.updateFileResource( fileResource ); }
private String getTrackedEntityAttributeValue( TrackedEntityAttributeValue attributeValue ) { ValueType valueType = attributeValue.getAttribute().getValueType(); if ( valueType.isBoolean() ) { return attributeValue.getValue() != null ? attributeValue.getValue() : "false"; } if ( valueType.isNumeric() ) { return attributeValue.getValue() != null ? attributeValue.getValue() : "0"; } return attributeValue.getValue() != null ? attributeValue.getValue() : ""; }