Skip to content

Commit

Permalink
Rename CoPerson to Person (CFM-7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Oct 13, 2021
1 parent a73bb4f commit 5aa9df2
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 73 deletions.
22 changes: 11 additions & 11 deletions app/config/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

"columns": {
"co_id": { "type": "integer", "foreignkey": { "table": "cos", "column": "id" }, "notnull": true },
"co_person_id": { "type": "integer", "foreignkey": { "table": "co_people", "column": "id" } },
"description": { "type": "string", "size": 128 },
"external_identity_id": { "type": "integer", "foreignkey": { "table": "external_identities", "column": "id" } },
"id": { "type": "integer", "autoincrement": true, "primarykey": true },
"name": { "type": "string", "size": 128, "notnull": true },
"org_identity_id": { "type": "integer", "foreignkey": { "table": "org_identities", "column": "id" } },
"person_id": { "type": "integer", "foreignkey": { "table": "people", "column": "id" } },
"status": { "type": "string", "size": 2 },
"type_id": { "type": "integer", "foreignkey": { "table": "types", "column": "id" }, "notnull": true },
"valid_from": { "type": "datetime" },
Expand Down Expand Up @@ -106,7 +106,7 @@
}
},

"co_people": {
"people": {
"columns": {
"id": {},
"co_id": {},
Expand All @@ -115,14 +115,14 @@
"date_of_birth": { "type": "date" }
},
"indexes": {
"co_people_i1": { "columns": [ "co_id" ] }
"people_i1": { "columns": [ "co_id" ] }
}
},

"org_identities": {
"external_identities": {
"columns": {
"id": {},
"co_person_id": { "notnull": true },
"person_id": { "notnull": true },
"status": {},
"affiliation": { "type": "string", "size": 32 },
"date_of_birth": { "type": "date" },
Expand All @@ -133,7 +133,7 @@
"valid_through": {}
},
"indexes": {
"org_identities_i1": { "columns": [ "co_person_id" ] }
"external_identities_i1": { "columns": [ "person_id" ] }
}
},

Expand All @@ -152,7 +152,7 @@
"indexes": {
"names_i1": { "columns": [ "type_id"] }
},
"mvea": [ "co_person", "org_identity" ],
"mvea": [ "person", "external_identity" ],
"sourced": true
},

Expand All @@ -166,11 +166,11 @@
"status": {}
},
"indexes": {
"identifiers_i1": { "columns": [ "identifier", "type_id", "co_person_id" ] },
"identifiers_i2": { "columns": [ "identifier", "type_id", "org_identity_id" ] },
"identifiers_i1": { "columns": [ "identifier", "type_id", "person_id" ] },
"identifiers_i2": { "columns": [ "identifier", "type_id", "external_identity_id" ] },
"identifiers_i3": { "columns": [ "type_id"] }
},
"mvea": [ "co_person", "org_identity" ],
"mvea": [ "person", "external_identity" ],
"sourced": true
}
},
Expand Down
11 changes: 7 additions & 4 deletions app/resources/locales/en_US/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ msgid "registry.cmd.opt.admin-username"
msgstr "Username of initial platform administrator"

msgid "registry.cmd.opt.force"
msgstr "Force a rerun of setup (only if you know what you are doing)""
msgstr "Force a rerun of setup (only if you know what you are doing)"

msgid "registry.cmd.opt.not"
msgstr "Calculate changes but do not apply"
Expand All @@ -74,9 +74,6 @@ msgstr "Generating salt file"
msgid "registry.ct.ApiUsers"
msgstr "{0,plural,=1{API User} other{API Users}}"

msgid "registry.ct.CoPeople"
msgstr "{0,plural,=1{CO Person} other{CO People}}"

msgid "registry.ct.CoSettings"
msgstr "{0,plural,=1{CO Setting} other{CO Settings}}"

Expand All @@ -89,6 +86,12 @@ msgstr "{0,plural,=1{COU} other{COUs}}"
msgid "registry.ct.Dashboards"
msgstr "{0,plural,=1{Dashboard} other{Dashboards}}"

msgid "registry.ct.ExternalIdentities"
msgstr "{0,plural,=1{External Identity} other{External Identities}}"

msgid "registry.ct.People"
msgstr "{0,plural,=1{Person} other{People}}"

### Enumerations
msgid "registry.en.BooleanEnum.0"
msgstr "False"
Expand Down
33 changes: 13 additions & 20 deletions app/src/Command/DatabaseCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* COmanage Database Command, shared between Match and Registry
* COmanage Database Command
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
Expand All @@ -19,16 +19,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link http://www.internet2.edu/comanage COmanage Project
* @package common
* @since COmanage Common v1.0.0
* @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)
*/

/**
* THIS FILE IS MASTERED IN THE COMMON REPOSITORY.
*/

declare(strict_types = 1);

