Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/dev/release'
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrebenchuk committed Nov 21, 2013
2 parents ee405bc + 1cbe6f7 commit 5bdad6a
Show file tree
Hide file tree
Showing 803 changed files with 33,783 additions and 11,036 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
CHANGELOG for 1.0.0-beta4
===================
This changelog references the relevant changes (new features, changes and bugs) done in 1.0.0-beta4 versions.

* 1.0.0-beta4 (2013-11-21)
* Grid refactoring
* Form validation improvements
* Make all entities as Extended
* JavaScript Tests
* End support for Internet Explorer 9

CHANGELOG for 1.0.0-beta3
===================
This changelog references the relevant changes (new features, changes and bugs) done in 1.0.0-beta3 versions.
Expand Down
24 changes: 12 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"doctrine/doctrine-bundle": "dev-master#2ed46398aae1b7699f6fe7467faf54493b4f2a24",
"doctrine/data-fixtures": "dev-master#dfc0dc9a3f6258c878768218fe49cc092ea8a8d1",
"doctrine/doctrine-fixtures-bundle": "dev-master#3caec4826e58fe47520b591f965b4adcdfc8a6c8",
"twig/extensions": "dev-master#f91a82ec225e5bb108e01a0f93c9be04f84dcfa0",
"twig/extensions": "dev-master#d4dc27cc824b2b4faf7edbfbe652e3fdaec696b6",
"symfony/assetic-bundle": "2.3.x-dev#65bd076341ac54ebfcd845d8471044fc4afa73d2",
"symfony/swiftmailer-bundle": "v2.3.4",
"symfony/monolog-bundle": "2.3.x-dev#03ed73bc11367b3156cc21f22ac37c7f70fcd10a",
"sensio/distribution-bundle": "dev-master#45664e203fd1364705091a58971cc6bd94fb5189",
"sensio/framework-extra-bundle": "dev-master#403e13e384d8a81c9c8a1adfe89356e9849c14ff",
"sensio/generator-bundle": "dev-master#e2572e829cc7b3d37c8fc46c9dfad9362378aad1",
"sensio/distribution-bundle": "dev-master#52b964d793e989768a44a8900b2373bdc9ce666a",
"sensio/framework-extra-bundle": "dev-master#d9b04ebff77407597b4a419e2714cea0682f297b",
"sensio/generator-bundle": "dev-master#6e08995d9d23d0d58a68ff13165bbd9daf6e227a",
"incenteev/composer-parameter-handler": "dev-master#bc06242a63298affc72d2089f93d8986a6217c4c",
"jms/job-queue-bundle": "dev-master#46e6c362dd94140b75d0a2ae986d65e6086d0a76",
"jms/job-queue-bundle": "dev-master#0604bf53a099639a56133a9ad84c550b7c0ca434",
"jms/serializer": "dev-master#3eeb721fe0144971bc49bc8a7cb9b362d2c27780",
"jms/serializer-bundle": "dev-master#7bf5700aafbd40ba5c2ac3e10548158cec1919c5",
"kriswallsmith/assetic": "1.1.x-dev#1d671c54f147ece319642132330927672b6190a7",
Expand All @@ -28,24 +28,24 @@
"knplabs/knp-paginator-bundle": "dev-master#769b83d01b3f76b011522599bd48e5e202d94ff4",
"friendsofsymfony/rest-bundle": "0.12.0",
"friendsofsymfony/jsrouting-bundle": "1.1.5",
"nelmio/api-doc-bundle": "dev-master#8728e825eaf89a5e1234f0ec6e4040d83b645faa",
"nelmio/api-doc-bundle": "dev-master#2ceea4871a6205c421dc3ce9b0a7b350aafe7000",
"ass/xmlsecurity": "dev-master#b2108c78164bb088c4d0a3469f609e9d755b7378",
"besimple/soap-common": "dev-master#11486d1a06c4d1610a4c9580b1999b4448b6c29f",
"besimple/soap-server": "dev-master#044d3997dbaad642961d509a6b0dd07005c4dd02",
"besimple/soap-bundle": "dev-master#b227172408c6e3d9a7c35ff5f90adce18e337abb",
"besimple/soap-wsdl": "dev-master#176951e6553385ed9aa71f85005793a65a333e5f",
"besimple/soap-server": "dev-master#1f28879843293edf7eb9a8cf49f846095b5ecf18",
"besimple/soap-bundle": "dev-master#6a29771b34dae7f9347eb5d66724684ee8283e41",
"besimple/soap-wsdl": "dev-master#9ae5798b9131df64f49e9d77732ec8ecd0ebf754",
"ddeboer/data-import": "dev-master#38e463da12333acdb7d59f72c93cd16878774a08",
"stof/doctrine-extensions-bundle": "dev-master#9da4489322c5442ff021c4cd3f28dd79b2a8df07",
"escapestudios/wsse-authentication-bundle": "dev-master#b195c37bc2f5e7842b4bdae05352b66126626b42",
"liip/imagine-bundle": "dev-master#61e56cb903c07919c3db32d46fd0c229498dae53",
"liip/imagine-bundle": "dev-master#61597fc20329ccce762b07c89f6ba2d8fa0f4c09",
"leafo/lessphp": "dev-master#bc4f33b4bfc889018ebe53611050729641b82dc6",
"willdurand/expose-translation-bundle": "0.2.1",
"apy/jsfv-bundle": "dev-master#ecd74cfce030aeb1812277250318aacdd5483631",
"genemu/form-bundle": "dev-master#9a68d6811fd80d1fe908af014687562301329d6e",
"genemu/form-bundle": "dev-master#156089856016abde934b92961724b9aa728b7eae",
"zendframework/zend-mail": "2.1.5",
"a2lix/translation-form-bundle": "1.x-dev#6388ad72a88c3c15e2eaee6c56ba046a60b47556",
"mtdowling/cron-expression": "v1.0.2",
"jdare/clank-bundle": "dev-master#67d7b852fccf1df60b718478413944c406f0baff",
"jdare/clank-bundle": "dev-master#3a3ac48d9e7e7bd032779b9b211bfa6286fbfb6b",
"lexik/maintenance-bundle": "dev-master#88b76d0de06fbea03cc152fbe2ce608957cd56ee",
"sylius/flow-bundle": "dev-master#2de453578954f781dbc45bd9f1466e4103f642f1"
},
Expand Down
41 changes: 41 additions & 0 deletions src/Oro/Bundle/AddressBundle/Datagrid/CountryDatagridHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Oro\Bundle\AddressBundle\Datagrid;

