Marcus Christie created AIRAVATA-2751:

             Summary: Dozer custom mapping to skip primitive fields that aren't 
                 Key: AIRAVATA-2751
             Project: Airavata
          Issue Type: Bug
            Reporter: Marcus Christie

I'm finding that primitive fields that aren't set on a thrift model, like 
{{long}}, are mapped into entities as a 0.  The Dozer mapping (see 
ObjectMapperSingleton) isn't calling {{isSet}} on the thrift models to make 
sure that they are mapped.

Here's some pseudo code that I think would do the trick, although I'm not sure 
if a CustomFieldMapper is the right way to customize this in Dozer (seemed like 
the best option given the research I did):
    public static ObjectMapperSingleton getInstance(){
        if(instance == null) {
            instance = new ObjectMapperSingleton();
            instance.setCustomFieldMapper(new CustomFieldMapper() {
                public boolean mapField(Object source, Object destination, 
Object sourceFieldValue, ClassMap classMap, FieldMap fieldMap) {
                    if (source instanceof TBase) {
                        TBase thriftSource = (TBase) source;
                        // TODO: following doesn't work, needs reflection
                        srcField = 
                        if (!thriftSource.isSet(srcField)) {
                            // Just skipping mapping field if not set on Thrift 
source model
                            return true;

                    return false;
        return instance;

This message was sent by Atlassian JIRA

Reply via email to