Skip to content

Commit

Permalink
Merge pull request #59 from australiangreens/geom-entity-reason
Browse files Browse the repository at this point in the history
Add Geometry-entity relationship reason
  • Loading branch information
johntwyman authored Aug 1, 2023
2 parents 96ae09e + 510cfd8 commit 620486a
Show file tree
Hide file tree
Showing 18 changed files with 189 additions and 814 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog
All notable changes for the CiviGeometry extension will be noted here.

## [1.12.0] - 2023-08-01
### Added
- Geometry.getcachedoverlaps APIv4 method
- `reason` field for Geometry-Entity relationship table (`civigeometry_geometry_entity`)
- Managed Entity Option Group for the `reason` field

## [1.11.0] - 2023-07-28
### Added
- GeometryEntity APIv4 entity with basic CRUD methods
Expand Down
11 changes: 10 additions & 1 deletion CRM/CiviGeometry/DAO/Geometry.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from au.org.greens.civigeometry/xml/schema/CRM/CiviGeometry/Geometry.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:02ef5e8786d1988485a442e43b15f27c)
* (GenCodeChecksum:26998ebb213bbf12a7c407b781fe0d94)
*/
use CRM_CiviGeometry_ExtensionUtil as E;

Expand All @@ -24,6 +24,13 @@ class CRM_CiviGeometry_DAO_Geometry extends CRM_Core_DAO {
*/
public static $_tableName = 'civigeometry_geometry';

/**
* Field to show when displaying a record.
*
* @var string
*/
public static $_labelField = 'label';

/**
* Should CiviCRM log any modifications to this table in the civicrm_log table.
*
Expand Down Expand Up @@ -138,6 +145,7 @@ public static function &fields() {
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('ID'),
'description' => E::ts('Unique Geometry ID'),
'required' => TRUE,
'where' => 'civigeometry_geometry.id',
Expand Down Expand Up @@ -207,6 +215,7 @@ public static function &fields() {
'is_archived' => [
'name' => 'is_archived',
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => E::ts('Is Archived'),
'description' => E::ts('Is this geometry archived?'),
'where' => 'civigeometry_geometry.is_archived',
'default' => '0',
Expand Down
12 changes: 11 additions & 1 deletion CRM/CiviGeometry/DAO/GeometryCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from au.org.greens.civigeometry/xml/schema/CRM/CiviGeometry/GeometryCollection.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:c820f9c0629916039df11d4895ede8d7)
* (GenCodeChecksum:d7e88053931cda06bec713f1afdebe86)
*/
use CRM_CiviGeometry_ExtensionUtil as E;

Expand All @@ -24,6 +24,13 @@ class CRM_CiviGeometry_DAO_GeometryCollection extends CRM_Core_DAO {
*/
public static $_tableName = 'civigeometry_geometry_collection';

/**
* Field to show when displaying a record.
*
* @var string
*/
public static $_labelField = 'label';

/**
* Should CiviCRM log any modifications to this table in the civicrm_log table.
*
Expand Down Expand Up @@ -138,6 +145,7 @@ public static function &fields() {
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('ID'),
'description' => E::ts('Unique GeometryCollection ID'),
'required' => TRUE,
'where' => 'civigeometry_geometry_collection.id',
Expand All @@ -151,6 +159,7 @@ public static function &fields() {
'geometry_collection_type_id' => [
'name' => 'geometry_collection_type_id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('Geometry Collection Type ID'),
'description' => E::ts('FK to civigeomety_geometry_collection_type'),
'required' => TRUE,
'where' => 'civigeometry_geometry_collection.geometry_collection_type_id',
Expand Down Expand Up @@ -226,6 +235,7 @@ public static function &fields() {
'is_archived' => [
'name' => 'is_archived',
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => E::ts('Is Archived'),
'description' => E::ts('Is this Geometry Collection archived'),
'where' => 'civigeometry_geometry_collection.is_archived',
'default' => '0',
Expand Down
3 changes: 2 additions & 1 deletion CRM/CiviGeometry/DAO/GeometryCollectionGeometry.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from au.org.greens.civigeometry/xml/schema/CRM/CiviGeometry/GeometryCollectionGeometry.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:0ba274e3125b1d7bf07d40ce082527d5)
* (GenCodeChecksum:4e26bec81904d9c27d1c7a9f51f92027)
*/
use CRM_CiviGeometry_ExtensionUtil as E;

Expand Down Expand Up @@ -103,6 +103,7 @@ public static function &fields() {
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('ID'),
'description' => E::ts('Unique Geometry ID'),
'required' => TRUE,
'where' => 'civigeometry_geometry_collection_geometry.id',
Expand Down
10 changes: 9 additions & 1 deletion CRM/CiviGeometry/DAO/GeometryCollectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from au.org.greens.civigeometry/xml/schema/CRM/CiviGeometry/GeometryCollectionType.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:fe2fcc715214608bf7cab118a93e28ec)
* (GenCodeChecksum:86243c796dbd1fa2321213290abca599)
*/
use CRM_CiviGeometry_ExtensionUtil as E;

Expand All @@ -24,6 +24,13 @@ class CRM_CiviGeometry_DAO_GeometryCollectionType extends CRM_Core_DAO {
*/
public static $_tableName = 'civigeometry_geometry_collection_type';

/**
* Field to show when displaying a record.
*
* @var string
*/
public static $_labelField = 'label';

/**
* Should CiviCRM log any modifications to this table in the civicrm_log table.
*
Expand Down Expand Up @@ -87,6 +94,7 @@ public static function &fields() {
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('ID'),
'description' => E::ts('Unique GeometryCollectionType ID'),
'required' => TRUE,
'where' => 'civigeometry_geometry_collection_type.id',
Expand Down
34 changes: 33 additions & 1 deletion CRM/CiviGeometry/DAO/GeometryEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from au.org.greens.civigeometry/xml/schema/CRM/CiviGeometry/GeometryEntity.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:8c5ae45be2adee0affc8827859427d90)
* (GenCodeChecksum:975a5fa2a229cae5b909950513534982)
*/
use CRM_CiviGeometry_ExtensionUtil as E;

Expand Down Expand Up @@ -76,6 +76,15 @@ class CRM_CiviGeometry_DAO_GeometryEntity extends CRM_Core_DAO {
*/
public $expiry_date;

/**
* The reason for the relationship between the geometry and entity
*
* @var string
* (SQL type: varchar(64))
* Note that values will be retrieved from the database as a string.
*/
public $reason;

/**
* Class constructor.
*/
Expand Down Expand Up @@ -120,6 +129,7 @@ public static function &fields() {
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('ID'),
'description' => E::ts('Unique GeometryEntity ID'),
'required' => TRUE,
'where' => 'civigeometry_geometry_entity.id',
Expand All @@ -133,6 +143,7 @@ public static function &fields() {
'entity_id' => [
'name' => 'entity_id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('Entity ID'),
'description' => E::ts('entity id that is associated with this geometry'),
'required' => TRUE,
'where' => 'civigeometry_geometry_entity.entity_id',
Expand Down Expand Up @@ -160,6 +171,7 @@ public static function &fields() {
'geometry_id' => [
'name' => 'geometry_id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('Geometry ID'),
'description' => E::ts('FK to Geometry Table'),
'required' => TRUE,
'where' => 'civigeometry_geometry_entity.geometry_id',
Expand All @@ -184,6 +196,26 @@ public static function &fields() {
'localizable' => 0,
'add' => NULL,
],
'reason' => [
'name' => 'reason',
'type' => CRM_Utils_Type::T_STRING,
'title' => E::ts('Reason'),
'description' => E::ts('The reason for the relationship between the geometry and entity'),
'required' => FALSE,
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
'where' => 'civigeometry_geometry_entity.reason',
'default' => NULL,
'table_name' => 'civigeometry_geometry_entity',
'entity' => 'GeometryEntity',
'bao' => 'CRM_CiviGeometry_DAO_GeometryEntity',
'localizable' => 0,
'pseudoconstant' => [
'optionGroupName' => 'OptionGroup_geom_entity_relationship_reason',
'optionEditPath' => 'civicrm/admin/options/OptionGroup_geom_entity_relationship_reason',
],
'add' => NULL,
],
];
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}
Expand Down
3 changes: 2 additions & 1 deletion CRM/CiviGeometry/DAO/GeometryOverlapCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from au.org.greens.civigeometry/xml/schema/CRM/CiviGeometry/GeometryOverlapCache.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:1fc0b657148c8d261d843726695c294f)
* (GenCodeChecksum:12f52bd7c9efbede862ca6997f14201e)
*/
use CRM_CiviGeometry_ExtensionUtil as E;

Expand Down Expand Up @@ -121,6 +121,7 @@ public static function &fields() {
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('ID'),
'description' => E::ts('Unique Geometry ID'),
'required' => TRUE,
'where' => 'civigeometry_geometry_overlap_cache.id',
Expand Down
10 changes: 9 additions & 1 deletion CRM/CiviGeometry/DAO/GeometryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from au.org.greens.civigeometry/xml/schema/CRM/CiviGeometry/GeometryType.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:7b6b7d9f84ac90e433434b302751ff87)
* (GenCodeChecksum:bca42adf6d80d8b90da5abb2a7b7cf75)
*/
use CRM_CiviGeometry_ExtensionUtil as E;

Expand All @@ -24,6 +24,13 @@ class CRM_CiviGeometry_DAO_GeometryType extends CRM_Core_DAO {
*/
public static $_tableName = 'civigeometry_geometry_type';

/**
* Field to show when displaying a record.
*
* @var string
*/
public static $_labelField = 'label';

/**
* Should CiviCRM log any modifications to this table in the civicrm_log table.
*
Expand Down Expand Up @@ -87,6 +94,7 @@ public static function &fields() {
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'title' => E::ts('ID'),
'description' => E::ts('Unique GeometryType ID'),
'required' => TRUE,
'where' => 'civigeometry_geometry_type.id',
Expand Down
8 changes: 7 additions & 1 deletion CRM/CiviGeometry/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Collection of upgrade steps.
*/
class CRM_CiviGeometry_Upgrader extends CRM_CiviGeometry_Upgrader_Base {
class CRM_CiviGeometry_Upgrader extends CRM_Extension_Upgrader_Base {

// By convention, functions that look like "function upgrade_NNNN()" are
// upgrade tasks. They are executed in order (like Drupal's hook_update_N).
Expand Down Expand Up @@ -180,4 +180,10 @@ public function upgrade_5184() {
return TRUE;
}

public function upgrade_5200() {
$this->ctx->log->info('Applying update 5200 - Adding reason field to civigeometry_geometry_entity table');
CRM_Core_DAO::executeQuery("ALTER TABLE civigeometry_geometry_entity ADD COLUMN reason varchar(64) DEFAULT NULL COMMENT 'Reason for relationship between geometry and entity'");
return TRUE;
}

}
Loading

0 comments on commit 620486a

Please sign in to comment.