svn commit: r1739558 - in /ofbiz/branches/release15.12/framework: webtools/widget/ widget/src/org/ofbiz/widget/renderer/fo/ widget/src/org/ofbiz/widget/test/ widget/templates/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1739558 - in /ofbiz/branches/release15.12/framework: webtools/widget/ widget/src/org/ofbiz/widget/renderer/fo/ widget/src/org/ofbiz/widget/test/ widget/templates/

nmalin
Author: nmalin
Date: Sun Apr 17 09:05:37 2016
New Revision: 1739558

URL: http://svn.apache.org/viewvc?rev=1739558&view=rev
Log:
Backport from trunk : correct the fop macro library to pass test testFopMacroLibrary(). This has been possible with the issue OFBIZ-7015 Ugrade Apache Tika library, to use tika for analyse the pdf as string
related issue OFBIZ-6497

Modified:
    ofbiz/branches/release15.12/framework/webtools/widget/MiscScreens.xml
    ofbiz/branches/release15.12/framework/widget/src/org/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java
    ofbiz/branches/release15.12/framework/widget/src/org/ofbiz/widget/test/WidgetMacroLibraryTests.java
    ofbiz/branches/release15.12/framework/widget/templates/foFormMacroLibrary.ftl

Modified: ofbiz/branches/release15.12/framework/webtools/widget/MiscScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release15.12/framework/webtools/widget/MiscScreens.xml?rev=1739558&r1=1739557&r2=1739558&view=diff
==============================================================================
--- ofbiz/branches/release15.12/framework/webtools/widget/MiscScreens.xml (original)
+++ ofbiz/branches/release15.12/framework/webtools/widget/MiscScreens.xml Sun Apr 17 09:05:37 2016
@@ -73,6 +73,7 @@ under the License.
                 <set field="headerStyle" value="header-row-1"/>
                 <set field="tableStyle" value="basic-table light-grid"/>
                 <set field="mainDecoratorName" from-field="mainDecoratorName" default-value="main-decorator"/>
+                <set field="webtoolsLayoutDemoLabelTitle" from-field="webtoolsLayoutDemoLabelTitle" default-value="WebtoolsLayoutDemo"/>
             </actions>
             <widgets>
                 <decorator-screen name="${mainDecoratorName}" location="${parameters.mainDecoratorLocation}">
@@ -97,7 +98,7 @@ under the License.
                                 <section name="Standard Page Start">
                                     <widgets>
                                         <container style="page-title">
-                                            <label text="${uiLabelMap.WebtoolsLayoutDemo}"/>
+                                            <label style="h1" text="${uiLabelMap.${webtoolsLayoutDemoLabelTitle}}"/>
                                         </container>
                                         <container style="button-bar button-style-1">
                                             <!-- Typically used for intra-app links -->
@@ -242,10 +243,10 @@ under the License.
         <section>
             <actions>
                 <set field="mainDecoratorName" value="SimpleDecorator"/>
+                <set field="webtoolsLayoutDemoLabelTitle" value="WebtoolsViewAsPdfTheHtmlLayoutDemo"/>
                 <property-map resource="WebtoolsUiLabels" map-name="uiLabelMap" global="true"/>
             </actions>
             <widgets>
-                <label style="h1">${uiLabelMap.WebtoolsViewAsPdfTheHtmlLayoutDemo}</label>
                 <include-screen name="WebtoolsLayoutDemo"/>
             </widgets>
         </section>
@@ -255,10 +256,10 @@ under the License.
         <section>
             <actions>
                 <set field="mainDecoratorName" value="SimpleDecorator"/>
+                <set field="webtoolsLayoutDemoLabelTitle" value="WebtoolsViewAsTextTheHtmlLayoutDemo"/>
                 <property-map resource="WebtoolsUiLabels" map-name="uiLabelMap" global="true"/>
             </actions>
             <widgets>
-                <label style="h1">${uiLabelMap.WebtoolsViewAsTextTheHtmlLayoutDemo}</label>
                 <include-screen name="WebtoolsLayoutDemo"/>
             </widgets>
         </section>

