=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java 2016-01-04 10:26:11 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValue.java 2016-01-07 12:15:33 +0000 @@ -76,7 +76,6 @@ */ private String value; - // ------------------------------------------------------------------------- // Constructors // ------------------------------------------------------------------------- @@ -91,7 +90,8 @@ setEntityInstance( entityInstance ); } - public TrackedEntityAttributeValue( TrackedEntityAttribute attribute, TrackedEntityInstance entityInstance, String value ) + public TrackedEntityAttributeValue( TrackedEntityAttribute attribute, TrackedEntityInstance entityInstance, + String value ) { setAttribute( attribute ); setEntityInstance( entityInstance ); @@ -187,7 +187,8 @@ @Override public String toString() { - return "[Tracked attribute=" + attribute + ", entityInstance=" + entityInstance + ", value='" + getValue() + "']"; + return "[Tracked attribute=" + attribute + ", entityInstance=" + entityInstance + ", value='" + getValue() + + "']"; } // ------------------------------------------------------------------------- @@ -269,8 +270,8 @@ } /** - * Property which temporarily stores the attribute value. The - * {@link getEncryptedValue} and {@link getPlainValue} methods handle the + * Property which temporarily stores the attribute value. The + * {@link getEncryptedValue} and {@link getPlainValue} methods handle the * value when requested. * * @param value the value to be stored. === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAudit.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAudit.java 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAudit.java 2016-01-07 12:15:33 +0000 @@ -55,23 +55,32 @@ private Date created; - private String value; + private String plainValue; + + private String encryptedValue; private String modifiedBy; private AuditType auditType; + /** + * This value is only used to store values from setValue when we don't know + * if attribute is set or not. + */ + private String value; + public TrackedEntityAttributeValueAudit() { } - public TrackedEntityAttributeValueAudit( TrackedEntityAttributeValue trackedEntityAttributeValue, String value, String modifiedBy, AuditType auditType ) + 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; + setValue( value ); this.modifiedBy = modifiedBy; this.auditType = auditType; } @@ -79,7 +88,7 @@ @Override public int hashCode() { - return Objects.hash( attribute, entityInstance, created, value, modifiedBy, auditType ); + return Objects.hash( attribute, entityInstance, created, getValue(), modifiedBy, auditType ); } @Override @@ -100,7 +109,7 @@ return Objects.equals( this.attribute, other.attribute ) && Objects.equals( this.entityInstance, other.entityInstance ) && Objects.equals( this.created, other.created ) - && Objects.equals( this.value, other.value ) + && Objects.equals( this.getValue(), other.getValue() ) && Objects.equals( this.modifiedBy, other.modifiedBy ) && Objects.equals( this.auditType, other.auditType ); } @@ -115,6 +124,26 @@ this.id = id; } + public String getPlainValue() + { + return (!getAttribute().getConfidential() && this.value != null ? this.value : this.plainValue); + } + + public void setPlainValue( String plainValue ) + { + this.plainValue = plainValue; + } + + public String getEncryptedValue() + { + return (getAttribute().getConfidential() && this.value != null ? this.value : this.encryptedValue); + } + + public void setEncryptedValue( String encryptedValue ) + { + this.encryptedValue = encryptedValue; + } + @JsonProperty( "trackedEntityAttribute" ) @JacksonXmlProperty( localName = "trackedEntityAttribute", namespace = DxfNamespaces.DXF_2_0 ) public TrackedEntityAttribute getAttribute() @@ -155,9 +184,16 @@ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public String getValue() { - return value; + return (getAttribute().getConfidential() ? this.getEncryptedValue() : this.getPlainValue()); } + /** + * Property which temporarily stores the attribute value. The + * {@link getEncryptedValue} and {@link getPlainValue} methods handle the + * value when requested. + * + * @param value the value to be stored. + */ public void setValue( String value ) { this.value = value; === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValue.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValue.hbm.xml 2016-01-04 10:26:11 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValue.hbm.xml 2016-01-07 12:15:33 +0000 @@ -1,25 +1,29 @@ + "-//Hibernate/Hibernate Mapping DTD 3.0//EN" + "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValueAudit.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValueAudit.hbm.xml 2015-12-07 12:49:42 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/trackedentityattributevalue/hibernate/TrackedEntityAttributeValueAudit.hbm.xml 2016-01-07 12:15:33 +0000 @@ -1,33 +1,39 @@ + "-//Hibernate/Hibernate Mapping DTD 3.0//EN" + "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - - - - - - - - - - - - - - - - - - - org.hisp.dhis.common.AuditType - 12 - - - - + + + + + + + + + + + + + + + + + + + + + org.hisp.dhis.common.AuditType + 12 + + + +