Jaggu Jaggu - 1 year ago 80
Java Question

Trying to insert defaltValue to a column through impex but getting error unable to insert default value in the place of null

Null value in second column (incoming csv file):->

input CSV: 10512,,


INSERT_UPDATE Product;code[unique=true];vendors(code)[translator=ca.batch.converter.StiboSetDefaultVendorIfNullTranslator];...


Extending de.hybris.platform.impex.jalo.translators.AbstractValueTranslator;

private final String defaultVendorCode = "000000";

public Object importValue(String valueExpr, final Item item)
throws JaloInvalidParameterException {

if (valueExpr == null || StringUtils.isEmpty(valueExpr)) {

LOG.debug("Current attribute value is null so inserting "
+ defaultVendorCode);
valueExpr = defaultVendorCode;


return valueExpr;

getting the same below error here also for the 12345 but final impex conveterd row has the number (impex row -> 10153;12345)

due to Argument mismatch trying to set value '000000' for attribute de.hybris.platform.jalo.product.Product.vendors (got java.lang.String, expected de.h

(impex row -> 10153;;)

Answer Source

I think the error message is quite clear on this:

(got java.lang.String, expected de.h ybris.platform.jalo.product.Product).,

For the translator you'd have to lookup the actual default vendor object instead of returning the default vendor code.

I think the easiest solution would be if you used a Decorator instead that then returns the code values of your "vendors" attribute. You can find detailed instructions here: https://wiki.hybris.com/display/release5/ImpEx+API#ImpExAPI-WritingOwnCellDecorator

but basically something like this:

public class MyDecorator implements CSVCellDecorator
   public String decorate( int position, Map<Integer, String> srcLine )
      // here add your custom logic to check and if applies return your default vendor code, otherwise return the given input value
      //String parsedValue=srcLine.get(position);
      //return parsedValue+"modified"; // some decoration stuff

Hope that helps a bit :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download