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?
Adds a setter/getter in the validator base that allows the importer to set the TripalImporter instance it uses for the validator to use.
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.
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
Create and update tests accordingly
Testing
Automated Testing
ValidatorBaseTest::testTripalLoggerGetterSetter
[x] Tests an exception is thrown when trying to get a logger that hasn't been set yet
[x] Tests setLogger() with a valid TripalLogger object and ensures it doesn't throw an exception
[x] Tests getLogger() after setting with a valid TripalLogger object to ensure we get the object back
[x] Converted the 2 cases checking if 1) a genus exists and 2) is configured from checking for exceptions thrown to checking for a logged error message
ValidatorTraitFileTypesTest:testFileMimeType
[x] Added a check for logged error messages inside the try-catch whenever setFileMimeType() is tested
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?
@todo
to log those messages insteadTesting
Automated Testing
ValidatorBaseTest::testTripalLoggerGetterSetter
The following tests were updated:
ValidatorTraitProjectTest::testProjectSetterGetter
ValidatorTraitGenusConfiguredTest::testConfiguredGenusSetterGetter
ValidatorTraitFileTypesTest:testFileMimeType