dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #42094
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21499: Using JSON format for toString methods. Improves readability in particular when looking at long l...
------------------------------------------------------------
revno: 21499
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-12-21 14:29:54 +0100
message:
Using JSON format for toString methods. Improves readability in particular when looking at long lists of objects. Can be inserted into JSON editors for pretty-printing.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeValue.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Expression.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramDataElement.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeDimension.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityDataElementDimension.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeValue.java 2015-11-23 07:21:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/AttributeValue.java 2015-12-21 13:29:54 +0000
@@ -124,11 +124,13 @@
@Override
public String toString()
{
- return "AttributeValue{" +
- "id=" + id +
- ", attribute=" + (attribute != null ? attribute.getUid() : "") +
- ", value='" + value + '\'' +
- '}';
+ return "{" +
+ "\"class\":\"" + getClass() + "\", " +
+ "\"id\":\"" + id + "\", " +
+ "\"created\":\"" + created + "\", " +
+ "\"attribute\":" + attribute + ", " +
+ "\"value\":\"" + value + "\" " +
+ "}";
}
@JsonIgnore
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2015-11-26 18:55:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2015-12-21 13:29:54 +0000
@@ -560,15 +560,15 @@
@Override
public String toString()
{
- return "[IdentifiableObject: " +
- "id='" + id +
- "', uid='" + uid +
- "', code='" + code +
- "', name='" + name +
- "', created='" + created +
- "', lastUpdated='" + lastUpdated +
- "', class='" + getClass() + '"' +
- "']";
+ return "{" +
+ "\"class\":\"" + getClass() + "\", " +
+ "\"id\":\"" + id + "\", " +
+ "\"uid\":\"" + uid + "\", " +
+ "\"code\":\"" + code + "\", " +
+ "\"name\":\"" + name + "\", " +
+ "\"created\":\"" + created + "\", " +
+ "\"lastUpdated\":\"" + lastUpdated + "\" " +
+ "}";
}
@Override
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java 2015-12-09 17:24:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java 2015-12-21 13:29:54 +0000
@@ -578,19 +578,17 @@
@Override
public String toString()
{
- return "DataElementOperand{" +
- "id=" + id +
- ", uid=" + uid +
- ", dataElement=" + dataElement +
- ", categoryOptionCombo=" + categoryOptionCombo +
- ", dataElementId=" + dataElementId +
- ", optionComboId=" + optionComboId +
- ", operandId='" + operandId + '\'' +
- ", operandName='" + operandName + '\'' +
- ", aggregationType='" + aggregationType + '\'' +
- ", aggregationLevels=" + aggregationLevels +
- ", frequencyOrder=" + frequencyOrder +
- ", operandType='" + operandType + '\'' +
+ return "{" +
+ "\"class\":\"" + getClass() + "\", " +
+ "\"id\":\"" + id + "\", " +
+ "\"uid\":\"" + uid + "\", " +
+ "\"dataElement\":" + dataElement + ", " +
+ "\"categoryOptionCombo\":" + categoryOptionCombo + ", " +
+ "\"dataElementId\":\"" + dataElementId + "\", " +
+ "\"optionComboId\":\"" + optionComboId + "\", " +
+ "\"operandId\":\"" + operandId + "\", " +
+ "\"operandName\":\"" + operandName + "\", " +
+ "\"operandType\":\"" + operandType + "\" " +
'}';
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java 2015-12-01 10:19:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java 2015-12-21 13:29:54 +0000
@@ -136,12 +136,6 @@
&& Objects.equals( this.format, other.format );
}
- @Override
- public String toString()
- {
- return "[" + name + "]";
- }
-
// -------------------------------------------------------------------------
// Getters and setters
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Expression.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Expression.java 2015-09-16 14:49:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Expression.java 2015-12-21 13:29:54 +0000
@@ -215,13 +215,13 @@
@Override
public String toString()
{
- return "Expression{" +
- "id=" + id +
- ", expression='" + expression + '\'' +
- ", explodedExpression='" + explodedExpression + '\'' +
- ", description='" + description + '\'' +
- ", dataElementsInExpression=" + dataElementsInExpression.size() +
- '}';
+ return "{" +
+ "\"class\":\"" + getClass() + "\", " +
+ "\"id\":\"" + id + "\", " +
+ "\"expression\":\"" + expression + "\", " +
+ "\"explodedExpression\":\"" + explodedExpression + "\", " +
+ "\"description\":\"" + description + "\" " +
+ "}";
}
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramDataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramDataElement.java 2015-12-16 10:13:09 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramDataElement.java 2015-12-21 13:29:54 +0000
@@ -94,7 +94,21 @@
{
return dataElement.getValueType();
}
-
+
+ @Override
+ public String toString()
+ {
+ return "{" +
+ "\"class\":\"" + getClass() + "\", " +
+ "\"id\":\"" + id + "\", " +
+ "\"uid\":\"" + uid + "\", " +
+ "\"program\":" + program + ", " +
+ "\"dataElement\":" + dataElement + ", " +
+ "\"created\":\"" + created + "\", " +
+ "\"lastUpdated\":\"" + lastUpdated + "\" " +
+ "}";
+ }
+
// -------------------------------------------------------------------------
// DimensionalItemObject
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java 2015-12-18 09:55:21 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramTrackedEntityAttribute.java 2015-12-21 13:29:54 +0000
@@ -33,7 +33,6 @@
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-import com.google.common.base.MoreObjects;
import org.hisp.dhis.analytics.AggregationType;
import org.hisp.dhis.common.BaseDimensionalItemObject;
import org.hisp.dhis.common.BaseIdentifiableObject;
@@ -126,6 +125,20 @@
return attribute.getValueType();
}
+ @Override
+ public String toString()
+ {
+ return "{" +
+ "\"class\":\"" + getClass() + "\", " +
+ "\"id\":\"" + id + "\", " +
+ "\"uid\":\"" + uid + "\", " +
+ "\"program\":" + program + ", " +
+ "\"attribute\":" + attribute + ", " +
+ "\"created\":\"" + created + "\", " +
+ "\"lastUpdated\":\"" + lastUpdated + "\" " +
+ "}";
+ }
+
// -------------------------------------------------------------------------
// DimensionalItemObject
// -------------------------------------------------------------------------
@@ -220,18 +233,6 @@
}
@Override
- public String toString()
- {
- return MoreObjects.toStringHelper( this )
- .add( "id", id )
- .add( "attribute", attribute )
- .add( "displayInList", displayInList )
- .add( "mandatory", mandatory )
- .add( "allowFutureDate", allowFutureDate )
- .toString();
- }
-
- @Override
public void mergeWith( IdentifiableObject other, MergeStrategy strategy )
{
super.mergeWith( other, strategy );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipType.java 2015-10-05 17:45:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/relationship/RelationshipType.java 2015-12-21 13:29:54 +0000
@@ -101,10 +101,17 @@
@Override
public String toString()
{
- return "RelationshipType{" +
- "aIsToB='" + aIsToB + '\'' +
- ", bIsToA='" + bIsToA + '\'' +
- '}';
+ return "{" +
+ "\"class\":\"" + getClass() + "\", " +
+ "\"id\":\"" + id + "\", " +
+ "\"uid\":\"" + uid + "\", " +
+ "\"code\":\"" + code + "\", " +
+ "\"name\":\"" + name + "\", " +
+ "\"created\":\"" + created + "\", " +
+ "\"lastUpdated\":\"" + lastUpdated + "\", " +
+ "\"aIsToB\":\"" + aIsToB + "\", " +
+ "\"bIsToA\":\"" + bIsToA + "\" " +
+ "}";
}
@Override
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeDimension.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeDimension.java 2015-02-25 20:40:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttributeDimension.java 2015-12-21 13:29:54 +0000
@@ -97,7 +97,13 @@
@Override
public String toString()
{
- return "[Id: " + id + ", attribute: " + attribute + ", legend set: " + legendSet + ", filter: " + filter + "]";
+ return "{" +
+ "\"class\":\"" + getClass() + "\", " +
+ "\"id\":\"" + id + "\", " +
+ "\"attribute\":" + attribute + ", " +
+ "\"legendSet\":" + legendSet + ", " +
+ "\"filter\":\"" + filter + "\" " +
+ "}";
}
@Override
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityDataElementDimension.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityDataElementDimension.java 2015-02-25 20:40:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityDataElementDimension.java 2015-12-21 13:29:54 +0000
@@ -94,11 +94,17 @@
{
return dataElement != null ? dataElement.getDisplayName() : null;
}
-
+
@Override
public String toString()
{
- return "[Id: " + id + ", data element: " + dataElement + ", legend set: " + legendSet + ", filter: " + filter + "]";
+ return "{" +
+ "\"class\":\"" + getClass() + "\", " +
+ "\"id\":\"" + id + "\", " +
+ "\"dataElement\":" + dataElement + ", " +
+ "\"legendSet\":" + legendSet + ", " +
+ "\"filter\":\"" + filter + "\" " +
+ "}";
}
@Override
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2015-11-19 04:01:09 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2015-12-21 13:29:54 +0000
@@ -678,26 +678,29 @@
@Override
public String toString()
{
- return "User{" +
- "surname='" + surname + '\'' +
- ", firstName='" + firstName + '\'' +
- ", email='" + email + '\'' +
- ", phoneNumber='" + phoneNumber + '\'' +
- ", jobTitle='" + jobTitle + '\'' +
- ", introduction='" + introduction + '\'' +
- ", gender='" + gender + '\'' +
- ", birthday=" + birthday +
- ", nationality='" + nationality + '\'' +
- ", employer='" + employer + '\'' +
- ", education='" + education + '\'' +
- ", interests='" + interests + '\'' +
- ", languages='" + languages + '\'' +
- ", lastCheckedInterpretations=" + lastCheckedInterpretations +
- ", userCredentials=" + userCredentials +
- ", groups=" + groups +
- ", organisationUnits=" + organisationUnits +
- ", dataViewOrganisationUnits=" + dataViewOrganisationUnits +
- ", apps=" + apps +
- '}';
+ return "{" +
+ "\"id\":\"" + id + "\", " +
+ "\"uid\":\"" + uid + "\", " +
+ "\"created\":\"" + created + "\", " +
+ "\"lastUpdated\":\"" + lastUpdated + "\", " +
+ "\"surname\":\"" + surname + "\", " +
+ "\"firstName\":\"" + firstName + "\", " +
+ "\"email\":\"" + email + "\", " +
+ "\"phoneNumber\":\"" + phoneNumber + "\", " +
+ "\"jobTitle\":\"" + jobTitle + "\", " +
+ "\"introduction\":\"" + introduction + "\", " +
+ "\"gender\":\"" + gender + "\", " +
+ "\"birthday\":\"" + birthday + "\", " +
+ "\"nationality\":\"" + nationality + "\", " +
+ "\"employer\":\"" + employer + "\", " +
+ "\"education\":\"" + education + "\", " +
+ "\"interests\":\"" + interests + "\", " +
+ "\"languages\":\"" + languages + "\", " +
+ "\"lastCheckedInterpretations\":\"" + lastCheckedInterpretations + "\", " +
+ "\"userCredentials\":\"" + userCredentials + "\", " +
+ "\"groups\":\"" + groups + "\", " +
+ "\"organisationUnits\":\"" + organisationUnits + "\", " +
+ "\"dataViewOrganisationUnits\":\"" + dataViewOrganisationUnits + "\" " +
+ "}";
}
}