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

g5.105 Implement TripalLogger to allow validators/traits to log their own messages #107

Closed carolyncaron closed 2 months ago

carolyncaron commented 2 months ago

Issue #105

Motivation

We want the ability to allow the validators to utilize the TripalLogger instance from the Tripal Importer. This will allow us to log messages in the service logs in place of exception messages where it is more appropriate to do so.

What does this PR do?

  1. Adds a setter/getter in the validator base that allows the importer to set the TripalImporter instance it uses for the validator to use.
  2. Update the Trait Importer to set the TripalLogger instance for each validator
    • In this PR, this only applies to the DuplicateTraits validator, so I've added a single call to setLogger() by this instance within the configureValidators() method.
    • For future discussion: We know that once the Traits Importer is updated to use all of the new validators, there will be more calls to setLogger(). @laceysanderson has suggested we can loop through all of the validators at the end of the configureValidators() method and set it for every validator regardless if they need it or not, to cut down on maintenance every time we want to add a new validator.
  3. Update exception messages currently marked as @todo to log those messages instead
    • GenusConfigured Trait:
    • [x] Check that genus exists in chado
    • [x] Check that genus is configured for the module
    • Project Trait:
    • [x] Check if project id <= 0
    • [x] Check if project name is an empty string
    • [x] Check if project exists in the database
    • FileTypes Trait:
    • [x] Check if the input file's MIME type is in the mime_to_delimiter_mapping array
  4. Create and update tests accordingly

Testing

Automated Testing

ValidatorBaseTest::testTripalLoggerGetterSetter

The following tests were updated:

ValidatorTraitProjectTest::testProjectSetterGetter

ValidatorTraitGenusConfiguredTest::testConfiguredGenusSetterGetter

ValidatorTraitFileTypesTest:testFileMimeType