Modified: ofbiz/branches/release15.12/framework/widget/src/org/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release15.12/framework/widget/src/org/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java?rev=1739558&r1=1739557&r2=1739558&view=diff
==============================================================================
--- ofbiz/branches/release15.12/framework/widget/src/org/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java (original)
+++ ofbiz/branches/release15.12/framework/widget/src/org/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java Sun Apr 17 09:05:37 2016
@@ -146,7 +146,16 @@ public class ScreenFopViewHandler extend
         
         Reader reader = new StringReader(screenOutString);
         StreamSource src = new StreamSource(reader);
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        /* Debug area, uncomment this to view the xml file generate before analyse by fop
+        try {
+                java.io.FileWriter fw = new java.io.FileWriter(new java.io.File("/tmp/temp.xsl.fo"));
+                fw.write(screenOutString);
+                fw.close();
+            } catch (IOException e) {
+                Debug.logError(e, "Couldn't save xls debug file: " + e.toString(), module);
+            }
+        */
         try {
             Fop fop = ApacheFopWorker.createFopInstance(out, contentType, foUserAgent);
             ApacheFopWorker.transform(src, null, fop);

Modified: ofbiz/branches/release15.12/framework/widget/src/org/ofbiz/widget/test/WidgetMacroLibraryTests.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release15.12/framework/widget/src/org/ofbiz/widget/test/WidgetMacroLibraryTests.java?rev=1739558&r1=1739557&r2=1739558&view=diff
==============================================================================
--- ofbiz/branches/release15.12/framework/widget/src/org/ofbiz/widget/test/WidgetMacroLibraryTests.java (original)
+++ ofbiz/branches/release15.12/framework/widget/src/org/ofbiz/widget/test/WidgetMacroLibraryTests.java Sun Apr 17 09:05:37 2016
@@ -19,7 +19,15 @@
 
 package org.ofbiz.widget.test;
 
-//import org.apache.tika.Tika;
+import java.io.InputStream;
+import java.net.ContentHandler;
+
+import org.apache.tika.Tika;
+import org.apache.tika.config.TikaConfig;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.parser.ParseContext;
+import org.apache.tika.parser.pdf.PDFParser;
+import org.apache.tika.sax.BodyContentHandler;
 import org.ofbiz.base.util.HttpClient;
 import org.ofbiz.base.util.HttpClientException;
 import org.ofbiz.base.util.SSLUtil;
@@ -93,7 +101,6 @@ public class WidgetMacroLibraryTests ext
         assertFalse("Csv Screen contains Macro on error : see " + screencsvUrl + " for more detail", screenOutString.contains("FreeMarker template error:"));
     }
 
-    /*TODO the fop render failed to generate the screen : correction needed before enable this test
     public void testFopMacroLibrary() throws Exception {
         String screentextUrl = screenUrl.concat("Fop");
         HttpClient http = initHttpClient();
@@ -103,14 +110,16 @@ public class WidgetMacroLibraryTests ext
         assertNotNull("Response failed from ofbiz", screenInputStream);
         assertEquals("Response contentType isn't good : " + http.getResponseContentType(), "application/pdf;charset=UTF-8", http.getResponseContentType());
 
-        Tika tika = new Tika();
-        String screenOutString = null;
+        String screenOutString = "";
         try {
-            screenOutString = tika.parseToString(screenInputStream);
+            BodyContentHandler handler = new BodyContentHandler(Integer.MAX_VALUE);
+            Metadata metadata = new Metadata();
+            new PDFParser().parse(screenInputStream, handler, metadata, new ParseContext());
+            screenOutString = handler.toString();
         } finally {
             screenInputStream.close();
         }
         //Test if a ftl macro error is present
         assertFalse("Fop Screen contains Macro on error : see " + screentextUrl + " for more detail", screenOutString.contains("FreeMarker template error:"));
-    }*/
+    }
 }

Modified: ofbiz/branches/release15.12/framework/widget/templates/foFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release15.12/framework/widget/templates/foFormMacroLibrary.ftl?rev=1739558&r1=1739557&r2=1739558&view=diff
==============================================================================
--- ofbiz/branches/release15.12/framework/widget/templates/foFormMacroLibrary.ftl (original)
+++ ofbiz/branches/release15.12/framework/widget/templates/foFormMacroLibrary.ftl Sun Apr 17 09:05:37 2016
@@ -49,7 +49,7 @@ under the License.
 <#macro renderDisplayField type imageLocation idName description title class alert inPlaceEditorUrl="" inPlaceEditorParams="">
 <@makeBlock class description />
 </#macro>
-<#macro renderHyperlinkField></#macro>
+<#macro renderHyperlinkField><!--hyper--></#macro>
 
 <#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled mask tabindex readonly placeholder=""><@makeBlock className value /></#macro>
 
@@ -73,14 +73,14 @@ under the License.
 <#macro renderSubmitField buttonType className alert formName title name event action imgSrc confirmation containerId ajaxUrl tabindex><@makeBlock "" "" /></#macro>
 <#macro renderResetField className alert name title><@makeBlock "" "" /></#macro>
 
-<#macro renderHiddenField name value id event action></#macro>
-<#macro renderIgnoredField></#macro>
+<#macro renderHiddenField name value id event action><!--hidden--></#macro>
+<#macro renderIgnoredField><!--ignore--></#macro>
 
 <#macro renderFieldTitle style title id fieldHelpText="" for=""><fo:block <@getFoStyle style/>>${title?default("")?replace("&nbsp;", " ")}</fo:block></#macro>
-<#macro renderSingleFormFieldTitle></#macro>
+<#macro renderSingleFormFieldTitle><!--title form--></#macro>
 
