How to map an attribute of Type Object in ORIKA

639 views Asked by At

I have a class OrderEntryData and inside I have an attribute which is a list of configurationInfoData (List< ConfigurationInfoData >) and inside this ConfigurationInfoData an attribute of Type Object (Object value). This value will be sometime a date , a string or a customClass.

I am using Orika for the webServices and I am trying to settle the OrderEntryDTO class.

File : customcommerceWebServices-beans.xml

<bean class="de.hybris.platform.commercewebservicescommons.dto.order.ConfigurationInfoWsDTO">
    <property name="label" type="java.lang.String" />
    <property name="value" type="java.lang.Object" />
</bean>

<bean class="de.hybris.platform.commercewebservicescommons.dto.order.OrderEntryWsDTO">
    <property name="configurationInfos" type="java.util.List&lt;de.hybris.platform.commercewebservicescommons.dto.order.ConfigurationInfoWsDTO>" />
    <property name="orderCode" type="java.lang.String" />
</bean>

I am testing with an Object which is an instance of AddressData. Cause the Mapping/Conversion of the address object is working well AddressData -> AddressDTO

the problem is (I think) Orika does not recognize the instance of the object (Object source) or the destination class (Object Target). In the response I should have a AddressWsDTO but I get :

"de.hybris.platform.cmssmarteditwebservices.dto.AbstractPageWsDTO@54330c75"

I tried to implement a converter cause I was thinking maybe Orika don't Know how to convert an object to an AddressData (not working).

@WsDTOMapping
public class ScalpAddressConverter extends BidirectionalConverter<AddressData, Object> {

@Override
public Object convertTo(AddressData addressData, Type<Object> type, MappingContext mappingContext) {
    return (Object) addressData;
}

@Override
public AddressData convertFrom(Object o, Type<AddressData> type, MappingContext mappingContext) {
    return (AddressData) o;
}
}
0

There are 0 answers