namespace App\Command;
Expand All @@ -49,7 +45,7 @@ class DatabaseCommand extends Command {
/**
* Build an Option Parser.
*
* @since COmanage Common v1.0.0
* @since COmanage Registry v5.0.0
* @param ConsoleOptionParser $parser ConsoleOptionParser
* @return ConsoleOptionParser ConsoleOptionParser
*/
Expand All @@ -58,7 +54,7 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
$parser->addOption('not', [
'short' => 'n',
'boolean' => true,
'help' => __(__('product.code').'.cmd.opt.not')
'help' => __('registry.cmd.opt.not')
]);

return $parser;
Expand All @@ -67,7 +63,7 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
/**
* Execute the Database Command.
*
* @since COmanage Match v1.0.0, COmanage Registry v5.0.0
* @since COmanage Registry v5.0.0
* @param Arguments $args Command Arguments
* @param ConsoleIo $io Console IO
* @throws RuntimeException
Expand All @@ -82,18 +78,15 @@ public function execute(Arguments $args, ConsoleIo $io) {
// debug and poorly maintained. DBAL doesn't have a schema format (like axmls)
// but it does everything else, and specifying a schema format is easy.

// What component are we?
$COmponent = __('product.code');

// First try to parse our schema file

$schemaFile = ROOT . DS . 'config' . DS . 'schema' . DS . 'schema.json';

if(!is_readable($schemaFile)) {
throw new \RuntimeException(__($COmponent.'.er.file', [$schemaFile]));
throw new \RuntimeException(__('registry.er.file', [$schemaFile]));
}

$io->out(__($COmponent.'.cmd.db.schema', [$schemaFile]));
$io->out(__('registry.cmd.db.schema', [$schemaFile]));

$json = file_get_contents($schemaFile);

Expand All @@ -105,7 +98,7 @@ public function execute(Arguments $args, ConsoleIo $io) {
// - An unmatched brace { }
// - A trailing comma (permitted in PHP but not JSON)
// - Single quotes instead of double quotes
throw new \RuntimeException(__($COmponent.'.er.schema.parse', [$schemaFile]));
throw new \RuntimeException(__('registry.er.schema.parse', [$schemaFile]));
}

// Use the ConnectionManager to get the database config to pass to adodb.
Expand Down Expand Up @@ -143,7 +136,7 @@ public function execute(Arguments $args, ConsoleIo $io) {
(array)$cCfg);

if(!isset($colCfg->type)) {
throw new \RuntimeException(__('match.er.schema.column', [$tName, $cName]));
throw new \RuntimeException(__('registry.er.schema.column', [$tName, $cName]));
}

// For type definitions see https://www.doctrine-project.org/projects/doctrine-dbal/en/2.12/reference/types.html#types
Expand Down Expand Up @@ -296,9 +289,9 @@ public function execute(Arguments $args, ConsoleIo $io) {
}

if(!$doSQL) {
$io->out(__($COmponent.'.cmd.db.noop'));
$io->out(__('registry.cmd.db.noop'));
} else {
$io->out(__($COmponent.'.cmd.db.ok'));
$io->out(__('registry.cmd.db.ok'));
}
}
catch(\Exception $e) {
Expand Down
44 changes: 27 additions & 17 deletions app/src/Command/TransmogrifyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,35 @@ class TransmogrifyCommand extends Command {
'displayField' => 'name'
],
//'dashboards' => [ 'source' => 'cm_co_dashboards' ]
'co_people' => [
'people' => [
'source' => 'cm_co_people',
'displayField' => 'id',
'cache' => [ 'co_id' ]
'cache' => [ 'co_id' ],
'fieldMap' => [
// Rename the changelog key
'co_person_id' => 'person_id'
]
],
'org_identities' => [
'external_identities' => [
'source' => 'cm_org_identities',
'displayField' => 'id',
'fieldMap' => [
'co_id' => null,
'co_person_id' => '&map_org_identity_co_person_id',
'person_id' => '&map_org_identity_co_person_id',
'o' => 'organization',
'ou' => 'department'
'ou' => 'department',
// Rename the changelog key
'org_identity_id' => 'external_identity_id'
],
'cache' => [ 'co_person_id' ]
'cache' => [ 'person_id' ]
],
'names' => [
'source' => 'cm_names',
'displayField' => 'id',
'booleans' => [ 'primary_name' ],
'fieldMap' => [
'co_person_id' => 'person_id',
'org_identity_id' => 'external_identity_id',
// We need to map type_id before we null out type
'type_id' => '&map_name_type',
'type' => null
Expand All @@ -102,6 +110,8 @@ class TransmogrifyCommand extends Command {
'displayField' => 'id',
'booleans' => [ 'login' ],
'fieldMap' => [
'co_person_id' => 'person_id',
'org_identity_id' => 'external_identity_id',
'type_id' => '&map_identifier_type',
'type' => null,
// XXX temporary until tables are migrated
Expand Down Expand Up @@ -276,7 +286,7 @@ public function execute(Arguments $args, ConsoleIo $io) {
$io->out(floor(($tally * 100)/$count) . "% done");
}

$max = $this->inconn->fetchColumn('SELECT MAX(id) FROM ' . $this->tables[$t]['source']);
$max = $this->inconn->fetchOne('SELECT MAX(id) FROM ' . $this->tables[$t]['source']);
$max++;

$io->out("= New max: " . $max);
Expand All @@ -302,17 +312,17 @@ protected function findCoId(array $row) {
// By the time we're called, we should have transmogrified the Org Identity
// and CO Person data, so we can just walk the caches

if(!empty($row['co_person_id'])) {
if(isset($this->cache['co_people']['id'][ $row['co_person_id'] ]['co_id'])) {
return $this->cache['co_people']['id'][ $row['co_person_id'] ]['co_id'];
if(!empty($row['person_id'])) {
if(isset($this->cache['people']['id'][ $row['person_id'] ]['co_id'])) {
return $this->cache['people']['id'][ $row['person_id'] ]['co_id'];
}
} elseif(!empty($row['org_identity_id'])) {
} elseif(!empty($row['external_identity_id'])) {
// Map the OrgIdentity to a CO Person, then to the CO
if(!empty($this->cache['org_identities']['id'][ $row['org_identity_id'] ]['co_person_id'])) {
$coPersonId = $this->cache['org_identities']['id'][ $row['org_identity_id'] ]['co_person_id'];
if(!empty($this->cache['external_identities']['id'][ $row['external_identity_id'] ]['person_id'])) {
$personId = $this->cache['external_identities']['id'][ $row['external_identity_id'] ]['person_id'];

if(isset($this->cache['co_people']['id'][ $coPersonId ]['co_id'])) {
return $this->cache['co_people']['id'][ $coPersonId ]['co_id'];
if(isset($this->cache['people']['id'][ $personId ]['co_id'])) {
return $this->cache['people']['id'][ $personId ]['co_id'];
}
}
}
Expand Down Expand Up @@ -463,7 +473,7 @@ protected function map_now(array $row) {

protected function map_org_identity_co_person_id(array $row) {
// PE eliminates OrgIdentityLink, so we need to map each Org Identity to
// a CO Person ID. This is a bit trickier than it sounds, since an Org Identity
// a Person ID. This is a bit trickier than it sounds, since an Org Identity
// could have been relinked.

// Before Transmogrification, we require that Org Identities are unpooled.
Expand All @@ -479,7 +489,7 @@ protected function map_org_identity_co_person_id(array $row) {
// do that.) Historical information remains available in history_records,
// and if the deployer keeps an archive of the old database.

// To figure out which co_person_id to use, we pull the record with the
// To figure out which person_id to use, we pull the record with the
// highest revision number. Note we might be transmogrifying a deleted row,
// so we can't ignore deleted rows here.

Expand Down
6 changes: 3 additions & 3 deletions app/src/Controller/Component/RegistryAuthComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,12 @@ public function getMenuPermissions() {
$permissions = [];

// XXX need to set permissions according to current user's roles
// Can manage CO People in the current CO
$permissions['co_people'] = true;

// Can access the Configuration Dashboard for the current CO
$permissions['configuration'] = true;

// Can manage People in the current CO
$permissions['people'] = true;

return $permissions;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* COmanage Registry CoPeople Controller
* COmanage Registry People Controller
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
Expand Down Expand Up @@ -33,11 +33,26 @@
use Cake\Log\Log;
//use \App\Lib\Enum\PermissionEnum;

class CoPeopleController extends StandardController {
class PeopleController extends StandardController {
// XXX need to update for couadmin
protected $permissions = [
// Actions that operate over an entity (ie: require an $id)
'entity' => [
/*
We should add a more configurable permissions setting that controls CO Person
visibility, probably via CO Settings. eg:
CO Admin - Only CO Admins can see CO Person records
COU Admin - COU Admins can see CO Person records, plus CO Person Role records they manage
Any Admin - Any CO or COU Admin can see any CO Person and CO Person Role record
CO Group - (intended for helpdesk, maybe create a special helpdesk group instead?) Any Admin + members of the Group
We might also want to introduce a new "Permission" object to abstract this out here
and in other places (like Enrollment Flow Authz). Though Permissions would still be
managed in the relevant UI (eg: CO Settings), the model abstraction would handle
rendering a View Element and processing the Permission at run time
See also: CO-931, CO-1156, CO-1524
*/
'canvas' => ['platformAdmin', 'coAdmin'],
'delete' => ['platformAdmin', 'coAdmin'],
'edit' => ['platformAdmin', 'coAdmin'],
Expand All @@ -50,6 +65,23 @@ class CoPeopleController extends StandardController {
]
];

public $pagination = [
'order' => [
// XXX this will sort by family name, but it this universally correct?
// so we need a configuration, or can we do something automagic?
// (ie: what is CJK sort order?)
// C=pinyin, so basically latin; J=KSTNHMYRW/AIUEO; K=hangugl
// so basically a mess... let's just use family name for now and wait for
// (and we haven't even gotten to other languages like Hindi)
// someone to file an RFE
'PrimaryName.family' => 'asc'
],
'sortableFields' => [
'PrimaryName.given',
'PrimaryName.family'
]
];

/**
* Handle a canvas request.
*
Expand Down
Loading

0 comments on commit 5aa9df2

Please sign in to comment.