=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java 2012-05-30 11:35:01 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/Interpretation.java 2012-05-31 18:16:45 +0000 @@ -38,6 +38,7 @@ import org.hisp.dhis.common.annotation.Scanned; import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.common.view.ExportView; +import org.hisp.dhis.reporttable.ReportTable; import org.hisp.dhis.user.User; import java.util.ArrayList; @@ -53,6 +54,8 @@ { private Chart chart; + private ReportTable reportTable; + private String text; private User user; @@ -78,6 +81,13 @@ this.created = new Date(); } + public Interpretation( ReportTable reportTable, String text ) + { + this.reportTable = reportTable; + this.text = text; + this.created = new Date(); + } + // ------------------------------------------------------------------------- // Logic // ------------------------------------------------------------------------- @@ -106,6 +116,20 @@ } @JsonProperty + @JsonDeserialize( as = BaseIdentifiableObject.class ) + @JsonView( { DetailedView.class, ExportView.class } ) + @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) + public ReportTable getReportTable() + { + return reportTable; + } + + public void setReportTable( ReportTable reportTable ) + { + this.reportTable = reportTable; + } + + @JsonProperty @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE ) public String getText() === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml' --- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml 2012-05-29 20:06:58 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/interpretation/hibernate/Interpretation.hbm.xml 2012-05-31 18:16:45 +0000 @@ -15,11 +15,14 @@ + + + + - - - + === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java 2012-05-31 17:02:03 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java 2012-05-31 18:16:45 +0000 @@ -55,16 +55,16 @@ */ public abstract class AbstractCrudController { - //------------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- // Dependencies - //------------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- @Autowired protected IdentifiableObjectManager manager; - //------------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- // GET - //------------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- @RequestMapping( method = RequestMethod.GET ) public String getObjectList( @RequestParam Map parameters, Model model, HttpServletRequest request ) throws Exception @@ -103,9 +103,9 @@ return StringUtils.uncapitalize( getEntitySimpleName() ); } - //------------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- // POST - //------------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- @RequestMapping( method = RequestMethod.POST, headers = { "Content-Type=application/xml, text/xml" } ) public void postXmlObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception @@ -119,9 +119,9 @@ throw new HttpRequestMethodNotSupportedException( RequestMethod.POST.toString() ); } - //------------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- // PUT - //------------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- @RequestMapping( value = "/{uid}", method = RequestMethod.PUT, headers = { "Content-Type=application/xml, text/xml" } ) @ResponseStatus( value = HttpStatus.NO_CONTENT ) @@ -137,9 +137,9 @@ throw new HttpRequestMethodNotSupportedException( RequestMethod.PUT.toString() ); } - //------------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- // DELETE - //------------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- @RequestMapping( value = "/{uid}", method = RequestMethod.DELETE ) @ResponseStatus( value = HttpStatus.NO_CONTENT ) @@ -148,9 +148,9 @@ throw new HttpRequestMethodNotSupportedException( RequestMethod.DELETE.toString() ); } - //------------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- // Helpers - //------------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- protected List getEntityList( WebMetaData metaData, WebOptions options ) { @@ -184,9 +184,9 @@ return manager.get( getEntityClass(), uid ); } - //------------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- // Reflection helpers - //------------------------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------- private Class entityClass; === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java 2012-05-30 11:35:01 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/InterpretationController.java 2012-05-31 18:16:45 +0000 @@ -28,9 +28,13 @@ */ import org.hisp.dhis.api.utils.ContextUtils; +import org.hisp.dhis.chart.Chart; +import org.hisp.dhis.chart.ChartService; import org.hisp.dhis.common.Pager; import org.hisp.dhis.interpretation.Interpretation; import org.hisp.dhis.interpretation.InterpretationService; +import org.hisp.dhis.reporttable.ReportTable; +import org.hisp.dhis.reporttable.ReportTableService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; @@ -57,6 +61,12 @@ @Autowired private InterpretationService interpretationService; + @Autowired + private ChartService chartService; + + @Autowired + private ReportTableService reportTableService; + @Override protected List getEntityList( WebMetaData metaData, WebOptions options ) { @@ -86,11 +96,46 @@ return entityList; } - @RequestMapping( value = "/{uid}/comment", method = RequestMethod.POST ) + @RequestMapping( value = "/chart/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } ) + public void shareChartInterpretation( @PathVariable( "uid" ) String chartUid, @RequestBody String text, HttpServletResponse response ) throws IOException + { + Chart chart = chartService.getChart( chartUid ); + + if ( chart == null ) + { + ContextUtils.conflictResponse( response, "Chart identifier not valid" ); + } + + Interpretation interpretation = new Interpretation( chart, text ); + + interpretationService.saveInterpretation( interpretation ); + + ContextUtils.okResponse( response, "Chart interpretation created" ); + } + + @RequestMapping( value = "/reportTable/{uid}", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } ) + public void shareReportTableInterpretation( @PathVariable( "uid" ) String reportTableUid, @RequestBody String text, HttpServletResponse response ) throws IOException + { + ReportTable reportTable = reportTableService.getReportTable( reportTableUid ); + + if ( reportTable == null ) + { + ContextUtils.conflictResponse( response, "Report table identifier not valid" ); + } + + Interpretation interpretation = new Interpretation( reportTable, text ); + + interpretationService.saveInterpretation( interpretation ); + + ContextUtils.okResponse( response, "Report table interpretation created" ); + } + + @RequestMapping( value = "/{uid}/comment", method = RequestMethod.POST, consumes = { "text/html", "text/plain" } ) public void postComment( @PathVariable( "uid" ) String uid, @RequestBody String text, HttpServletResponse response ) throws IOException { interpretationService.addInterpretationComment( uid, text ); ContextUtils.okResponse( response, "Comment created" ); } + }