Skip to content

Commit

Permalink
ApplicationState skeleton (CFM-194)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Mar 7, 2024
1 parent 2f20bcd commit 360058c
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/config/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,19 @@
"ext_identity_sources_records_i2": { "columns": [ "external_identity_id" ] },
"ext_identity_sources_records_i3": { "columns": [ "external_identity_source_id", "source_key" ] }
}
},

"application_states": {
"columns": {
"id": {},
"person_id": {},
"tag": { "type": "string", "size": 128 },
"value": { "type": "string", "size": 256 }
},
"indexes": {
"application_states_i1": { "columns": [ "person_id" ] }
},
"changelog": false
}
},

Expand Down
40 changes: 40 additions & 0 deletions app/src/Model/Entity/ApplicationState.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* COmanage Registry Application State Entity
*
* 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)
*/

declare(strict_types = 1);

namespace App\Model\Entity;

use Cake\ORM\Entity;

class ApplicationState extends Entity {
protected $_accessible = [
'*' => true,
'id' => false,
'slug' => false,
];
}
80 changes: 80 additions & 0 deletions app/src/Model/Table/ApplicationStatesTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
/**
* COmanage Registry Application States Table
*
* 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)
*/

declare(strict_types = 1);

namespace App\Model\Table;

use Cake\ORM\Table;
use Cake\Validation\Validator;

class ApplicationStatesTable extends Table {
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;

/**
* Perform Cake Model initialization.
*
* @since COmanage Registry v5.0.0
* @param array $config Configuration options passed to constructor
*/

public function initialize(array $config): void {
// Timestamp behavior handles created/modified updates
$this->addBehavior('Log');
$this->addBehavior('Timestamp');

$this->setTableType(\App\Lib\Enum\TableTypeEnum::Metadata);

// Define associations
$this->belongsTo('People');

$this->setDisplayField('tag');
}

/**
* Set validation rules.
*
* @since COmanage Registry v5.0.0
* @param Validator $validator Validator
* @return Validator Validator
* @throws InvalidArgumentException
* @throws RecordNotFoundException
*/

public function validationDefault(Validator $validator): Validator {
$schema = $this->getSchema();

$this->registerPrimaryKeyValidation($validator, $this->getPrimaryLinks());

$this->registerStringValidation($validator, $schema, 'tag', true);

$this->registerStringValidation($validator, $schema, 'value', false);

return $validator;
}
}
3 changes: 3 additions & 0 deletions app/src/Model/Table/PeopleTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public function initialize(array $config): void {
$this->hasMany('AdHocAttributes')
->setDependent(true)
->setCascadeCallbacks(true);
$this->hasMany('ApplicationStates')
->setDependent(true)
->setCascadeCallbacks(true);
$this->hasMany('EmailAddresses')
->setDependent(true)
->setCascadeCallbacks(true);
Expand Down

0 comments on commit 360058c

Please sign in to comment.