Skip to content

Commit

Permalink
Miscellaneous EIS fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Feb 18, 2024
1 parent 823bda8 commit ed3a2d4
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 13 deletions.
21 changes: 11 additions & 10 deletions app/src/Lib/Traits/PrimaryLinkTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ trait PrimaryLinkTrait {
// pairs, where the key is the field (eg: co_id) and the value is the table
// (eg: Cos).
private $primaryLinks = [];

// Allow empty primary link?
private $allowEmpty = false;
private $allowEmptyActions = [];

// Actions that can have an unkeyed (ie: self asserted) primary link ID
private $unkeyedActions = ['add', 'index'];
Expand Down Expand Up @@ -69,14 +69,15 @@ public function acceptsCoId(): bool {
}

/**
* Whether the primary link is permitted to be empty.
* Check to see whether the specified actions permits the primary link to be empty.
*
* @since COmanage Registry v5.0.0
* @param boolean $allowEmpty true if the primary link is permitted to be empty
* @param string $action Action
* @return boolean true if permitted, false otherwise
*/

public function allowEmptyPrimaryLink() {
return $this->allowEmpty;
public function allowEmptyPrimaryLink(string $action) {
return in_array($action , $this->allowEmptyActions);
}

/**
Expand Down Expand Up @@ -251,7 +252,7 @@ public function getPrimaryLinks(): array {
*/

public function getPrimaryLinkTableName(string $primaryLink): string {
return $this->primaryLinks[$primaryLink];
return $this->primaryLinks[$primaryLink] ?? 'Cos';
}

/**
Expand Down Expand Up @@ -421,11 +422,11 @@ public function setAcceptsCoId(bool $accepts) {
* Set whether the primary link is permitted to be empty.
*
* @since COmanage Registry v5.0.0
* @param boolean $allowEmpty true if the primary link is permitted to be empty
* @param array $actions Actions where the primary link is allowed to be empty
*/

public function setAllowEmptyPrimaryLink(bool $allowEmpty) {
$this->allowEmpty = $allowEmpty;
public function setAllowEmptyPrimaryLink(array $actions) {
$this->allowEmptyActions = array_merge($this->allowEmptyActions, $actions);
}

/**
Expand Down
25 changes: 24 additions & 1 deletion app/src/Model/Table/ExtIdentitySourceRecordsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ExtIdentitySourceRecordsTable extends Table {
use \App\Lib\Traits\PermissionsTrait;
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\QueryModificationTrait;
use \App\Lib\Traits\SearchFilterTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;

Expand Down Expand Up @@ -72,10 +73,32 @@ public function initialize(array $config): void {
$this->setPrimaryLink(['external_identity_source_id']);
$this->setRequiresCO(true);

$this->setViewContains([
// These are required for the link to work from the Artifacts page
$this->setAllowUnkeyedPrimaryCO(['index']);
$this->setAllowEmptyPrimaryLink(['index']);

$this->setIndexContains([
'ExternalIdentitySources'
]);

$this->setViewContains([
'ExternalIdentitySources'
]);
/*
// XXX This doesn't seem to correlate to what actually renders?
$this->setFilterConfig([
'external_identity_source_id' => [
'type' => 'field',
'active' => true,
'order' => 1
],
'source_key' => [
'type' => 'field',
'active' => true,
'order' => 2
]
]);*/

$this->setPermissions([
// Actions that operate over an entity (ie: require an $id)
'entity' => [
Expand Down
1 change: 1 addition & 0 deletions app/src/Model/Table/ExternalIdentitiesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
use \App\Lib\Enum\ActionEnum;
use \App\Lib\Enum\ExternalIdentityStatusEnum;

class ExternalIdentitiesTable extends Table {
Expand Down
3 changes: 2 additions & 1 deletion app/src/Model/Table/PipelinesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,8 @@ protected function syncExternalIdentity(
// ever able to add persistant record keys to the Backend
// interface this code should "just work".

// We do rely on this block to process EIR related models.
// We do rely on this block to process EIR related models,
// which have roleIdentifiers that allow us to match records.

foreach($externalIdentity->$amodel as $aentity) {
if($aentity->id == $arecord['id']) {
Expand Down
46 changes: 46 additions & 0 deletions app/templates/ExtIdentitySourceRecords/columns.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* COmanage Registry External Identity Source Records Index Columns
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

$indexColumns = [
// We start with id to ensure there is a clickable field in the row
'id' => [
'type' => 'link'
],
'external_identity_source_id' => [
'type' => 'relatedLink',
'model' => 'external_identity_source',
'field' => 'description',
'sortable' => true
],
'source_key' => [
'type' => 'echo',
'sortable' => true
],
'last_update' => [
'type' => 'datetime'
]
];
2 changes: 1 addition & 1 deletion app/templates/ExternalIdentities/fields-nav.inc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ $topLinks = [
[
'icon' => 'history',
'order' => 'Default',
'label' => __d('operation', 'HistoryRecords'),
'label' => __d('controller', 'HistoryRecords', [99]),
'link' => [
'controller' => 'history_records',
'action' => 'index',
Expand Down

0 comments on commit ed3a2d4

Please sign in to comment.