-
Notifications
You must be signed in to change notification settings - Fork 51
New Controller Class to replace the ChadoOrganismAutocompleteController #2293
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 Controller Class to replace the ChadoOrganismAutocompleteController #2293
Conversation
…anismFormElementControllerTest, and the ChadoOrganismWidgetDefault is updated to use the new controller class instead of the ChadoOrganismAutocomplete controller
|
The merging of #2294 should allow your tests to pass despite deprecations. However, be aware that #2297 will bring back failing on deprecations in D11 specifically. For any tests that directly test deprecated methods, you should add the |
…efault_id in getSelectElement
tripal_chado/src/Controller/ChadoOrganismFormElementController.php
Outdated
Show resolved
Hide resolved
dsenalik
left a comment
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.
Awesome work!
I think we should update the organism selects in the importers.
Specifically, the FASTA and GFF importers have organism select elements that could now use this new class.
tripal/tripal_chado/src/Plugin/TripalImporter/FASTAImporter.php
Lines 46 to 55 in 34e10c1
| // get the list of organisms | |
| $organisms = chado_get_organism_select_options(); | |
| $form['organism_id'] = [ | |
| '#title' => t('Organism'), | |
| '#type' => 'select', | |
| '#description' => t("Choose the organism to which these sequences are associated"), | |
| '#required' => TRUE, | |
| '#options' => $organisms, | |
| ]; |
tripal/tripal_chado/src/Plugin/TripalImporter/GFF3Importer.php
Lines 397 to 412 in 34e10c1
| // get the list of organisms | |
| $organisms = chado_get_organism_select_options(FALSE, TRUE); | |
| // get the sequence ontology CV id | |
| $conditions = ['cv.name' => 'sequence']; | |
| $cv_records = $this->cvterm_buddy->getCv($conditions, []); | |
| $sequence_cv_id = $cv_records[0]->getValue('cv.cv_id'); | |
| $form['organism_id'] = [ | |
| '#title' => t('Existing Organism'), | |
| '#type' => 'select', | |
| '#description' => t("Choose an existing organism to which the entries in the GFF file will be associated."), | |
| '#required' => TRUE, | |
| '#options' => $organisms, | |
| '#empty_option' => t('- Select -'), | |
| ]; |
Co-authored-by: Douglas Senalik <[email protected]>
Co-authored-by: Douglas Senalik <[email protected]>
Co-authored-by: Douglas Senalik <[email protected]>
Co-authored-by: Douglas Senalik <[email protected]>
Co-authored-by: Douglas Senalik <[email protected]>
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.
I am very very sorry to say I request one more change.
The analysis field does not convert to autocomplete
I forgot that it is in the parent class
We need to change it here
never mind not relevant to this pr that only deals with the organism controller
tripal/tripal_chado/src/TripalImporter/ChadoImporterBase.php
Lines 254 to 282 in 34e10c1
| public function addAnalysis($form, &$form_state) { | |
| $chado = $this->connection; | |
| // Get the list of analyses. | |
| $query = $chado->select('1:analysis', 'A'); | |
| $query->fields('A', ['analysis_id', 'name']); | |
| $query->orderBy('A.name'); | |
| $analyses = []; | |
| $results = $query->execute(); | |
| while ($analysis = $results->fetchObject()) { | |
| $analyses[$analysis->analysis_id] = $analysis->name; | |
| } | |
| // Add the form element. | |
| $element['analysis_id'] = [ | |
| '#title' => t('Analysis'), | |
| '#type' => 'select', | |
| '#description' => t('Choose the analysis to which the uploaded data ' . | |
| 'will be associated. Why specify an analysis for a data load? All ' . | |
| 'data comes from some place, even if downloaded from a website. By ' . | |
| 'specifying analysis details for all data imports it provides ' . | |
| 'provenance and helps end user to reproduce the data set if needed. ' . | |
| 'At a minimum it indicates the source of the data.'), | |
| '#required' => $this->plugin_definition['require_analysis'], | |
| '#options' => $analyses, | |
| ]; | |
| return $element; |
laceysanderson
left a comment
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.
Some code comments --this is looking really good ❤️
tripal_chado/src/Controller/ChadoOrganismAutocompleteController.php
Outdated
Show resolved
Hide resolved
tripal_chado/src/Controller/ChadoOrganismAutocompleteController.php
Outdated
Show resolved
Hide resolved
tripal_chado/src/Controller/ChadoOrganismFormElementController.php
Outdated
Show resolved
Hide resolved
tripal_chado/src/Controller/ChadoOrganismFormElementController.php
Outdated
Show resolved
Hide resolved
tripal_chado/src/Controller/ChadoOrganismFormElementController.php
Outdated
Show resolved
Hide resolved
tripal_chado/src/Controller/ChadoOrganismFormElementController.php
Outdated
Show resolved
Hide resolved
|
Regarding the test failure: https://github.com/tripal/tripal/actions/runs/18112268169/job/51540955913?pr=2293#step:5:26
This happens when the field is optional. I say we just allow the getPkeyId() to take NULL as a param and then return it without change. This way we don't need if's in every place this is called when it's optional. |
Co-authored-by: Lacey-Anne Sanderson <[email protected]>
Co-authored-by: Lacey-Anne Sanderson <[email protected]>
Co-authored-by: Lacey-Anne Sanderson <[email protected]>
Co-authored-by: Lacey-Anne Sanderson <[email protected]>
Co-authored-by: Lacey-Anne Sanderson <[email protected]>
Co-authored-by: Lacey-Anne Sanderson <[email protected]>
…and making the getPkeyId method to allow null as a parameter
laceysanderson
left a comment
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.
tldr; This is ready for merge! You addressed all the outstanding concerns, the code looks good, and the manual testing done below works perfectly. Good job and Thanks!!! ❤️ 🎉
Manual Testing
✅ Creating a germplasm variety through the UI (selecting its organism via the updated field; SELECT) works great as does editing and deleting it.
✅ Creating a germplasm variety through the UI (selecting its organism via the updated field; AUTO COMPLETE) works great as does editing and deleting it.
✅ Editing genes published via the GFF3 importer when either a SELECT or AUTOCOMPLETE on the organism widget is used works beautifully with no errors.
✅ Organisms with infraspecies provided work beautifully in both SELECT and AUTOCOMPLETE.
✅ GFF3 importer with updated form element works great.
✅ Fasta importer with updated form element also works great.
New Feature
Issue #2284
Description
This PR introduces a new controller class, ChadoOrganismFormElementController, which replaces and extends the functionality of the existing ChadoOrganismAutocompleteController. It retains all existing methods while adding methods for generating the autocomplete/select elements used in the organism widget. Additionally, it includes a method to get the select options as a direct replacement for chado_get_organism_select_options() method.
Testing
Automated testing
ChadoOrganismFormElementControllerTest class containing the following methods:
1. Select element with valid default id given
2. Autocomplete with valid default id given
3. Autocomplete with valid default value given
4. Select element with valid default value given
5. Autocomplete with invalid default id given