dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #34951
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17928: minor refactor in JacksonTEIService, move adding of TEI to outside of deserialization try-catch b...
------------------------------------------------------------
revno: 17928
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-01-09 21:12:28 +0700
message:
minor refactor in JacksonTEIService, move adding of TEI to outside of deserialization try-catch block
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupAccess.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.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/common/BaseIdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2014-12-29 18:17:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2015-01-09 14:12:28 +0000
@@ -28,34 +28,32 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import org.apache.commons.lang.Validate;
import org.hisp.dhis.acl.Access;
import org.hisp.dhis.acl.AccessStringHelper;
import org.hisp.dhis.common.annotation.Description;
+import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.DimensionalView;
-import org.hisp.dhis.common.view.SharingBasicView;
-import org.hisp.dhis.common.view.SharingDetailedView;
-import org.hisp.dhis.common.view.SharingExportView;
+import org.hisp.dhis.common.view.ExportView;
import org.hisp.dhis.schema.PropertyType;
import org.hisp.dhis.schema.annotation.Property;
import org.hisp.dhis.schema.annotation.PropertyRange;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserGroupAccess;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
/**
* @author Bob Jolliffe
@@ -281,7 +279,7 @@
@Override
@JsonProperty
- @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class } )
+ @JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
@PropertyRange( min = 8, max = 8 )
public String getPublicAccess()
@@ -296,7 +294,7 @@
@Override
@JsonProperty
- @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class } )
+ @JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public boolean getExternalAccess()
{
@@ -310,7 +308,7 @@
@Override
@JsonProperty
- @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class } )
+ @JsonView( { DetailedView.class, ExportView.class } )
@JsonSerialize( as = BaseIdentifiableObject.class )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public User getUser()
@@ -325,7 +323,7 @@
@Override
@JsonProperty
- @JsonView( { SharingBasicView.class, SharingDetailedView.class, SharingExportView.class } )
+ @JsonView( { DetailedView.class, ExportView.class } )
@JacksonXmlElementWrapper( localName = "userGroupAccesses", namespace = DxfNamespaces.DXF_2_0 )
@JacksonXmlProperty( localName = "userGroupAccess", namespace = DxfNamespaces.DXF_2_0 )
public Set<UserGroupAccess> getUserGroupAccesses()
@@ -340,6 +338,7 @@
@Override
@JsonProperty
+ @JsonView( { DetailedView.class } )
@JacksonXmlProperty( localName = "access", namespace = DxfNamespaces.DXF_2_0 )
public Access getAccess()
{
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupAccess.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupAccess.java 2014-12-29 16:03:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserGroupAccess.java 2015-01-09 14:12:28 +0000
@@ -29,10 +29,8 @@
*/
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.DxfNamespaces;
/**
@@ -74,8 +72,12 @@
}
@JsonProperty
- @JsonSerialize( as = BaseIdentifiableObject.class )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+ public String userGroupUid()
+ {
+ return userGroup != null ? userGroup.getUid() : null;
+ }
+
public UserGroup getUserGroup()
{
return userGroup;
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java 2014-11-06 13:26:50 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/JacksonTrackedEntityInstanceService.java 2015-01-09 14:12:28 +0000
@@ -28,18 +28,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StreamUtils;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -99,20 +98,21 @@
ImportSummaries importSummaries = new ImportSummaries();
String input = StreamUtils.copyToString( inputStream, Charset.forName( "UTF-8" ) );
+ TrackedEntityInstances trackedEntityInstances = new TrackedEntityInstances();
+
try
{
- TrackedEntityInstances trackedEntityInstances = fromXml( input, TrackedEntityInstances.class );
-
- for ( TrackedEntityInstance trackedEntityInstance : trackedEntityInstances.getTrackedEntityInstances() )
- {
- trackedEntityInstance.setTrackedEntityInstance( null );
- importSummaries.addImportSummary( addTrackedEntityInstance( trackedEntityInstance ) );
- }
+ TrackedEntityInstances fromXml = fromXml( input, TrackedEntityInstances.class );
+ trackedEntityInstances.getTrackedEntityInstances().addAll( fromXml.getTrackedEntityInstances() );
}
catch ( Exception ex )
{
- TrackedEntityInstance trackedEntityInstance = fromXml( input, TrackedEntityInstance.class );
- trackedEntityInstance.setTrackedEntityInstance( null );
+ TrackedEntityInstance fromXml = fromXml( input, TrackedEntityInstance.class );
+ trackedEntityInstances.getTrackedEntityInstances().add( fromXml );
+ }
+
+ for ( TrackedEntityInstance trackedEntityInstance : trackedEntityInstances.getTrackedEntityInstances() )
+ {
importSummaries.addImportSummary( addTrackedEntityInstance( trackedEntityInstance ) );
}
@@ -125,18 +125,21 @@
ImportSummaries importSummaries = new ImportSummaries();
String input = StreamUtils.copyToString( inputStream, Charset.forName( "UTF-8" ) );
+ TrackedEntityInstances trackedEntityInstances = new TrackedEntityInstances();
+
try
{
- TrackedEntityInstances trackedEntityInstances = fromJson( input, TrackedEntityInstances.class );
-
- for ( TrackedEntityInstance trackedEntityInstance : trackedEntityInstances.getTrackedEntityInstances() )
- {
- importSummaries.addImportSummary( addTrackedEntityInstance( trackedEntityInstance ) );
- }
+ TrackedEntityInstances fromJson = fromJson( input, TrackedEntityInstances.class );
+ trackedEntityInstances.getTrackedEntityInstances().addAll( fromJson.getTrackedEntityInstances() );
}
catch ( Exception ex )
{
- TrackedEntityInstance trackedEntityInstance = fromJson( input, TrackedEntityInstance.class );
+ TrackedEntityInstance fromJson = fromJson( input, TrackedEntityInstance.class );
+ trackedEntityInstances.getTrackedEntityInstances().add( fromJson );
+ }
+
+ for ( TrackedEntityInstance trackedEntityInstance : trackedEntityInstances.getTrackedEntityInstances() )
+ {
importSummaries.addImportSummary( addTrackedEntityInstance( trackedEntityInstance ) );
}