Skip to content

Commit

Permalink
Merge pull request #7 from spryker-middleware/dev
Browse files Browse the repository at this point in the history
Release 1.0.0
  • Loading branch information
vhrychenko authored May 15, 2018
2 parents dafdd8e + b74dae3 commit c1339fb
Show file tree
Hide file tree
Showing 32 changed files with 1,585 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
build:
dependencies:
before:
- composer config repositories.spryker composer https://code.spryker.com/repo/private
environment:
php:
version: 7.1

checks:
php:
code_rating: true

filter:
excluded_paths:
- config/*
- tests/*
- src/Generated/*
- src/Pyz/*
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
language: php

php:
- 7.1

cache:
directories:
- vendor
- $HOME/.composer/cache

env:
global:
- APPLICATION_ENV=development
- APPLICATION_STORE=DE

install:
- composer install --no-interaction --prefer-dist

script:
- vendor/bin/phpcs src --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml
- vendor/bin/phpmd src text vendor/spryker/architecture-sniffer/src/ruleset.xml --minimumpriority=2

notifications:
email: false
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Report Module
Report module provides reporting functionality for Spryker Middleware
[![Build Status](https://travis-ci.org/spryker-middleware/report.svg?branch=master)](https://travis-ci.org/spryker-middleware/report)

## Installation

Expand Down
21 changes: 21 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace: SprykerMiddleware
actor: Tester

include:
- tests/SprykerMiddlewareTest/Zed/Report

paths:
tests: tests
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
settings:
bootstrap: _bootstrap.php
suite_class: \PHPUnit_Framework_TestSuite
colors: true
memory_limit: 1024M
log: true
coverage:
enabled: true
whitelist: { include: ['src/*'] }
13 changes: 12 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@
"license": "MIT",
"require": {
"php": ">=7.1",
"spryker-middleware/process": "dev-dev"
"spryker-middleware/process": "^1.0.0"
},
"require-dev": {
"spryker/calculation": "*",
"spryker/cart": "*",
"spryker/code-sniffer": "*",
"spryker/propel": "*",
"spryker/silex": "*",
"spryker/testify": "*",
"spryker/transfer": "*",
"spryker/architecture-sniffer": "dev-master",
"phpmd/phpmd": "^2.4"
},
"autoload": {
"psr-4": {
Expand Down
40 changes: 40 additions & 0 deletions src/SprykerMiddleware/Shared/Process/Transfer/process.transfer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0"?>
<transfers xmlns="spryker:transfer-01"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="spryker:transfer-01 http://static.spryker.com/transfer-01.xsd">

<transfer name="ProcessResult">
<property name="processName" type="string"/>
<property name="startTime" type="int"/>
<property name="endTime" type="int"/>
<property name="itemCount" type="int"/>
<property name="processedItemCount" type="int"/>
<property name="failedItemCount" type="int"/>
<property name="skippedItemCount" type="int"/>
<property name="stageResults" type="StageResults[]" singular="stageResult"/>
<property name="processConfiguration" type="ProcessConfiguration"/>
</transfer>

<transfer name="StageResults">
<property name="stageName" type="string"/>
<property name="inputItemCount" type="string"/>
<property name="outputItemCount" type="string"/>
<property name="totalExecutionTime" type="int"/>
</transfer>

<transfer name="ProcessConfiguration">
<property name="iteratorPluginName" type="string"/>
<property name="inputStreamPlugin" type="StreamConfiguration"/>
<property name="outputStreamPlugin" type="StreamConfiguration"/>
<property name="loggerPluginName" type="string"/>
<property name="stagePluginNames" type="string[]" singular="stagePluginName"/>
<property name="preProcessHookPluginNames" type="string[]" singular="preProcessHookPluginName"/>
<property name="postProcessHookPluginNames" type="string[]" singular="postProcessHookPluginName"/>
</transfer>

<transfer name="StreamConfiguration">
<property name="StreamPluginName" type="string"/>
<property name="path" type="string"/>
</transfer>

</transfers>
77 changes: 77 additions & 0 deletions src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace SprykerMiddleware\Zed\Report\Business\Model;

use Generated\Shared\Transfer\ProcessResultTransfer;
use Generated\Shared\Transfer\SpyProcessEntityTransfer;
use SprykerMiddleware\Zed\Report\Persistence\ReportEntityManagerInterface;
use SprykerMiddleware\Zed\Report\Persistence\ReportRepositoryInterface;

class ProcessResult implements ProcessResultInterface
{
/**
* @var \SprykerMiddleware\Zed\Report\Persistence\ReportRepositoryInterface
*/
protected $reportRepository;

