=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/RedirectController.java' --- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/RedirectController.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/RedirectController.java 2013-11-12 09:04:21 +0000 @@ -31,6 +31,9 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + /** * @author Morten Olav Hansen */ @@ -38,8 +41,8 @@ public class RedirectController { @RequestMapping(value = { "/api-fred", "/" }) - public String redirectToCurrentVersion() + public void redirectToCurrentVersion( HttpServletResponse response ) throws IOException { - return "redirect:/api-fred/v1"; + response.sendRedirect( "/api-fred/v1" ); } } === modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java' --- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java 2013-11-01 13:59:33 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java 2013-11-12 09:04:21 +0000 @@ -29,7 +29,6 @@ */ import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.lang3.StringEscapeUtils; import org.hisp.dhis.api.controller.organisationunit.OrganisationUnitLevelController; import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.dataset.DataSet; @@ -48,7 +47,6 @@ import org.hisp.dhis.web.webapi.v1.exception.ETagVerificationException; import org.hisp.dhis.web.webapi.v1.exception.FacilityNotFoundException; import org.hisp.dhis.web.webapi.v1.exception.UuidFormatException; -import org.hisp.dhis.web.webapi.v1.utils.ContextUtils; import org.hisp.dhis.web.webapi.v1.utils.MessageUtils; import org.hisp.dhis.web.webapi.v1.utils.ValidationUtils; import org.hisp.dhis.web.webapi.v1.validation.group.Create; @@ -61,7 +59,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; import org.springframework.util.DigestUtils; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; @@ -246,7 +243,7 @@ } @RequestMapping( value = "", method = RequestMethod.GET ) - public String readFacilities( Model model, + public ResponseEntity readFacilities( @RequestParam( value = "updatedSince", required = false ) Date lastUpdated, @RequestParam( value = "allProperties", required = false, defaultValue = "true" ) Boolean allProperties, @RequestParam( value = "fields", required = false ) String fields, @@ -304,26 +301,7 @@ } } - setAccessRights( model ); - - model.addAttribute( "esc", StringEscapeUtils.class ); - model.addAttribute( "entity", facilities ); - ContextUtils.populateContextPath( model, request ); - model.addAttribute( "baseUrl", linkTo( FredController.class ).toString() ); - model.addAttribute( "pageName", "facilities" ); - model.addAttribute( "page", FredController.PREFIX + "/facilities.vm" ); - - if ( offset == 0 ) - { - model.addAttribute( "prevDisabled", true ); - } - - if ( (offset + (limitValue == null ? 0 : limitValue) >= organisationUnitService.getNumberOfOrganisationUnits()) ) - { - model.addAttribute( "nextDisabled", true ); - } - - return FredController.PREFIX + "/layout"; + return new ResponseEntity( facilities, HttpStatus.OK ); } private Integer getLimitValue( String limit, int defaultValue ) @@ -350,7 +328,7 @@ } @RequestMapping( value = "/{id}", method = RequestMethod.GET ) - public String readFacility( Model model, @PathVariable String id, + public ResponseEntity readFacility( @PathVariable String id, @RequestParam( value = "allProperties", required = false, defaultValue = "true" ) Boolean allProperties, @RequestParam( value = "fields", required = false ) String fields, HttpServletRequest request ) throws FacilityNotFoundException @@ -373,43 +351,7 @@ facility.setHref( facility.getHref() + ".json" ); } - setAccessRights( model ); - - model.addAttribute( "esc", StringEscapeUtils.class ); - model.addAttribute( "entity", facility ); - - List dataSets = new ArrayList( dataSetService.getAllDataSets() ); - Collections.sort( dataSets, IdentifiableObjectNameComparator.INSTANCE ); - model.addAttribute( "dataSets", dataSets ); - - ContextUtils.populateContextPath( model, request ); - - model.addAttribute( "baseUrl", linkTo( FredController.class ).toString() ); - model.addAttribute( "pageName", "facility" ); - model.addAttribute( "page", FredController.PREFIX + "/facility.vm" ); - - return FredController.PREFIX + "/layout"; - } - - private void setAccessRights( Model model ) - { - // TODO fix this, a proper mock currentuserservice should be implemented - if ( currentUserService != null && currentUserService.getCurrentUser() != null ) - { - Set authorities = currentUserService.getCurrentUser().getUserCredentials().getAllAuthorities(); - - model.addAttribute( "canCreate", authorities.contains( "F_FRED_CREATE" ) || currentUserService.currentUserIsSuper() ); - model.addAttribute( "canRead", authorities.contains( "M-dhis-web-api-fred" ) || currentUserService.currentUserIsSuper() ); - model.addAttribute( "canUpdate", authorities.contains( "F_FRED_UPDATE" ) || currentUserService.currentUserIsSuper() ); - model.addAttribute( "canDelete", authorities.contains( "F_FRED_DELETE" ) || currentUserService.currentUserIsSuper() ); - } - else - { - model.addAttribute( "canCreate", false ); - model.addAttribute( "canRead", false ); - model.addAttribute( "canUpdate", false ); - model.addAttribute( "canDelete", false ); - } + return new ResponseEntity( facility, HttpStatus.OK ); } private void addHierarchyPropertyToFacility( List organisationUnitLevels, Facility facility ) === removed file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityServiceController.java' --- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityServiceController.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityServiceController.java 1970-01-01 00:00:00 +0000 @@ -1,263 +0,0 @@ -package org.hisp.dhis.web.webapi.v1.controller; - -/* - * Copyright (c) 2004-2013, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.geotools.filter.text.cql2.CQL; -import org.geotools.filter.text.cql2.CQLException; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.web.webapi.v1.domain.Facility; -import org.hisp.dhis.web.webapi.v1.exception.DuplicateCodeException; -import org.hisp.dhis.web.webapi.v1.exception.DuplicateUidException; -import org.hisp.dhis.web.webapi.v1.exception.DuplicateUuidException; -import org.hisp.dhis.web.webapi.v1.exception.FacilityNotFoundException; -import org.hisp.dhis.web.webapi.v1.utils.ValidationUtils; -import org.hisp.dhis.web.webapi.v1.validation.group.Create; -import org.hisp.dhis.web.webapi.v1.validation.group.Update; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.filter.Filter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.core.convert.ConversionService; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import javax.validation.ConstraintViolation; -import javax.validation.Validator; -import javax.validation.groups.Default; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author Morten Olav Hansen - */ -@Controller(value = "facility-service-controller-" + FredController.PREFIX) -@RequestMapping(FacilityServiceController.RESOURCE_PATH) -@PreAuthorize("hasRole('M_dhis-web-api-fred') or hasRole('ALL')") -public class FacilityServiceController -{ - public static final String RESOURCE_PATH = "/" + FredController.PREFIX + "/facility-service"; - - @Autowired - private OrganisationUnitService organisationUnitService; - - @Autowired - private Validator validator; - - @Autowired - private ConversionService conversionService; - - @Autowired - @Qualifier("objectMapperFactoryBean") - private ObjectMapper objectMapper; - - //-------------------------------------------------------------------------- - // EXTRA WEB METHODS - //-------------------------------------------------------------------------- - - @RequestMapping(value = "/{id}/activate", method = RequestMethod.POST) - @PreAuthorize("hasRole('F_FRED_UPDATE') or hasRole('ALL')") - public ResponseEntity activateFacility( @PathVariable String id ) throws FacilityNotFoundException - { - OrganisationUnit organisationUnit = getOrganisationUnit( id ); - - if ( organisationUnit == null ) - { - throw new FacilityNotFoundException(); - } - - organisationUnit.setActive( true ); - organisationUnitService.updateOrganisationUnit( organisationUnit ); - - return new ResponseEntity( HttpStatus.OK ); - } - - @RequestMapping(value = "/{id}/deactivate", method = RequestMethod.POST) - @PreAuthorize("hasRole('F_FRED_UPDATE') or hasRole('ALL')") - public ResponseEntity deactivateFacility( @PathVariable String id ) throws FacilityNotFoundException - { - OrganisationUnit organisationUnit = getOrganisationUnit( id ); - - if ( organisationUnit == null ) - { - throw new FacilityNotFoundException(); - } - - organisationUnit.setActive( false ); - organisationUnitService.updateOrganisationUnit( organisationUnit ); - - return new ResponseEntity( HttpStatus.OK ); - } - - @RequestMapping(value = "/validate", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity validateFacilityForCreate( @RequestBody Facility facility ) throws Exception - { - Set> constraintViolations = validator.validate( facility, Default.class, Create.class ); - - String json = ValidationUtils.constraintViolationsToJson( constraintViolations ); - - HttpHeaders headers = new HttpHeaders(); - headers.add( "Content-Type", MediaType.APPLICATION_JSON_VALUE ); - - if ( constraintViolations.isEmpty() ) - { - OrganisationUnit organisationUnit = conversionService.convert( facility, OrganisationUnit.class ); - - if ( organisationUnitService.getOrganisationUnit( organisationUnit.getUuid() ) != null ) - { - throw new DuplicateUuidException(); - } - if ( organisationUnitService.getOrganisationUnit( organisationUnit.getUid() ) != null ) - { - throw new DuplicateUidException(); - } - else if ( organisationUnit.getCode() != null && organisationUnitService.getOrganisationUnitByCode( organisationUnit.getCode() ) != null ) - { - throw new DuplicateCodeException(); - } - - return new ResponseEntity( json, headers, HttpStatus.OK ); - } - else - { - return new ResponseEntity( json, headers, HttpStatus.UNPROCESSABLE_ENTITY ); - } - } - - @RequestMapping(value = "/validate", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity validateFacilityForUpdate( @RequestBody Facility facility ) throws Exception - { - Set> constraintViolations = validator.validate( facility, Default.class, Update.class ); - - String json = ValidationUtils.constraintViolationsToJson( constraintViolations ); - - HttpHeaders headers = new HttpHeaders(); - headers.add( "Content-Type", MediaType.APPLICATION_JSON_VALUE ); - - if ( constraintViolations.isEmpty() ) - { - OrganisationUnit organisationUnit = conversionService.convert( facility, OrganisationUnit.class ); - OrganisationUnit ou = organisationUnitService.getOrganisationUnit( facility.getUuid() ); - - if ( ou == null ) - { - throw new FacilityNotFoundException(); - } - else if ( organisationUnit.getCode() != null ) - { - OrganisationUnit ouByCode = organisationUnitService.getOrganisationUnitByCode( organisationUnit.getCode() ); - - if ( ouByCode != null && !ou.getUid().equals( ouByCode.getUid() ) ) - { - throw new DuplicateCodeException(); - } - } - - return new ResponseEntity( json, headers, HttpStatus.OK ); - } - else - { - return new ResponseEntity( json, headers, HttpStatus.UNPROCESSABLE_ENTITY ); - } - } - - @RequestMapping(value = "/cql", method = RequestMethod.POST, consumes = MediaType.TEXT_PLAIN_VALUE) - public ResponseEntity cqlRequest( @RequestBody String cqlString ) throws IOException, CQLException - { - HttpHeaders headers = new HttpHeaders(); - headers.add( "Content-Type", MediaType.APPLICATION_JSON_VALUE ); - - if ( cqlString == null || cqlString.isEmpty() ) - { - return new ResponseEntity( "{}", headers, HttpStatus.OK ); - } - - Filter filter = CQL.toFilter( cqlString ); - - List allOrganisationUnits = new ArrayList( organisationUnitService.getAllOrganisationUnits() ); - List facilities = new ArrayList(); - - for ( OrganisationUnit organisationUnit : allOrganisationUnits ) - { - if ( organisationUnit.getFeatureType() != null - && organisationUnit.getFeatureType().equals( OrganisationUnit.FEATURETYPE_POINT ) - && organisationUnit.getCoordinates() != null && !organisationUnit.getCoordinates().isEmpty() ) - { - SimpleFeature feature = conversionService.convert( organisationUnit, SimpleFeature.class ); - - if ( filter.evaluate( feature ) ) - { - Facility facility = conversionService.convert( organisationUnit, Facility.class ); - facilities.add( facility ); - } - } - } - - Map resultSet = new HashMap(); - resultSet.put( "facilities", facilities ); - - String json = objectMapper.writeValueAsString( resultSet ); - - return new ResponseEntity( json, headers, HttpStatus.OK ); - } - - //-------------------------------------------------------------------------- - // UTILS - //-------------------------------------------------------------------------- - - private OrganisationUnit getOrganisationUnit( String id ) - { - OrganisationUnit organisationUnit; - - if ( id.length() == 11 ) - { - organisationUnit = organisationUnitService.getOrganisationUnit( id ); - } - else - { - organisationUnit = organisationUnitService.getOrganisationUnitByUuid( id ); - } - - return organisationUnit; - } -} - === modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FredController.java' --- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FredController.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FredController.java 2013-11-12 09:04:21 +0000 @@ -28,17 +28,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import org.hisp.dhis.web.webapi.v1.utils.ContextUtils; -import org.springframework.http.MediaType; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import javax.servlet.http.HttpServletRequest; - -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; /** * @author Morten Olav Hansen @@ -50,15 +45,9 @@ { public static final String PREFIX = "v1"; - @RequestMapping(value = "", method = RequestMethod.GET, produces = { MediaType.TEXT_HTML_VALUE, MediaType.TEXT_XML_VALUE }) - public String home( Model model, HttpServletRequest request ) + @RequestMapping( value = "" ) + public void redirectToV1( HttpServletResponse response ) throws IOException { - ContextUtils.populateContextPath( model, request ); - - model.addAttribute( "baseUrl", linkTo( FredController.class ).toString() ); - model.addAttribute( "pageName", "home" ); - model.addAttribute( "page", FredController.PREFIX + "/index.vm" ); - - return FredController.PREFIX + "/layout"; + response.sendRedirect( "v1/facilities" ); } } === modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/OrganisationUnitToFacilityConverter.java' --- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/OrganisationUnitToFacilityConverter.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/OrganisationUnitToFacilityConverter.java 2013-11-12 09:04:21 +0000 @@ -67,7 +67,7 @@ try { - facility.setHref( linkTo( FacilityController.class ).slash( organisationUnit.getUid() ).toString() ); + facility.setHref( linkTo( FacilityController.class ).slash( organisationUnit.getUuid() ).toString() ); } catch ( IllegalStateException ignored ) { === modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/resources/META-INF/dhis/webapi-fred.xml' --- dhis-2/dhis-web/dhis-web-api-fred/src/main/resources/META-INF/dhis/webapi-fred.xml 2013-07-16 12:07:31 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/main/resources/META-INF/dhis/webapi-fred.xml 2013-11-12 09:04:21 +0000 @@ -49,16 +49,11 @@ - - - - - @@ -76,17 +71,6 @@ - - - - - - - - - - - === removed directory 'dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity' === removed directory 'dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1' === removed file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facilities.vm' --- dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facilities.vm 2013-03-08 09:47:01 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facilities.vm 1970-01-01 00:00:00 +0000 @@ -1,209 +0,0 @@ - - - - - -
- - -
- -
- #listContent() -
- -
- #mapContent() -
-
- -
- -#macro( listContent ) - - - - - - - - - - #foreach( $facility in $entity.facilities ) - - - - - - #end - -
NameActions
$esc.escapeHtml4($facility.name) -
- #if( $facility.active ) - - #else - - #end - -
-
- - -#end - -#macro( mapContent ) -
-
-
-#end === removed file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facility.vm' --- dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facility.vm 2013-03-08 15:09:56 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facility.vm 1970-01-01 00:00:00 +0000 @@ -1,187 +0,0 @@ - - - - -
-
-
-
- -
-
- #set( $inputSize = "span12") - -
- Facility - - - - - - - - - - - - - - - - -
- DHIS 2 - - #foreach( $identifier in $entity.identifiers ) - #if( $identifier.context == "DHIS2_CODE" ) - #set( $dhis2Code = $identifier.id ) - #end - #if( $identifier.context == "DHIS2_UID" ) - #set( $dhis2Uid = $identifier.id ) - #end - #end - - - - - - - - #set( $dhis2Parent = $entity.properties.get('parent') ) - - - - - #set( $dhis2DataSets = $entity.properties.get('dataSets') ) - - - - -
-
- - - Back -
-
- -
- -
-
- === removed file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/index.vm' --- dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/index.vm 2013-03-08 07:08:05 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/index.vm 1970-01-01 00:00:00 +0000 @@ -1,25 +0,0 @@ -
-
-

Facility Registry Expansion Development

- -

The Open Facility Registry Service Project or FRED - "Facility Registry Expansion Development" will - model the benefits of an NHIS Health Information Exchange (HIE) and provide a roadmap for implementation of the full range of - NHIS components. The development and documentation of a Facility Registry Service (a master facilities list along with - documented methods of interoperability) will provide a common and replicable solution for integrated e/mHealth systems. In - collaboration with national entities,academia, solution providers, NGOs (NetHope members) and donors, we will develop a - standards-based service that reflect national policies and regulation, using the subset of the Facility Registry Service to - illustrate how the rest of the NHIS components can be similarly orchestrated. In a repeatable fashion, FRED will complete the - design, development, and reference implementation of a Facility Registry Service and prepare for its interoperability with - existing key e/mHealth tools in multiple countries during the next 9-12 months. FRED will provide an open source, - standards-based, repeatable approach to the implementation of a Facility Registry Service; it will at the same time accommodate - unique national requirements as well as allow for continuous and evolutionary improvements. -

- -

- - Read the specification » - -

-
-
=== removed file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/layout.vm' --- dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/layout.vm 2012-12-28 11:28:02 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/layout.vm 1970-01-01 00:00:00 +0000 @@ -1,71 +0,0 @@ - - - - - - FRED Facility API v1.0 (DHIS2) - - - - - - - - - - - - - - - - - - - - - -
-
-
- #parse( $page ) -
-
-
- - - === removed directory 'dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/api-fred-resources' === removed directory 'dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/api-fred-resources/js' === removed file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/api-fred-resources/js/markerclusterer.min.js' --- dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/api-fred-resources/js/markerclusterer.min.js 2012-12-08 22:01:14 +0000 +++ dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/api-fred-resources/js/markerclusterer.min.js 1970-01-01 00:00:00 +0000 @@ -1,21 +0,0 @@ -(function(){var d=null;function e(a){return function(b){this[a]=b}}function h(a){return function(){return this[a]}}var j; -function k(a,b,c){this.extend(k,google.maps.OverlayView);this.c=a;this.a=[];this.f=[];this.ca=[53,56,66,78,90];this.j=[];this.A=!1;c=c||{};this.g=c.gridSize||60;this.l=c.minimumClusterSize||2;this.J=c.maxZoom||d;this.j=c.styles||[];this.X=c.imagePath||this.Q;this.W=c.imageExtension||this.P;this.O=!0;if(c.zoomOnClick!=void 0)this.O=c.zoomOnClick;this.r=!1;if(c.averageCenter!=void 0)this.r=c.averageCenter;l(this);this.setMap(a);this.K=this.c.getZoom();var f=this;google.maps.event.addListener(this.c, -"zoom_changed",function(){var a=f.c.getZoom();if(f.K!=a)f.K=a,f.m()});google.maps.event.addListener(this.c,"idle",function(){f.i()});b&&b.length&&this.C(b,!1)}j=k.prototype;j.Q="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/images/m";j.P="png";j.extend=function(a,b){return function(a){for(var b in a.prototype)this.prototype[b]=a.prototype[b];return this}.apply(a,[b])};j.onAdd=function(){if(!this.A)this.A=!0,n(this)};j.draw=function(){}; -function l(a){if(!a.j.length)for(var b=0,c;c=a.ca[b];b++)a.j.push({url:a.X+(b+1)+"."+a.W,height:c,width:c})}j.S=function(){for(var a=this.o(),b=new google.maps.LatLngBounds,c=0,f;f=a[c];c++)b.extend(f.getPosition());this.c.fitBounds(b)};j.z=h("j");j.o=h("a");j.V=function(){return this.a.length};j.ba=e("J");j.I=h("J");j.G=function(a,b){for(var c=0,f=a.length,g=f;g!==0;)g=parseInt(g/10,10),c++;c=Math.min(c,b);return{text:f,index:c}};j.$=e("G");j.H=h("G"); -j.C=function(a,b){for(var c=0,f;f=a[c];c++)q(this,f);b||this.i()};function q(a,b){b.s=!1;b.draggable&&google.maps.event.addListener(b,"dragend",function(){b.s=!1;a.L()});a.a.push(b)}j.q=function(a,b){q(this,a);b||this.i()};function r(a,b){var c=-1;if(a.a.indexOf)c=a.a.indexOf(b);else for(var f=0,g;g=a.a[f];f++)if(g==b){c=f;break}if(c==-1)return!1;b.setMap(d);a.a.splice(c,1);return!0}j.Y=function(a,b){var c=r(this,a);return!b&&c?(this.m(),this.i(),!0):!1}; -j.Z=function(a,b){for(var c=!1,f=0,g;g=a[f];f++)g=r(this,g),c=c||g;if(!b&&c)return this.m(),this.i(),!0};j.U=function(){return this.f.length};j.getMap=h("c");j.setMap=e("c");j.w=h("g");j.aa=e("g"); -j.v=function(a){var b=this.getProjection(),c=new google.maps.LatLng(a.getNorthEast().lat(),a.getNorthEast().lng()),f=new google.maps.LatLng(a.getSouthWest().lat(),a.getSouthWest().lng()),c=b.fromLatLngToDivPixel(c);c.x+=this.g;c.y-=this.g;f=b.fromLatLngToDivPixel(f);f.x-=this.g;f.y+=this.g;c=b.fromDivPixelToLatLng(c);b=b.fromDivPixelToLatLng(f);a.extend(c);a.extend(b);return a};j.R=function(){this.m(!0);this.a=[]}; -j.m=function(a){for(var b=0,c;c=this.f[b];b++)c.remove();for(b=0;c=this.a[b];b++)c.s=!1,a&&c.setMap(d);this.f=[]};j.L=function(){var a=this.f.slice();this.f.length=0;this.m();this.i();window.setTimeout(function(){for(var b=0,c;c=a[b];b++)c.remove()},0)};j.i=function(){n(this)}; -function n(a){if(a.A)for(var b=a.v(new google.maps.LatLngBounds(a.c.getBounds().getSouthWest(),a.c.getBounds().getNorthEast())),c=0,f;f=a.a[c];c++)if(!f.s&&b.contains(f.getPosition())){for(var g=a,u=4E4,o=d,v=0,m=void 0;m=g.f[v];v++){var i=m.getCenter();if(i){var p=f.getPosition();if(!i||!p)i=0;else var w=(p.lat()-i.lat())*Math.PI/180,x=(p.lng()-i.lng())*Math.PI/180,i=Math.sin(w/2)*Math.sin(w/2)+Math.cos(i.lat()*Math.PI/180)*Math.cos(p.lat()*Math.PI/180)*Math.sin(x/2)*Math.sin(x/2),i=6371*2*Math.atan2(Math.sqrt(i), -Math.sqrt(1-i));i=this.l&&a.setMap(d); -a=this.c.getZoom();if((b=this.k.I())&&a>b)for(a=0;b=this.a[a];a++)b.setMap(this.c);else if(this.a.length0&&a.e[0]0&&a.e[1] */ -@Ignore //TODO Enable as integration test +@Ignore public class FacilityControllerTest extends FredSpringWebTest { @Autowired @@ -72,7 +72,7 @@ MockHttpSession session = getSession( "ALL" ); mvc.perform( get( "/v1/facilities" ).session( session ).accept( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.facilities" ).isArray() ) .andExpect( status().isOk() ); } @@ -83,7 +83,7 @@ MockHttpSession session = getSession( "M_dhis-web-api-fred" ); mvc.perform( get( "/v1/facilities" ).session( session ).accept( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.facilities" ).isArray() ) .andExpect( status().isOk() ); } @@ -106,7 +106,7 @@ MockHttpSession session = getSession( "ALL" ); mvc.perform( get( "/v1/facilities" ).session( session ).accept( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.facilities" ).isArray() ) .andExpect( jsonPath( "$.facilities[0].name" ).value( "OrgUnitA" ) ) .andExpect( status().isOk() ); @@ -118,7 +118,7 @@ MockHttpSession session = getSession( "ALL" ); mvc.perform( get( "/v1/facilities/abc123" ).session( session ).accept( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.code" ).value( HttpStatus.NOT_FOUND.toString() ) ) .andExpect( status().isNotFound() ); } @@ -133,7 +133,7 @@ mvc.perform( get( "/v1/facilities/" + organisationUnit.getUid() ).session( session ).accept( MediaType.APPLICATION_JSON ) ) .andExpect( header().string( "ETag", Matchers.notNullValue() ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( status().isOk() ); } @@ -146,7 +146,7 @@ MockHttpSession session = getSession( "ALL" ); mvc.perform( get( "/v1/facilities/" + organisationUnit.getUid() ).session( session ).accept( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.uuid", Matchers.notNullValue() ) ) .andExpect( jsonPath( "$.name" ).value( "OrgUnitA" ) ) .andExpect( jsonPath( "$.active" ).value( true ) ) @@ -165,7 +165,7 @@ MockHttpSession session = getSession( "ALL" ); mvc.perform( get( "/v1/facilities/" + organisationUnit.getUuid() ).session( session ).accept( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.uuid", Matchers.notNullValue() ) ) .andExpect( jsonPath( "$.name" ).value( "OrgUnitA" ) ) .andExpect( jsonPath( "$.active" ).value( true ) ) @@ -185,7 +185,7 @@ MockHttpSession session = getSession( "ALL" ); mvc.perform( put( "/v1/facilities/INVALID_IDENTIFIER" ).content( "{}" ).session( session ).contentType( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.code" ).value( HttpStatus.NOT_FOUND.toString() ) ) .andExpect( status().isNotFound() ); } @@ -256,7 +256,7 @@ mvc.perform( put( "/v1/facilities/" + organisationUnit.getUid() ).content( objectMapper.writeValueAsString( facility ) ) .session( session ).contentType( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.uuid", Matchers.notNullValue() ) ) .andExpect( jsonPath( "$.name" ).value( "FacilityB" ) ) .andExpect( jsonPath( "$.active" ).value( false ) ) @@ -280,7 +280,7 @@ mvc.perform( put( "/v1/facilities/" + organisationUnit.getUuid() ).content( objectMapper.writeValueAsString( facility ) ) .session( session ).contentType( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.uuid", Matchers.notNullValue() ) ) .andExpect( jsonPath( "$.name" ).value( "FacilityB" ) ) .andExpect( jsonPath( "$.active" ).value( false ) ) @@ -303,7 +303,7 @@ mvc.perform( put( "/v1/facilities/" + organisationUnit.getUuid() ).content( objectMapper.writeValueAsString( facility ) ) .session( session ).contentType( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( status().isPreconditionFailed() ); } @@ -336,7 +336,7 @@ mvc.perform( post( "/v1/facilities" ).content( "{}" ) .session( session ).contentType( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( status().isUnprocessableEntity() ); } @@ -350,7 +350,7 @@ mvc.perform( post( "/v1/facilities" ).content( objectMapper.writeValueAsString( facility ) ) .session( session ).contentType( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( status().isPreconditionFailed() ); } @@ -363,7 +363,7 @@ mvc.perform( post( "/v1/facilities" ).content( objectMapper.writeValueAsString( facility ) ) .session( session ).contentType( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.uuid", Matchers.notNullValue() ) ) .andExpect( jsonPath( "$.name" ).value( "FacilityA" ) ) .andExpect( jsonPath( "$.active" ).value( true ) ) @@ -383,7 +383,7 @@ mvc.perform( post( "/v1/facilities" ).content( objectMapper.writeValueAsString( facility ) ) .session( session ).contentType( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.uuid" ).value( "aabbccdd-aabb-aabb-aabb-aabbccddeeff" ) ) .andExpect( jsonPath( "$.name" ).value( "FacilityA" ) ) .andExpect( jsonPath( "$.active" ).value( true ) ) @@ -402,7 +402,7 @@ mvc.perform( post( "/v1/facilities" ).content( objectMapper.writeValueAsString( facility ) ) .session( session ).contentType( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.uuid", Matchers.notNullValue() ) ) .andExpect( jsonPath( "$.name" ).value( "FacilityA" ) ) .andExpect( jsonPath( "$.active" ).value( false ) ) @@ -421,7 +421,7 @@ mvc.perform( post( "/v1/facilities" ).content( objectMapper.writeValueAsString( facility ) ) .session( session ).contentType( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.uuid", Matchers.notNullValue() ) ) .andExpect( jsonPath( "$.name" ).value( "FacilityA" ) ) .andExpect( jsonPath( "$.active" ).value( true ) ) @@ -432,7 +432,7 @@ mvc.perform( post( "/v1/facilities" ).content( objectMapper.writeValueAsString( facility ) ) .session( session ).contentType( MediaType.APPLICATION_JSON ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.uuid", Matchers.notNullValue() ) ) .andExpect( jsonPath( "$.name" ).value( "FacilityA" ) ) .andExpect( jsonPath( "$.active" ).value( true ) ) @@ -461,7 +461,7 @@ MockHttpSession session = getSession( "ALL" ); mvc.perform( delete( "/v1/facilities/INVALID_IDENTIFIER" ).session( session ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( jsonPath( "$.code" ).value( HttpStatus.NOT_FOUND.toString() ) ) .andExpect( status().isNotFound() ); } @@ -475,7 +475,7 @@ MockHttpSession session = getSession( "ALL" ); mvc.perform( delete( "/v1/facilities/" + organisationUnit.getUid() ).session( session ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( status().isOk() ); } @@ -488,7 +488,7 @@ MockHttpSession session = getSession( "ALL" ); mvc.perform( delete( "/v1/facilities/" + organisationUnit.getUuid() ).session( session ) ) - .andExpect( content().contentType( MediaType.APPLICATION_JSON ) ) + .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( status().isOk() ); }