WIP reports API plus api docs

This commit is contained in:
John Woodlock
2012-05-15 18:09:51 +10:00
parent e96d623a46
commit 06fa7ff146
5 changed files with 2701 additions and 63 deletions
+2071
View File
File diff suppressed because it is too large Load Diff
+564
View File
@@ -0,0 +1,564 @@
html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;}
a img { outline: none; border: 0; }
h1 { font-size: 180%; font-weight: bold; }
h2 { font-size: 165%; font-weight: bold; }
h3 { font-size: 145%; font-weight: bold; }
h4 { font-size: 120%; font-weight: bold; }
h5 { font-size: 120%; font-weight: bold; }
h6 { font-size: 110%; font-weight: bold; }
h1, h2, h3, h4, h5, h6 { margin: 0 0 0.5em 0; line-height: 1.2em; }
p { margin: 1em 0; }
em {font-style: italic;}
html {
background-color: rgb(240, 240, 255);
}
body {
padding: 0; margin: 0;
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
font-size: 15px;
line-height: 22px;
min-width: 1000px;
background-color: gray;
border-top: 15px solid black;
}
#flybar {
font-size: 14px;
line-height: 20px;
}
.method-example h1, .method-example h2, .method-example h3, .method-example h4, .method-example h5, .method-example h6, #flybar, .footer {
font-family: Helvetica, Arial, sans-serif;
}
.method-example code {
font-family: Monaco, Consolas, "Lucida Console", monospace;
font-size: 12px;
line-height: 18px;
}
#flybar {
position: fixed;
z-index: 100;
height: 40px;
min-width: 745px;
left: 0; right: 0; top: 0;
padding-left: 560px;
background: #eee;
background: -webkit-gradient(linear, left top, left bottom, from(#f8f8f8), to(#dadada));
background: -moz-linear-gradient(top, #f8f8f8, #dadada);
border-top: 15px solid black;
border-bottom: 1px solid #888;
-webkit-box-shadow: 0 3px 5px rgba(0,0,0,0.1);
-moz-box-shadow: 0 3px 5px rgba(0,0,0,0.1);
box-shadow: 0 3px 5px rgba(0,0,0,0.1);
}
#nav-logo {
display: block;
height: 30px;
position: absolute;
top: 7px;
left: 10px;
}
.flybar-button {
text-align: center;
text-transform: uppercase;
font-size: 12px;
padding: 0 1em;
line-height: 40px;
border-right: 1px solid transparent;
border-left: 1px solid transparent;
text-decoration: none;
font-weight: bold;
color: black;
}
.flybar-nav {
display: block;
float: left;
width: 150px;
position: relative;
}
.flybar-language {
display: block;
float: left;
position: relative;
}
.flybar-language .flybar-button {
float: left;
clear: none;
border-right: 1px solid transparent;
border-left: 1px solid transparent;
min-width: 80px;
margin-left: -1px;
}
.flybar-menu {
display: none;
position: absolute;
top: 41px;
width: 500px;
background-color: rgba(249, 249, 249, 0.99);
border: 1px solid rgb(187, 187, 187);
border-top: 0;
padding: 1em;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
-webkit-box-shadow: 0 3px 5px rgba(0,0,0,0.1);
-moz-box-shadow: 0 3px 5px rgba(0,0,0,0.1);
box-shadow: 0 3px 5px rgba(0,0,0,0.1);
}
#toc-menu {
right: -245px;
}
#language-menu {
left: -25px;
}
#language-menu li {
display: inline-block;
margin-right: 25px;
}
.flybar-menu h3 {
text-transform: uppercase;
font-size: 100%;
}
.flybar-menu h4 {
text-transform: uppercase;
font-size: 90%;
color: rgb(155, 155, 155);
margin: 0.5em 0 0.5em 0;
}
.flybar-menu ul {
margin: 0 0 1em 1em;
}
.flybar-nav:hover .flybar-menu,
.flybar-nav.active .flybar-menu {
display: block;
}
.flybar-button:hover,
.flybar-button.active,
.flybar-nav:hover .flybar-button,
.flybar-nav.active .flybar-button {
background: #eee;
background: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#f8f8f8));
background: -moz-linear-gradient(top, #eee, #f8f8f8);
border-left: 1px solid rgb(187, 187, 187);
border-right: 1px solid rgb(187, 187, 187);
}
.flybar-nav:hover .flybar-menu,,
.flybar-button.active {
margin-right: -1px;
}
.flybar-nav:hover .flybar-button,
.flybar-nav.active .flybar-button {
height: 51px;
color: #000;
background: -webkit-gradient(linear, left top, left bottom, from(#e5e5e5), to(#fff));
background: -moz-linear-gradient(top, #e5e5e5, #fff);
}
.toc-column1 {
width: 180px;
}
.toc-column2 {
width: 205px;
}
.toc-column1, .toc-column2, .toc-column3, .toc-column4, .toc-column5, .toc-column6 {
float: left;
}
.toc-section {
width: 235px;
font-size: 90%;
}
#toc-menu-button {
border-right: 1px solid #bbb;
}
code {
white-space: pre;
white-space: -o-pre-wrap;
white-space: -moz-pre-wrap;
white-space: pre-wrap;
display: block;
margin: 1em 0;
line-height: 1.5em;
}
.method-section {
clear: left;
padding: 1em 0;
padding-top: 60px;
margin-left: -580px;
}
.method-section:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.method-description {
width: 540px;
float: left;
padding-right: 20px;
color: black;
}
.method-description p {
}
h1 {
text-transform: uppercase;
}
.method-description h4 {
/*font-family: monospace;*/
}
.method-description h5 {
font-size: 110%;
color: rgb(155, 155, 155);
text-transform: uppercase;
clear: both;
padding: 0.5em 0;
}
.method-example {
margin-left: 560px;
padding-left: 20px;
min-width: 380px;
}
.method-example code {
white-space: pre;
white-space: -o-pre-wrap;
white-space: -moz-pre-wrap;
white-space: pre-wrap;
}
.method-example {
color: rgb(105, 105, 125);
}
.method-example p {
font-style: italic;
color: rgb(105, 105, 105);
}
.method-error:before {
content: "EXAMPLE ERROR";
color: rgb(155, 155, 185);
display: block;
}
.method-declaration:before {
content: "DEFINITION";
color: rgb(155, 155, 185);
display: block;
}
.method-request:before {
content: "EXAMPLE REQUEST";
color: rgb(155, 155, 185);
display: block;
}
.method-response:before {
content: "EXAMPLE RESPONSE";
color: rgb(155, 155, 185);
display: block;
}
.expected-result:before {
content: "RESULT";
color: rgb(155, 155, 185);
display: block;
}
.method-response, .method-error {
font-size: 90%;
}
.method-example li {
font-family: monospace;
color: black;
}
.method-example ul {
margin: 1em 0;
}
.method-example table {
font-family: monospace;
color: black;
}
.method-example td {
padding-right: 20px;
padding-bottom: 5px;
vertical-align: top;
}
.method-example table th {
font-weight: bold;
}
.method-example code {
color: black;
}
.prompt:after {
content: '$ ';
color: gray;
display: block;
}
.prompt.curl:after { content: '$ '; }
.prompt.ruby:after { content: '>> ' }
.prompt.python:after { content: '>>> ' }
.prompt.php:after { content: 'php > ' }
.prompt.java:after { content: '' }
.method-name {
font-family: monospace;
font-weight: bold;
}
.notification-request:before {
content: "EXAMPLE NOTIFICATION";
color: rgb(155, 155, 185);
display: block;
}
.notification-event:before {
content: "EVENT";
color: rgb(155, 155, 185);
display: block;
}
#page-wrapper {
background-color: white;
color: black;
}
#main-content-wrapper {
background-color: rgb(240, 240, 255);
margin-left: 579px;
padding: 0 20px 40px 20px;
border-left: 1px solid rgb(229, 229, 238);
}
#api-summary-example {
margin-top: 48px;
}
.argument-list {
font-size: 90%;
line-height: 1.5em;
}
.argument-list dl {
font-size: 95%;
padding: 1em 0;
line-height: 1.5em;
}
.argument-list:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.argument-list dl:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.argument-list dt {
clear:both;
width:34%;
float:left;
text-align:right;
font-weight: bold;
margin-top: 8px;
}
.event-types.argument-list dt {
width: 48%;
}
.event-types.argument-list dd {
width: 48%;
}
.argument-list dt:after {
content: ":";
}
.argument-list dd {
float:right;
width: 65%;
}
.argument-list dl dd {
width: 65%;
}
.argument-list dt + dd {
margin-top: 8px;
font-weight: bold;
}
.argument-list dd dl dd dl {
width: 95%;
}
.argument-list dd dl dd dl dd {
width: 65%;
}
.argument-list dd dl dd dl dt {
width:31%;
}
.argument-list dd span {
font-style: italic;
font-weight: normal;
}
.old-syle-anchor {display:block;height:0;width:0;}
strong { font-weight: bold; }
.footer {
position: fixed;
bottom: 0;
height: 30px;
border-top: 1px solid #ccc;
background: #eee;
background: -webkit-gradient(linear, left top, left bottom, from(#f8f8f8), to(#dadada));
background: -moz-linear-gradient(top, #f8f8f8, #dadada);
width: 100%;
opacity: 0.95;
font-size: 13px;
}
.footer input[type="text"] {
height: 14px;
padding: 3px;
border: 1px solid #aaa;
border-radius: 4px;
}
.suggestion-box {
float: right;
padding-top: 3px;
padding-right: 10px;
}
.footer input[type="submit"]:hover {
background: -webkit-gradient(
linear,
center top,
center bottom,
from(#fefefe),
to(#dbdbdb),
color-stop(80%, #eeeeee),
color-stop(0%, #eeeeee)
);
background: -moz-linear-gradient(
top,
#fff,
#fff
);
}
.footer input[type="submit"]:active {
background: -webkit-gradient(
linear,
center top,
center bottom,
from(#c0c0c0),
to(#fefefe),
color-stop(0%, #e1e1e1),
color-stop(30%, #eeeeee),
color-stop(80%, #fff)
);
background: -moz-linear-gradient(
top,
#c0c0c0,
#fefefe
);
border: 1px solid #a3a3a3;
}
.footer input[type="submit"] {
height: 22px;
padding: 3px;
font-size: 13px;
font-family: "proxima-nova-1","proxima-nova-2", Helvetica, Arial, sans-serif;
color: #454545;
text-shadow: 0px 1px 0px #fff;
text-align: center;
border: 1px solid #aaa;
background: -webkit-gradient(
linear,
center top,
center bottom,
from(#fefefe),
to(#dbdbdb),
color-stop(50%, #eeeeee)
);
background: -moz-linear-gradient(
top,
#fefefe,
#dbdbdb
);
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-webkit-background-clip: padding-box;
-webkit-backface-visibility: hidden;
}
.stripe-version {
float: left;
}
@@ -166,8 +166,8 @@ function initialiseReporting(params) {
if (params.reportQuery) reportQuery = params.reportQuery;
var theParams = {Name: reportQuery, Type: 'parameter'};
getReportData(theParams, setupReportListSuccess)
var theParams = {Type: 'parameter'};
getReportData(reportQuery, theParams, setupReportListSuccess)
}
function setCurrentDate() {
@@ -435,9 +435,7 @@ function runTheReport()
return;
}
var theParams;
if ((reportListing[reportListingIndex].type == 'Pentaho')) theParams = {pentahoReportName: reportListing[reportListingIndex].name, Type: 'report'}
else theParams = {Name: reportListing[reportListingIndex].name, Type: 'report'};
var theParams = {Type: 'report'};
var pValue;
var reportParameterName;
@@ -471,14 +469,14 @@ function runTheReport()
switch(reportListing[reportListingIndex].type)
{
case "Table":
if (showOption == "XLS") getExportCSV(theParams)
if (showOption == "XLS") getExportCSV(selectedRpt, theParams)
else
{
reportDataSuccess = function(data, textStatus, jqXHR){
createTable(data);
showTableReport();
};
getReportData(theParams, reportDataSuccess);
getReportData(selectedRpt, theParams, reportDataSuccess);
}
break;
case "Chart":
@@ -487,10 +485,10 @@ function runTheReport()
createChart(data);
showChartReport(reportListing[reportListingIndex].subtype);
};
getReportData(theParams, reportDataSuccess);
getReportData(selectedRpt, theParams, reportDataSuccess);
break;
case "Pentaho":
getPentahoReport(theParams);
getPentahoReport(selectedRpt, theParams);
break;
default:
@@ -581,8 +579,8 @@ var parameterTableHtml = '<table><tr>';
eval(generateSelectSuccessVariable(listOfParameters[i].name, listOfParameters[i].label, selectOne, selectAll));
var theParams = {Name: listOfParameters[i].name, Type: 'parameter'};
getReportData(theParams, selectSuccess)
var theParams = {Type: 'parameter'};
getReportData(listOfParameters[i].name, theParams, selectSuccess)
}
}
@@ -614,8 +612,8 @@ setupParameterListSuccess = function(data, textStatus, jqXHR){
setupReportListSuccess = function(data, textStatus, jqXHR){
showMsgE("In setupReportListSuccess");
theParams = {Name: 'FullParameterList', Type: 'parameter'};
getReportData(theParams, setupParameterListSuccess);
theParams = {Type: 'parameter'};
getReportData('FullParameterList', theParams, setupParameterListSuccess);
var prevId = -1;
var currId;
@@ -672,8 +670,8 @@ setupReportListSuccess = function(data, textStatus, jqXHR){
function copyXLSon() {
showMsg("Turning them on");
$('#ToolTables_FRshowTable_0').css('display', 'inline');
$('#ToolTables_FRshowTable_1').css('display', 'inline');
$('#ToolTables_RshowTable_0').css('display', 'inline');
$('#ToolTables_RshowTable_1').css('display', 'inline');
ttInstances = TableTools.fnGetMasters();
for (i in ttInstances) {
ttInstances[i].that.fnResizeButtons();
@@ -684,8 +682,8 @@ function copyXLSon() {
function copyXLSoff() {
showMsg("Turning them off");
$('#ToolTables_FRshowTable_0').css('display', 'none');
$('#ToolTables_FRshowTable_1').css('display', 'none');
$('#ToolTables_RshowTable_0').css('display', 'none');
$('#ToolTables_RshowTable_1').css('display', 'none');
filteredCopyXLSon = false;
}
@@ -768,22 +766,22 @@ return 'var selectSuccess = function(data, textStatus,jqXHR){' +
function createChart(theData) {
FRData = new google.visualization.DataTable();
FRData.addColumn('string', dataTableDef.aoColumns[0].sTitle);
FRData.addColumn('number', dataTableDef.aoColumns[1].sTitle);
FRData.addRows(dataTableDef.aaData.length);
RData = new google.visualization.DataTable();
RData.addColumn('string', dataTableDef.aoColumns[0].sTitle);
RData.addColumn('number', dataTableDef.aoColumns[1].sTitle);
RData.addRows(dataTableDef.aaData.length);
var ii = 0;
var numberData;
var dblQuotePos;
for (var i in dataTableDef.aaData)
{
FRData.setValue(ii, 0, dataTableDef.aaData[i][0]);
RData.setValue(ii, 0, dataTableDef.aaData[i][0]);
if (dataTableDef.aoColumns[1].sType == "title-numeric" && dataTableDef.aaData[i][1].substr(0, 11) == '<span title') numberData = getOrigTitleNumericValue(dataTableDef.aaData[i][1])
else numberData = dataTableDef.aaData[i][1];
FRData.setValue(ii, 1, numberData);
RData.setValue(ii, 1, numberData);
ii = ii + 1;
};
}
@@ -889,8 +887,8 @@ function convertCRtoBR(str) {
function showTableReport() {
isNewTable = true;
$('#StretchyReportOutput').html( '<table cellpadding="0" cellspacing="1" border="0" class="display" id="FRshowTable" width=100%></table>' );
oTable = $('#FRshowTable').dataTable(dataTableDef);
$('#StretchyReportOutput').html( '<table cellpadding="0" cellspacing="1" border="0" class="display" id="RshowTable" width=100%></table>' );
oTable = $('#RshowTable').dataTable(dataTableDef);
oSettings = oTable.fnSettings();
showMsg("1st recs displayed is: " + fnRecordsDisplay());
@@ -901,17 +899,17 @@ function showTableReport() {
function showChartReport(rptSubType) {
/*
* $('#StretchyReportOutput').html( '<table><tr><td width="25%" valign="top"><table
* cellpadding="0" cellspacing="1" border="0" class="display" id="FRshowTable"
* cellpadding="0" cellspacing="1" border="0" class="display" id="RshowTable"
* width=100%></table></td><td width="75%" align="right"><div
* id=FRshowChart></div></td></tr></table>' );
* $('#FRshowTable').dataTable(dataTableDef);
* id=RshowChart></div></td></tr></table>' );
* $('#RshowTable').dataTable(dataTableDef);
*/
$('#StretchyReportOutput').html( '<table><tr></td><td width="100%" align="center"><div id=FRshowChart></div></td></tr></table>' );
$('#StretchyReportOutput').html( '<table><tr></td><td width="100%" align="center"><div id=RshowChart></div></td></tr></table>' );
var options;
var FRchart;
var Rchart;
switch(rptSubType)
{
@@ -922,8 +920,8 @@ var FRchart;
// chartArea: {left:0,top:0, width:"100%",height:"100%"}
};
FRchart = new google.visualization.PieChart(document.getElementById('FRshowChart'));
FRchart.draw(FRData, options);
Rchart = new google.visualization.PieChart(document.getElementById('RshowChart'));
Rchart.draw(RData, options);
break;
case "Bar":
options = {
@@ -933,8 +931,8 @@ var FRchart;
// chartArea: {left:0,top:0, width:"100%",height:"100%"}
};
FRchart = new google.visualization.BarChart(document.getElementById('FRshowChart'));
FRchart.draw(FRData, options);
Rchart = new google.visualization.BarChart(document.getElementById('RshowChart'));
Rchart.draw(RData, options);
break;
default:
alert("System Error: Unknown Chart Type: " + rptSubType);
@@ -945,9 +943,9 @@ var FRchart;
/*
* var FRchart = new
* google.visualization.PieChart(document.getElementById('FRshowChart'));
* FRchart.draw(FRData, {legend: 'right', is3D: true, width: 400, height: 500,
* var Rchart = new
* google.visualization.PieChart(document.getElementById('RshowChart'));
* Rchart.draw(RData, {legend: 'right', is3D: true, width: 400, height: 500,
* chartArea: {left:0,top:0, width:"100%",height:"100%"}});
*/
/*
@@ -960,7 +958,7 @@ var FRchart;
* dataTableDef.aaData[i][1]}); }
*
*
* var FRchart = new Highcharts.Chart({ chart: { renderTo: 'FRshowChart',
* var Rchart = new Highcharts.Chart({ chart: { renderTo: 'RshowChart',
* defaultSeriesType: 'bar' }, title: { text: 'Historic World Population by
* Region' }, xAxis: { categories: chartCategories, title: { text: null } },
* yAxis: { min: -5000000, title: { text: 'Population (millions)', align: 'high' } },
@@ -975,17 +973,17 @@ var FRchart;
}
function getReportData(inParams, successFunction) {
if (isAuthRequest == true) getReportDataAuth(inParams, successFunction)
else getReportDataNoAuth(inParams, successFunction);
function getReportData(rptName, inParams, successFunction) {
if (isAuthRequest == true) getReportDataAuth(rptName, inParams, successFunction)
else getReportDataNoAuth(rptName, inParams, successFunction);
}
function getReportDataAuth(inParams, successFunction) {
function getReportDataAuth(rptName, inParams, successFunction) {
alert("needs fixing up, dont rely on data")
var inQueryParameters = {};
for (var i in inParams ) inQueryParameters["FR_" + i] = inParams[i];
if (rptDB > "") inQueryParameters["FR_rptDB"] = rptDB;
for (var i in inParams ) inQueryParameters["R_" + i] = inParams[i];
if (rptDB > "") inQueryParameters["R_rptDB"] = rptDB;
OAuthSimple().reset();
var OAuthProcess = (new OAuthSimple()).sign({
@@ -1029,24 +1027,24 @@ function buildReportParms(inParams) {
for (var i in inParams )
{
if (paramCount > 1) reportParams += "&"
reportParams += encodeURIComponent("FR_" + i) + "=" + encodeURIComponent(inParams[i]);
reportParams += encodeURIComponent("R_" + i) + "=" + encodeURIComponent(inParams[i]);
paramCount = paramCount + 1;
}
if (rptDB > "")
{
if (paramCount > 1) reportParams += "&"
reportParams = encodeURIComponent("FR_rptDB") + "=" + encodeURIComponent(rptDB);
reportParams = encodeURIComponent("R_rptDB") + "=" + encodeURIComponent(rptDB);
}
return reportParams
}
function getReportDataNoAuth(inParams, successFunction) {
function getReportDataNoAuth(rptName, inParams, successFunction) {
var inQueryParameters = buildReportParms(inParams);
showMsgE("getReportDataNoAuth: " + inQueryParameters);
$.ajax({
url: RESTUrl,
url: RESTUrl + "/" + rptName,
type:'GET',
dataType: 'json',
data: inQueryParameters,
@@ -1068,10 +1066,13 @@ function getReportDataNoAuth(inParams, successFunction) {
}
function getExportCSV(inParams) {
function getExportCSV(rptName, inParams) {
var inQueryParameters = buildReportParms(inParams);
var fullExportUrl = RESTUrl + "?" + inQueryParameters + "&exportCSV=true";
if (inQueryParameters > "") inQueryParameters = "?" + inQueryParameters + "&exportCSV=true"
else inQueryParameters = "?exportCSV=true"
var fullExportUrl = RESTUrl + "/" + rptName + inQueryParameters;
showMsg("full export url: " + fullExportUrl);
var loadHTML = '<iframe id=rptLoadingFrame src="' + fullExportUrl + '" frameborder="0" onload="jQuery.stretchyReporting.clearLoadingImg();" width="100%" height="600px" style="background:url(';
loadHTML += "'" + loadingImg + "'" + ') no-repeat scroll 50% 100px;"><p>Your browser does not support iframes.</p></iframe>';
@@ -1081,8 +1082,9 @@ function getExportCSV(inParams) {
}
function getPentahoReport(inParams) {
function getPentahoReport(rptName, inParams) {
//todo
var currentReportName = inparams.name; //remember to include this when doing pentaho example
var inQueryParameters = "?output-type=" + $('#rptOutputType option:selected').val();
// var paramCount = 1;
for (var i in inParams )
@@ -16,6 +16,6 @@
<script type="text/javascript" src="${resValue}/libs/DataTables-1.8.2/extras/TableTools/media/js/TableTools.min.js"></script>
<script type="text/javascript" src="${resValue}/libs/jquery.i18n.properties-min-1.0.9.js"></script>
<script type="text/javascript" src="${resValue}/libs/OAuthSimple.js"></script>
<script type="text/javascript" src="${resValue}/stretchyreporting/stretchyreporting-0.967.js"></script>
<script type="text/javascript" src="${resValue}/stretchyreporting/stretchyreporting-0.968.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
@@ -7,6 +7,7 @@ import java.util.Set;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
@@ -35,14 +36,14 @@ public class ReportingApiResource {
private ReadExtraDataAndReportingService ReadExtraDataAndReportingService;
@GET
@Path("{reportName}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, "application/x-msdownload" })
public Response retrieveReport(@Context UriInfo uriInfo) {
public Response retrieveReport(@PathParam("reportName") final String reportName, @Context UriInfo uriInfo) {
MultivaluedMap<String, String> queryParams = uriInfo
.getQueryParameters();
String name = queryParams.getFirst("FR_Name");
String type = queryParams.getFirst("FR_Type");
String type = queryParams.getFirst("R_Type");
String exportCSV = queryParams.getFirst("exportCSV");
Map<String, String> extractedQueryParams = new HashMap<String, String>();
@@ -52,29 +53,29 @@ public class ReportingApiResource {
String pValue;
for (String k : keys) {
if (k.startsWith("FR_")) {
pKey = "${" + k.substring(3) + "}";
if (k.startsWith("R_")) {
pKey = "${" + k.substring(2) + "}";
pValue = queryParams.get(k).get(0);
extractedQueryParams.put(pKey, pValue);
}
}
logger.info("BEGINNING REQUEST FOR: " + name);
logger.info("BEGINNING REQUEST FOR: " + reportName);
if ((exportCSV == null) || (!(exportCSV.equalsIgnoreCase("true")))) {
GenericResultset result = this.ReadExtraDataAndReportingService
.retrieveGenericResultset(name, type, extractedQueryParams);
.retrieveGenericResultset(reportName, type, extractedQueryParams);
return Response.ok().entity(result).build();
}
StreamingOutput result = this.ReadExtraDataAndReportingService
.retrieveReportCSV(name, type, extractedQueryParams);
.retrieveReportCSV(reportName, type, extractedQueryParams);
return Response
.ok()
.entity(result)
.header("Content-Disposition",
"attachment;filename=" + name.replaceAll(" ", "")
"attachment;filename=" + reportName.replaceAll(" ", "")
+ ".csv").build();
}