Skip to content

Commit

Permalink
Initial implementation of Identifier Assignment (CFM-57)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Jul 31, 2023
1 parent bf13ef9 commit afd5ab2
Show file tree
Hide file tree
Showing 58 changed files with 2,449 additions and 165 deletions.
6 changes: 4 additions & 2 deletions app/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"App\\": "src/",
"CoreServer\\": "plugins/CoreServer/src/",
"FileConnector\\": "availableplugins/FileConnector/src/",
"SqlConnector\\": "availableplugins/SqlConnector/src/"
"SqlConnector\\": "availableplugins/SqlConnector/src/",
"CoreAssigner\\": "plugins/CoreAssigner/src/"
}
},
"autoload-dev": {
Expand All @@ -41,7 +42,8 @@
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/",
"CoreServer\\Test\\": "plugins/CoreServer/tests/",
"FileConnector\\Test\\": "availableplugins/FileConnector/tests/",
"SqlConnector\\Test\\": "availableplugins/SqlConnector/tests/"
"SqlConnector\\Test\\": "availableplugins/SqlConnector/tests/",
"CoreAssigner\\Test\\": "plugins/CoreAssigner/tests/"
}
},
"scripts": {
Expand Down
26 changes: 24 additions & 2 deletions app/config/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
"columns": {
"co_id": { "type": "integer", "foreignkey": { "table": "cos", "column": "id" }, "notnull": true },
"comment": { "type": "string", "size": 256 },
"context": { "type": "string", "size": 2 },
"cou_id": { "type": "integer", "foreignkey": { "table": "cous", "column": "id" } },
"description": { "type": "string", "size": 128 },
"external_identity_id": { "type": "integer", "foreignkey": { "table": "external_identities", "column": "id" } },
"external_identity_role_id": { "type": "integer", "foreignkey": { "table": "external_identity_roles", "column": "id" } },
"group_id": { "type": "integer", "foreignkey": { "table": "groups", "column": "id" } },
"id": { "type": "integer", "autoincrement": true, "primarykey": true },
"identifier_assignment_id": { "type": "integer", "foreignkey": { "table": "identifier_assignments", "column": "id" }, "notnull": true },
"language": { "type": "string", "size": 16 },
"name": { "type": "string", "size": 128, "notnull": true },
"ordr": { "type": "integer" },
Expand Down Expand Up @@ -171,8 +173,7 @@
"cous_i1": { "columns": [ "co_id" ] },
"cous_i2": { "columns": [ "name" ] },
"cous_i3": { "columns": [ "co_id", "name" ] },
"cous_i4": { "needed": false, "columns": [ "parent_id" ]
}
"cous_i4": { "needed": false, "columns": [ "parent_id" ] }
}
},

Expand Down Expand Up @@ -578,6 +579,27 @@
"indexes": {
"servers_i1": { "columns": [ "co_id" ] }
}
},

"identifier_assignments": {
"columns": {
"id": {},
"co_id": {},
"description": {},
"plugin": {},
"status": {},
"context": {},
"group_id": {},
"identifier_type_id": { "type": "integer", "foreignkey": { "table": "types", "column": "id" }, "notnull": false },
"login": { "type": "boolean" },
"email_address_type_id": { "type": "integer", "foreignkey": { "table": "types", "column": "id" }, "notnull": false },
"ordr": {}
},
"indexes": {
"identifier_assignments_i1": { "columns": [ "co_id" ] },
"identifier_assignments_i2": { "needed": false, "columns": [ "email_address_type_id" ] },
"identifier_assignments_i3": { "needed": false, "columns": [ "identifier_type_id" ] }
}
}
},

