private void createDesignDocForAggregations ( ) throws URISyntaxException , UnsupportedEncodingException , IOException , ClientProtocolException { HttpResponse response = null ; URI uri = new URI ( CouchDBConstants . PROTOCOL , null , httpHost . getHostName ( ) , httpHost . getPort ( ) , CouchDBConstants . URL_SEPARATOR + databaseName . toLowerCase ( ) + CouchDBConstants . URL_SEPARATOR + "_design/" + CouchDBConstants . AGGREGATIONS , null , null ) ; HttpPut put = new HttpPut ( uri ) ; CouchDBDesignDocument designDocument = new CouchDBDesignDocument ( ) ; Map < String , MapReduce > views = new HashMap < String , CouchDBDesignDocument . MapReduce > ( ) ; designDocument . setLanguage ( CouchDBConstants . LANGUAGE ) ; createViewForCount ( views ) ; createViewForSum ( views ) ; createViewForMax ( views ) ; createViewForMin ( views ) ; createViewForAvg ( views ) ; designDocument . setViews ( views ) ; String jsonObject = gson . toJson ( designDocument ) ; StringEntity entity = new StringEntity ( jsonObject ) ; put . setEntity ( entity ) ; try { response = httpClient . execute ( httpHost , put , CouchDBUtils . getContext ( httpHost ) ) ; } finally { CouchDBUtils . closeContent ( response ) ; } }
Creates the design doc for aggregations .