dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #04425
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1472: Work in progress on embedded help function. Parsing the docbook help file using XSLT.
------------------------------------------------------------
revno: 1472
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-02-23 18:10:02 +0100
message:
Work in progress on embedded help function. Parsing the docbook help file using XSLT.
added:
dhis-2/dhis-options/src/main/java/org/hisp/dhis/options/help/
dhis-2/dhis-options/src/main/java/org/hisp/dhis/options/help/DefaultHelpManager.java
dhis-2/dhis-options/src/main/java/org/hisp/dhis/options/help/HelpManager.java
dhis-2/dhis-options/src/main/resources/help_content.xml
dhis-2/dhis-options/src/main/resources/help_stylesheet.xsl
dhis-2/dhis-options/src/test/java/org/hisp/dhis/options/help/
dhis-2/dhis-options/src/test/java/org/hisp/dhis/options/help/HelpManagerTest.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/help/action/GetHelpContentAction.java
modified:
dhis-2/dhis-options/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormAssociationService.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
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
--
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.
=== added directory 'dhis-2/dhis-options/src/main/java/org/hisp/dhis/options/help'
=== added file 'dhis-2/dhis-options/src/main/java/org/hisp/dhis/options/help/DefaultHelpManager.java'
--- dhis-2/dhis-options/src/main/java/org/hisp/dhis/options/help/DefaultHelpManager.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-options/src/main/java/org/hisp/dhis/options/help/DefaultHelpManager.java 2010-02-23 17:10:02 +0000
@@ -0,0 +1,70 @@
+package org.hisp.dhis.options.help;
+
+/*
+ * Copyright (c) 2004-2007, 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.io.OutputStream;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.springframework.core.io.ClassPathResource;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class DefaultHelpManager
+ implements HelpManager
+{
+ public void getHelpContent( OutputStream out, String id )
+ {
+ try
+ {
+ TransformerFactory factory = TransformerFactory.newInstance();
+
+ Source stylesheet = new StreamSource( new ClassPathResource( "help_stylesheet.xsl" ).getInputStream() );
+
+ Transformer transformer = factory.newTransformer( stylesheet );
+
+ transformer.setParameter( "sectionId", id );
+
+ Source source = new StreamSource( new ClassPathResource( "help_content.xml" ).getInputStream() );
+
+ Result result = new StreamResult( out );
+
+ transformer.transform( source, result );
+ }
+ catch ( Exception ex )
+ {
+ throw new RuntimeException( "Failed to get help content", ex );
+ }
+ }
+}
=== added file 'dhis-2/dhis-options/src/main/java/org/hisp/dhis/options/help/HelpManager.java'
--- dhis-2/dhis-options/src/main/java/org/hisp/dhis/options/help/HelpManager.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-options/src/main/java/org/hisp/dhis/options/help/HelpManager.java 2010-02-23 17:10:02 +0000
@@ -0,0 +1,40 @@
+package org.hisp.dhis.options.help;
+
+/*
+ * Copyright (c) 2004-2007, 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.io.OutputStream;
+
+/**
+ * @author Lars Helge Overland
+ */
+public interface HelpManager
+{
+ final String ID = HelpManager.class.getName();
+
+ void getHelpContent( OutputStream out, String id );
+}
=== modified file 'dhis-2/dhis-options/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-options/src/main/resources/META-INF/dhis/beans.xml 2010-02-10 17:00:47 +0000
+++ dhis-2/dhis-options/src/main/resources/META-INF/dhis/beans.xml 2010-02-23 17:10:02 +0000
@@ -185,4 +185,7 @@
</property>
</bean>
+ <bean id="org.hisp.dhis.options.help.HelpManager"
+ class="org.hisp.dhis.options.help.DefaultHelpManager"/>
+
</beans>
=== added file 'dhis-2/dhis-options/src/main/resources/help_content.xml'
--- dhis-2/dhis-options/src/main/resources/help_content.xml 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-options/src/main/resources/help_content.xml 2010-02-23 17:10:02 +0000
@@ -0,0 +1,40 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<chapter>
+ <title>Data Quality</title>
+ <para>The data quality module provides means to improve the quality of the data in the system. This can be done through validation rules and various statistical checks.</para>
+ <section id="learningObjectives">
+ <title>Learning Objectives</title>
+ <para>After reading this module you will be able to understand:</para>
+ <orderedlist>
+ <listitem>
+ <para>What is data quality and its importance for HMIS.</para>
+ </listitem>
+ <listitem>
+ <para>How to do data quality check at point of data entry.</para>
+ </listitem>
+ <listitem>
+ <para>How to create data validation rules.</para>
+ </listitem>
+ <listitem>
+ <para>How to carry out data triangulation.</para>
+ </listitem>
+ <listitem>
+ <para>How to analyze data status.</para>
+ </listitem>
+ </orderedlist>
+ <para>This stuff is in a paragraph</para>
+ </section>
+ <section id="overview">
+ <title>Overview of data quality check</title>
+ <para>Ensuring data quality is a key concern in building an effective HMIS. Data quality has different dimensions including:</para>
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>Correctness:</emphasis> Data should be within the normal range for data collected at that facility. There should be no gross discrepancies when compared with data from related data elements.</para>
+ </listitem>
+ <listitem>
+ <para><emphasis>Completeness:</emphasis> Data for all data elements for all health facilities/blocks/Taluka/districts should have been submitted.</para>
+ </listitem>
+ </itemizedlist>
+ <para>This stuff is in a paragraph</para>
+ </section>
+</chapter>
=== added file 'dhis-2/dhis-options/src/main/resources/help_stylesheet.xsl'
--- dhis-2/dhis-options/src/main/resources/help_stylesheet.xsl 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-options/src/main/resources/help_stylesheet.xsl 2010-02-23 17:10:02 +0000
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:param name="sectionId">learningObjectives</xsl:param>
+
+<xsl:template match="title">
+ <h3><xsl:value-of select="."/></h3>
+</xsl:template>
+
+<xsl:template match="para">
+ <p><xsl:value-of select="."/></p>
+</xsl:template>
+
+<xsl:template match="orderedlist">
+ <ol>
+ <xsl:for-each select="listitem">
+ <li><xsl:value-of select="para"/></li>
+ </xsl:for-each>
+ </ol>
+</xsl:template>
+
+<xsl:template match="itemizedlist">
+ <ul>
+ <xsl:for-each select="listitem">
+ <li><xsl:value-of select="para"/></li>
+ </xsl:for-each>
+ </ul>
+</xsl:template>
+
+<xsl:template match="/">
+ <xsl:apply-templates select="chapter/section[@id=$sectionId]"/>
+</xsl:template>
+
+</xsl:stylesheet>
=== added directory 'dhis-2/dhis-options/src/test/java/org/hisp/dhis/options/help'
=== added file 'dhis-2/dhis-options/src/test/java/org/hisp/dhis/options/help/HelpManagerTest.java'
--- dhis-2/dhis-options/src/test/java/org/hisp/dhis/options/help/HelpManagerTest.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-options/src/test/java/org/hisp/dhis/options/help/HelpManagerTest.java 2010-02-23 17:10:02 +0000
@@ -0,0 +1,62 @@
+package org.hisp.dhis.options.help;
+
+/*
+ * Copyright (c) 2004-2007, 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.io.ByteArrayOutputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.DhisSpringTest;
+import org.junit.Test;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class HelpManagerTest
+ extends DhisSpringTest
+{
+ private static final Log log = LogFactory.getLog( HelpManagerTest.class );
+
+ private HelpManager helpManager;
+
+ @Override
+ public void setUpTest()
+ {
+ helpManager = (HelpManager) getBean( HelpManager.ID );
+ }
+
+ @Test
+ public void testGetHelpContent()
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ helpManager.getHelpContent( out, "overview" );
+
+ log.debug( out.toString() );
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormAssociationService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormAssociationService.java 2010-02-22 15:25:35 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormAssociationService.java 2010-02-23 17:10:02 +0000
@@ -30,11 +30,6 @@
import java.util.Collection;
import java.util.List;
-import org.hisp.dhis.dataentryform.DataEntryForm;
-import org.hisp.dhis.dataentryform.DataEntryFormAssociation;
-import org.hisp.dhis.dataentryform.DataEntryFormAssociationService;
-import org.hisp.dhis.dataentryform.DataEntryFormAssociationStore;
-import org.hisp.dhis.dataentryform.DataEntryFormService;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -44,7 +39,6 @@
public class DefaultDataEntryFormAssociationService
implements DataEntryFormAssociationService
{
-
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -56,13 +50,6 @@
this.dataEntryFormAssociationStore = dataEntryFormAssociationStore;
}
- private DataEntryFormService dataEntryFormService;
-
- public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
- {
- this.dataEntryFormService = dataEntryFormService;
- }
-
// -------------------------------------------------------------------------
// DataEntryFormAssociationService implementation
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2010-02-23 14:38:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2010-02-23 17:10:02 +0000
@@ -7,6 +7,7 @@
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- Store definitions -->
+
<bean id="org.hisp.dhis.dataentryform.DataEntryFormAssociationStore"
class="org.hisp.dhis.dataentryform.hibernate.HibernateDataEntryFormAssociationStore">
<property name="sessionFactory" ref="sessionFactory"/>
=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/help/action/GetHelpContentAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/help/action/GetHelpContentAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/help/action/GetHelpContentAction.java 2010-02-23 17:10:02 +0000
@@ -0,0 +1,77 @@
+package org.hisp.dhis.help.action;
+
+/*
+ * Copyright (c) 2004-2007, 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.io.OutputStream;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.hisp.dhis.options.help.HelpManager;
+import org.hisp.dhis.util.StreamActionSupport;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class GetHelpContentAction
+ extends StreamActionSupport
+{
+ private HelpManager helpManager;
+
+ public void setHelpManager( HelpManager helpManager )
+ {
+ this.helpManager = helpManager;
+ }
+
+ private String id;
+
+ public void setId( String id )
+ {
+ this.id = id;
+ }
+
+ @Override
+ protected String execute( HttpServletResponse response, OutputStream out )
+ throws Exception
+ {
+ helpManager.getHelpContent( out, id );
+
+ return SUCCESS;
+ }
+
+ @Override
+ protected String getContentType()
+ {
+ return CONTENT_TYPE_HTML;
+ }
+
+ @Override
+ protected String getFilename()
+ {
+ return "help.html";
+ }
+}
=== 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 2010-02-04 11:04:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2010-02-23 17:10:02 +0000
@@ -534,7 +534,12 @@
<bean id="org.hisp.dhis.help.action.PopupHelpAction" class="org.hisp.dhis.help.action.PopupHelpAction"
scope="prototype">
</bean>
-
+
+ <bean id="org.hisp.dhis.help.action.GetHelpContentAction" class="org.hisp.dhis.help.action.GetHelpContentAction"
+ scope="prototype">
+ <property name="helpManager" ref="org.hisp.dhis.options.help.HelpManager"/>
+ </bean>
+
<!-- Common actions -->
<bean id="org.hisp.dhis.commons.action.GetDataElementAction"
=== 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 2010-02-04 11:04:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2010-02-23 17:10:02 +0000
@@ -232,6 +232,10 @@
<result name="success" type="velocity">/popup.vm</result>
<param name="page">/dhis-web-commons/help/helpPopup.vm</param>
</action>
+
+ <action name="getHelpContent" class="org.hisp.dhis.help.action.GetHelpContentAction">
+ <result name="success" type="outputStreamResult"></result>
+ </action>
</package>