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
Implemented CustomFieldValidator to inject a point of prevention before a source field value is fetched during mapping #266
Conversation
@gilbertg ; can you rebase to force a retest please. |
@gilbertg ; any update? |
Hi, sorry Gareth, been super busy. Have not lost sight of this, will get it
done asap.
~Gilbert
…On 22 Jun 2017 01:26, "Gareth Healy" ***@***.***> wrote:
@gilbertg <https://github.com/gilbertg> ; any update?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#266 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEO4GAJrp4SzD5H2xgGb0ZPwP1Z-IRmeks5sGiUhgaJpZM4GJ4vd>
.
|
Hi @garethahealy , failing on a unit test - not sure this is related to my change - either way, perhaps you could eyeball it before I jump into debugging? If you recognise anything obvious, it'll help. ~gilbert |
@gilbertg ; i've noticed this locally - but not seen it on travis before. It seems to have happened from a recent commit. I fixed by adding:
to:@orange-buffalo ; any ideas? it started happening when the singleton PR got merged. |
Master branch has now been fixed @gilbertg. If you rebase, the failing tests should now pass. |
…re a source field value is fetched during mapping A custom field validator is usually in conjunction with a CustomFieldMapper when implementing the CustomFieldMapperAndValidator interface. Use this when you want logic to prevent source field values being fetched. e.g. when checking lazy loaded relationships in an ORM If a custom field validator is specified, Dozer will invoke this class when performing all field mappings. If false is returned from the call the source field value will never be fetched, and subsequently the field will never be mapped.
@garethahealy yay, finally got a green light. Thanks! |
CC @orange-buffalo for review. |
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.
Sorry for huge delay with review, guys. I've put my comments below.
// either deep field map or generic map. The is the most likely | ||
// scenario | ||
mapFromFieldMap(srcObj, destObj, srcFieldValue, fieldMapping); | ||
if (canMapField) { |
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.
This is a significant change in core functionality, it should be covered with the tests.
fieldMapped = customFieldMapper.mapField(srcObj, destObj, srcFieldValue, fieldMapping.getClassMap(), fieldMapping); | ||
|
||
boolean canMapField = true; | ||
if (customFieldMapper != null && customFieldMapper instanceof CustomFieldMapperAndValidator) { |
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 do not believe that customFieldMapper instanceof CustomFieldMapperAndValidator
is the best way to go here. I would say that "mapping the filed" and "filtering source fields" are two different responsibilities. They should be represented in MapperProcessor
via two different objects of two different interfaces.
@gilbertg ; have you had any chance to review comments? |
@gilbertg ; i know its been a while, but have you had chance to review the comments? |
HI Gareth, no, i haven't.
Tbh I lost interest - since the whole thing turned laborious - and i am no
longer working with the project that required that fix.
Regards,
Gilbert
…On Thu, 2 Jan 2020 at 15:49, Gareth Healy ***@***.***> wrote:
@gilbertg <https://github.com/gilbertg> ; i know its been a while, but
have you had chance to review the comments?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#266?email_source=notifications&email_token=ABB3QGDTEN5GZ4WBNT2NC5DQ3XWGRA5CNFSM4BRHRPO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH6MAUQ#issuecomment-570212434>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABB3QGEFQG3QJNATRUI3KOLQ3XWGRANCNFSM4BRHRPOQ>
.
--
Gilbert Grant
Cell: +27 (0) 82 875 1008 Mail: gilbert@iron-nest.com
<http://www.iron-nest.com>
*PLEASE CONSIDER THE ENVIRONMENT BEFORE YOU PRINT*
|
A custom field validator is usually in conjunction with a
CustomFieldMapper when implementing the CustomFieldMapperAndValidator
interface.
Use this when you want logic to prevent source field values being
fetched.
e.g. when checking lazy loaded relationships in an ORM
If a custom field validator is specified, Dozer will invoke this class
when performing all field mappings. If false is returned from the call
the source field value will never be fetched, and subsequently the field
will never be mapped.