Expand Down
11 changes: 11 additions & 0 deletions app/plugins/CoreAssigner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# CoreAssigner 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-assigner
```
24 changes: 24 additions & 0 deletions app/plugins/CoreAssigner/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "your-name-here/core-assigner",
"description": "CoreAssigner plugin for CakePHP",
"type": "cakephp-plugin",
"license": "MIT",
"require": {
"php": ">=7.2",
"cakephp/cakephp": "4.4.*"
},
"require-dev": {
"phpunit/phpunit": "^8.5 || ^9.3"
},
"autoload": {
"psr-4": {
"CoreAssigner\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"CoreAssigner\\Test\\": "tests/",
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/"
}
}
}
30 changes: 30 additions & 0 deletions app/plugins/CoreAssigner/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="CoreAssigner">
<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>
74 changes: 74 additions & 0 deletions app/plugins/CoreAssigner/resources/locales/en_US/core_assigner.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# COmanage Registry Localizations (core_assigner 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-plugins
# @since COmanage Registry v5.0.0
# @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)

msgid "controller.FormatAssigners"
msgstr "{0,plural,=1{Format Assigner} other{Format Assigners}}"

msgid "enumeration.CollisionModeEnum.R"
msgstr "Random"

msgid "enumeration.CollisionModeEnum.S"
msgstr "Sequential"

msgid "enumeration.PermittedCharactersEnum.AN"
msgstr "AlphaNumeric Only"

msgid "enumeration.PermittedCharactersEnum.AD"
msgstr "AlphaNumeric and Dot, Dash, Underscore"

msgid "enumeration.PermittedCharactersEnum.AQ"
msgstr "AlphaNumeric and Dot, Dash, Underscore, Apostrophe"

msgid "enumeration.PermittedCharactersEnum.AL"
msgstr "Any"

msgid "field.FormatAssigners.collision_mode"
msgstr "Collision Mode"

msgid "field.FormatAssigners.collision_mode.desc"
msgstr "How to assign collision numbers when required"

msgid "field.FormatAssigners.format"
msgstr "Format"

msgid "field.FormatAssigners.format.desc"
msgstr "See the <a href=\"https://spaces.at.internet2.edu/display/COmanage/Format+Identifier+Assignment+Plugin#FormatIdentifierAssignmentPlugin-Format\">documentation</a> for details"

msgid "field.FormatAssigners.maximum"
msgstr "Maximum Collision Value"

msgid "field.FormatAssigners.maximum.desc"
msgstr "The maximum value for randomly generated collision numbers"

msgid "field.FormatAssigners.minimum"
msgstr "Minimum Collision Value"

msgid "field.FormatAssigners.minimum.desc"
msgstr "The minimum value for randomly generated collision numbers, or the starting value for sequences"

msgid "field.FormatAssigners.permitted_characters"
msgstr "Permitted Characters"

msgid "field.FormatAssigners.permitted_characters.desc"
msgstr "When substituting parameters in a format, only permit these characters to be used"
10 changes: 10 additions & 0 deletions app/plugins/CoreAssigner/src/Controller/AppController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);

namespace CoreAssigner\Controller;

use App\Controller\AppController as BaseController;

class AppController extends BaseController
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* COmanage Registry Format Assigners Controller
*
* 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-plugins
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types=1);

namespace CoreAssigner\Controller;

use App\Controller\StandardPluginController;

class FormatAssignersController extends StandardPluginController {
public $paginate = [
'order' => [
'FormatAssigners.format' => 'asc'
]
];
}
93 changes: 93 additions & 0 deletions app/plugins/CoreAssigner/src/CoreAssignerPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
declare(strict_types=1);

namespace CoreAssigner;

use Cake\Console\CommandCollection;
use Cake\Core\BasePlugin;
use Cake\Core\ContainerInterface;
use Cake\Core\PluginApplicationInterface;
use Cake\Http\MiddlewareQueue;
use Cake\Routing\RouteBuilder;

/**
* Plugin for CoreAssigner
*/
class CoreAssignerPlugin extends BasePlugin
{
/**
* Load all the plugin configuration and bootstrap logic.
*
* The host application is provided as an argument. This allows you to load
* additional plugin dependencies, or attach events.
*
* @param \Cake\Core\PluginApplicationInterface $app The host application
* @return void
*/
public function bootstrap(PluginApplicationInterface $app): void
{
}

/**
* Add routes for the plugin.
*
* If your plugin has many routes and you would like to isolate them into a separate file,
* you can create `$plugin/config/routes.php` and delete this method.
*
* @param \Cake\Routing\RouteBuilder $routes The route builder to update.
* @return void
*/
public function routes(RouteBuilder $routes): void
{
$routes->plugin(
'CoreAssigner',
['path' => '/core-assigner'],
function (RouteBuilder $builder) {
// Add custom routes here

$builder->fallbacks();
}
);
parent::routes($routes);
}

/**
* Add middleware for the plugin.
*
* @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to update.
* @return \Cake\Http\MiddlewareQueue
*/
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
{
// Add your middlewares here

return $middlewareQueue;
}

/**
* Add commands for the plugin.
*
* @param \Cake\Console\CommandCollection $commands The command collection to update.
* @return \Cake\Console\CommandCollection
*/
public function console(CommandCollection $commands): CommandCollection
{
// Add your commands here

$commands = parent::console($commands);

return $commands;
}

/**
* Register application container services.
*
* @param \Cake\Core\ContainerInterface $container The Container to update.
* @return void
* @link https://book.cakephp.org/4/en/development/dependency-injection.html#dependency-injection
*/
public function services(ContainerInterface $container): void
{
// Add your services here
}
}
37 changes: 37 additions & 0 deletions app/plugins/CoreAssigner/src/Lib/Enum/CollisionModeEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* COmanage Registry Collision Mode Enum
*
* 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-plugins
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types = 1);

namespace CoreAssigner\Lib\Enum;

use App\Lib\Enum\StandardEnum;

class CollisionModeEnum extends StandardEnum {
const Random = 'R';
const Sequential = 'S';
}
Loading

0 comments on commit afd5ab2

Please sign in to comment.