← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5798: Removed FOP stuff from web api-. Did not scale well.

 

------------------------------------------------------------
revno: 5798
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-01-24 14:28:00 +0100
message:
  Removed FOP stuff from web api-. Did not scale well.
removed:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XslFoPdfView.java
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/identifiable-row.xsl
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/list.xsl
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/model2fop.xsl
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/pdf-wrapper.xsl
modified:
  dhis-2/dhis-web/dhis-web-api/pom.xml
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/TransformCache.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/TransformCacheImpl.java
  dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/servlet.xml
  dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/identifiable-row.xsl
  dhis-2/pom.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
=== modified file 'dhis-2/dhis-web/dhis-web-api/pom.xml'
--- dhis-2/dhis-web/dhis-web-api/pom.xml	2011-12-26 09:25:32 +0000
+++ dhis-2/dhis-web/dhis-web-api/pom.xml	2012-01-24 13:28:00 +0000
@@ -58,10 +58,6 @@
       <groupId>org.springframework</groupId>
       <artifactId>spring-oxm</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.apache.xmlgraphics</groupId>
-      <artifactId>fop</artifactId>
-    </dependency>
   </dependencies>
 
   <properties>

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/TransformCache.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/TransformCache.java	2011-12-03 14:35:34 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/TransformCache.java	2012-01-24 13:28:00 +0000
@@ -43,14 +43,5 @@
      * @throws TransformerConfigurationException  
      */
     Transformer getHtmlTransformer()
-        throws TransformerConfigurationException;
-
-    /**
-     * A transformer for rendering elements to xsl-fop
-     * 
-     * @return the transformer
-     * @throws TransformerConfigurationException  
-     */
-    Transformer getFopTransformer()
         throws TransformerConfigurationException;   
 }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/TransformCacheImpl.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/TransformCacheImpl.java	2011-12-13 14:16:32 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/TransformCacheImpl.java	2012-01-24 13:28:00 +0000
@@ -30,6 +30,7 @@
 import java.io.IOException;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import javax.xml.transform.ErrorListener;
 import javax.xml.transform.Source;
 import javax.xml.transform.Templates;
@@ -37,6 +38,7 @@
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.stream.StreamSource;
+
 import org.amplecode.staxwax.transformer.LoggingErrorListener;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Component;
@@ -52,18 +54,12 @@
 {
     static final String MODEL2HTML = "model2html.xsl";
 
-    static final String MODEL2FOP = "model2fop.xsl";
-
     static final String HTMLXSLT_RESOURCE = "/templates/html/";
 
-    static final String FOPXSLT_RESOURCE = "/templates/pdf/";
-
     static private TransformCache instance;
 
     private Templates htmlCachedTransform;
 
-    private Templates fopCachedTransform;
-
     private TransformCacheImpl()
         throws IOException, TransformerConfigurationException
     {
@@ -73,12 +69,9 @@
         factory.setErrorListener( errorListener );
 
         Source model2html = new StreamSource( new ClassPathResource( HTMLXSLT_RESOURCE + MODEL2HTML ).getInputStream() );
-        Source model2fop = new StreamSource( new ClassPathResource( FOPXSLT_RESOURCE + MODEL2FOP ).getInputStream() );
 
         factory.setURIResolver( new ClassPathUriResolver( HTMLXSLT_RESOURCE ) );
         htmlCachedTransform = factory.newTemplates( model2html );
-        factory.setURIResolver( new ClassPathUriResolver( FOPXSLT_RESOURCE ) );
-        fopCachedTransform = factory.newTemplates( model2fop );
     }
 
     protected static TransformCache instance()
@@ -103,11 +96,4 @@
     {
         return htmlCachedTransform.newTransformer();
     }
-
-    @Override
-    public Transformer getFopTransformer()
-        throws TransformerConfigurationException
-    {
-        return fopCachedTransform.newTransformer();
-    }
 }