use Doctrine\ORM\Query;
use Doctrine\ORM\EntityRepository;

use Oro\Bundle\DataGridBundle\Event\BuildAfter;
use Oro\Bundle\DataGridBundle\Datasource\Orm\OrmDatasource;

class CountryDatagridHelper
{
/**
* Returns query builder callback for country filter form type
*
* @return callable
*/
public function getCountryFilterQueryBuilder()
{
return function (EntityRepository $er) {
return $er->createQueryBuilder('c')
->orderBy('c.name', 'ASC');
};
}

/**
* Set country translation query walker
*
* @param BuildAfter $event
*/
public function onBuildAfter(BuildAfter $event)
{
$source = $event->getDatagrid()->getDatasource();
if ($source instanceof OrmDatasource) {
$source->getQueryBuilder()->getQuery()->setHint(
Query::HINT_CUSTOM_OUTPUT_WALKER,
'Gedmo\Translatable\Query\TreeWalker\TranslationWalker'
);
}
}
}
31 changes: 11 additions & 20 deletions src/Oro/Bundle/AddressBundle/Tests/Functional/API/RestApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,29 +209,20 @@ public function testGetCountry($countries)
}
}

/**
* @depends testGetRegions
* @param $regions
*/
public function testGetRegion($regions)
public function testGetRegion()
{
foreach ($regions as $region) {
$this->client->request(
'GET',
$this->client->generate('oro_api_get_region'),
array('id' => $region['combined_code'])
);
/** @var $result Response */
$result = $this->client->getResponse();
ToolsAPI::assertJsonResponse($result, 200);
$result = ToolsAPI::jsonToArray($result->getContent());
$this->assertEquals($region, $result);
}
$this->client->request(
'GET',
$this->client->generate('oro_api_get_region'),
array('id' => 'US.LA')
);
/** @var $result Response */
$result = $this->client->getResponse();
ToolsAPI::assertJsonResponse($result, 200);
$result = ToolsAPI::jsonToArray($result->getContent());
$this->assertEquals('US.LA', $result['combined_code']);
}

