(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
141 lines
16 KiB
HTML
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"><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>
|