=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XslFoPdfView.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XslFoPdfView.java	2011-12-03 14:35:34 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XslFoPdfView.java	1970-01-01 00:00:00 +0000
@@ -1,86 +0,0 @@
-package org.hisp.dhis.api.view;
-
-/*
- * Copyright (c) 2004-2011, 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 org.apache.fop.apps.Fop;
-import org.apache.fop.apps.FopFactory;
-import org.apache.xmlgraphics.util.MimeConstants;
-import org.springframework.web.servlet.view.AbstractUrlBasedView;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.util.JAXBSource;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.sax.SAXResult;
-import java.util.Map;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class XslFoPdfView extends AbstractUrlBasedView
-{
-    public static final String PDF_CONTENT_TYPE = "application/pdf";
-
-    public XslFoPdfView()
-    {
-        setContentType( PDF_CONTENT_TYPE );
-    }
-
-    @Override
-    protected void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response ) throws Exception
-    {
-        response.setContentType( getContentType() );
-        model = ViewUtils.filterModel( model );
-
-        Object domainModel = model.get( "model" );
-
-        if ( domainModel == null )
-        {
-            // throw exception
-        }
-
-        JAXBContext context = JAXBContext.newInstance( domainModel.getClass() );
-        Marshaller marshaller = context.createMarshaller();
-        marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, false );
-        marshaller.setProperty( Marshaller.JAXB_ENCODING, "UTF-8" );
-
-        Source xmlSource = new JAXBSource( context, domainModel );
-
-        Transformer transformer = TransformCacheImpl.instance().getFopTransformer();
-
-        FopFactory fopFactory = FopFactory.newInstance();
-        Fop fop = fopFactory.newFop( MimeConstants.MIME_PDF, response.getOutputStream() );
-
-        Result result = new SAXResult( fop.getDefaultHandler() );
-        transformer.transform( xmlSource, result );
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/servlet.xml'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/servlet.xml	2012-01-05 20:39:23 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/servlet.xml	2012-01-24 13:28:00 +0000
@@ -22,7 +22,6 @@
         <entry key="json" value="application/json" />
         <entry key="jsonp" value="application/javascript" />
         <entry key="xml" value="application/xml" />
-        <!--<entry key="pdf" value="application/pdf" />-->
         <entry key="html" value="text/html" />
         <entry key="png" value="image/png" />
       </map>
@@ -47,14 +46,6 @@
           <property name="suffix" value=".xsl" />
           <property name="viewClass" value="org.hisp.dhis.api.view.XsltHtmlView" />
         </bean>
-
-<!--
-        <bean name="xslFoPdfViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
-          <property name="prefix" value="/templates/pdf/" />
-          <property name="suffix" value=".xsl" />
-          <property name="viewClass" value="org.hisp.dhis.api.view.XslFoPdfView" />
-        </bean>
--->
       </list>
     </property>
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/identifiable-row.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/identifiable-row.xsl	2011-12-21 13:29:45 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/identifiable-row.xsl	2012-01-24 13:28:00 +0000
@@ -9,7 +9,6 @@
       <td> <a href="{@link}.xml">xml</a> </td>
       <td> <a href="{@link}.json">json</a> </td>
       <td> <a href="{@link}.jsonp">jsonp</a> </td>
-      <!--<td> <a href="{@link}.pdf">pdf</a> </td>-->
     </tr>
   </xsl:template>
 

=== removed directory 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf'
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/identifiable-row.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/identifiable-row.xsl	2011-12-19 14:55:04 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/identifiable-row.xsl	1970-01-01 00:00:00 +0000
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0"
-                xmlns:fo="http://www.w3.org/1999/XSL/Format";
-                xmlns="http://www.w3.org/1999/xhtml";>
-
-  <xsl:template match="*" mode="row">
-    <fo:block font-size="10pt" font-weight="bold" border-bottom="1pt solid black"><xsl:value-of select="@name" /></fo:block>
-
-    <fo:table border-top="1pt solid black" margin-bottom="9pt" table-layout="fixed">
-      <fo:table-body>
-        <fo:table-row>
-          <fo:table-cell><fo:block>ID</fo:block></fo:table-cell>
-          <fo:table-cell><fo:block><xsl:value-of select="@id" /></fo:block></fo:table-cell>
-        </fo:table-row>
-        <fo:table-row>
-          <fo:table-cell><fo:block>Code</fo:block></fo:table-cell>
-          <fo:table-cell><fo:block><xsl:value-of select="@code" /></fo:block></fo:table-cell>
-        </fo:table-row>
-        <fo:table-row>
-          <fo:table-cell><fo:block>Last Updated</fo:block></fo:table-cell>
-          <fo:table-cell><fo:block><xsl:value-of select="@lastUpdated" /></fo:block></fo:table-cell>
-        </fo:table-row>
-      </fo:table-body>
-    </fo:table>
-
-  </xsl:template>
-
-</xsl:stylesheet>

=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/list.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/list.xsl	2011-12-19 14:55:04 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/list.xsl	1970-01-01 00:00:00 +0000
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
-                xmlns:fo="http://www.w3.org/1999/XSL/Format";
-                xmlns:d="http://dhis2.org/schema/dxf/2.0";
-    >
-
-  <xsl:output method="pdf" />
-
-  <xsl:include href="identifiable-row.xsl"/>
-
-  <xsl:template match="d:resources|d:maps|d:charts|d:categories|d:categoryCombos|
-    d:categoryOptions|d:categoryOptionCombos|d:dataElements|d:indicators|
-    d:organisationUnits|d:dataElementGroups|d:dataElementGroupSets|
-    d:documents|d:indicatorGroups|d:indicatorGroupSets|d:organisationUnitGroups|
-    d:organisationUnitGroupSets|d:indicatorTypes|d:attributeTypes|d:reports|
-    d:sqlViews|d:validationRules|d:validationRuleGroups|d:users|d:reportTables">
-
-    <fo:root>
-      <fo:layout-master-set>
-        <fo:simple-page-master master-name="A4">
-          <fo:region-body margin="1in" />
-        </fo:simple-page-master>
-      </fo:layout-master-set>
-
-      <fo:page-sequence master-reference="A4">
-        <fo:flow flow-name="xsl-region-body">
-          <fo:block font-size="20pt" border-bottom="2pt solid black" margin-bottom="20pt"><xsl:value-of select="local-name()" /></fo:block>
-
-          <xsl:apply-templates select="child::*" mode="row"/>
-
-        </fo:flow>
-      </fo:page-sequence>
-    </fo:root>
-  </xsl:template>
-
-  <!--
-  <xsl:template match="d:dataElement">
-    <fo:block font-size="12pt" font-weight="bold" border-bottom="1pt solid black"><xsl:value-of select="@name" /></fo:block>
-    <fo:table border-top="1pt solid black" margin-bottom="10pt" table-layout="fixed">
-      <fo:table-body>
-        <fo:table-row>
-          <fo:table-cell><fo:block>ShortName</fo:block></fo:table-cell>
-          <fo:table-cell><fo:block><xsl:value-of select="@shortName" /></fo:block></fo:table-cell>
-        </fo:table-row>
-        <fo:table-row>
-          <fo:table-cell><fo:block>LastUpdated</fo:block></fo:table-cell>
-          <fo:table-cell><fo:block><xsl:value-of select="@lastUpdated" /></fo:block></fo:table-cell>
-        </fo:table-row>
-        <fo:table-row>
-          <fo:table-cell><fo:block>Active</fo:block></fo:table-cell>
-          <fo:table-cell><fo:block><xsl:value-of select="d:active" /></fo:block></fo:table-cell>
-        </fo:table-row>
-        <fo:table-row>
-          <fo:table-cell><fo:block>AggregationOperator</fo:block></fo:table-cell>
-          <fo:table-cell><fo:block><xsl:value-of select="d:aggregationOperator" /></fo:block></fo:table-cell>
-        </fo:table-row>
-        <fo:table-row>
-          <fo:table-cell><fo:block>DomainType</fo:block></fo:table-cell>
-          <fo:table-cell><fo:block><xsl:value-of select="d:domainType" /></fo:block></fo:table-cell>
-        </fo:table-row>
-        <fo:table-row>
-          <fo:table-cell><fo:block>SortOrder</fo:block></fo:table-cell>
-          <fo:table-cell><fo:block><xsl:value-of select="d:sortOrder" /></fo:block></fo:table-cell>
-        </fo:table-row>
-        <fo:table-row>
-          <fo:table-cell><fo:block>Type</fo:block></fo:table-cell>
-          <fo:table-cell><fo:block><xsl:value-of select="d:type" /></fo:block></fo:table-cell>
-        </fo:table-row>
-        <fo:table-row>
-          <fo:table-cell><fo:block>ZeroIsSignificant</fo:block></fo:table-cell>
-          <fo:table-cell><fo:block><xsl:value-of select="d:zeroIsSignificant" /></fo:block></fo:table-cell>
-        </fo:table-row>
-      </fo:table-body>
-    </fo:table>
-  </xsl:template>
--->
-</xsl:stylesheet>

=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/model2fop.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/model2fop.xsl	2011-12-07 14:04:35 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/model2fop.xsl	1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
-                version="1.0">
-
-  <xsl:include href="list.xsl"/>
-
-</xsl:stylesheet>
\ No newline at end of file

=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/pdf-wrapper.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/pdf-wrapper.xsl	2011-12-19 14:55:04 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/pdf/pdf-wrapper.xsl	1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
-                xmlns:fo="http://www.w3.org/1999/XSL/Format";
-                xmlns:d="http://dhis2.org/schema/dxf/2.0";
-    >
-
-  <xsl:output method="xml" />
-
-  <xsl:template match="/">
-    <fo:root>
-      <fo:layout-master-set>
-        <fo:simple-page-master master-name="A4">
-          <fo:region-body margin="1in" />
-        </fo:simple-page-master>
-      </fo:layout-master-set>
-
-      <fo:page-sequence master-reference="A4">
-        <fo:flow flow-name="xsl-region-body">
-          <fo:block font-size="20pt" border-bottom="2pt solid black" margin-bottom="20pt">DataElements</fo:block>
-
-          <xsl:apply-templates />
-
-        </fo:flow>
-      </fo:page-sequence>
-    </fo:root>
-  </xsl:template>
-
-</xsl:stylesheet>

=== modified file 'dhis-2/pom.xml'
--- dhis-2/pom.xml	2012-01-22 05:29:27 +0000
+++ dhis-2/pom.xml	2012-01-24 13:28:00 +0000
@@ -770,13 +770,6 @@
         <version>2.2.2</version>
       </dependency>
 
-      <!-- XSL-FO -->
-      <dependency>
-        <groupId>org.apache.xmlgraphics</groupId>
-        <artifactId>fop</artifactId>
-        <version>1.0</version>
-      </dependency>
-
     </dependencies>
   </dependencyManagement>