Data Import Addon - bug - cannot import data in property with type "Long"

Hi,

I’m facing a bug of DataImport Module.
I cannot import data mapped on an Entity field with type Long.

The problem is probably located here de.diedavids.cuba.dataimport.binding.DatatypeFactory#getValue

    Object getValue(AttributeBindRequest bindRequest) {
    switch (bindRequest.javaType) {
        case Integer: return getIntegerValue(bindRequest.rawValue, bindRequest.dataRow)
        case Double: return getDoubleValue(bindRequest.rawValue, bindRequest.dataRow)
        case Date: return getDateValue(bindRequest.importConfiguration, bindRequest.rawValue)
        case Boolean: return getBooleanValue(bindRequest.importConfiguration, bindRequest.rawValue, bindRequest.dataRow)
        case BigDecimal: return getBigDecimalValue(bindRequest.rawValue, bindRequest.dataRow)
        case String: return getStringValue(bindRequest.rawValue)
        case Enum: return getEnumValue(bindRequest)
    }
}

The Long Datatype is not managed.

I attached a reproducer

  • launch de project
  • create launch configuration
    • entity : MyEntity
    • data file : data.csv.
  • Run import

==> it fails. No data inserted.

If you change the datatype of the field in MyEntity to integer, it is ok.

By the way,
could it be possible to improve log messages like in …

de.diedavids.cuba.dataimport.binding.DatatypeFactory#getIntegerValue
    
    [...]
    catch (NumberFormatException e) {
        log.warn("Number could not be read: '$rawValue' in [$dataRow]. Will be ignored.")
    }

… adding the name of the field that refers to the wrong value. the fieldname is in the bindRequest Object in the caller method Object getValue(AttributeBindRequest bindRequest).

It would be simplify further investigations.

Regard,
GuillaumeDataImportLongReproducer.zip (89.8 KB)

hi @guillaume.lundy,

thanks for reaching out. You are right - i think I just forgot about Long. Since you already took a deep look into the code, perhaps you are interested in creating a PR with a appropriate fix?

Bye
Mario

1 Like

Hi @mario

The PR is done.

Rgds,
Guillaume

1 Like

Hi,

thanks for the PR and the support.

Support for Long and LocalDate is now part of 0.11.0.

Bye
Mario