← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7663: fixes deserialization issues with periods. also fixes misc namespace issues.

 

------------------------------------------------------------
revno: 7663
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-07-21 18:59:47 +0200
message:
  fixes deserialization issues with periods. also fixes misc namespace issues.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonPeriodDeserializer.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportConflict.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportCount.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportTypeSummary.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/adapter/JacksonPeriodDeserializer.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonPeriodDeserializer.java	2012-07-14 10:40:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonPeriodDeserializer.java	2012-07-21 16:59:47 +0000
@@ -29,7 +29,6 @@
 
 import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
 import com.fasterxml.jackson.databind.DeserializationContext;
 import com.fasterxml.jackson.databind.JsonDeserializer;
 import org.hisp.dhis.period.Period;
@@ -37,6 +36,37 @@
 
 import java.io.IOException;
 
+class LocalPeriod
+{
+    private String id;
+
+    private String name;
+
+    LocalPeriod()
+    {
+    }
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public void setId( String id )
+    {
+        this.id = id;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+}
+
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
@@ -47,14 +77,8 @@
     public Period deserialize( JsonParser jp, DeserializationContext ctxt )
         throws IOException, JsonProcessingException
     {
-        while ( jp.nextToken() != JsonToken.END_OBJECT )
-        {
-            if ( "id".equals( jp.getCurrentName() ) )
-            {
-                return PeriodType.getPeriodFromIsoString( jp.getText() );
-            }
-        }
-        
-        return null;        
+        LocalPeriod p = jp.readValueAs( LocalPeriod.class );
+
+        return p.getId() == null ? null : PeriodType.getPeriodFromIsoString( p.getId() );
     }
 }

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportConflict.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportConflict.java	2012-04-02 17:23:48 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportConflict.java	2012-07-21 16:59:47 +0000
@@ -30,8 +30,9 @@
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.hisp.dhis.common.Dxf2Namespace;
 
-@JacksonXmlRootElement( localName = "conflict" )
+@JacksonXmlRootElement( localName = "conflict", namespace = Dxf2Namespace.NAMESPACE )
 public class ImportConflict
 {
     private String object;

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportCount.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportCount.java	2012-06-05 15:36:07 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportCount.java	2012-07-21 16:59:47 +0000
@@ -53,7 +53,7 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty( isAttribute = true, namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( isAttribute = true )
     public int getImported()
     {
         return imported;
@@ -65,7 +65,7 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty( isAttribute = true, namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( isAttribute = true )
     public int getUpdated()
     {
         return updated;
@@ -77,7 +77,7 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty( isAttribute = true, namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( isAttribute = true )
     public int getIgnored()
     {
         return ignored;

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java	2012-06-05 15:36:07 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/importsummary/ImportSummary.java	2012-07-21 16:59:47 +0000
@@ -31,11 +31,12 @@
 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.hisp.dhis.common.Dxf2Namespace;
 
 import java.util.ArrayList;
 import java.util.List;
 
-@JacksonXmlRootElement( localName = "importSummary" )
+@JacksonXmlRootElement( localName = "importSummary", namespace = Dxf2Namespace.NAMESPACE )
 public class ImportSummary
 {
     private ImportStatus status;
@@ -59,7 +60,7 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public ImportStatus getStatus()
     {
         return status;
@@ -71,7 +72,7 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public String getDescription()
     {
         return description;
@@ -83,7 +84,7 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public ImportCount getDataValueCount()
     {
         return dataValueCount;
@@ -95,8 +96,8 @@
     }
 
     @JsonProperty
-    @JacksonXmlElementWrapper( localName = "conflicts" )
-    @JacksonXmlProperty( localName = "conflict" )
+    @JacksonXmlElementWrapper( localName = "conflicts", namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( localName = "conflict", namespace = Dxf2Namespace.NAMESPACE )
     public List<ImportConflict> getConflicts()
     {
         return conflicts;
@@ -108,7 +109,7 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty
+    @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
     public String getDataSetComplete()
     {
         return dataSetComplete;

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportTypeSummary.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportTypeSummary.java	2012-06-05 15:36:07 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/ImportTypeSummary.java	2012-07-21 16:59:47 +0000
@@ -58,7 +58,7 @@
     }
 
     @JsonProperty
-    @JacksonXmlProperty( isAttribute = true, namespace = Dxf2Namespace.NAMESPACE )
+    @JacksonXmlProperty( isAttribute = true )
     public String getType()
     {
         return type;