Skip to content

Commit

Permalink
Initial implementation of AssignerJob and ProvisionerJob (CFM-169)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed May 18, 2024
1 parent 207bb59 commit f13295c
Show file tree
Hide file tree
Showing 38 changed files with 1,136 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use App\Lib\Enum\ProvisioningStatusEnum;
use App\Lib\Util\SchemaManager;
use App\Lib\Util\StringUtilities;
use App\Lib\Util\TableUtilities;

class SqlProvisionersTable extends Table {
use \App\Lib\Traits\AutoViewVarsTrait;
Expand All @@ -64,7 +65,8 @@ class SqlProvisionersTable extends Table {
'AdHocAttributes',
'Addresses',
'EmailAddresses',
'ExternalIdentities',
// External Identities are not provisionable
// 'ExternalIdentities',
'GroupMembers',
'Identifiers',
'Names',
Expand Down Expand Up @@ -108,7 +110,7 @@ class SqlProvisionersTable extends Table {
'source_table' => 'email_addresses',
'related' => []
],
'ExternalIdentities' => [
/* 'ExternalIdentities' => [
'table' => 'external_identities',
'name' => 'SpExternalIdentities',
'source' => 'ExternalIdentities',
Expand All @@ -135,7 +137,7 @@ class SqlProvisionersTable extends Table {
'Addresses',
'TelephoneNumbers'
]
],
],*/
'GroupMembers' => [
'table' => 'group_members',
'name' => 'SpGroupMembers',
Expand Down Expand Up @@ -412,7 +414,7 @@ protected function syncEntity(
'connection' => ConnectionManager::get($dataSource)
];

$SpTable = TableRegistry::getTableLocator()->get(alias: $mconfig['name'], options: $options);
$SpTable = TableUtilities::getTableFromRegistry(alias: $mconfig['name'], options: $options);

try {
$curEntity = $SpTable->get($data->id);
Expand Down Expand Up @@ -568,7 +570,7 @@ public function syncReferenceData(int $id, string $dataSource='targetdb') {
'connection' => ConnectionManager::get($dataSource)
];

$SpTable = TableRegistry::getTableLocator()->get(alias: $m['name'], options: $options);
$SpTable = TableUtilities::getTableFromRegistry(alias: $m['name'], options: $options);

// Next get the source table model

Expand Down Expand Up @@ -660,7 +662,7 @@ protected function syncRelatedEntities(
'connection' => ConnectionManager::get($dataSource)
];

$SpTable = TableRegistry::getTableLocator()->get(alias: $mconfig['name'], options: $options);
$SpTable = TableUtilities::getTableFromRegistry(alias: $mconfig['name'], options: $options);

// We have the source values, but we need to convert them to arrays
// for patchEntities
Expand Down Expand Up @@ -744,7 +746,7 @@ protected function syncRelatedEntities(
'connection' => ConnectionManager::get($dataSource)
];

$SubTable = TableRegistry::getTableLocator()->get(alias: $subconfig['name'], options: $options);
$SubTable = TableUtilities::getTableFromRegistry(alias: $subconfig['name'], options: $options);

foreach($toDelete as $d) {
// We shouldn't get here if either $parentKey or $d->id is null...
Expand Down
51 changes: 8 additions & 43 deletions app/availableplugins/SqlConnector/src/config/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,41 +93,6 @@
},
"changelog": false
},

"external_identities": {
"columns": {
"id": {},
"person_id": { "notnull": true },
"status": {},
"date_of_birth": { "type": "date" }
},
"indexes": {
"external_identities_i1": { "columns": [ "person_id" ] }
},
"changelog": false
},

"external_identity_roles": {
"columns": {
"id": {},
"external_identity_id": { "notnull": true },
"status": {},
"ordr": {},
"affiliation_type_id": { "type": "integer", "foreignkey": { "table": "types", "column": "id" } },
"title": { "type": "string", "size": 128 },
"organization": { "type": "string", "size": 128 },
"department": { "type": "string", "size": 128 },
"manager_identifier": { "type": "string", "size": 512 },
"sponsor_identifier": { "type": "string", "size": 512 },
"valid_from": {},
"valid_through": {}
},
"indexes": {
"external_identity_roles_i1": { "columns": [ "external_identity_id" ] },
"external_identity_roles_i2": { "columns": [ "affiliation_type_id" ] }
},
"changelog": false
},

"groups": {
"columns": {
Expand All @@ -153,7 +118,7 @@
},
"indexes": {
},
"mvea": [ "person", "person_role", "external_identity", "external_identity_role" ],
"mvea": [ "person", "person_role" ],
"changelog": false
},

Expand All @@ -173,7 +138,7 @@
"indexes": {
"addresses_i1": { "columns": [ "type_id" ] }
},
"mvea": [ "person", "person_role", "external_identity", "external_identity_role" ],
"mvea": [ "person", "person_role" ],
"changelog": false
},

Expand All @@ -188,7 +153,7 @@
"indexes": {
"email_addresses_i3": { "columns": [ "type_id" ] }
},
"mvea": [ "person", "external_identity" ],
"mvea": [ "person" ],
"changelog": false
},

Expand All @@ -203,7 +168,7 @@
"indexes": {
"identifiers_i3": { "columns": [ "type_id" ] }
},
"mvea": [ "person", "external_identity", "group" ],
"mvea": [ "person", "group" ],
"changelog": false
},

Expand All @@ -223,7 +188,7 @@
"indexes": {
"names_i1": { "columns": [ "type_id" ] }
},
"mvea": [ "person", "external_identity" ],
"mvea": [ "person" ],
"changelog": false
},

