Skip to content

Commit

Permalink
Various fixes (NOJIRA)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Jan 15, 2019
1 parent 6be06a2 commit 7ff1b1d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/src/Controller/Component/AuthorizationComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AuthorizationComponent extends Component {
* @since COmanage Match v1.0.0
*/

public function initialize($config) {
public function initialize(array $config) {
parent::initialize($config);

$this->Permissions = TableRegistry::get('Permissions');
Expand Down
8 changes: 4 additions & 4 deletions app/src/Lib/Match/MatchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ protected function upsert(string $sor, string $sorid, AttributeManager $attribut

$rowid = null;

$dbh->startTrans();
$this->dbc->startTrans();

try {
// SELECT FOR UPDATE only locks rows of matching records. ie: On an insert
Expand All @@ -726,16 +726,16 @@ protected function upsert(string $sor, string $sorid, AttributeManager $attribut

$stmt = $this->dbc->Prepare($sql);

$rowid = (int)$this->dbc->GetOne($stmt, [$sor, $sorid]);
$rowid = $this->dbc->GetOne($stmt, [$sor, $sorid]);

if($rowid !== null) {
// $rowid should be the same before and after
$rowid = $this->update($rowid, $attributes, $referenceId);
$rowid = $this->update((int)$rowid, $attributes, $referenceId);
} else {
$rowid = $this->insert($sor, $sorid, $attributes, $referenceId);
}

$dbh->commit();
$this->dbc->completeTrans();
}
catch(\Exception $e) {
$dbh->failTrans();
Expand Down
25 changes: 13 additions & 12 deletions app/src/Lib/Match/ResultManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,10 @@ class ResultManager {
* @since COmanage Match v1.0.0
* @param string $referenceId Reference ID
* @param array $attributes Array of matchgrid attributes
* @throws RuntimeException
*/

public function add(array $attributes) {
// XXX note this overwrites any previous candidate with the same referenceId, is that OK?
// what if there are two SOR entries with different attributes but the same referenceId?
// $this->results[$referenceId][$rowId] = $attributes;

if(empty($attributes)) {
return;
}
Expand All @@ -83,7 +80,12 @@ public function add(array $attributes) {
}
}

// XXX throw error if !$referenceId || $rowid
// We might get a null $referenceId (pending matches), but we shouldn't get
// a null $rowId.
if(!$rowId) {
throw new \RuntimeException(__('match.er.format'));
}

$this->results[$referenceId][$rowId] = $parsed;

$this->rawResults[$rowId] = $attributes;
Expand Down Expand Up @@ -142,13 +144,11 @@ public function getReferenceIds() {
*/

public function getResultsForJson($mode="search") {
// XXX why does this set everything BUT the top level attribute? ("candidates" or "matchRequests")
$ret = [];

foreach($this->results as $referenceId => $sorRow) {
// XXX note $candidate is NOT used by mode=pending
// Note $candidate is not used by mode=pending
$candidate = ['referenceId' => $referenceId];
// XXX add confidence?

foreach($sorRow as $rowId => $attrs) {
$parsed = ['matchRequest' => $rowId];
Expand All @@ -172,7 +172,6 @@ public function getResultsForJson($mode="search") {
$complex[ $super[0] ][ $sub[1] ][ $sub[0] ] = $v;
}
} elseif($a == 'sorid') {
// XXX should this be handled via Attribute Manager? or a config entry?
// Special case
$parsed['identifiers'][] = [
"type" => "sor",
Expand Down Expand Up @@ -203,7 +202,6 @@ public function getResultsForJson($mode="search") {

unset($candidate['sorAttributes']['request_time']);

// XXX Note resolutionTime not yet defined in strawman
if(!empty($candidate['sorAttributes']['resolution_time'])) {
$candidate['resolutionTime'] = strftime("%FT%TZ",
strtotime($candidate['sorAttributes']['resolution_time']));
Expand All @@ -228,8 +226,11 @@ public function getResultsForJson($mode="search") {
$ret[$rowId]['referenceId'] = $referenceId;
}
} else {
// XXX request/resolution time are not defined in the strawman for potential match
// results, should they be?
// Bump up request time, there shouldn't be a resolution_time for
// pending requests
$candidate['requestTime'] = strftime("%FT%TZ",
strtotime($parsed['request_time']));

unset($parsed['request_time']);
unset($parsed['resolution_time']);

Expand Down
2 changes: 1 addition & 1 deletion app/src/Template/Matchgrids/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ if($action == 'add' || $action == 'edit') {
print $this->Field->control('referenceid_start',
['default' => 1001]);

print $this->Field->control('referenceid_prefix',
print $this->Field->control('referenceid-prefix',
[],
false);
}

0 comments on commit 7ff1b1d

Please sign in to comment.