← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11886: Background-process notifications, using web api resource and removed action class variant

 

------------------------------------------------------------
revno: 11886
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-09-03 20:28:38 +0200
message:
  Background-process notifications, using web api resource and removed action class variant
removed:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlNotifications.vm
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetNotificationsAction.java
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DefaultEventStore.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/hibernate/HibernateImportDataValueStore.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SystemController.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataMartForm.vm


--
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-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java	2013-09-03 18:28:38 +0000
@@ -257,7 +257,7 @@
             " AND ous.idlevel" + rootOrgunit.getLevel() + "=" + rootOrgunit.getId() +
             " AND adv.periodid IN (" + periodids + ") ";
 
-        return jdbcTemplate.queryForInt( sql );
+        return jdbcTemplate.queryForObject( sql, Integer.class );
     }
 
     public void deleteAggregatedDataValues( Collection<Integer> dataElementIds, Collection<Integer> periodIds, Collection<Integer> organisationUnitIds )

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DefaultEventStore.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DefaultEventStore.java	2013-09-03 09:40:41 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/DefaultEventStore.java	2013-09-03 18:28:38 +0000
@@ -138,16 +138,6 @@
         return events;
     }
 
-    private List<Integer> getIdList( IdentifiableObject identifiableObject )
-    {
-        if ( identifiableObject != null )
-        {
-            return Arrays.asList( identifiableObject.getId() );
-        }
-
-        return new ArrayList<Integer>();
-    }
-
     private List<Integer> getIdList( List<? extends IdentifiableObject> identifiableObjects )
     {
         List<Integer> integers = new ArrayList<Integer>();

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/hibernate/HibernateImportDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/hibernate/HibernateImportDataValueStore.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/hibernate/HibernateImportDataValueStore.java	2013-09-03 18:28:38 +0000
@@ -125,6 +125,6 @@
     {
         String sql = "SELECT COUNT(*) FROM importdatavalue WHERE status = '" + status.name() + "'";
         
-        return jdbcTemplate.queryForInt( sql );
+        return jdbcTemplate.queryForObject( sql, Integer.class );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-09-03 15:24:51 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2013-09-03 18:28:38 +0000
@@ -101,10 +101,6 @@
 
     private static final String PROGRAM_STAGE_SECTION_UPLOADED = "program_stage_section_uploaded";
 
-    private static final String ANONYMOUS_PROGRAM_UPLOADED = "anonymous_program_uploaded";
-
-    private static final String PATIENT_REGISTERED = "patient_registered";
-
     private static final String SINGLE_EVENT_UPLOADED = "single_event_uploaded";
 
     private ActivityComparator activityComparator = new ActivityComparator();

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SystemController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SystemController.java	2013-09-02 12:36:55 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SystemController.java	2013-09-03 18:28:38 +0000
@@ -107,7 +107,8 @@
     }
 
     @RequestMapping( value = "/tasks/{category}", method = RequestMethod.GET, produces = { "*/*", "application/json" } )
-    public void getTaskJson( HttpServletResponse response, @PathVariable("category") String category ) throws IOException
+    public void getTaskJson( @PathVariable("category") String category, 
+        @RequestParam(required=false) String lastId, HttpServletResponse response ) throws IOException
     {
         List<Notification> notifications = new ArrayList<Notification>();
 
@@ -117,7 +118,7 @@
 
             TaskId taskId = new TaskId( taskCategory, currentUserService.getCurrentUser() );
 
-            notifications = notifier.getNotifications( taskId, null );
+            notifications = notifier.getNotifications( taskId, lastId );
         }
 
         JacksonUtils.toJson( response.getOutputStream(), notifications );

=== removed file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlNotifications.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlNotifications.vm	2012-04-11 09:02:06 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/htmlNotifications.vm	1970-01-01 00:00:00 +0000
@@ -1,13 +0,0 @@
-#if( $notifications.size() > 0 )
-<table class="notificationTable">
-<col width="120">
-<col width="380">
-#foreach( $notification in $notifications )
-<tr>
-	<td>${format.formatDateTime( $notification.time )}:</td>
-	<td>${encoder.htmlEncode( $notification.message )} #if( $velocityCount == 1 )&nbsp;
-		#if( $notification.completed )<img src='../images/completed.png'>#else<img src='../images/ajax-loader-bar.gif'>#end#end</td>
-</tr>
-#end
-</table>
-#end
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2013-08-23 16:11:13 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2013-09-03 18:28:38 +0000
@@ -1824,9 +1824,9 @@
 {
 	var lastUid = $( '#' + tableId ).prop( 'lastUid' ); // Store on table property
 	
-	var param = lastUid ? '&lastUid=' + lastUid : '';
+	var param = ( undefined !== lastUid ) ? '?lastId=' + lastUid : '';
 	
-	$.getJSON( '../dhis-web-commons-ajax-json/getNotifications.action?category=' + category + param, function( notifications )
+	$.getJSON( '../api/system/tasks/' + category + param, function( notifications )
 	{
 		var html = '', 
 			isComplete = false;
@@ -1850,7 +1850,9 @@
 					$( '#loaderSpan' ).replaceWith ( '' ); // Hide previous loader bar
 				}
 				
-				html += '<tr><td>' + notification.time + '</td><td>' + notification.message + ' &nbsp;';
+				var time = ( undefined != notification.time ) ? notification.time.replace( 'T', ' ' ).substring( 0, 19 ) : '';
+				
+				html += '<tr><td>' + time + '</td><td>' + notification.message + ' &nbsp;';
 				html += notification.completed == 'true' ?  '<img src="../images/completed.png">' : loaderHtml;
 				html += '</td></tr>';
 			} );

=== removed file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetNotificationsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetNotificationsAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetNotificationsAction.java	1970-01-01 00:00:00 +0000
@@ -1,103 +0,0 @@
-package org.hisp.dhis.commons.action;
-
-/*
- * 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 java.util.ArrayList;
-import java.util.List;
-
-import org.hisp.dhis.scheduling.TaskCategory;
-import org.hisp.dhis.scheduling.TaskId;
-import org.hisp.dhis.system.notification.Notification;
-import org.hisp.dhis.system.notification.Notifier;
-import org.hisp.dhis.user.CurrentUserService;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Lars Helge Overland
- */
-public class GetNotificationsAction
-    implements Action
-{    
-    @Autowired
-    private Notifier notifier;
-
-    @Autowired
-    private CurrentUserService currentUserService;
-    
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-    
-    private String category;
-
-    public void setCategory( String category )
-    {
-        this.category = category;
-    }
-
-    private String lastUid;
-    
-    public void setLastUid( String lastUid )
-    {
-        this.lastUid = lastUid;
-    }
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-    
-    private List<Notification> notifications = new ArrayList<Notification>();
-    
-    public List<Notification> getNotifications()
-    {
-        return notifications;
-    }
-    
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-    
-    @Override
-    public String execute()
-        throws Exception
-    {
-        if ( category != null )
-        {
-            TaskCategory taskCategory = TaskCategory.valueOf( category.toUpperCase() );
-
-            TaskId taskId = new TaskId( taskCategory, currentUserService.getCurrentUser() );
-            
-            notifications = notifier.getNotifications( taskId, lastUid );
-        }
-        
-        return SUCCESS;
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2013-09-01 21:38:52 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2013-09-03 18:28:38 +0000
@@ -292,9 +292,6 @@
 
   <!-- Common actions -->
 
-  <bean id="org.hisp.dhis.commons.action.GetNotificationsAction" class="org.hisp.dhis.commons.action.GetNotificationsAction"
-    scope="prototype" />
-
   <bean id="org.hisp.dhis.commons.action.GetUserAction" class="org.hisp.dhis.commons.action.GetUserAction" scope="prototype">
     <property name="userService" ref="org.hisp.dhis.user.UserService" />
   </bean>

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2013-08-16 12:29:21 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2013-09-03 18:28:38 +0000
@@ -465,11 +465,6 @@
 
   <package name="dhis-web-commons-ajax-html" extends="dhis-web-commons" namespace="/dhis-web-commons-ajax-html">
 
-    <action name="getNotifications" class="org.hisp.dhis.commons.action.GetNotificationsAction">
-      <result name="success" type="velocity">/dhis-web-commons/ajax/htmlNotifications.vm</result>
-      <param name="onExceptionReturn">plainTextError</param>
-    </action>
-
     <action name="getUser" class="org.hisp.dhis.commons.action.GetUserAction">
       <result name="success" type="velocity">
         /dhis-web-commons/ajax/htmlUser.vm

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm	2013-05-23 09:39:06 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/importDataValue.vm	2013-09-03 18:28:38 +0000
@@ -62,8 +62,8 @@
 
 <div id="notificationDiv">
 <table id="notificationTable" class="notificationTable" style="display:none">
-<col width="120">
-<col width="380">
+<col width="140">
+<col width="360">
 </table>
 </div>
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataMartForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataMartForm.vm	2013-06-18 20:42:30 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewDataMartForm.vm	2013-09-03 18:28:38 +0000
@@ -43,7 +43,7 @@
 
 <div>
 <table id="notificationTable" class="notificationTable" style="display:none">
-<col width="120">
-<col width="380">
+<col width="140">
+<col width="360">
 </table>
 </div>