-<#macro renderFormOpen linkUrl formType targetWindow containerId containerStyle autocomplete name viewIndexField viewSizeField viewIndex viewSize useRowSubmit><fo:block <@getFoStyle containerStyle/>></#macro>
-<#macro renderFormClose focusFieldName formName containerId hasRequiredField></fo:block></#macro>
+<#macro renderFormOpen linkUrl formType targetWindow containerId containerStyle autocomplete name viewIndexField viewSizeField viewIndex viewSize useRowSubmit></#macro>
+<#macro renderFormClose focusFieldName formName containerId hasRequiredField></#macro>
 <#macro renderMultiFormClose></#macro>
 
 <#macro renderFormatListWrapperOpen formName style columnStyles><fo:table table-layout="fixed" border="solid black" <@getFoStyle style/>><#list columnStyles as columnStyle><fo:table-column<#if columnStyle?has_content> <@getFoStyle columnStyle/></#if>/></#list></#macro>
@@ -97,16 +97,16 @@ under the License.
 <#macro renderFormatHeaderRowCellOpen style positionSpan><fo:table-cell <#if positionSpan?has_content && positionSpan gt 1 >number-columns-spanned="${positionSpan}"</#if><#if style?has_content><@getFoStyle "${style}"/><#else><@getFoStyle "listtitlestyle"/></#if>><fo:block></#macro>
 <#macro renderFormatHeaderRowCellClose></fo:block></fo:table-cell></#macro>
 
-<#macro renderFormatHeaderRowFormCellOpen style><fo:table-cell></#macro>
-<#macro renderFormatHeaderRowFormCellClose></fo:table-cell></#macro>
+<#macro renderFormatHeaderRowFormCellOpen style></#macro>
+<#macro renderFormatHeaderRowFormCellClose></#macro>
 <#macro renderFormatHeaderRowFormCellTitleSeparator style isLast></#macro>
 
 <#macro renderFormatItemRowOpen formName itemIndex altRowStyles evenRowStyle oddRowStyle><fo:table-row <@getFoStyle "${altRowStyles}"/>></#macro>
 <#macro renderFormatItemRowClose formName></fo:table-row></#macro>
 <#macro renderFormatItemRowCellOpen fieldName style positionSpan><fo:table-cell <#if positionSpan?has_content && positionSpan gt 1 >number-columns-spanned="${positionSpan}"</#if><#if style?has_content><@getFoStyle style/><#else><@getFoStyle "tabletext"/></#if>></#macro>
 <#macro renderFormatItemRowCellClose fieldName></fo:table-cell></#macro>
-<#macro renderFormatItemRowFormCellOpen style><fo:table-cell></#macro>
-<#macro renderFormatItemRowFormCellClose></fo:table-cell></#macro>
+<#macro renderFormatItemRowFormCellOpen style></#macro>
+<#macro renderFormatItemRowFormCellClose></#macro>
 
 <#macro renderFormatSingleWrapperOpen formName style><fo:table><fo:table-column column-width="1.75in"/><fo:table-column column-width="1.75in"/><fo:table-column column-width="1.75in"/><fo:table-column column-width="1.75in"/><fo:table-body></#macro>
 <#macro renderFormatSingleWrapperClose formName></fo:table-body></fo:table></#macro>
@@ -119,7 +119,7 @@ under the License.
 <#macro renderFormatFieldRowWidgetCellOpen positionSpan style><fo:table-cell text-align="left" padding="2pt" padding-left="5pt" <#if positionSpan?has_content && positionSpan gt 1 >number-columns-spanned="${positionSpan}"</#if>></#macro>
 <#macro renderFormatFieldRowWidgetCellClose></fo:table-cell></#macro>
 
-<#macro renderFormatEmptySpace> </#macro>
+<#macro renderFormatEmptySpace> <@makeBlock "" " " /><!--space--></#macro>
 
 <#macro renderTextFindField name value defaultOption opEquals opBeginsWith opContains opIsEmpty opNotEqual className alert size maxlength autocomplete titleStyle hideIgnoreCase ignCase ignoreCase><@makeBlock className value tabindex/></#macro>
 
@@ -145,7 +145,7 @@ under the License.
 <#macro formatBoundaryComment boundaryType widgetType widgetName></#macro>
 <#macro makeHiddenFormLinkForm actionUrl name parameters targetWindow></#macro>
 <#macro makeHiddenFormLinkAnchor linkStyle hiddenFormName event action imgSrc description><@renderField description /></#macro>
-<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc title targetParameters alternate linkUrl targetWindow description confirmation uniqueItemName="" height="" width="" id=""></#macro>
+<#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc title targetParameters alternate linkUrl targetWindow description confirmation uniqueItemName="" height="" width="" id=""><fo:block/><!--link--></#macro>
 <#macro renderTooltip tooltip tooltipStyle></#macro>
 <#macro renderAsterisks requiredField requiredStyle></#macro>
 </#escape>