/**
* @var \SprykerMiddleware\Zed\Report\Persistence\ReportEntityManagerInterface
*/
protected $reportEntityManager;

/**
* @param \SprykerMiddleware\Zed\Report\Persistence\ReportRepositoryInterface $reportRepository
* @param \SprykerMiddleware\Zed\Report\Persistence\ReportEntityManagerInterface $reportEntityManager
*/
public function __construct(
ReportRepositoryInterface $reportRepository,
ReportEntityManagerInterface $reportEntityManager
) {
$this->reportRepository = $reportRepository;
$this->reportEntityManager = $reportEntityManager;
}

/**
* @param \Generated\Shared\Transfer\ProcessResultTransfer $processResultTransfer
*
* @return \Generated\Shared\Transfer\ProcessResultTransfer
*/
public function saveProcessResult(ProcessResultTransfer $processResultTransfer): ProcessResultTransfer
{
$spyProcessEntityTransfer = new SpyProcessEntityTransfer();
$spyProcessEntityTransfer->setProcessName($processResultTransfer->getProcessName());
$spyProcessEntityTransfer = $this->reportEntityManager->saveProcess($spyProcessEntityTransfer);

return $this->reportEntityManager->saveProcessResult($processResultTransfer, $spyProcessEntityTransfer);
}

/**
* @param int $idResult
*
* @return \Generated\Shared\Transfer\ProcessResultTransfer
*/
public function findProcessResultByResultId(int $idResult): ProcessResultTransfer
{
return $this->reportRepository->findProcessResultByResultId($idResult);
}

/**
* @param int $idResult
*
* @return \Generated\Shared\Transfer\SpyProcessEntityTransfer
*/
public function findProcessByIdResult(int $idResult): SpyProcessEntityTransfer
{
return $this->reportRepository->findProcessByIdResult($idResult);
}

