Skip to content

Commit

Permalink
Fix handling of unresolved requests via UI (CO-2381) and other miscel…
Browse files Browse the repository at this point in the history
…laneous fixes (NOJIRA)
  • Loading branch information
Benn Oshrin committed Apr 23, 2022
1 parent ebc5abf commit c645d96
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
8 changes: 4 additions & 4 deletions app/src/Controller/MatchgridsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,16 @@ public function reconcile(string $id) {
throw new \RuntimeException(__('match.er.args', ['reconcile']));
}

$results = $MatchService->getRequest($rowId);
$request = $MatchService->getRequest($rowId);
$candidates = [];

if($results->count() == 0) {
if($request->count() == 0) {
// No such request ID
throw new \RuntimeException(__('match.er.reconcile.notfound', [$rowId]));
}

// Parse the original request
$origReq = $results->getRawResults();
$origReq = $request->getRawResults();

if(!empty($origReq[$rowId]['referenceId'])) {
// This is a resolved request
Expand All @@ -252,7 +252,7 @@ public function reconcile(string $id) {
// another interface to AttributeManager for the moment.
$AttributeManager = new \App\Lib\Match\AttributeManager();
// We have an array but parseFromJSON wants an object
$AttributeManager->parseFromJSON(json_decode(json_encode($results->getResultsForJson('current'))));
$AttributeManager->parseFromJSON(json_decode(json_encode($request->getResultsForJson('current'))));

$results = $MatchService->searchReferenceId($sor, $sorid, $AttributeManager);

Expand Down
4 changes: 3 additions & 1 deletion app/src/Lib/Identifier/Sequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

namespace App\Lib\Identifier;

use Cake\ORM\TableRegistry;

class Sequence extends ReferenceIdService {
/**
* Generate a Reference Identifier.
Expand All @@ -41,7 +43,7 @@ class Sequence extends ReferenceIdService {
*/

public function generate(\App\Model\Entity\Matchgrid $mgConfig, \ADOConnection $dbc) {
$MatchgridSettings = Cake\Datasource\FactoryLocator::get('Table')->get('MatchgridSettings');
$MatchgridSettings = TableRegistry::getTableLocator()->get('MatchgridSettings');

// We'll use the matchgrid ID rather than name in the sequence name to avoid
// issues if the matchgrid is renamed for some reason.
Expand Down
2 changes: 1 addition & 1 deletion app/src/Lib/Match/AttributeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function parseFromJSON(\stdClass $json) {
if(is_array($vobject) && !empty($vobject['type'])) {
$g = $vobject['type'];
} elseif(!empty($vobject->type)) {
$g = !empty($vobject->type);
$g = $vobject->type;
}

foreach($vobject as $vk => $vv) {
Expand Down
6 changes: 3 additions & 3 deletions app/src/Lib/Match/MatchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
namespace App\Lib\Match;

use Cake\Log\Log;
use Cake\Datasource\FactoryLocator;
use Cake\ORM\TableRegistry;

use \App\Lib\Enum\ConfidenceModeEnum;
use \App\Lib\Enum\ReferenceIdEnum;
Expand Down Expand Up @@ -104,7 +104,7 @@ public function attachReferenceId(string $sor, string $sorid, AttributeManager $
*/

protected function generateReferenceId() {
$MatchgridSettings = FactoryLocator::get('Table')->get('MatchgridSettings');
$MatchgridSettings = TableRegistry::getTableLocator()->get('MatchgridSettings');

if($MatchgridSettings->getReferenceIdMethod($this->mgConfig->id) == ReferenceIdEnum::Sequence) {
$IdService = new \App\Lib\Identifier\Sequence;
Expand Down Expand Up @@ -773,7 +773,7 @@ public function searchReferenceId(string $sor, string $sorid, AttributeManager $
*/

public function setConfig(int $matchgridId) {
$Matchgrids = FactoryLocator::get('Table')->get('Matchgrids');
$Matchgrids = TableRegistry::getTableLocator()->get('Matchgrids');

$this->mgConfig = $Matchgrids->findById($matchgridId)
->where(['status' => StatusEnum::Active])
Expand Down
6 changes: 3 additions & 3 deletions app/src/Lib/Traits/MatchgridLinkTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

namespace App\Lib\Traits;

use Cake\Datasource\FactoryLocator;
use Cake\ORM\TableRegistry;

trait MatchgridLinkTrait {
// Does the associated model require a matchgrid ID?
Expand Down Expand Up @@ -79,8 +79,8 @@ public function calculateMatchgridId(int $id) {
// Look up $linkAttr to get its Matchgrid. We currently assume only
// one level of nesting.

$linkTable = FactoryLocator::get('Table')->get($this->getPrimaryLinkTableName());

$linkTable = TableRegistry::getTableLocator()->get($this->getPrimaryLinkTableName());
return $linkTable->calculateMatchgridId($obj->$linkAttr);
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/Model/Table/ApiUsersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Datasource\FactoryLocator;
use Cake\ORM\TableRegistry;
use Cake\Validation\Validator;

use \App\Lib\Enum\ResolutionModeEnum;
Expand Down Expand Up @@ -122,7 +122,7 @@ public function checkUsername(\App\Model\Entity\ApiUser $entity, array $options)
if($entity->matchgrid_id) {
// This is a Matchgrid API user, so make sure it is prefixed with the matchgrid name

$matchgrids = FactoryLocator::get('Table')->get('Matchgrids');
$matchgrids = TableRegistry::getTableLocator()->get('Matchgrids');
// This throws Cake\Datasource\Exception\RecordNotFoundException if not found
$matchgrid = $matchgrids->get($entity->matchgrid_id);

Expand Down
4 changes: 2 additions & 2 deletions app/src/Model/Table/MatchgridRecordsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
namespace App\Model\Table;

use Cake\ORM\Table;
use Cake\Datasource\FactoryLocator;
use Cake\ORM\TableRegistry;

class MatchgridRecordsTable extends Table {
use \App\Lib\Traits\AutoViewVarsTrait;
Expand Down Expand Up @@ -67,7 +67,7 @@ public function initialize(array $config): void {
// Use the matchgrid ID to figure out the attribute configuration for
// search filter purposes

$Matchgrid = FactoryLocator::get('Table')->get('Matchgrids');
$Matchgrid = TableRegistry::getTableLocator()->get('Matchgrids');

$mgconfig = $Matchgrid->getMatchgridConfig($config['matchgrid_id']);

Expand Down

0 comments on commit c645d96

Please sign in to comment.