Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 4.6.0.v201606072122</property>
<property name="units">in</property>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<property name="imageDPI">72</property>
<parameters>
<scalar-parameter name="token" id="6">
<text-property name="helpText">Application Token</text-property>
<property name="valueType">static</property>
<property name="dataType">string</property>
<property name="distinct">true</property>
<simple-property-list name="defaultValue">
<value type="constant">eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBZG1pbmlzdHJhdG9yIiwiaWF0IjoxNTgwNjcxOTg5LCJleHAiOjE1ODA2NzkxODl9.IrF7mxccNOTd5XROZeYXBa1V8_rX67NKmdoVnR6kfLFDae7g0q-Di6PrStJs81SmVbMXIw23j0mr8pP00EqvzA</value>
</simple-property-list>
<list-property name="selectionList"/>
<property name="paramType">simple</property>
<property name="controlType">text-box</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
</scalar-parameter>
</parameters>
<data-sources>
<script-data-source name="restDataSource" id="4"/>
</data-sources>
<data-sets>
<script-data-set name="restDataSet" id="5">
<list-property name="resultSetHints">
<structure>
<property name="position">1</property>
<property name="name">id</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">customer</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">revenue</property>
<property name="dataType">decimal</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">id</property>
</structure>
<structure>
<property name="columnName">customer</property>
</structure>
<structure>
<property name="columnName">revenue</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">id</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">customer</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">revenue</property>
<property name="dataType">decimal</property>
</structure>
</list-property>
</structure>
<property name="dataSource">restDataSource</property>
<method name="open"><![CDATA[logger = java.util.logging.Logger.getLogger("birt.report.logger");
importPackage(Packages.java.io);
importPackage(Packages.java.net);
//ini perintah untuk logging ya, karena kebetulan tidak ada fitur debug
logger.info('Selesai import package...');
var HTTP_POST = "POST";
var HTTP_GET = "GET";
var SAMPLE_API = "http://localhost:1081";
var BEARER = "Bearer ";
var AUTHORIZATION = "Authorization";
var TOKEN = "token";
var HTTP_CONTENT_TYPE = "Content-Type";
var APPLICATION_JSON = "application/json";
var UTF_8 = "UTF-8";
//ini perintah untuk get parameter token melalui URL, ?token=xxxxx
var pToken = params['token'];
logger.info('pToken = ' + pToken);
//base function untuk mendapatkan response dari URL REST API
function subscribe(url, method, token) {
var address = new URL(url);
var urlConnection = address.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.setRequestMethod(method);
urlConnection.setRequestProperty(HTTP_CONTENT_TYPE, APPLICATION_JSON+"; "+UTF_8);
if(token != null) {
var bearerToken = BEARER + token;
logger.info(">> bearerToken = " + bearerToken);
urlConnection.setRequestProperty(AUTHORIZATION, bearerToken);
}
urlConnection.connect();
var buffReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
var inputLine;
var response = "";
while ((line = buffReader.readLine()) != null) {
response += line;
}
buffReader.close();
urlConnection.disconnect();
return response;
}
//main function untuk memanggil API dalam bentuk array yang berasal dari JSON
function getData(){
var token = pToken;
var revenueApi = SAMPLE_API + "/api/sample/v1/get-revenue";
var response = subscribe(revenueApi, HTTP_POST, token);
logger.info('>> response = ' + response);
var json = JSON.parse(response);
return json['data'];
}
rowNo = 0;
data = getData();]]></method>
<method name="fetch"><![CDATA[length = data.length;
if (rowNo >= length){
return false;
}
else{
row["id"] = data[rowNo].id;
row["customer"] = data[rowNo].customer;
row["revenue"] = data[rowNo].revenue;
rowNo++;
return true;
}]]></method>
</script-data-set>
</data-sets>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<table id="1531">
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">thin</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">thin</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">thin</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">thin</property>
<property name="dataSet">restDataSet</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">id</property>
<text-property name="displayName">id</text-property>
<expression name="expression" type="javascript">dataSetRow["id"]</expression>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">customer</property>
<text-property name="displayName">customer</text-property>
<expression name="expression" type="javascript">dataSetRow["customer"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">revenue</property>
<text-property name="displayName">revenue</text-property>
<expression name="expression" type="javascript">dataSetRow["revenue"]</expression>
<property name="dataType">decimal</property>
</structure>
</list-property>
<column id="1550"/>
<column id="1551"/>
<column id="1552"/>
<header>
<row id="1532">
<cell id="1533">
<label id="1534">
<text-property name="text">ID</text-property>
</label>
</cell>
<cell id="1535">
<label id="1536">
<text-property name="text">Customer</text-property>
</label>
</cell>
<cell id="1537">
<label id="1538">
<text-property name="text">Revenue</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="1539">
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">thin</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">thin</property>
<cell id="1540">
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">thin</property>
<data id="1541">
<property name="fontSize">8pt</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">id</property>
<text-property name="displayName">id</text-property>
<expression name="expression" type="javascript">dataSetRow["id"]</expression>
<property name="dataType">integer</property>
<property name="allowExport">true</property>
</structure>
</list-property>
<property name="resultSetColumn">id</property>
</data>
</cell>
<cell id="1542">
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">thin</property>
<data id="1543">
<property name="fontSize">8pt</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">customer</property>
<text-property name="displayName">customer</text-property>
<expression name="expression" type="javascript">dataSetRow["customer"]</expression>
<property name="dataType">string</property>
<property name="allowExport">true</property>
</structure>
</list-property>
<property name="resultSetColumn">customer</property>
</data>
</cell>
<cell id="1544">
<data id="1545">
<property name="fontSize">8pt</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">revenue</property>
<text-property name="displayName">revenue</text-property>
<expression name="expression" type="javascript">dataSetRow["revenue"]</expression>
<property name="dataType">decimal</property>
<property name="allowExport">true</property>
</structure>
</list-property>
<property name="resultSetColumn">revenue</property>
</data>
</cell>
</row>
</detail>
</table>
</body>
</report>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.