dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18420
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7762: Tidied up web ui for integration configuration, including ability to start/stop routes
------------------------------------------------------------
revno: 7762
committer: Bob Jolliffe <bobjolliffe@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-07-30 11:02:43 +0100
message:
Tidied up web ui for integration configuration, including ability to start/stop routes
added:
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/RouteOperationAction.java
modified:
dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/DisplayRoutesAction.java
dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties
dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/displayRoutes.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-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/DisplayRoutesAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/DisplayRoutesAction.java 2012-05-24 09:45:14 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/DisplayRoutesAction.java 2012-07-30 10:02:43 +0000
@@ -27,13 +27,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.List;
-
+import com.opensymphony.xwork2.Action;
+import java.util.Collection;
+import java.util.LinkedList;
import org.apache.camel.CamelContext;
+import org.apache.camel.model.ModelCamelContext;
import org.apache.camel.model.RouteDefinition;
-import com.opensymphony.xwork2.Action;
-
/**
* @author Bob Jolliffe
* @version $Id$
@@ -45,16 +45,21 @@
// Dependencies
// -------------------------------------------------------------------------
- private CamelContext builtinCamelContext;
+ private ModelCamelContext builtinCamelContext;
public void setBuiltinCamelContext( CamelContext camelContext )
{
- this.builtinCamelContext = camelContext;
- }
-
- private List<RouteDefinition> routeDefinitions;
-
- public List<RouteDefinition> getRouteDefinitions()
+ this.builtinCamelContext = (ModelCamelContext) camelContext;
+ }
+
+ public CamelContext getBuiltinCamelContext()
+ {
+ return builtinCamelContext;
+ }
+
+ private Collection<RouteDefinition> routeDefinitions;
+
+ public Collection<RouteDefinition> getRouteDefinitions()
{
return routeDefinitions;
}
@@ -63,11 +68,19 @@
// Action implementation
// -------------------------------------------------------------------------
+ @Override
public String execute()
throws Exception
{
- routeDefinitions = builtinCamelContext.getRouteDefinitions();
-
+ routeDefinitions = new LinkedList<RouteDefinition>();
+ for (RouteDefinition routeDefinition : builtinCamelContext.getRouteDefinitions())
+ {
+ // hide the internal routes
+ if (!routeDefinition.getId().startsWith( "internal") )
+ {
+ routeDefinitions.add( routeDefinition);
+ }
+ }
return SUCCESS;
}
}
=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/RouteOperationAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/RouteOperationAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/integration/RouteOperationAction.java 2012-07-30 10:02:43 +0000
@@ -0,0 +1,128 @@
+package org.hisp.dhis.importexport.action.integration;
+
+/*
+ * Copyright (c) 2004-2012, 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.opensymphony.xwork2.Action;
+import org.apache.camel.CamelContext;
+import org.apache.camel.model.ModelCamelContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author Bob Jolliffe
+ * @version $Id$
+ */
+public class RouteOperationAction
+ implements Action
+{
+
+ private static final Log log = LogFactory.getLog( RouteOperationAction.class );
+
+ // -------------------------------------------------------------------------
+ // Http Parameters
+ // -------------------------------------------------------------------------
+
+ private String id;
+
+ public void setId( String id )
+ {
+ this.id = id;
+ }
+
+ public enum Operation { enable, disable ; }
+
+ private Operation operation;
+
+ public void setOperation( Operation operation )
+ {
+ this.operation = operation;
+ }
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ModelCamelContext builtinCamelContext;
+
+ public void setBuiltinCamelContext( CamelContext camelContext )
+ {
+ this.builtinCamelContext = (ModelCamelContext) camelContext;
+ }
+
+ public CamelContext getBuiltinCamelContext()
+ {
+ return builtinCamelContext;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ switch (operation) {
+ case enable:
+ enableRoute();
+ break;
+
+ case disable:
+ disableRoute();
+ break;
+
+ default:
+ log.debug( "Unsupported route operation");
+ break;
+ }
+
+ return SUCCESS;
+ }
+
+ private void enableRoute()
+ {
+ try
+ {
+ builtinCamelContext.startRoute( id );
+ } catch ( Exception ex )
+ {
+ log.info( "Route start exception: " + ex.getMessage());
+ }
+ }
+
+ private void disableRoute()
+ {
+ try
+ {
+ builtinCamelContext.stopRoute( id );
+ } catch ( Exception ex )
+ {
+ log.info( "Route stop exception: " + ex.getMessage());
+ }
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml 2012-07-06 08:01:27 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml 2012-07-30 10:02:43 +0000
@@ -194,6 +194,11 @@
<property name="builtinCamelContext" ref="camel-builtin" />
</bean>
+ <bean id="org.hisp.dhis.importexport.action.integration.RouteOperationAction"
+ class="org.hisp.dhis.importexport.action.integration.RouteOperationAction">
+ <property name="builtinCamelContext" ref="camel-builtin" />
+ </bean>
+
<!-- DXF2 MetaData import/export -->
<bean id="org.hisp.dhis.importexport.action.dxf2.MetaDataImportFormAction"
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties 2012-07-04 20:16:23 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties 2012-07-30 10:02:43 +0000
@@ -299,7 +299,10 @@
add_route=Add route
route=Route
integration_configuration=Integration Configuration
+state=Status
data_element_id_scheme=Data element ID scheme
+enable=Enable
+disable=Disable
org_unit_id_scheme=Org unit ID scheme
uid=UID
name=Name
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml 2012-07-06 08:01:27 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml 2012-07-30 10:02:43 +0000
@@ -226,13 +226,6 @@
<result name="input" type="velocity-xml">/dhis-web-importexport/responseInput.vm</result>
</action>
- <action name="displayRoutes" class="org.hisp.dhis.importexport.action.integration.DisplayRoutesAction">
- <result name="success" type="velocity">/main.vm</result>
- <param name="page">/dhis-web-importexport/displayRoutes.vm</param>
- <param name="menu">/dhis-web-importexport/mainMenu.vm</param>
- <param name="javascripts" />
- </action>
-
<action name="showAddRouteForm" class="org.hisp.dhis.importexport.action.integration.ShowAddRouteFormAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-importexport/showAddRouteForm.vm</param>
@@ -273,6 +266,18 @@
<param name="onExceptionReturn">plainTextError</param>
</action>
+ <!-- Camel configuration -->
+
+ <action name="displayRoutes" class="org.hisp.dhis.importexport.action.integration.DisplayRoutesAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-importexport/displayRoutes.vm</param>
+ <param name="menu">/dhis-web-importexport/mainMenu.vm</param>
+ <param name="javascripts" />
+ </action>
+
+ <action name="routeOperation" class="org.hisp.dhis.importexport.action.integration.RouteOperationAction">
+ <result name="success" type="redirect">displayRoutes.action</result>
+ </action>
</package>
</struts>
=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/displayRoutes.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/displayRoutes.vm 2012-04-30 18:45:56 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/displayRoutes.vm 2012-07-30 10:02:43 +0000
@@ -6,27 +6,28 @@
<input type="button" value="$i18n.getString( 'add_route' )" onclick="window.location.href='showAddRouteForm.action'"/>
</div>
+
<table class="listTable" id="routesList" width='100%'>
<col/>
<col/>
<thead>
<tr>
<th>$i18n.getString( "route" )</th>
+ <th>$i18n.getString( "state" )</th>
<th>$i18n.getString( "description" )</th>
<th class="{sorter: false}" style="width:80px;">$i18n.getString( "operations" )</th>
</tr>
</thead>
<tbody id="list">
#set( $mark = false )
- #foreach( $routeDefinition in $routeDefinitions )
- <!--<td>$routeDefinition.toString()<td>-->
+ #foreach( $route in $routeDefinitions )
<tr #alternate( $mark )>
- <td>$encoder.htmlEncode( $routeDefinition.id )</td>
- <td>$encoder.htmlEncode( $routeDefinition.description.text )</td>
+ <td>$encoder.htmlEncode( $route.id )</td>
+ <td>$encoder.htmlEncode( $route.getStatus( $builtinCamelContext ) )</td>
+ <td>$encoder.htmlEncode( $route.descriptionText )</td>
<td style="text-align:right">
- <a href="javascript:notImplemented( $routeDefinition.id )" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a>
- <a href="javascript:notImplemented( $routeDefinition.id )" title="$i18n.getString( 'enable' )"><img src="../images/check.png" alt="$i18n.getString( 'enable' )"/></a>
- <a href="javascript:notImplemented( $routeDefinition.id )" title="$i18n.getString( 'disable' )"><img src="../images/cross.png" alt="$i18n.getString( 'disable' )"/></a>
+ <a href="routeOperation.action?id=$route.id&operation=enable" title="$i18n.getString( 'enable' )"><img src="../images/check.png" alt="$i18n.getString( 'enable' )"/></a>
+ <a href="routeOperation.action?id=$route.id&operation=disable" title="$i18n.getString( 'disable' )"><img src="../images/cross.png" alt="$i18n.getString( 'disable' )"/></a>
</td>
</tr>
#end