dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20228
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9152: minor changes to web-api, also added back periodType setter in MapView (value is ignored, it is n...
------------------------------------------------------------
revno: 9152
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-11-29 14:22:38 +0100
message:
minor changes to web-api, also added back periodType setter in MapView (value is ignored, it is needed for POJO compliance)
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonPeriodSerializer.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonPeriodTypeDeserializer.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonPeriodTypeSerializer.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.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/JacksonPeriodSerializer.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonPeriodSerializer.java 2012-07-14 10:40:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonPeriodSerializer.java 2012-11-29 13:22:38 +0000
@@ -44,16 +44,16 @@
@Override
public void serialize( Period value, JsonGenerator jgen, SerializerProvider provider ) throws IOException, JsonProcessingException
{
- if ( value.getIsoDate() != null )
+ if ( value != null && value.getIsoDate() != null )
{
jgen.writeStartObject();
jgen.writeStringField( "id", value.getIsoDate() );
-
+
if ( value.getName() != null )
{
jgen.writeStringField( "name", value.getName() );
}
-
+
jgen.writeEndObject();
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonPeriodTypeDeserializer.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonPeriodTypeDeserializer.java 2012-03-22 13:48:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonPeriodTypeDeserializer.java 2012-11-29 13:22:38 +0000
@@ -28,7 +28,6 @@
*/
import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import org.hisp.dhis.period.PeriodType;
@@ -42,10 +41,10 @@
extends JsonDeserializer<PeriodType>
{
@Override
- public PeriodType deserialize( JsonParser jp, DeserializationContext ctxt ) throws IOException, JsonProcessingException
+ public PeriodType deserialize( JsonParser jp, DeserializationContext context ) throws IOException
{
String periodTypeString = jp.readValueAs( String.class );
- return PeriodType.getPeriodTypeByName( periodTypeString );
+ return periodTypeString == null ? null : PeriodType.getPeriodTypeByName( periodTypeString );
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonPeriodTypeSerializer.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonPeriodTypeSerializer.java 2012-03-22 13:48:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/adapter/JacksonPeriodTypeSerializer.java 2012-11-29 13:22:38 +0000
@@ -28,7 +28,6 @@
*/
import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.hisp.dhis.period.PeriodType;
@@ -42,8 +41,11 @@
extends JsonSerializer<PeriodType>
{
@Override
- public void serialize( PeriodType value, JsonGenerator jgen, SerializerProvider provider ) throws IOException, JsonProcessingException
+ public void serialize( PeriodType value, JsonGenerator jgen, SerializerProvider provider ) throws IOException
{
- jgen.writeString( value.getName() );
+ if ( value != null )
+ {
+ jgen.writeString( value.getName() );
+ }
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2012-11-19 19:06:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2012-11-29 13:22:38 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.Dxf2Namespace;
import org.hisp.dhis.common.IdentifiableObject;
@@ -71,11 +72,11 @@
public static final String LEGEND_TYPE_AUTOMATIC = "automatic";
public static final String LEGEND_TYPE_PREDEFINED = "predefined";
-
+
private static final long serialVersionUID = 1866358818802275436L;
private String layer;
-
+
private String valueType;
private IndicatorGroup indicatorGroup;
@@ -91,7 +92,7 @@
private OrganisationUnit parentOrganisationUnit;
private OrganisationUnitLevel organisationUnitLevel;
-
+
private String legendType;
private Integer method;
@@ -109,13 +110,13 @@
private Integer radiusHigh;
private Double opacity;
-
+
private OrganisationUnitGroupSet organisationUnitGroupSet;
-
+
private Integer areaRadius;
private transient String parentGraph;
-
+
private transient int parentLevel;
public MapView()
@@ -158,7 +159,7 @@
{
return indicator != null ? indicator.getName() : dataElement != null ? dataElement.getName() : uid;
}
-
+
@JsonProperty
@JsonView( {DetailedView.class, ExportView.class} )
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
@@ -251,6 +252,11 @@
return period != null ? period.getPeriodType() : null;
}
+ public void setPeriodType( PeriodType periodType )
+ {
+ // ignore
+ }
+
@JsonProperty
@JsonSerialize( using = JacksonPeriodSerializer.class )
@JsonDeserialize( using = JacksonPeriodDeserializer.class )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java 2012-09-10 08:50:51 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataValueSetController.java 2012-11-29 13:22:38 +0000
@@ -27,14 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.api.utils.ContextUtils.CONTENT_TYPE_JSON;
-import static org.hisp.dhis.api.utils.ContextUtils.CONTENT_TYPE_XML;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.servlet.http.HttpServletResponse;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.api.utils.ContextUtils;
@@ -54,6 +46,13 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.hisp.dhis.api.utils.ContextUtils.CONTENT_TYPE_JSON;
+import static org.hisp.dhis.api.utils.ContextUtils.CONTENT_TYPE_XML;
+
@Controller
@RequestMapping( value = DataValueSetController.RESOURCE_PATH )
public class DataValueSetController
@@ -61,29 +60,27 @@
public static final String RESOURCE_PATH = "/dataValueSets";
private static final Log log = LogFactory.getLog( DataValueSetController.class );
-
+
@Autowired
private DataValueSetService dataValueSetService;
@Autowired
private IntegrationService integrationService;
-
+
@RequestMapping( method = RequestMethod.GET, produces = { "text/html", "text/plain" } )
public String getDataValueSets( Model model ) throws Exception
{
DataValueSets dataValueSets = new DataValueSets();
dataValueSets.getDataValueSets().add( new DataValueSet() );
-
+
model.addAttribute( "model", dataValueSets );
return "dataValueSets";
}
@RequestMapping( method = RequestMethod.GET, produces = "application/xml" )
- public void getDataValueSet( @RequestParam String dataSet,
- @RequestParam String period,
- @RequestParam String orgUnit,
- HttpServletResponse response ) throws IOException
+ public void getDataValueSet( @RequestParam String dataSet, @RequestParam String period,
+ @RequestParam String orgUnit, HttpServletResponse response ) throws IOException
{
log.info( "Get data value set for data set: " + dataSet + ", period: " + period + ", org unit: " + orgUnit );
@@ -94,24 +91,20 @@
@RequestMapping( method = RequestMethod.POST, consumes = "application/xml" )
@PreAuthorize( "hasRole('ALL') or hasRole('F_DATAVALUE_ADD')" )
public void postDxf2DataValueSet( ImportOptions importOptions,
- HttpServletResponse response,
- InputStream in,
- Model model ) throws IOException
+ HttpServletResponse response, InputStream in, Model model ) throws IOException
{
ImportSummary summary = dataValueSetService.saveDataValueSet( in, importOptions );
- log.info( "Data values set saved " + importOptions );
+ log.info( "Data values set saved " + importOptions );
- response.setContentType( CONTENT_TYPE_XML );
+ response.setContentType( CONTENT_TYPE_XML );
JacksonUtils.toXml( response.getOutputStream(), summary );
}
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
@PreAuthorize( "hasRole('ALL') or hasRole('F_DATAVALUE_ADD')" )
public void postJsonDataValueSet( ImportOptions importOptions,
- HttpServletResponse response,
- InputStream in,
- Model model ) throws IOException
+ HttpServletResponse response, InputStream in, Model model ) throws IOException
{
ImportSummary summary = dataValueSetService.saveDataValueSetJson( in, importOptions );
@@ -124,19 +117,17 @@
@RequestMapping( method = RequestMethod.POST, consumes = "application/sdmx+xml" )
@PreAuthorize( "hasRole('ALL') or hasRole('F_DATAVALUE_ADD')" )
public void postSDMXDataValueSet( ImportOptions importOptions,
- HttpServletResponse response,
- InputStream in,
- Model model ) throws IOException
+ HttpServletResponse response, InputStream in, Model model ) throws IOException
{
ImportSummary summary = integrationService.importSDMXDataValueSet( in, importOptions );
-
- log.info( "Data values set saved " + importOptions );
-
- response.setContentType( CONTENT_TYPE_XML );
+
+ log.info( "Data values set saved " + importOptions );
+
+ response.setContentType( CONTENT_TYPE_XML );
JacksonUtils.toXml( response.getOutputStream(), summary );
}
-
- @ExceptionHandler(IllegalArgumentException.class)
+
+ @ExceptionHandler( IllegalArgumentException.class )
public void handleError( IllegalArgumentException ex, HttpServletResponse response )
throws IOException
{