Author: jleroux
Date: Mon Mar 27 11:57:07 2017 New Revision: 1788911 URL: http://svn.apache.org/viewvc?rev=1788911&view=rev Log: Documented: Complete Birt Flexible Reports documentation (OFBIZ-9188) This is the technical documentation about the Flexible Reports. It's done with Markdown files with links to Confluence for images Also the HTML version soon used in the wiki Added: ofbiz/ofbiz-plugins/trunk/birt/documents/Report master creation.md (with props) ofbiz/ofbiz-plugins/trunk/birt/documents/Report master creation.md.html (with props) Added: ofbiz/ofbiz-plugins/trunk/birt/documents/Report master creation.md URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/birt/documents/Report%20master%20creation.md?rev=1788911&view=auto ============================================================================== --- ofbiz/ofbiz-plugins/trunk/birt/documents/Report master creation.md (added) +++ ofbiz/ofbiz-plugins/trunk/birt/documents/Report master creation.md Mon Mar 27 11:57:07 2017 @@ -0,0 +1,113 @@ +# Report master creation # + +## Introduction ## +A report master is an OFBiz content which allows a user to generate data reports. It defines data connexion, and a general filtering form for data. It can be based on an entity, a dedicated service, or in a wider sense on any shape a data connexion can take and return back a map. + +## Pre-requisite ## +- OFBiz +- Birt plugin + +## Report Master based on an entity/view ## + + +1. Create or choice a database entity or view +2. Create the general filtering form within the file plugins/birt/widget/birt/BirtMasterForms.xml. The only informations to be changed are entity-name and form name. + +```xml + <form name="CTNT_MASTER_EXAMPLE" type="single" extends="AbstractFlexibleReportSearchForm"> + <auto-fields-entity entity-name="Example" default-field-type="find"/> + </form> +``` + +3. Add the informations about this Master in the database using the file plugins/birt/data/BirtMasterData.xml + +```xml + <DataResource dataResourceId="DR_MASTER_EXAMPLE" dataResourceTypeId="ELECTRONIC_TEXT" dataTemplateTypeId="FORM_COMBINED" /> + <ElectronicText dataResourceId="DR_MASTER_EXAMPLE"> + <textData><![CDATA[<!--default domain form--> + <form name="${masterContentId}_${contentId}" type="single" extends="${masterContentId}" extends- resource="component://birt/widget/birt/BirtMasterForms.xml"> + </form>]]> + </textData> + </ElectronicText> + <Content contentId="CTNT_MASTER_EXAMPLE" contentTypeId="REPORT_MASTER" dataResourceId="DR_MASTER_EXAMPLE" statusId="CTNT_PUBLISHED" contentName="Example" description="Master Content for Example" /> + <!-- Data retrieval will be done using perform find on entity Example--> + <ContentAttribute contentId="CTNT_MASTER_EXAMPLE" attrName="Entity" attrValue="Example"/> +``` + +The form in the database is the form that will allow users to change form parameters. You can add any field you desire. Some field names are though reserved: reportContentId, overrideFilters, entityViewName, birtContentType. + +4. Add in the file content/config/contentEntityLabels.xml the Property that will allow translation for your report master description. + +```xml + <property key="Content.description.CTNT_MASTER_EXAMPLE"> + <value xml:lang="en">Example</value> + <value xml:lang="fr">Exemple</value> + </property> +``` + +Your Report Master is created ! You can now create reports using it. + +## Report Master based on a service ## +Create in plugins/birt/src/org/ofbiz/birt/birt/BirtMasterReportServices.java 2 dedicated services (see examples there) + +1. The first one, which name will return 4 items: + * an object of type Map<String, String> called dataMap. **Keys**: data field names. **Values**: data types (OFBiz types). + * an object of type Map<String, String> called fieldDisplayLabels. **Keys**: data field names. **Values**: the names displayed to the user. This output is optional, should it be missing, the keys will be displayed. + * an object of type Map<String, String> called filterMap. **Keys**: data filtering field names (exact names used for the form fields). **Values**: data type (OFBiz type). This output is optional, if missing, filters can not be displayed on the report. + * an object of type Map<String, String> called filterDisplayLabels. **Keys**: data filtering field names (exact names used for the form fields). **Values**: names to be displayed to the user. This output is optional, should it be missing, the keys will be displayed. +2. The second service will actually get the data. It receives an object (Object type) called reportContext. From this object, you can obtain the map parameters using the following code: + +```java + Map<String, Object> parameters = (Map<String, Object>) reportContext.getParameterValue("parameters"); +``` + +This Map will give access fields of the filtering form. +This service will return a list called list of type List<GenericValue>, containing the data. A Map<String, Object> would also do. + +3. create the parent form in the file plugins/birt/widget/birt/BirtMasterForms.xml. +Field names created here must be then names used on the Map parameters of the previous service, and also corresponding to the map filterMap. + +```xml + <form name="CTNT_MASTER_TURNOVER" type="single" extends="AbstractFlexibleReportSearchForm"> + <field name="fromDate"><date-time type="date"/></field> + <field name="thruDate"><date-time type="date"/></field> + <field name="productCategoryId"><lookup target-form-name="LookupProductCategory"/></field> + <field name="productStoreId"><lookup target-form-name="LookupProductStore"/></field> + </form> +``` + +4. Create the master in database following. + +```xml + <CustomMethod customMethodId="CM_FB_TURNOVER" customMethodTypeId="FLEXIBLE_BIRT" customMethodName="flexibleReportTurnOver" description="service to resolve invoice for turnover report domain"/> + <DataResource dataResourceId="DR_MASTER_TURNOVER" dataResourceTypeId="ELECTRONIC_TEXT" dataTemplateTypeId="FORM_COMBINED" /> + <ElectronicText dataResourceId="DR_MASTER_TURNOVER"> + <textData><![CDATA[<!--default domain form--> + <form name="${masterContentId}_${contentId}" type="single" extends="${masterContentId}" extends-resource="component://birt/widget/birt/BirtMasterForms.xml"> + </form>]]> + </textData> + </ElectronicText> + <Content contentId="CTNT_MASTER_TURNOVER" customMethodId="CM_FB_TURNOVER" contentTypeId="REPORT_MASTER" dataResourceId="DR_MASTER_TURNOVER" statusId="CTNT_PUBLISHED" contentName="Turnover" description="Master Content for TURNOVER domain" /> + <!-- Data retrieval will be done using two service calls. First the contentAttribute Service gives the service that will define which data and label will be retrieved, + and which filter and label are supported by the report design (default value will call the second service with "prepareField" suffix). + Second, the custom method gives the service to retrieve all data in the report design. + Here : flexibleReportTurnOverPrepareFields (customMethodName + "prepareFields") then flexibleReportTurnOver--> + <ContentAttribute contentId="CTNT_MASTER_TURNOVER" attrName="Service" attrValue="default"/> +``` + +The form in the database is the form that will allow users to change form parameters. You can add any field you desire. Some field names are reserved: reportContentId, overrideFilters, entityViewName, birtContentType. + +5. Import these data in the base using Webtools XML import (or the longer "gradlew 'ofbiz -l readers=seed,ext' command). +6. Add in the file content/config/contentEntityLabels.xml the Property which will translate your report Master description. + +```xml + <property key="Content.description.CTNT_MASTER_TURNOVER"> + <value xml:lang="en">Turnover (product)</value> + <value xml:lang="fr">Rotation (des stocks)</value> + </property> +``` + +Entities diagram +----------------- +The following diagram shows the Entities linked with Content to store report_master/report. +![Report_Master](https://cwiki.apache.org/confluence/download/attachments/68720496/Report_Master.png?api=v2) Propchange: ofbiz/ofbiz-plugins/trunk/birt/documents/Report master creation.md ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-plugins/trunk/birt/documents/Report master creation.md ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-plugins/trunk/birt/documents/Report master creation.md ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/ofbiz-plugins/trunk/birt/documents/Report master creation.md.html URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/birt/documents/Report%20master%20creation.md.html?rev=1788911&view=auto ============================================================================== --- ofbiz/ofbiz-plugins/trunk/birt/documents/Report master creation.md.html (added) +++ ofbiz/ofbiz-plugins/trunk/birt/documents/Report master creation.md.html Mon Mar 27 11:57:07 2017 @@ -0,0 +1,140 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <meta http-equiv="Content-Style-Type" content="text/css" /> + <meta name="generator" content="pandoc" /> + <title></title> + <style type="text/css">code{white-space: pre;}</style> + <style type="text/css"> +div.sourceCode { overflow-x: auto; } +table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode { + margin: 0; padding: 0; vertical-align: baseline; border: none; } +table.sourceCode { width: 100%; line-height: 100%; } +td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; } +td.sourceCode { padding-left: 5px; } +code > span.kw { color: #007020; font-weight: bold; } /* Keyword */ +code > span.dt { color: #902000; } /* DataType */ +code > span.dv { color: #40a070; } /* DecVal */ +code > span.bn { color: #40a070; } /* BaseN */ +code > span.fl { color: #40a070; } /* Float */ +code > span.ch { color: #4070a0; } /* Char */ +code > span.st { color: #4070a0; } /* String */ +code > span.co { color: #60a0b0; font-style: italic; } /* Comment */ +code > span.ot { color: #007020; } /* Other */ +code > span.al { color: #ff0000; font-weight: bold; } /* Alert */ +code > span.fu { color: #06287e; } /* Function */ +code > span.er { color: #ff0000; font-weight: bold; } /* Error */ +code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ +code > span.cn { color: #880000; } /* Constant */ +code > span.sc { color: #4070a0; } /* SpecialChar */ +code > span.vs { color: #4070a0; } /* VerbatimString */ +code > span.ss { color: #bb6688; } /* SpecialString */ +code > span.im { } /* Import */ +code > span.va { color: #19177c; } /* Variable */ +code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */ +code > span.op { color: #666666; } /* Operator */ +code > span.bu { } /* BuiltIn */ +code > span.ex { } /* Extension */ +code > span.pp { color: #bc7a00; } /* Preprocessor */ +code > span.at { color: #7d9029; } /* Attribute */ +code > span.do { color: #ba2121; font-style: italic; } /* Documentation */ +code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ +code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ +code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */ + </style> +</head> +<body> +<h1 id="report-master-creation">Report master creation</h1> +<h2 id="introduction">Introduction</h2> +<p>A report master is an OFBiz content which allows a user to generate data reports. It defines data connexion, and a general filtering form for data. It can be based on an entity, a dedicated service, or in a wider sense on any shape a data connexion can take and return back a map.</p> +<h2 id="pre-requisite">Pre-requisite</h2> +<ul> +<li>OFBiz</li> +<li>Birt plugin</li> +</ul> +<h2 id="report-master-based-on-an-entityview">Report Master based on an entity/view</h2> +<ol style="list-style-type: decimal"> +<li>Create or choice a database entity or view</li> +<li>Create the general filtering form within the file plugins/birt/widget/birt/BirtMasterForms.xml. The only informations to be changed are entity-name and form name.</li> +</ol> +<div class="sourceCode"><pre class="sourceCode xml"><code class="sourceCode xml"> <span class="kw"><form</span><span class="ot"> name=</span><span class="st">"CTNT_MASTER_EXAMPLE"</span><span class="ot"> type=</span><span class="st">"single"</span><span class="ot"> extends=</span><span class="st">"AbstractFlexibleReportSearchForm"</span><span class="kw">></span> + <span class="kw"><auto-fields-entity</span><span class="ot"> entity-name=</span><span class="st">"Example"</span><span class="ot"> default-field-type=</span><span class="st">"find"</span><span class="kw">/></span> + <span class="kw"></form></span></code></pre></div> +<ol start="3" style="list-style-type: decimal"> +<li>Add the informations about this Master in the database using the file plugins/birt/data/BirtMasterData.xml</li> +</ol> +<div class="sourceCode"><pre class="sourceCode xml"><code class="sourceCode xml"> <span class="kw"><DataResource</span><span class="ot"> dataResourceId=</span><span class="st">"DR_MASTER_EXAMPLE"</span><span class="ot"> dataResourceTypeId=</span><span class="st">"ELECTRONIC_TEXT"</span><span class="ot"> dataTemplateTypeId=</span><span class="st">"FORM_COMBINED"</span> <span class="kw">/></span> + <span class="kw"><ElectronicText</span><span class="ot"> dataResourceId=</span><span class="st">"DR_MASTER_EXAMPLE"</span><span class="kw">></span> + <span class="kw"><textData></span><span class="bn"><![CDATA[</span><!--default domain form--> + <form name="${masterContentId}_${contentId}" type="single" extends="${masterContentId}" extends- resource="component://birt/widget/birt/BirtMasterForms.xml"> + </form><span class="bn">]]></span> + <span class="kw"></textData></span> + <span class="kw"></ElectronicText></span> + <span class="kw"><Content</span><span class="ot"> contentId=</span><span class="st">"CTNT_MASTER_EXAMPLE"</span><span class="ot"> contentTypeId=</span><span class="st">"REPORT_MASTER"</span><span class="ot"> dataResourceId=</span><span class="st">"DR_MASTER_EXAMPLE"</span><span class="ot"> statusId=</span><span class="st">"CTNT_PUBLISHED"</span><span class="ot"> contentName=</span><span class="st">"Example"</span><span class="ot"> description=</span><span class="st">"Master Content for Example"</span> <span class="kw">/></span> + <span class="co"><!-- Data retrieval will be done using perform find on entity Example--></span> + <span class="kw"><ContentAttribute</span><span class="ot"> contentId=</span><span class="st">"CTNT_MASTER_EXAMPLE"</span><span class="ot"> attrName=</span><span class="st">"Entity"</span><span class="ot"> attrValue=</span><span class="st">"Example"</span><span class="kw">/></span></code></pre></div> +<p>The form in the database is the form that will allow users to change form parameters. You can add any field you desire. Some field names are though reserved: reportContentId, overrideFilters, entityViewName, birtContentType.</p> +<ol start="4" style="list-style-type: decimal"> +<li>Add in the file content/config/contentEntityLabels.xml the Property that will allow translation for your report master description.</li> +</ol> +<div class="sourceCode"><pre class="sourceCode xml"><code class="sourceCode xml"> <span class="kw"><property</span><span class="ot"> key=</span><span class="st">"Content.description.CTNT_MASTER_EXAMPLE"</span><span class="kw">></span> + <span class="kw"><value</span><span class="ot"> xml:lang=</span><span class="st">"en"</span><span class="kw">></span>Example<span class="kw"></value></span> + <span class="kw"><value</span><span class="ot"> xml:lang=</span><span class="st">"fr"</span><span class="kw">></span>Exemple<span class="kw"></value></span> + <span class="kw"></property></span></code></pre></div> +<p>Your Report Master is created ! You can now create reports using it.</p> +<h2 id="report-master-based-on-a-service">Report Master based on a service</h2> +<p>Create in plugins/birt/src/org/ofbiz/birt/birt/BirtMasterReportServices.java 2 dedicated services (see examples there)</p> +<ol style="list-style-type: decimal"> +<li>The first one, which name will return 4 items:</li> +</ol> +<ul> +<li>an object of type Map<String, String> called dataMap. <strong>Keys</strong>: data field names. <strong>Values</strong>: data types (OFBiz types).</li> +<li>an object of type Map<String, String> called fieldDisplayLabels. <strong>Keys</strong>: data field names. <strong>Values</strong>: the names displayed to the user. This output is optional, should it be missing, the keys will be displayed.</li> +<li>an object of type Map<String, String> called filterMap. <strong>Keys</strong>: data filtering field names (exact names used for the form fields). <strong>Values</strong>: data type (OFBiz type). This output is optional, if missing, filters can not be displayed on the report.</li> +<li>an object of type Map<String, String> called filterDisplayLabels. <strong>Keys</strong>: data filtering field names (exact names used for the form fields). <strong>Values</strong>: names to be displayed to the user. This output is optional, should it be missing, the keys will be displayed.</li> +</ul> +<ol start="2" style="list-style-type: decimal"> +<li>The second service will actually get the data. It receives an object (Object type) called reportContext. From this object, you can obtain the map parameters using the following code:</li> +</ol> +<div class="sourceCode"><pre class="sourceCode java"><code class="sourceCode java"> Map<String, Object> parameters = (Map<String, Object>) reportContext.<span class="fu">getParameterValue</span>(<span class="st">"parameters"</span>);</code></pre></div> +<p>This Map will give access fields of the filtering form. This service will return a list called list of type List<GenericValue>, containing the data. A Map<String, Object> would also do.</p> +<ol start="3" style="list-style-type: decimal"> +<li>create the parent form in the file plugins/birt/widget/birt/BirtMasterForms.xml. Field names created here must be then names used on the Map parameters of the previous service, and also corresponding to the map filterMap.</li> +</ol> +<div class="sourceCode"><pre class="sourceCode xml"><code class="sourceCode xml"> <span class="kw"><form</span><span class="ot"> name=</span><span class="st">"CTNT_MASTER_TURNOVER"</span><span class="ot"> type=</span><span class="st">"single"</span><span class="ot"> extends=</span><span class="st">"AbstractFlexibleReportSearchForm"</span><span class="kw">></span> + <span class="kw"><field</span><span class="ot"> name=</span><span class="st">"fromDate"</span><span class="kw">><date-time</span><span class="ot"> type=</span><span class="st">"date"</span><span class="kw">/></field></span> + <span class="kw"><field</span><span class="ot"> name=</span><span class="st">"thruDate"</span><span class="kw">><date-time</span><span class="ot"> type=</span><span class="st">"date"</span><span class="kw">/></field></span> + <span class="kw"><field</span><span class="ot"> name=</span><span class="st">"productCategoryId"</span><span class="kw">><lookup</span><span class="ot"> target-form-name=</span><span class="st">"LookupProductCategory"</span><span class="kw">/></field></span> + <span class="kw"><field</span><span class="ot"> name=</span><span class="st">"productStoreId"</span><span class="kw">><lookup</span><span class="ot"> target-form-name=</span><span class="st">"LookupProductStore"</span><span class="kw">/></field></span> + <span class="kw"></form></span></code></pre></div> +<ol start="4" style="list-style-type: decimal"> +<li>Create the master in database following.</li> +</ol> +<div class="sourceCode"><pre class="sourceCode xml"><code class="sourceCode xml"> <span class="kw"><CustomMethod</span><span class="ot"> customMethodId=</span><span class="st">"CM_FB_TURNOVER"</span><span class="ot"> customMethodTypeId=</span><span class="st">"FLEXIBLE_BIRT"</span><span class="ot"> customMethodName=</span><span class="st">"flexibleReportTurnOver"</span><span class="ot"> description=</span><span class="st">"service to resolve invoice for turnover report domain"</span><span class="kw">/></span> + <span class="kw"><DataResource</span><span class="ot"> dataResourceId=</span><span class="st">"DR_MASTER_TURNOVER"</span><span class="ot"> dataResourceTypeId=</span><span class="st">"ELECTRONIC_TEXT"</span><span class="ot"> dataTemplateTypeId=</span><span class="st">"FORM_COMBINED"</span> <span class="kw">/></span> + <span class="kw"><ElectronicText</span><span class="ot"> dataResourceId=</span><span class="st">"DR_MASTER_TURNOVER"</span><span class="kw">></span> + <span class="kw"><textData></span><span class="bn"><![CDATA[</span><!--default domain form--> + <form name="${masterContentId}_${contentId}" type="single" extends="${masterContentId}" extends-resource="component://birt/widget/birt/BirtMasterForms.xml"> + </form><span class="bn">]]></span> + <span class="kw"></textData></span> + <span class="kw"></ElectronicText></span> + <span class="kw"><Content</span><span class="ot"> contentId=</span><span class="st">"CTNT_MASTER_TURNOVER"</span><span class="ot"> customMethodId=</span><span class="st">"CM_FB_TURNOVER"</span><span class="ot"> contentTypeId=</span><span class="st">"REPORT_MASTER"</span><span class="ot"> dataResourceId=</span><span class="st">"DR_MASTER_TURNOVER"</span><span class="ot"> statusId=</span><span class="st">"CTNT_PUBLISHED"</span><span class="ot"> contentName=</span><span class="st">"Turnover"</span><span class="ot"> description=</span><span class="st">"Master Content for TURNOVER domain"</span> <span class="kw">/></span> + <span class="co"><!-- Data retrieval will be done using two service calls. First the contentAttribute Service gives the service that will define which data and label will be retrieved,</span> +<span class="co"> and which filter and label are supported by the report design (default value will call the second service with "prepareField" suffix).</span> +<span class="co"> Second, the custom method gives the service to retrieve all data in the report design.</span> +<span class="co"> Here : flexibleReportTurnOverPrepareFields (customMethodName + "prepareFields") then flexibleReportTurnOver--></span> + <span class="kw"><ContentAttribute</span><span class="ot"> contentId=</span><span class="st">"CTNT_MASTER_TURNOVER"</span><span class="ot"> attrName=</span><span class="st">"Service"</span><span class="ot"> attrValue=</span><span class="st">"default"</span><span class="kw">/></span></code></pre></div> +<p>The form in the database is the form that will allow users to change form parameters. You can add any field you desire. Some field names are reserved: reportContentId, overrideFilters, entityViewName, birtContentType.</p> +<ol start="5" style="list-style-type: decimal"> +<li>Import these data in the base using Webtools XML import (or the longer "gradlew 'ofbiz -l readers=seed,ext' command).</li> +<li>Add in the file content/config/contentEntityLabels.xml the Property which will translate your report Master description.</li> +</ol> +<div class="sourceCode"><pre class="sourceCode xml"><code class="sourceCode xml"> <span class="kw"><property</span><span class="ot"> key=</span><span class="st">"Content.description.CTNT_MASTER_TURNOVER"</span><span class="kw">></span> + <span class="kw"><value</span><span class="ot"> xml:lang=</span><span class="st">"en"</span><span class="kw">></span>Turnover (product)<span class="kw"></value></span> + <span class="kw"><value</span><span class="ot"> xml:lang=</span><span class="st">"fr"</span><span class="kw">></span>Rotation (des stocks)<span class="kw"></value></span> + <span class="kw"></property></span></code></pre></div> +<h2 id="entities-diagram">Entities diagram</h2> +<p>The following diagram shows the Entities linked with Content to store report_master/report. <img src="https://cwiki.apache.org/confluence/download/attachments/68720496/Report_Master.png?api=v2" alt="Report_Master" /></p> +</body> +</html> Propchange: ofbiz/ofbiz-plugins/trunk/birt/documents/Report master creation.md.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/ofbiz-plugins/trunk/birt/documents/Report master creation.md.html ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/ofbiz-plugins/trunk/birt/documents/Report master creation.md.html ------------------------------------------------------------------------------ svn:mime-type = text/html |
Free forum by Nabble | Edit this page |