From 5ac44dd01f8510c1ddb198ba0021b51e561e301c Mon Sep 17 00:00:00 2001 From: Brett Minnie Date: Mon, 12 May 2014 15:32:00 +0100 Subject: [PATCH 1/6] Added internal support for Y-d-m H:i:s date format --- composer.lock | 10 +++++----- src/Opg/Common/Model/Entity/DateFormat.php | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 9f9633e4..653f8e52 100644 --- a/composer.lock +++ b/composer.lock @@ -1022,16 +1022,16 @@ }, { "name": "guzzle/guzzle", - "version": "v3.9.0", + "version": "v3.9.1", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle3.git", - "reference": "e4d12d7d6acccf75a5e504114e2df9195e494108" + "reference": "92d9934f2fca1da15178c91239576ae26e505e60" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/e4d12d7d6acccf75a5e504114e2df9195e494108", - "reference": "e4d12d7d6acccf75a5e504114e2df9195e494108", + "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/92d9934f2fca1da15178c91239576ae26e505e60", + "reference": "92d9934f2fca1da15178c91239576ae26e505e60", "shasum": "" }, "require": { @@ -1110,7 +1110,7 @@ "rest", "web service" ], - "time": "2014-04-23 21:43:40" + "time": "2014-05-07 17:04:22" }, { "name": "jms/metadata", diff --git a/src/Opg/Common/Model/Entity/DateFormat.php b/src/Opg/Common/Model/Entity/DateFormat.php index 84d28ba7..ce84d4b4 100644 --- a/src/Opg/Common/Model/Entity/DateFormat.php +++ b/src/Opg/Common/Model/Entity/DateFormat.php @@ -15,6 +15,7 @@ final class DateFormat const REGEXP_DATE_TIME = '/^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}$/'; + const REGEXP_MYSQL_DATE_TIME = '/[0-9]{4}-[0-9]{1,2}-[0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}$/'; /** * @var string */ @@ -25,6 +26,11 @@ final class DateFormat */ protected static $DateTimeFormat = 'd/m/Y H:i:s'; + /** + * @var string + */ + protected static $DateTimeMysqlExport = 'Y-d-m H:i:s'; + /** * @return string */ @@ -57,6 +63,10 @@ public static function createDateTime($strDateTime) return \DateTime::createFromFormat(self::getDateTimeFormat(), $strDateTime); } + if (preg_match(self::REGEXP_MYSQL_DATE_TIME, trim($strDateTime))) { + return \DateTime::createFromFormat(self::$DateTimeMysqlExport, $strDateTime); + } + throw new InvalidDateFormatException( "'{$strDateTime}' was not in the expected format " . self::getDateTimeFormat() ); From f79d9ed0f0c6296260306a1972333b34beb3801e Mon Sep 17 00:00:00 2001 From: Brett Minnie Date: Thu, 15 May 2014 13:52:29 +0100 Subject: [PATCH 2/6] APOLLO-2823 plugged in per task rag-rating stub --- src/Opg/Common/Model/Entity/HasRagRating.php | 12 ++++++ .../Core/Model/Entity/CaseItem/Task/Task.php | 37 +++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 src/Opg/Common/Model/Entity/HasRagRating.php diff --git a/src/Opg/Common/Model/Entity/HasRagRating.php b/src/Opg/Common/Model/Entity/HasRagRating.php new file mode 100644 index 00000000..6e91572e --- /dev/null +++ b/src/Opg/Common/Model/Entity/HasRagRating.php @@ -0,0 +1,12 @@ +setCreatedTime(); } @@ -150,7 +160,7 @@ public function setDueDateString($dueDate) } /** - * @return string $dueDate + * @return \DateTime $dueDate */ public function getDueDate() { @@ -430,4 +440,25 @@ public function setCase(CaseItem $case) return $this; } + + /** + * @return int + */ + public function getRagRating() + { + $dateDiff = $this->getDueDate()->diff(new \DateTime); + + $daysOffset = $dateDiff->days; + if($dateDiff->invert == 1) { + $daysOffset *= -1; + } + + if ($daysOffset > 0) { + return 3; + } + elseif ($daysOffset < 0) { + return 1; + } + return 2; + } } From 97760d816e82c57311435f63088734c547f9183d Mon Sep 17 00:00:00 2001 From: Brett Minnie Date: Thu, 15 May 2014 14:15:51 +0100 Subject: [PATCH 3/6] APOLLO-2824 Case rag rating stubbed in --- .../Core/Model/Entity/CaseItem/CaseItem.php | 59 ++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/src/Opg/Core/Model/Entity/CaseItem/CaseItem.php b/src/Opg/Core/Model/Entity/CaseItem/CaseItem.php index b793d978..06faa41b 100755 --- a/src/Opg/Core/Model/Entity/CaseItem/CaseItem.php +++ b/src/Opg/Core/Model/Entity/CaseItem/CaseItem.php @@ -7,6 +7,7 @@ use Opg\Common\Model\Entity\EntityInterface; use Opg\Common\Model\Entity\HasNotesInterface; use Opg\Common\Model\Entity\HasCorrespondenceInterface; +use Opg\Common\Model\Entity\HasRagRating; use Opg\Common\Model\Entity\HasUidInterface; use Opg\Common\Model\Entity\Traits\ExchangeArray; use Opg\Common\Model\Entity\Traits\InputFilter; @@ -32,7 +33,8 @@ * @ORM\MappedSuperclass * @package Opg\Core\Model\Entity\CaseItem */ -abstract class CaseItem implements EntityInterface, \IteratorAggregate, CaseItemInterface, HasUidInterface, HasNotesInterface, HasCorrespondenceInterface +abstract class CaseItem implements EntityInterface, \IteratorAggregate, CaseItemInterface, HasUidInterface, + HasNotesInterface, HasCorrespondenceInterface, HasRagRating { use ToArray; use HasNotes; @@ -196,6 +198,22 @@ abstract class CaseItem implements EntityInterface, \IteratorAggregate, CaseItem */ protected $taskStatus = []; + /** + * Non persistable entity + * @var int + * @ReadOnly + * @Accessor(getter="getRagRating") + */ + protected $ragRating; + + /** + * Non persistable entity + * @var int + * @ReadOnly + * @Accessor(getter="getRagTotal") + */ + protected $ragTotal; + public function __construct() { $this->tasks = new ArrayCollection(); @@ -707,4 +725,43 @@ public function getRegistrationDateString() return ''; } + + /** + * @return int + */ + public function getRagRating() + { + $rag = array( + '1' => 0, + '2' => 0, + '3' => 0 + ); + + foreach ($this->tasks as $taskItem) { + $rag[$taskItem->getRagRating()]++; + } + + //Apply rules + if (($rag['3'] >= 1) || $rag['2'] > 2) { + return 3; + } + elseif ($rag['2'] >= 1) { + return 2; + } + return 1; + } + + /** + * @return int + */ + public function getRagTotal() + { + $total = 0; + + foreach ($this->tasks as $taskItem) { + $total += $taskItem->getRagRating(); + } + + return $total; + } } From 23588be43460e06e0ccfd6e582fa58370103e02d Mon Sep 17 00:00:00 2001 From: Brett Minnie Date: Thu, 15 May 2014 14:29:40 +0100 Subject: [PATCH 4/6] APOLLO-2824 Updated unit tests --- .../Core/Model/Entity/CaseItem/Lpa/LpaTest.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/OpgTest/Core/Model/Entity/CaseItem/Lpa/LpaTest.php b/tests/OpgTest/Core/Model/Entity/CaseItem/Lpa/LpaTest.php index 61a32027..a9a79f42 100644 --- a/tests/OpgTest/Core/Model/Entity/CaseItem/Lpa/LpaTest.php +++ b/tests/OpgTest/Core/Model/Entity/CaseItem/Lpa/LpaTest.php @@ -481,10 +481,10 @@ public function testArrayRecursive() 'attorneyDeclarationSignatoryFullName' => null, 'correspondentComplianceAssertion' => 1, 'certificateProviders' => array(), - 'paymentByDebitCreditCard' => false, - 'paymentByCheque' => false, - 'feeExemptionAppliedFor' => false, - 'feeRemissionAppliedFor' => false, + 'paymentByDebitCreditCard' => 0, + 'paymentByCheque' => 0, + 'feeExemptionAppliedFor' => 0, + 'feeRemissionAppliedFor' => 0, 'caseAttorneySingular' => false, 'caseAttorneyJointlyAndSeverally' => false, 'caseAttorneyJointly' => false, @@ -495,12 +495,14 @@ public function testArrayRecursive() 'applicationType' => 0, 'registrationDate' => null, 'closedDate' => null, - 'lifeSustainingTreatment' => false, + 'lifeSustainingTreatment' => null, 'lifeSustainingTreatmentSignatureDate' => null, 'notificationDate' => null, 'dispatchDate' => null, 'noticeGivenDate' => null, - 'correspondence' => null + 'correspondence' => null, + 'ragRating' => null, + 'ragTotal' => null ), $lpa->toArrayRecursive() ); From baf95687f12e2d5aa508e0e29a1dea663ca79b03 Mon Sep 17 00:00:00 2001 From: Brett Minnie Date: Thu, 15 May 2014 14:30:47 +0100 Subject: [PATCH 5/6] APOLLO-2823 Updated unit tests --- tests/OpgTest/Core/Model/Entity/CaseItem/Task/TaskTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/OpgTest/Core/Model/Entity/CaseItem/Task/TaskTest.php b/tests/OpgTest/Core/Model/Entity/CaseItem/Task/TaskTest.php index 607d946d..0e8e4eae 100755 --- a/tests/OpgTest/Core/Model/Entity/CaseItem/Task/TaskTest.php +++ b/tests/OpgTest/Core/Model/Entity/CaseItem/Task/TaskTest.php @@ -27,7 +27,8 @@ class TaskTest extends \PHPUnit_Framework_TestCase 'assignedUser' => null, 'priority' => 'high', 'errorMessages' => array(), - 'case' => null + 'case' => null, + 'ragRating' => null ); /** From e348087b554ded5c948ab8ccad4702d358ed63d1 Mon Sep 17 00:00:00 2001 From: Jeremy Quinton Date: Thu, 15 May 2014 15:08:35 +0100 Subject: [PATCH 6/6] [APOLLO-2316] - removing lint checking --- build/build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/build.xml b/build/build.xml index 9e47a217..18984c7f 100755 --- a/build/build.xml +++ b/build/build.xml @@ -2,7 +2,7 @@ - +