TripalCultivate / TripalCultivate-Phenotypes

Provides generic support for large scale phenotypic data and traits with importers, content pages and visualizations.
GNU General Public License v3.0
1 stars 0 forks source link

G4.87 Split GENUS validator into new style validators. #87

Open laceysanderson opened 1 week ago

laceysanderson commented 1 week ago

Branch

g4.87-genusValidators

Groups

Group 2 - Data Importing, Group 4 - API | Services | Plugins

Dependencies

Describe

This issue is meant to upgrade the existing Genus to the new style described in Issue #82. These will be in inputType metadata and will be given the form values. The original Project is not needed as it is handled by the drupal form validate by making the field required 🤔

Does not remove the original validator! Does not update trait importer to use this new validator.

Design

I think we want two validators:

  1. Genus exists and is configured with phenotypes.
  2. Project exists and is configured to this genus.

I don't think either one requires any config as they should both have everything they need in the form values. Neither should look at the file in any way ;-p

reynoldtan commented 1 week ago

psudo-code for the genusExists() plugin:

class GenusExists {
  public function validateMetadata($form_values) {
     // Locate/extract the genus field from the form_values. 
     // This assumes that there is field named ‘genus’.

     // If the importer is configured to validate for genus and
     // this validator could not find a genus field.
     1. Throw an exception to the developer: you need/forgot a genus field.

     // If found

     Genus is a string value ie. Cicer or Lens.
     1. Check that it exits in chado.organism using the organism.genus.

     Failed if not found.

     2. Check that the genus is configured, that is the genus 
     trait, method, unit and database are set.

     Failed if not configured.
   } 
}
reynoldtan commented 1 week ago

For the project validator plugin: Proposing the name projectGenusMatch() - this means that I am validating that project exits and is paired to a genus. The name projectExists() might be good/suited for validator to just check if the project exists alone for Importer that collects just project information.

This plugin assumes the existence of fields named genus and project.

class projectGenusMatch {
  public function validateMetadata($form_values) {
    // Locate the project field from $form_values.
    // Can be the project id or project name.

    // Locate the genus field from $form_values.
    // Genus is a string value ie. Cicer or Lens.

    // Not Found
    If the importer is configured to validate for project + genus 
    and this validator could not find a genus and project field.
    1. Throw an exception - could not find a project and/or genus field. 

    // Found both fields:
    1. Check if project exits in chado.project

    Failed if not found.

    2. Check the genus paired/set to the project if it matches the value
    of the genus field.

    Failed if it does not match. 
  }
}
laceysanderson commented 1 week ago

For the project one, maybe we need two validators? One to check if the project exists in chado because as you say this is more generic and another to check that the pair is configured. Something like projectExists and projectGenusMatch?

reynoldtan commented 1 week ago

Project exists - validates the project exists in chado.project.

class projectExists {
  public function validateMetadata($form_values) {
    // Locate the project field from $form_values.
    // Can be the project id or project name.

    // Not Found
    If the importer is configured to validate for project 
    and this validator could not find a project field.
    1. Throw an exception - could not find a project field. 

    // Found project field:
    1. Check if project exits in chado.project

    Failed if not found.
  }
}