dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18813
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7988: Sql view, made it possible to create sql views through the web api by appending /execute to a sql...
------------------------------------------------------------
revno: 7988
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-08-29 18:24:08 +0200
message:
Sql view, made it possible to create sql views through the web api by appending /execute to a sql view identifier.
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SqlViewController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.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-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SqlViewController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SqlViewController.java 2012-07-21 14:01:44 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SqlViewController.java 2012-08-29 16:24:08 +0000
@@ -80,4 +80,27 @@
GridUtils.toCsv( grid, response.getOutputStream() );
}
+
+ @RequestMapping( value = "/{uid}/execute", method = RequestMethod.POST )
+ public void executeView( @PathVariable( "uid" ) String uid, HttpServletResponse response )
+ {
+ SqlView sqlView = sqlViewService.getSqlViewByUid( uid );
+
+ if ( sqlView == null )
+ {
+ ContextUtils.notFoundResponse( response, "SQL view not found" );
+ return;
+ }
+
+ String result = sqlViewService.createViewTable( sqlView );
+
+ if ( result != null )
+ {
+ ContextUtils.conflictResponse( response, result );
+ }
+ else
+ {
+ ContextUtils.createdResponse( response, "SQL view created" );
+ }
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java 2012-07-21 15:46:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java 2012-08-29 16:24:08 +0000
@@ -141,6 +141,12 @@
printResponse( response, message );
}
+ public static void createdResponse( HttpServletResponse response, String message )
+ {
+ response.setStatus( HttpServletResponse.SC_CREATED );
+ printResponse( response, message );
+ }
+
public static void notFoundResponse( HttpServletResponse response, String message )
{
response.setStatus( HttpServletResponse.SC_NOT_FOUND );