Files
ofbiz-plugins/birt/documents/Report master creation.md.html
T
Jacques Le Roux f247052b1c 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

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-plugins/trunk@1788911 13f79535-47bb-0310-9956-ffa450edef68
2017-03-27 11:57:07 +00:00

141 lines
16 KiB
HTML

<!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">&lt;form</span><span class="ot"> name=</span><span class="st">&quot;CTNT_MASTER_EXAMPLE&quot;</span><span class="ot"> type=</span><span class="st">&quot;single&quot;</span><span class="ot"> extends=</span><span class="st">&quot;AbstractFlexibleReportSearchForm&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;auto-fields-entity</span><span class="ot"> entity-name=</span><span class="st">&quot;Example&quot;</span><span class="ot"> default-field-type=</span><span class="st">&quot;find&quot;</span><span class="kw">/&gt;</span>
<span class="kw">&lt;/form&gt;</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">&lt;DataResource</span><span class="ot"> dataResourceId=</span><span class="st">&quot;DR_MASTER_EXAMPLE&quot;</span><span class="ot"> dataResourceTypeId=</span><span class="st">&quot;ELECTRONIC_TEXT&quot;</span><span class="ot"> dataTemplateTypeId=</span><span class="st">&quot;FORM_COMBINED&quot;</span> <span class="kw">/&gt;</span>
<span class="kw">&lt;ElectronicText</span><span class="ot"> dataResourceId=</span><span class="st">&quot;DR_MASTER_EXAMPLE&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;textData&gt;</span><span class="bn">&lt;![CDATA[</span>&lt;!--default domain form--&gt;
&lt;form name=&quot;${masterContentId}_${contentId}&quot; type=&quot;single&quot; extends=&quot;${masterContentId}&quot; extends- resource=&quot;component://birt/widget/birt/BirtMasterForms.xml&quot;&gt;
&lt;/form&gt;<span class="bn">]]&gt;</span>
<span class="kw">&lt;/textData&gt;</span>
<span class="kw">&lt;/ElectronicText&gt;</span>
<span class="kw">&lt;Content</span><span class="ot"> contentId=</span><span class="st">&quot;CTNT_MASTER_EXAMPLE&quot;</span><span class="ot"> contentTypeId=</span><span class="st">&quot;REPORT_MASTER&quot;</span><span class="ot"> dataResourceId=</span><span class="st">&quot;DR_MASTER_EXAMPLE&quot;</span><span class="ot"> statusId=</span><span class="st">&quot;CTNT_PUBLISHED&quot;</span><span class="ot"> contentName=</span><span class="st">&quot;Example&quot;</span><span class="ot"> description=</span><span class="st">&quot;Master Content for Example&quot;</span> <span class="kw">/&gt;</span>
<span class="co">&lt;!-- Data retrieval will be done using perform find on entity Example--&gt;</span>
<span class="kw">&lt;ContentAttribute</span><span class="ot"> contentId=</span><span class="st">&quot;CTNT_MASTER_EXAMPLE&quot;</span><span class="ot"> attrName=</span><span class="st">&quot;Entity&quot;</span><span class="ot"> attrValue=</span><span class="st">&quot;Example&quot;</span><span class="kw">/&gt;</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">&lt;property</span><span class="ot"> key=</span><span class="st">&quot;Content.description.CTNT_MASTER_EXAMPLE&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;value</span><span class="ot"> xml:lang=</span><span class="st">&quot;en&quot;</span><span class="kw">&gt;</span>Example<span class="kw">&lt;/value&gt;</span>
<span class="kw">&lt;value</span><span class="ot"> xml:lang=</span><span class="st">&quot;fr&quot;</span><span class="kw">&gt;</span>Exemple<span class="kw">&lt;/value&gt;</span>
<span class="kw">&lt;/property&gt;</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&lt;String, Object&gt; parameters = (Map&lt;String, Object&gt;) reportContext.<span class="fu">getParameterValue</span>(<span class="st">&quot;parameters&quot;</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">&lt;form</span><span class="ot"> name=</span><span class="st">&quot;CTNT_MASTER_TURNOVER&quot;</span><span class="ot"> type=</span><span class="st">&quot;single&quot;</span><span class="ot"> extends=</span><span class="st">&quot;AbstractFlexibleReportSearchForm&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;field</span><span class="ot"> name=</span><span class="st">&quot;fromDate&quot;</span><span class="kw">&gt;&lt;date-time</span><span class="ot"> type=</span><span class="st">&quot;date&quot;</span><span class="kw">/&gt;&lt;/field&gt;</span>
<span class="kw">&lt;field</span><span class="ot"> name=</span><span class="st">&quot;thruDate&quot;</span><span class="kw">&gt;&lt;date-time</span><span class="ot"> type=</span><span class="st">&quot;date&quot;</span><span class="kw">/&gt;&lt;/field&gt;</span>
<span class="kw">&lt;field</span><span class="ot"> name=</span><span class="st">&quot;productCategoryId&quot;</span><span class="kw">&gt;&lt;lookup</span><span class="ot"> target-form-name=</span><span class="st">&quot;LookupProductCategory&quot;</span><span class="kw">/&gt;&lt;/field&gt;</span>
<span class="kw">&lt;field</span><span class="ot"> name=</span><span class="st">&quot;productStoreId&quot;</span><span class="kw">&gt;&lt;lookup</span><span class="ot"> target-form-name=</span><span class="st">&quot;LookupProductStore&quot;</span><span class="kw">/&gt;&lt;/field&gt;</span>
<span class="kw">&lt;/form&gt;</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">&lt;CustomMethod</span><span class="ot"> customMethodId=</span><span class="st">&quot;CM_FB_TURNOVER&quot;</span><span class="ot"> customMethodTypeId=</span><span class="st">&quot;FLEXIBLE_BIRT&quot;</span><span class="ot"> customMethodName=</span><span class="st">&quot;flexibleReportTurnOver&quot;</span><span class="ot"> description=</span><span class="st">&quot;service to resolve invoice for turnover report domain&quot;</span><span class="kw">/&gt;</span>
<span class="kw">&lt;DataResource</span><span class="ot"> dataResourceId=</span><span class="st">&quot;DR_MASTER_TURNOVER&quot;</span><span class="ot"> dataResourceTypeId=</span><span class="st">&quot;ELECTRONIC_TEXT&quot;</span><span class="ot"> dataTemplateTypeId=</span><span class="st">&quot;FORM_COMBINED&quot;</span> <span class="kw">/&gt;</span>
<span class="kw">&lt;ElectronicText</span><span class="ot"> dataResourceId=</span><span class="st">&quot;DR_MASTER_TURNOVER&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;textData&gt;</span><span class="bn">&lt;![CDATA[</span>&lt;!--default domain form--&gt;
&lt;form name=&quot;${masterContentId}_${contentId}&quot; type=&quot;single&quot; extends=&quot;${masterContentId}&quot; extends-resource=&quot;component://birt/widget/birt/BirtMasterForms.xml&quot;&gt;
&lt;/form&gt;<span class="bn">]]&gt;</span>
<span class="kw">&lt;/textData&gt;</span>
<span class="kw">&lt;/ElectronicText&gt;</span>
<span class="kw">&lt;Content</span><span class="ot"> contentId=</span><span class="st">&quot;CTNT_MASTER_TURNOVER&quot;</span><span class="ot"> customMethodId=</span><span class="st">&quot;CM_FB_TURNOVER&quot;</span><span class="ot"> contentTypeId=</span><span class="st">&quot;REPORT_MASTER&quot;</span><span class="ot"> dataResourceId=</span><span class="st">&quot;DR_MASTER_TURNOVER&quot;</span><span class="ot"> statusId=</span><span class="st">&quot;CTNT_PUBLISHED&quot;</span><span class="ot"> contentName=</span><span class="st">&quot;Turnover&quot;</span><span class="ot"> description=</span><span class="st">&quot;Master Content for TURNOVER domain&quot;</span> <span class="kw">/&gt;</span>
<span class="co">&lt;!-- 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 &quot;prepareField&quot; 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 + &quot;prepareFields&quot;) then flexibleReportTurnOver--&gt;</span>
<span class="kw">&lt;ContentAttribute</span><span class="ot"> contentId=</span><span class="st">&quot;CTNT_MASTER_TURNOVER&quot;</span><span class="ot"> attrName=</span><span class="st">&quot;Service&quot;</span><span class="ot"> attrValue=</span><span class="st">&quot;default&quot;</span><span class="kw">/&gt;</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 &quot;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">&lt;property</span><span class="ot"> key=</span><span class="st">&quot;Content.description.CTNT_MASTER_TURNOVER&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;value</span><span class="ot"> xml:lang=</span><span class="st">&quot;en&quot;</span><span class="kw">&gt;</span>Turnover (product)<span class="kw">&lt;/value&gt;</span>
<span class="kw">&lt;value</span><span class="ot"> xml:lang=</span><span class="st">&quot;fr&quot;</span><span class="kw">&gt;</span>Rotation (des stocks)<span class="kw">&lt;/value&gt;</span>
<span class="kw">&lt;/property&gt;</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>