← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14233: more renamings of tracker controllers

 

------------------------------------------------------------
revno: 14233
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-03-17 09:46:22 +0100
message:
  more renamings of tracker controllers
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EnrollmentController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityInstanceController.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/event/EnrollmentController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EnrollmentController.java	2014-03-17 08:22:01 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EnrollmentController.java	2014-03-17 08:46:22 +0000
@@ -87,14 +87,14 @@
     public String getEnrollments(
         @RequestParam( value = "orgUnit", required = false ) String orgUnitUid,
         @RequestParam( value = "program", required = false ) String programUid,
-        @RequestParam( value = "person", required = false ) String personUid,
+        @RequestParam( value = "trackedEntityInstance", required = false ) String trackedEntityInstanceUid,
         @RequestParam( value = "status", required = false ) EnrollmentStatus status,
         @RequestParam Map<String, String> parameters, Model model ) throws NotFoundException
     {
         WebOptions options = new WebOptions( parameters );
         Enrollments enrollments;
 
-        if ( orgUnitUid == null && programUid == null && personUid == null )
+        if ( orgUnitUid == null && programUid == null && trackedEntityInstanceUid == null )
         {
             enrollments = status != null ? enrollmentService.getEnrollments( status ) : enrollmentService.getEnrollments();
         }
@@ -105,10 +105,10 @@
 
             enrollments = enrollmentService.getEnrollments( program, organisationUnit );
         }
-        else if ( programUid != null && personUid != null )
+        else if ( programUid != null && trackedEntityInstanceUid != null )
         {
             Program program = getProgram( programUid );
-            TrackedEntityInstance trackedEntityInstance = getPerson( personUid );
+            TrackedEntityInstance trackedEntityInstance = getTrackedEntityInstance( trackedEntityInstanceUid );
 
             enrollments = status != null ? enrollmentService.getEnrollments( program, trackedEntityInstance, status )
                 : enrollmentService.getEnrollments( program, trackedEntityInstance );
@@ -126,7 +126,7 @@
         }
         else
         {
-            TrackedEntityInstance trackedEntityInstance = getPerson( personUid );
+            TrackedEntityInstance trackedEntityInstance = getTrackedEntityInstance( trackedEntityInstanceUid );
             enrollments = status != null ? enrollmentService.getEnrollments( trackedEntityInstance, status ) : enrollmentService.getEnrollments( trackedEntityInstance );
         }
 
@@ -271,13 +271,13 @@
         return enrollment;
     }
 
