Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New base table third party setting + Drupal 10.2 fixes #1805

Merged
merged 45 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2d79c7f
Fix for field listing in 10.2.x
spficklin Mar 3, 2024
5c45935
Restored ChadoFieldItemBase
spficklin Mar 3, 2024
8127c44
Using third party settings to set default chado tables on entity types
spficklin Mar 3, 2024
26b5b20
Added start of the isCompatible() function for fields
spficklin Mar 3, 2024
d5807a3
fix third party settings bug
dsenalik Mar 4, 2024
c51b0a5
object_table only passed through static variable
dsenalik Mar 4, 2024
39e8393
select_base_column also becomes a static variable
dsenalik Mar 4, 2024
674f266
rework of chado field base and complexity reduction
dsenalik Mar 4, 2024
4e8f54b
a bunch of Drupal 10.2 related changes
dsenalik Mar 5, 2024
fb055a7
changes from pr #1795 for the fields
dsenalik Mar 5, 2024
a380a3c
forgot to transfer three annotations
dsenalik Mar 5, 2024
566d855
missed fix in prop field
dsenalik Mar 5, 2024
d7928cc
biosample should be biomaterial
dsenalik Mar 5, 2024
804ca7e
array_design should be arraydesign
dsenalik Mar 5, 2024
c481e0e
additional biomaterial, arraydesign corrections
dsenalik Mar 5, 2024
ba390eb
add third party setting to schema
dsenalik Mar 5, 2024
01866a0
split get linker table functionality
dsenalik Mar 5, 2024
c518e4f
my proposal for the isCompatible() function
dsenalik Mar 5, 2024
6b98e93
isCompatible for single-content-type fields
dsenalik Mar 6, 2024
cd550cc
typo fix
dsenalik Mar 6, 2024
bdb6528
getTableColumns split into two functions
dsenalik Mar 6, 2024
1ffc20c
isCompatible for "primitive" type fields
dsenalik Mar 6, 2024
1a809b2
isCompatible for all other linker fields
dsenalik Mar 6, 2024
bfa382a
isCompatible for remaining fields
dsenalik Mar 6, 2024
15d1f68
need to use TripalEntityType class
dsenalik Mar 6, 2024
b348a4d
debugging message for testing isCompatible functions
dsenalik Mar 6, 2024
7b10957
fix ChadoAdditionalType field
dsenalik Mar 7, 2024
61d5b86
finished the isComplete() check
spficklin Mar 7, 2024
39c49b7
Merge branch '4.x' into tv4g1-issue1440-limit_fields
dsenalik Mar 14, 2024
46ddae0
Merge branch '4.x' into tv4g1-issue1440-limit_fields
dsenalik Mar 15, 2024
01c081f
Assume compatible when base table is not defined
dsenalik Mar 16, 2024
07ca52d
allow base_table to be null
dsenalik Mar 16, 2024
b0dfc9d
Ajax different under Drupal 10.2
dsenalik Mar 16, 2024
ea92c26
Allow synonym linker to be undefined
dsenalik Mar 16, 2024
0b08df1
revert recent changes to synonym field, move to issue #1817
dsenalik Mar 16, 2024
88f98c7
First field on a content type sets the base table
spficklin Mar 17, 2024
9b202e8
fix Undefined variable $base_table
dsenalik Mar 17, 2024
e18b164
typo fix
dsenalik Mar 17, 2024
a4bc925
tripal_chado_form_alter() now Drupal version aware
dsenalik Mar 17, 2024
5aaaac7
Update tripal_chado/src/TripalField/ChadoFieldItemBase.php
dsenalik Mar 18, 2024
5a58617
Update tripal_chado/src/TripalField/ChadoFieldItemBase.php
dsenalik Mar 18, 2024
3a3a3eb
code to remove partially added incompatible fields
dsenalik Mar 18, 2024
95beea4
use correct way to get machine name
dsenalik Mar 18, 2024
ea8c680
make new function non-public
dsenalik Mar 18, 2024
03326ee
Stephen left in my now-obsolete comments
dsenalik Mar 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -381,31 +381,25 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {

/** @var \Drupal\tripal_chado\Database\ChadoConnection $chado **/
$chado = \Drupal::service('tripal_chado.database');
$schema = $chado->schema();
/** @var \Drupal\tripal_chado\Database\ChadoConnection $chado **/
$chado = \Drupal::service('tripal_chado.database');
$schema = $chado->schema();

// If the base table has a 'type_id' column, then it is compatible.
$base_table_def = $schema->getTableDef($base_table, ['format' => 'Drupal']);
if (isset($base_table_def['fields']['type_id'])) {
$compatible = TRUE;
}
// If the base table has a 'type_id' column, then it is compatible.
$base_table_def = $schema->getTableDef($base_table, ['format' => 'Drupal']);
if (isset($base_table_def['fields']['type_id'])) {
$compatible = TRUE;
}

$prop_def = $schema->getTableDef($base_table . 'prop', ['format' => 'Drupal']);
// If the property table exists, and has a foreign key to the base table,
// then this content type is compatible.
if ($prop_def) {
if (array_key_exists($base_table, $prop_def['foreign keys'])) {
$compatible = TRUE;
}
$prop_def = $schema->getTableDef($base_table . 'prop', ['format' => 'Drupal']);
// If the property table exists, and has a foreign key to the base table,
// then this content type is compatible.
if ($prop_def) {
if (array_key_exists($base_table, $prop_def['foreign keys'])) {
$compatible = TRUE;
}
}
else {
// If base table is not defined, assume compatible
$compatible = TRUE;
}

return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$table_columns = $this->getTableColumns($base_table, self::$valid_base_column_types);
if (count($table_columns) < 1) {
$compatible = FALSE;
}
$table_columns = $this->getTableColumns($base_table, self::$valid_base_column_types);
if (count($table_columns) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$table_columns = $this->getTableColumns($base_table, self::$valid_base_column_types);
if (count($table_columns) < 1) {
$compatible = FALSE;
}
$table_columns = $this->getTableColumns($base_table, self::$valid_base_column_types);
if (count($table_columns) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,30 +236,23 @@ public static function storageSettingsFormValidate(array $form, FormStateInterfa
* @see \Drupal\tripal_chado\TripalField\ChadoFieldItemBase::isCompatible()
*/
public function isCompatible(TripalEntityType $entity_type) : bool {
$compatible = TRUE;
$compatible = FALSE;

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {

/** @var \Drupal\tripal_chado\Database\ChadoConnection $chado **/
$chado = \Drupal::service('tripal_chado.database');
$schema = $chado->schema();
/** @var \Drupal\tripal_chado\Database\ChadoConnection $chado **/
$chado = \Drupal::service('tripal_chado.database');
$schema = $chado->schema();

// If the property table exists, and has a foreign key to the base table,
// then this content type is compatible.
$prop_def = $schema->getTableDef($base_table . 'prop', ['format' => 'Drupal']);
if ($prop_def) {
if (array_key_exists($base_table, $prop_def['foreign keys'])) {
$compatible = FALSE;
}
// If the property table exists, and has a foreign key to the base table,
// then this content type is compatible.
$prop_def = $schema->getTableDef($base_table . 'prop', ['format' => 'Drupal']);
if ($prop_def) {
if (array_key_exists($base_table, $prop_def['foreign keys'])) {
$compatible = TRUE;
}
}
else {
// If base table is not defined, assume compatible
$compatible = TRUE;
}

return $compatible;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ public static function tripalTypes($field_definition) {
* @see \Drupal\tripal_chado\TripalField\ChadoFieldItemBase::isCompatible()
*/
public function isCompatible(TripalEntityType $entity_type) : bool {
$compatible = TRUE;
$compatible = FALSE;

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
// This is a "specialty" field for a single content type
// If base table is not defined, assume compatible
if (!$base_table or ($base_table == 'feature')) {
if ($base_table == 'feature') {
$compatible = TRUE;
}
return $compatible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,14 @@ public static function tripalTypes($field_definition) {
* @see \Drupal\tripal_chado\TripalField\ChadoFieldItemBase::isCompatible()
*/
public function isCompatible(TripalEntityType $entity_type) : bool {
$compatible = TRUE;
$compatible = FALSE;

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');

// This is a "specialty" field for a single content type
// If base table is not defined, assume compatible
if (!$base_table or ($base_table == 'feature')) {
if ($base_table == 'feature') {
$compatible = TRUE;
}
return $compatible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public static function tripalTypes($field_definition) {
* @see \Drupal\tripal_chado\TripalField\ChadoFieldItemBase::isCompatible()
*/
public function isCompatible(TripalEntityType $entity_type) : bool {
$compatible = TRUE;
$compatible = FALSE;

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
// This is a "specialty" field for a single content type
// If base table is not defined, assume compatible
if (!$base_table or ($base_table == 'feature')) {
if ($base_table == 'feature') {
$compatible = TRUE;
}
return $compatible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ public static function tripalTypes($field_definition) {
* @see \Drupal\tripal_chado\TripalField\ChadoFieldItemBase::isCompatible()
*/
public function isCompatible(TripalEntityType $entity_type) : bool {
$compatible = TRUE;
$compatible = FALSE;

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
// This is a "specialty" field for a single content type
// If base table is not defined, assume compatible
if (!$base_table or ($base_table == 'feature')) {
if ($base_table == 'feature') {
$compatible = TRUE;
}
return $compatible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ public static function tripalTypes($field_definition) {
* @see \Drupal\tripal_chado\TripalField\ChadoFieldItemBase::isCompatible()
*/
public function isCompatible(TripalEntityType $entity_type) : bool {
$compatible = TRUE;
$compatible = FALSE;

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
// This is a "specialty" field for a single content type
// If base table is not defined, assume compatible
if (!$base_table or ($base_table == 'analysis')) {
if ($base_table == 'analysis') {
$compatible = TRUE;
}
return $compatible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,9 @@ public function isCompatible(TripalEntityType $entity_type) : bool {

// Get the base table for the content type.
$base_table = $entity_type->getThirdPartySetting('tripal', 'chado_base_table');
if ($base_table) {
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
$linker_tables = $this->getLinkerTables(self::$object_table, $base_table);
if (count($linker_tables) < 1) {
$compatible = FALSE;
}
return $compatible;
}
Expand Down
Loading
Loading