-
Notifications
You must be signed in to change notification settings - Fork 10
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
Automatic Creation of Single Valued, String Chado Fields #261
Conversation
Added id space and accession attributes for tripal entity CV terms.
Merged new tripal field handling code in entities to existing entities. The new tripal field interface will now be recognized by the system.
Fixed bug in annotation of tripal entities where the storage handler was not provided.
…he TripalEntity class
Added missing semicolons when creating new empty array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests should be fixed now :-)
Code review-wise: this PR is looking good.
It works for single-value, single-property fields like those on the organism content type.
We will need to create more fields in order to ensure the ChadoStorage handles more complex fields like foreign key single- + multi-value fields. There is placeholders to test these two in the automated testing for when we get to implementing them :-)
@risharde this one is also ready for you to review! |
I did a quick review of the changes @laceysanderson . All looks good. Thanks for makin these fixes. |
I had a brief moment for coding, so I added in support for text fields. These are unlimited strings (e.g. organism.description). So, now when you prepare Chado you should see the single-valued text fields appear as fields. |
In the process of working on a complex fields (obi__organism), I've discovered that we have a problem with this PR. When setting the storage settings for a field, those are persistent between instances of the field. So, if we use the same field for two different content types and link that field to a Chado table, it will always be linked to only one Chado table. For example the If there aren't any objections I think we move forward with a functional review by @risharde and merge if all is good and I'll make a new PR afterwards with the complex field and the fix for the problem I just described. |
Overall working great @spficklin! 1 warning (hopefully minor) in the tripal prepare step - screenshot attached. [GOOD] Uninstall Tripal, pull this branch and reinstall Tripal (or start from a brand new installation) [GOOD] Go to Admin > Structure > Tripal Content Types. Pick any content type. You will see the set of fields that have been added. They should not appear in the 'Disabled' section but should be in the Content section. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functional tests worked so we're good to go here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR diff size of 10989 lines exceeds the maximum allowed for the inline comments feature.
Approved by @laceysanderson and @risharde ... all tests are passing but the Drupal 10 check which is breaking on Docker. So, merging. |
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function tripalValuesTemplate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function tripalValuesTemplate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
public function updateValues($values) { | ||
$indexed_values = $this->indexValues($values); | ||
|
||
public function updateValues($values) : bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function updateValues
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
* @return bool | ||
* True if the field was added successfully. False otherwise. | ||
*/ | ||
public function addBundleField(string $bundle, array $field_def) : bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function addBundleField
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method formElement
has 5 arguments (exceeds 4 allowed). Consider refactoring.
Code Climate has analyzed commit 82893db and detected 23 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 8.9% (50% is the threshold). This pull request will bring the total coverage in the repository to 22.2% (-2.1% change). View more on Code Climate. |
Issues Addressed
Issue #129
Issue #236
Issue #237
Wait to review this until after the merge of PR #254 because this PR has that code in it and all of the changes in that PR are also showing up here.
Description
This PR provides new functionality for field creation. It will automatically add all single-valued string fields to all content types during the Chado Prepare step. The only exception is the 'Pub' content type. That one requires some special handling. You can also create new entities for content types where the string fields are sufficient to meet the unique constraint (e.g. Organism).
This PR does not implement the
ChadoStorage::deleteValues()
function (issue tripal/tripal#1350) because there is not yet a distinction between an "Unpublish" and a "Delete" so I thought it would be best to not implement a delete until we had the buttons. TheChadoStorage::findValues()
function is also not yet implemented (issue tripal/tripal#1351).This PR also does not support integer fields, text fields or other database fields other than
character varying
. I left a "@todo" comment in the code to finish those up. But this PR is provided now so that everyone can have access to the new code.How to Test