← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11198: Adding simple R script for refreshing SQL views via the API.

 

------------------------------------------------------------
revno: 11198
committer: Jason P. Pickering <jason.p.pickering@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-06-11 17:28:55 +0200
message:
  Adding simple R script for refreshing SQL views via the API.
added:
  resources/util/refreshSQLViews.R


--
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
=== added file 'resources/util/refreshSQLViews.R'
--- resources/util/refreshSQLViews.R	1970-01-01 00:00:00 +0000
+++ resources/util/refreshSQLViews.R	2013-06-11 15:28:55 +0000
@@ -0,0 +1,19 @@
+#Author: Jason P. Pickering
+#A simple script to refresh DHIS2 SQL views using R and curl
+#Modify to suit your needs
+username<-"admin"
+password<-"district"
+server<-"http://apps.dhis2.org/demo/";
+
+#Do not modify below, unless you need to.
+require(XML)
+require(RCurl)
+pass<-paste0(username,":",password)
+url<-paste0(server,"/api/sqlViews.xml")
+response<-getURL(url,userpwd=pass,httpauth = 1L, header=FALSE,ssl.verifypeer = FALSE)
+doc<-xmlTreeParse(response, useInternal = TRUE)
+top <- xmlRoot(doc)
+urls<-as.list(xmlSApply(top[[2]], xmlGetAttr, "href"))
+commands<-paste0('curl "',urls,'/execute" -X POST -u ',pass,' -v')
+for (i in 1:length(commands)) {
+system(commands[i]) }
\ No newline at end of file