Expand All @@ -237,7 +202,7 @@
"indexes": {
"pronouns_i1": { "columns": [ "type_id" ] }
},
"mvea": [ "person", "external_identity" ],
"mvea": [ "person" ],
"changelog": false
},

Expand All @@ -254,7 +219,7 @@
"indexes": {
"telephone_numbers_i1": { "columns": [ "type_id" ] }
},
"mvea": [ "person", "person_role", "external_identity", "external_identity_role" ],
"mvea": [ "person", "person_role" ],
"changelog": false
},

Expand All @@ -268,7 +233,7 @@
"indexes": {
"urls_i1": { "columns": [ "type_id" ] }
},
"mvea": [ "person", "external_identity" ],
"mvea": [ "person" ],
"changelog": false
},

Expand Down
6 changes: 4 additions & 2 deletions app/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"CoreAssigner\\": "plugins/CoreAssigner/src/",
"CoreServer\\": "plugins/CoreServer/src/",
"FileConnector\\": "availableplugins/FileConnector/src/",
"SqlConnector\\": "availableplugins/SqlConnector/src/"
"SqlConnector\\": "availableplugins/SqlConnector/src/",
"CoreJob\\": "plugins/CoreJob/src/"
}
},
"autoload-dev": {
Expand All @@ -45,7 +46,8 @@
"CoreAssigner\\Test\\": "plugins/CoreAssigner/tests/",
"CoreServer\\Test\\": "plugins/CoreServer/tests/",
"FileConnector\\Test\\": "availableplugins/FileConnector/tests/",
"SqlConnector\\Test\\": "availableplugins/SqlConnector/tests/"
"SqlConnector\\Test\\": "availableplugins/SqlConnector/tests/",
"CoreJob\\Test\\": "plugins/CoreJob/tests/"
}
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use Cake\ORM\TableRegistry;
use Cake\Utility\Hash;
use Cake\Validation\Validator;
use App\Lib\Util\TableUtilities;

class SqlAssignersTable extends Table {
use \App\Lib\Traits\AutoViewVarsTrait;
Expand Down Expand Up @@ -128,7 +129,7 @@ public function assign($ia, $entity): string {
'connection' => ConnectionManager::get('sqlassigner')
];

$SourceTable = TableRegistry::getTableLocator()->get(
$SourceTable = TableUtilities::getTableFromRegistry(
alias: 'SourceIdentifiers',
options: $options
);
Expand Down
11 changes: 11 additions & 0 deletions app/plugins/CoreJob/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# CoreJob plugin for CakePHP

## Installation

You can install this plugin into your CakePHP application using [composer](https://getcomposer.org).

The recommended way to install composer packages is:

```
composer require your-name-here/core-job
```
24 changes: 24 additions & 0 deletions app/plugins/CoreJob/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "your-name-here/core-job",
"description": "CoreJob plugin for CakePHP",
"type": "cakephp-plugin",
"license": "MIT",
"require": {
"php": ">=7.2",
"cakephp/cakephp": "4.5.*"
},
"require-dev": {
"phpunit/phpunit": "^8.5 || ^9.3"
},
"autoload": {
"psr-4": {
"CoreJob\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"CoreJob\\Test\\": "tests/",
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/"
}
}
}
30 changes: 30 additions & 0 deletions app/plugins/CoreJob/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
>
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
</php>

<!-- Add any additional test suites you want to run here -->
<testsuites>
<testsuite name="CoreJob">
<directory>tests/TestCase/</directory>
</testsuite>
</testsuites>

<!-- Setup fixture extension -->
<extensions>
<extension class="Cake\TestSuite\Fixture\PHPUnitExtension" />
</extensions>

<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</phpunit>
68 changes: 68 additions & 0 deletions app/plugins/CoreJob/resources/locales/en_US/core_job.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# COmanage Registry Localizations (core_job domain)
#
# 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)

msgid "error.co_id"
msgstr "Requested {0} entity {1} is not in CO {2}"

msgid "opt.assigner.context"
msgstr "Identifier Assignment context"

msgid "opt.entities"
msgstr "Comma separated list of entity IDs to process"

msgid "opt.provisioner.model"
msgstr "Model to provision"

msgid "opt.provisioner.provisioning_target_id"
msgstr "Provisioning Target ID"

msgid "Assigner.cancel_summary"
msgstr "Job canceled after reviewing {0} entities and assigning {1} Identifier(s)"

msgid "Assigner.error.assign"
msgstr "Error assigning {0}: {1}"

msgid "Assigner.finish_summary"
msgstr "Reviewed {0} entities and assigned {1} Identifier(s)"

msgid "Assigner.result.assigned"
msgstr "Assigned {0}: {1}"

msgid "Assigner.start_summary"
msgstr "Assigning all Identifiers in context {0} for CO {1} ({2} entities)"

msgid "Provisioner.cancel_summary"
msgstr "Job canceled after provisioning {0} entities ({1} errors)"

msgid "Provisioner.error.status"
msgstr "Provisioner is disabled"

msgid "Provisioner.finish_summary"
msgstr "Reprovisioned {0} entities ({1} errors)"

msgid "Provisioner.result.provisioned"
msgstr "Reprovisioned"

msgid "Provisioner.start_summary"
msgstr "Reprovisioning {0} {1} entities for Provisioning Target {2}"
10 changes: 10 additions & 0 deletions app/plugins/CoreJob/src/Controller/AppController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);

namespace CoreJob\Controller;

use App\Controller\AppController as BaseController;

class AppController extends BaseController
{
}
Loading

0 comments on commit f13295c

Please sign in to comment.