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() : ""; }
public static TrackedEntityAttributeValue createTrackedEntityAttributeValue( char uniqueChar, TrackedEntityInstance entityInstance, TrackedEntityAttribute attribute ) { TrackedEntityAttributeValue attributeValue = new TrackedEntityAttributeValue(); attributeValue.setEntityInstance( entityInstance ); attributeValue.setAttribute( attribute ); attributeValue.setValue( "Attribute" + uniqueChar ); return attributeValue; }
/** * 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()); }
public TrackedEntityAttributeValue( TrackedEntityAttribute attribute, TrackedEntityInstance entityInstance ) { setAttribute( attribute ); setEntityInstance( entityInstance ); }
public TrackedEntityAttributeValue( TrackedEntityAttribute attribute, TrackedEntityInstance entityInstance, String value ) { setAttribute( attribute ); setEntityInstance( entityInstance ); setValue( value ); }
filter( value -> attributeValueMap.containsKey( value.getAttribute().getUid() ) ). forEach( value -> String newValue = attributeValueMap.get( value.getAttribute().getUid() ); value.setValue( newValue ); attributeValueMap.remove( value.getAttribute().getUid() ); } ); TrackedEntityAttributeValue value = new TrackedEntityAttributeValue(); value.setValue( attributeValueMap.get( key ) ); value.setAttribute( attribute );
/** * 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); }
@Override public void updateTrackedEntityAttributeValue( TrackedEntityAttributeValue attributeValue ) if ( attributeValue != null && StringUtils.isEmpty( attributeValue.getValue() ) ) if ( attributeValue == null || attributeValue.getAttribute() == null || attributeValue.getAttribute().getValueType() == null ) attributeValue.setAutoFields(); String result = dataValueIsValid( attributeValue.getValue(), attributeValue.getAttribute().getValueType() ); attributeValue.getAuditValue(), currentUserService.getCurrentUsername(), AuditType.UPDATE ); attributeValueStore.update( attributeValue ); if ( attributeValue.getAttribute().isGenerated() && attributeValue.getAttribute().getTextPattern() != null ) .useReservedValue( attributeValue.getAttribute().getTextPattern(), attributeValue.getValue() );
@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() ); attributeValue.setAutoFields(); if ( attributeValue.getAttribute().getValueType().isFile() && !addFileValue( attributeValue ) ) String.format( "FileResource with id '%s' not found", attributeValue.getValue() ) ); if ( attributeValue.getValue() != null ) if ( attributeValue.getAttribute().isGenerated() && attributeValue.getAttribute().getTextPattern() != null ) .useReservedValue( attributeValue.getAttribute().getTextPattern(), attributeValue.getValue() );
if ( readableAttributes.contains( attributeValue.getAttribute() ) ) attribute.setCreated( DateUtils.getIso8601NoTz( attributeValue.getCreated() ) ); attribute.setLastUpdated( DateUtils.getIso8601NoTz( attributeValue.getLastUpdated() ) ); attribute.setDisplayName( attributeValue.getAttribute().getDisplayName() ); attribute.setAttribute( attributeValue.getAttribute().getUid() ); attribute.setValueType( attributeValue.getAttribute().getValueType() ); attribute.setCode( attributeValue.getAttribute().getCode() ); attribute.setValue( attributeValue.getValue() ); attribute.setStoredBy( attributeValue.getStoredBy() ); attribute.setSkipSynchronization( attributeValue.getAttribute().getSkipSynchronization() );
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() ); }
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; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((entityInstance == null) ? 0 : entityInstance.hashCode()); result = prime * result + ((attribute == null) ? 0 : attribute.hashCode()); result = prime * result + ((getValue() == null) ? 0 : getValue().hashCode()); return result; }
public void addAttributeValue( TrackedEntityAttributeValue attributeValue ) { trackedEntityAttributeValues.add( attributeValue ); attributeValue.setEntityInstance( this ); }
public TrackedEntityAttributeValue() { setAutoFields(); }
private Map<String, TrackedEntityAttributeValue> getTeiAttributeValueMap( List<TrackedEntityAttributeValue> teiAttributeValues ) { return teiAttributeValues.stream().collect( Collectors.toMap( tav -> tav.getAttribute().getUid(), tav -> tav ) ); }
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; } }
public void removeAttributeValue( TrackedEntityAttributeValue attributeValue ) { trackedEntityAttributeValues.remove( attributeValue ); attributeValue.setEntityInstance( null ); }
private TrackedEntityAttributeValue createTrackedEntityAttributeValue( Map<String, String> parsedMessage, SMSCode code, TrackedEntityInstance trackedEntityInstance ) { String value = parsedMessage.get( code.getCode() ); TrackedEntityAttribute trackedEntityAttribute = code.getTrackedEntityAttribute(); TrackedEntityAttributeValue trackedEntityAttributeValue = new TrackedEntityAttributeValue(); trackedEntityAttributeValue.setAttribute( trackedEntityAttribute ); trackedEntityAttributeValue.setEntityInstance( trackedEntityInstance ); trackedEntityAttributeValue.setValue( value ); return trackedEntityAttributeValue; } }