/**
* @depends testGetRegion
*/
public function testGetCountryRegion()
{
$this->client->request(
Expand Down
101 changes: 93 additions & 8 deletions src/Oro/Bundle/BatchBundle/Command/BatchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

namespace Oro\Bundle\BatchBundle\Command;

use Monolog\Handler\StreamHandler;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\Validator;
use Symfony\Component\Validator\Constraints as Assert;
use Monolog\Handler\StreamHandler;
use Doctrine\ORM\EntityManager;
use Oro\Bundle\BatchBundle\Entity\JobExecution;
use Symfony\Component\Validator\ConstraintViolationList;
use Oro\Bundle\BatchBundle\Entity\JobInstance;
use Oro\Bundle\BatchBundle\Job\ExitStatus;
use Oro\Bundle\BatchBundle\Job\BatchStatus;

Expand All @@ -30,7 +32,21 @@ protected function configure()
->setName('oro:batch:job')
->setDescription('Launch a registered job instance')
->addArgument('code', InputArgument::REQUIRED, 'Job instance code')
->addArgument('execution', InputArgument::OPTIONAL, 'Job execution id');
->addArgument('execution', InputArgument::OPTIONAL, 'Job execution id')
->addOption(
'config',
'c',
InputOption::VALUE_REQUIRED,
'Override job configuration (formatted as json. ie: ' .
'php app/console oro:batch:job -c \'[{"reader":{"filePath":"/tmp/foo.csv"}}]\' ' .
'acme_product_import)'
)
->addOption(
'email',
null,
InputOption::VALUE_REQUIRED,
'The email to notify at the end of the job execution'
);
}

/**
Expand All @@ -40,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$noDebug = $input->getOption('no-debug');
if (!$noDebug) {
$logger = $this->getContainer()->get('logger');
$logger = $this->getContainer()->get('monolog.logger.batch');
// Fixme: Use ConsoleHandler available on next Symfony version (2.4 ?)
$logger->pushHandler(new StreamHandler('php://stdout'));
}
Expand All @@ -54,11 +70,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
$job = $this->getConnectorRegistry()->getJob($jobInstance);
$jobInstance->setJob($job);

$errors = $this->getValidator()->validate($jobInstance, array('Default', 'Execution'));
if (count($errors) > 0) {
throw new \RuntimeException(sprintf('Job "%s" is invalid: %s', $code, $this->getErrorMessages($errors)));
// Override job configuration
if ($config = $input->getOption('config')) {
$job->setConfiguration(
$this->decodeConfiguration($config)
);
}

$this->validate($input, $jobInstance);

$executionId = $input->getArgument('execution');
if ($executionId) {
$jobExecution = $this->getEntityManager()->getRepository('OroBatchBundle:JobExecution')->find($executionId);
Expand Down Expand Up @@ -100,6 +120,36 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

/**
* Validate job instance
*/
protected function validate(InputInterface $input, JobInstance $jobInstance)
{
$validator = $this->getValidator();

// Override mail notifier recipient email
$email = $input->getOption('email');
if ($email) {
$errors = $validator->validateValue($email, new Assert\Email());
if (count($errors) > 0) {
throw new \RuntimeException(
sprintf('Email "%s" is invalid: %s', $email, $this->getErrorMessages($errors))
);
}
$this
->getMailNotifier()
->setRecipientEmail($email);
}

$errors = $validator->validate($jobInstance, array('Default', 'Execution'));
if (count($errors) > 0) {
throw new \RuntimeException(
sprintf('Job "%s" is invalid: %s', $jobInstance->getCode(), $this->getErrorMessages($errors))
);
}
}


/**
* @return EntityManager
*/
Expand All @@ -116,6 +166,14 @@ protected function getValidator()
return $this->getContainer()->get('validator');
}

/**
* @return Validator
*/
protected function getMailNotifier()
{
return $this->getContainer()->get('oro_batch.mail_notifier');
}

/**
* @return \Oro\Bundle\BatchBundle\Connector\ConnectorRegistry
*/
Expand All @@ -134,4 +192,31 @@ private function getErrorMessages(ConstraintViolationList $errors)

return $errorsStr;
}

private function decodeConfiguration($data)
{
$config = json_decode($data, true);

switch (json_last_error()) {
case JSON_ERROR_DEPTH:
$error = 'Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
$error = 'Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
$error = 'Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
$error = 'Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
$error = 'Malformed UTF-8 characters, possibly incorrectly encoded';
break;
default:
return $config;
}

throw new \InvalidArgumentException($error);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function getConfigTreeBuilder()

$root
->children()
->booleanNode('enable_mail_notification')->defaultFalse()->end()
->scalarNode('sender_email')->defaultValue('mailer@bap.com')->end()
->end()
->end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@ public function load(array $configs, ContainerBuilder $container)
$loader->load('services.yml');

$container->setParameter('oro_batch.mail_notifier.sender_email', $config['sender_email']);
if ($config['enable_mail_notification']) {
$container
->getDefinition('oro_batch.mail_notifier')
->addTag('oro_batch.notifier');
}
}
}
4 changes: 4 additions & 0 deletions src/Oro/Bundle/BatchBundle/Entity/JobInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use JMS\Serializer\Annotation\Exclude;
use Oro\Bundle\BatchBundle\Job\Job;

/**
Expand Down Expand Up @@ -95,6 +96,7 @@ class JobInstance
/**
* @var Job
* @Assert\Valid
* @Exclude
*/
protected $job;

Expand All @@ -106,6 +108,7 @@ class JobInstance
* cascade={"persist", "remove"},
* orphanRemoval=true
* )
* @Exclude
*/
protected $jobExecutions;

Expand Down Expand Up @@ -295,6 +298,7 @@ public function setJob($job)
$this->job = $job;

if ($job) {
// need to merge configuration to allow passing of extra parameters
$jobConfiguration = $job->getConfiguration();
$this->rawConfiguration = array_merge_recursive($this->rawConfiguration, $jobConfiguration);
}
Expand Down
Loading

0 comments on commit 5bdad6a

Please sign in to comment.