-    private TrackedEntityInstance getPerson( String id ) throws NotFoundException
+    private TrackedEntityInstance getTrackedEntityInstance( String id ) throws NotFoundException
     {
         TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getTrackedEntityInstance( id );
 
         if ( trackedEntityInstance == null )
         {
-            throw new NotFoundException( "Person", id );
+            throw new NotFoundException( "TrackedEntityInstance", id );
         }
 
         return trackedEntityInstance;

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityInstanceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityInstanceController.java	2014-03-17 08:22:01 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityInstanceController.java	2014-03-17 08:46:22 +0000
@@ -104,7 +104,7 @@
 
         if ( attributeFilters != null )
         {
-            trackedEntityInstances = personsByFilter( attributeFilters, orgUnitUid );
+            trackedEntityInstances = trackedEntityInstancesByFilter( attributeFilters, orgUnitUid );
         }
         else if ( orgUnitUid != null )
         {
@@ -129,11 +129,11 @@
         model.addAttribute( "model", trackedEntityInstances );
         model.addAttribute( "viewClass", options.getViewClass( "basic" ) );
 
-        return "persons";
+        return "trackedEntityInstances";
     }
 
     @SuppressWarnings( "unchecked" )
-    private TrackedEntityInstances personsByFilter( List<String> attributeFilters, String orgUnitUid )
+    private TrackedEntityInstances trackedEntityInstancesByFilter( List<String> attributeFilters, String orgUnitUid )
     {
         Criteria criteria = sessionFactory.getCurrentSession().createCriteria( org.hisp.dhis.trackedentity.TrackedEntityInstance.class );
         criteria.createAlias( "attributeValues", "attributeValue" );
@@ -173,7 +173,7 @@
 
             if ( attribute == null )
             {
-                throw new HttpClientErrorException( HttpStatus.BAD_REQUEST, "PersonAttribute with UID " + split[0] + " does not exist." );
+                throw new HttpClientErrorException( HttpStatus.BAD_REQUEST, "TrackedEntityAttribute with UID " + split[0] + " does not exist." );
             }
 
             if ( "like".equals( split[1].toLowerCase() ) )
@@ -236,16 +236,16 @@
 
     @RequestMapping( value = "/{id}", method = RequestMethod.GET )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_ACCESS_PATIENT_ATTRIBUTES')" )
-    public String getPerson( @PathVariable String id, @RequestParam Map<String, String> parameters, Model model )
+    public String getTrackedEntityInstance( @PathVariable String id, @RequestParam Map<String, String> parameters, Model model )
         throws NotFoundException
     {
         WebOptions options = new WebOptions( parameters );
-        TrackedEntityInstance trackedEntityInstance = getPerson( id );
+        TrackedEntityInstance trackedEntityInstance = getTrackedEntityInstance( id );
 
         model.addAttribute( "model", trackedEntityInstance );
         model.addAttribute( "viewClass", options.getViewClass( "detailed" ) );
 
-        return "person";
+        return "trackedEntityInstance";
     }
 
     // -------------------------------------------------------------------------
@@ -254,7 +254,7 @@
 
     @RequestMapping( value = "", method = RequestMethod.POST, consumes = MediaType.APPLICATION_XML_VALUE )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_PATIENT_ADD')" )
-    public void postPersonXml( HttpServletRequest request, HttpServletResponse response )
+    public void postTrackedEntityInstanceXml( HttpServletRequest request, HttpServletResponse response )
         throws IOException
     {
         ImportSummaries importSummaries = trackedEntityInstanceService.saveTrackedEntityInstanceXml( request.getInputStream() );
@@ -280,7 +280,7 @@
 
     @RequestMapping( value = "", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_PATIENT_ADD')" )
-    public void postPersonJson( HttpServletRequest request, HttpServletResponse response )
+    public void postTrackedEntityInstanceJson( HttpServletRequest request, HttpServletResponse response )
         throws IOException
     {
         ImportSummaries importSummaries = trackedEntityInstanceService.saveTrackedEntityInstanceJson( request.getInputStream() );
@@ -311,7 +311,7 @@
     @RequestMapping( value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_XML_VALUE )
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_PATIENT_ADD')" )
-    public void updatePersonXml( @PathVariable String id, HttpServletRequest request, HttpServletResponse response )
+    public void updateTrackedEntityInstanceXml( @PathVariable String id, HttpServletRequest request, HttpServletResponse response )
         throws IOException
     {
         ImportSummary importSummary = trackedEntityInstanceService.updateTrackedEntityInstanceXml( id, request.getInputStream() );
@@ -321,7 +321,7 @@
     @RequestMapping( value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE )
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_PATIENT_ADD')" )
-    public void updatePersonJson( @PathVariable String id, HttpServletRequest request, HttpServletResponse response )
+    public void updateTrackedEntityInstanceJson( @PathVariable String id, HttpServletRequest request, HttpServletResponse response )
         throws IOException
     {
         ImportSummary importSummary = trackedEntityInstanceService.updateTrackedEntityInstanceJson( id, request.getInputStream() );
@@ -335,10 +335,10 @@
     @RequestMapping( value = "/{id}", method = RequestMethod.DELETE )
     @ResponseStatus( value = HttpStatus.NO_CONTENT )
     @PreAuthorize( "hasRole('ALL') or hasRole('F_PATIENT_DELETE')" )
-    public void deletePerson( @PathVariable String id )
+    public void deleteTrackedEntityInstance( @PathVariable String id )
         throws NotFoundException
     {
-        TrackedEntityInstance trackedEntityInstance = getPerson( id );
+        TrackedEntityInstance trackedEntityInstance = getTrackedEntityInstance( id );
         trackedEntityInstanceService.deleteTrackedEntityInstance( trackedEntityInstance );
     }
 
@@ -346,14 +346,14 @@
     // HELPERS
     // -------------------------------------------------------------------------
 
-    private TrackedEntityInstance getPerson( String id )
+    private TrackedEntityInstance getTrackedEntityInstance( String id )
         throws NotFoundException
     {
         TrackedEntityInstance trackedEntityInstance = trackedEntityInstanceService.getTrackedEntityInstance( id );
 
         if ( trackedEntityInstance == null )
         {
-            throw new NotFoundException( "Person", id );
+            throw new NotFoundException( "TrackedEntityInstance", id );
         }
         return trackedEntityInstance;
     }
@@ -365,7 +365,7 @@
 
         if ( program == null )
         {
-            throw new NotFoundException( "Person", id );
+            throw new NotFoundException( "TrackedEntityInstance", id );
         }
 
         return program;
@@ -373,7 +373,7 @@
 
     private String getResourcePath( HttpServletRequest request, ImportSummary importSummary )
     {
-        return ContextUtils.getContextPath( request ) + "/api/" + "persons" + "/" + importSummary.getReference();
+        return ContextUtils.getContextPath( request ) + "/api/" + "trackedEntityInstances" + "/" + importSummary.getReference();
     }
 
     private OrganisationUnit getOrganisationUnit( String orgUnitUid )