Compare commits

..

No commits in common. 'main' and 'laravel-11' have entirely different histories.

@ -7,7 +7,8 @@ use Ae3\JasperServer\Laravel\Integrator\app\Enums\ReportFormatEnum;
use Ae3\JasperServer\Laravel\Integrator\app\Services\Contracts\JasperServerRequestServiceContract; use Ae3\JasperServer\Laravel\Integrator\app\Services\Contracts\JasperServerRequestServiceContract;
use Jaspersoft\Client\Client; use Jaspersoft\Client\Client;
class JasperServerRequestService implements JasperServerRequestServiceContract { class JasperServerRequestService implements JasperServerRequestServiceContract
{
/** /**
* @var Client|null * @var Client|null
*/ */
@ -89,7 +90,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param $value * @param $value
* @return $this * @return $this
*/ */
public function addInputControl(string $key, $value): self { public function addInputControl(string $key, $value): self
{
if (!$this->inputControls) { if (!$this->inputControls) {
$this->inputControls = []; $this->inputControls = [];
} }
@ -101,7 +103,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param int $timeout * @param int $timeout
* @return $this * @return $this
*/ */
public function setRequestTimeout(int $timeout): self { public function setRequestTimeout(int $timeout): self
{
$this->requestTimeout = $timeout; $this->requestTimeout = $timeout;
return $this; return $this;
} }
@ -110,7 +113,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param string $format * @param string $format
* @return $this * @return $this
*/ */
public function setFormat(string $format): self { public function setFormat(string $format): self
{
$this->format = $format; $this->format = $format;
return $this; return $this;
} }
@ -119,7 +123,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param $attachmentsPrefix * @param $attachmentsPrefix
* @return $this * @return $this
*/ */
public function setAttachmentsPrefix($attachmentsPrefix): self { public function setAttachmentsPrefix($attachmentsPrefix): self
{
$this->attachmentsPrefix = $attachmentsPrefix; $this->attachmentsPrefix = $attachmentsPrefix;
return $this; return $this;
} }
@ -128,7 +133,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param bool $freshData * @param bool $freshData
* @return $this * @return $this
*/ */
public function setFreshData(bool $freshData): self { public function setFreshData(bool $freshData): self
{
$this->freshData = $freshData; $this->freshData = $freshData;
return $this; return $this;
} }
@ -137,7 +143,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param bool $interactive * @param bool $interactive
* @return $this * @return $this
*/ */
public function setInteractive(bool $interactive): self { public function setInteractive(bool $interactive): self
{
$this->interactive = $interactive; $this->interactive = $interactive;
return $this; return $this;
} }
@ -146,7 +153,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param bool $onePagePerSheet * @param bool $onePagePerSheet
* @return $this * @return $this
*/ */
public function setOnePagePerSheet(bool $onePagePerSheet): self { public function setOnePagePerSheet(bool $onePagePerSheet): self
{
$this->onePagePerSheet = $onePagePerSheet; $this->onePagePerSheet = $onePagePerSheet;
return $this; return $this;
} }
@ -155,7 +163,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param string $pages * @param string $pages
* @return $this * @return $this
*/ */
public function setPages(string $pages): self { public function setPages(string $pages): self
{
$this->pages = $pages; $this->pages = $pages;
return $this; return $this;
} }
@ -164,7 +173,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param bool $saveDataSnapshot * @param bool $saveDataSnapshot
* @return $this * @return $this
*/ */
public function setSaveDataSnapshot(bool $saveDataSnapshot): self { public function setSaveDataSnapshot(bool $saveDataSnapshot): self
{
$this->saveDataSnapshot = $saveDataSnapshot; $this->saveDataSnapshot = $saveDataSnapshot;
return $this; return $this;
} }
@ -173,7 +183,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param string $transformerKey * @param string $transformerKey
* @return $this * @return $this
*/ */
public function setTransformerKey(string $transformerKey): self { public function setTransformerKey(string $transformerKey): self
{
$this->transformerKey = $transformerKey; $this->transformerKey = $transformerKey;
return $this; return $this;
} }
@ -182,7 +193,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param string $contentDisposition * @param string $contentDisposition
* @return $this * @return $this
*/ */
public function setContentDisposition(string $contentDisposition): self { public function setContentDisposition(string $contentDisposition): self
{
$this->contentDisposition = $contentDisposition; $this->contentDisposition = $contentDisposition;
return $this; return $this;
} }
@ -190,7 +202,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
/** /**
* @return string Binary data of report * @return string Binary data of report
*/ */
public function getReport(): string { public function getReport(): string
{
return $this->report; return $this->report;
} }
@ -198,11 +211,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param string $uri * @param string $uri
* @return $this * @return $this
*/ */
public function call(string $uri): self { public function call(string $uri): self
if (method_exists($this->client, 'setRequestTimeout')) { {
$this->client->setRequestTimeout($this->requestTimeout);
}
$this->report = $this->client->reportService()->runReport( $this->report = $this->client->reportService()->runReport(
$uri, $uri,
$this->format, $this->format,
@ -222,7 +232,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
/** /**
* @return void * @return void
*/ */
public function inline(): void { public function inline(): void
{
$this->setContentDisposition(ContentDispositionEnum::INLINE); $this->setContentDisposition(ContentDispositionEnum::INLINE);
$this->setHeader($this->report); $this->setHeader($this->report);
echo $this->getReport(); echo $this->getReport();
@ -232,7 +243,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param string|null $filename * @param string|null $filename
* @return void * @return void
*/ */
public function download(?string $filename = null): void { public function download(?string $filename = null): void
{
if (in_array($this->format, ReportFormatEnum::downloadable())) { if (in_array($this->format, ReportFormatEnum::downloadable())) {
$this->setContentDisposition(ContentDispositionEnum::ATTACHMENT); $this->setContentDisposition(ContentDispositionEnum::ATTACHMENT);
$this->setHeader($this->report, $filename); $this->setHeader($this->report, $filename);
@ -246,7 +258,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param string|null $filename * @param string|null $filename
* @return void * @return void
*/ */
private function setHeader(string $report, ?string $filename = null) { private function setHeader(string $report, ?string $filename = null)
{
if (!$filename) { if (!$filename) {
$filename = uniqid(); $filename = uniqid();
} }
@ -266,7 +279,8 @@ class JasperServerRequestService implements JasperServerRequestServiceContract {
* @param string $filename * @param string $filename
* @return string * @return string
*/ */
private function appendFormatExtension(string $filename): string { private function appendFormatExtension(string $filename): string
return $filename . '.' . $this->format; {
} return $filename . '.' . $this->format;
}
} }

Loading…
Cancel
Save