/**
* @param int $idProcess
*
* @return \Generated\Shared\Transfer\SpyProcessEntityTransfer
*/
public function findProcessByProcessId(int $idProcess): SpyProcessEntityTransfer
{
return $this->reportRepository->findProcessByProcessId($idProcess);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace SprykerMiddleware\Zed\Report\Business\Model;

use Generated\Shared\Transfer\ProcessResultTransfer;
use Generated\Shared\Transfer\SpyProcessEntityTransfer;

interface ProcessResultInterface
{
/**
* @param \Generated\Shared\Transfer\ProcessResultTransfer $processResultTransfer
*
* @return \Generated\Shared\Transfer\ProcessResultTransfer
*/
public function saveProcessResult(ProcessResultTransfer $processResultTransfer): ProcessResultTransfer;

/**
* @param int $idResult
*
* @return \Generated\Shared\Transfer\ProcessResultTransfer
*/
public function findProcessResultByResultId(int $idResult): ProcessResultTransfer;

/**
* @param int $idResult
*
* @return \Generated\Shared\Transfer\SpyProcessEntityTransfer
*/
public function findProcessByIdResult(int $idResult): SpyProcessEntityTransfer;

/**
* @param int $idProcess
*
* @return \Generated\Shared\Transfer\SpyProcessEntityTransfer
*/
public function findProcessByProcessId(int $idProcess): SpyProcessEntityTransfer;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace SprykerMiddleware\Zed\Report\Business;

use Spryker\Zed\Kernel\Business\AbstractBusinessFactory;
use SprykerMiddleware\Zed\Report\Business\Model\ProcessResult;
use SprykerMiddleware\Zed\Report\Business\Model\ProcessResultInterface;

/**
* @method \SprykerMiddleware\Zed\Report\Persistence\ReportRepositoryInterface getRepository()
* @method \SprykerMiddleware\Zed\Report\Persistence\ReportEntityManagerInterface getEntityManager()
*/
class ReportBusinessFactory extends AbstractBusinessFactory
{
/**
* @return \SprykerMiddleware\Zed\Report\Business\Model\ProcessResultInterface
*/
public function createProcessResult(): ProcessResultInterface
{
return new ProcessResult(
$this->getRepository(),
$this->getEntityManager()
);
}
}
61 changes: 61 additions & 0 deletions src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace SprykerMiddleware\Zed\Report\Business;

use Generated\Shared\Transfer\ProcessResultTransfer;
use Generated\Shared\Transfer\SpyProcessEntityTransfer;
use Spryker\Zed\Kernel\Business\AbstractFacade;

/**
* @method \SprykerMiddleware\Zed\Report\Business\ReportBusinessFactory getFactory()
*/
class ReportFacade extends AbstractFacade implements ReportFacadeInterface
{
/**
* @param \Generated\Shared\Transfer\ProcessResultTransfer $processResultTransfer
*
* @return \Generated\Shared\Transfer\ProcessResultTransfer
*/
public function saveProcessResult(ProcessResultTransfer $processResultTransfer): ProcessResultTransfer
{
return $this->getFactory()
->createProcessResult()
->saveProcessResult($processResultTransfer);
}

/**
* @param int $idResult
*
* @return \Generated\Shared\Transfer\ProcessResultTransfer
*/
public function findProcessResultByResultId(int $idResult): ProcessResultTransfer
{
return $this->getFactory()
->createProcessResult()
->findProcessResultByResultId($idResult);
}

/**
* @param int $idResult
*
* @return \Generated\Shared\Transfer\SpyProcessEntityTransfer
*/
public function findProcessByIdResult(int $idResult): SpyProcessEntityTransfer
{
return $this->getFactory()
->createProcessResult()
->findProcessByIdResult($idResult);
}

/**
* @param int $idProcess
*
* @return \Generated\Shared\Transfer\SpyProcessEntityTransfer
*/
public function findProcessByProcessId(int $idProcess): SpyProcessEntityTransfer
{
return $this->getFactory()
->createProcessResult()
->findProcessByProcessId($idProcess);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace SprykerMiddleware\Zed\Report\Business;

use Generated\Shared\Transfer\ProcessResultTransfer;
use Generated\Shared\Transfer\SpyProcessEntityTransfer;

interface ReportFacadeInterface
{
/**
* @param \Generated\Shared\Transfer\ProcessResultTransfer $processResultTransfer
*
* @return \Generated\Shared\Transfer\ProcessResultTransfer
*/
public function saveProcessResult(ProcessResultTransfer $processResultTransfer): ProcessResultTransfer;

/**
* @param int $idResult
*
* @return \Generated\Shared\Transfer\ProcessResultTransfer
*/
public function findProcessResultByResultId(int $idResult): ProcessResultTransfer;

/**
* @param int $idResult
*
* @return \Generated\Shared\Transfer\SpyProcessEntityTransfer
*/
public function findProcessByIdResult(int $idResult): SpyProcessEntityTransfer;

/**
* @param int $idProcess
*
* @return \Generated\Shared\Transfer\SpyProcessEntityTransfer
*/
public function findProcessByProcessId(int $idProcess): SpyProcessEntityTransfer;
}
Loading

0 comments on commit c1339fb

Please sign in to comment.