BPM problem with BigDecimal

Hi,

In 2.3.3 jmix version , I have a problem with the BPM module when starting a form with two BigDecimal type fields:

image

The only way to start the form is by changing the data type to Double both in the form and in the entity in which I´m going to save the data.

Is there any way I can start with BigDecimal and not error when starting the form?

This is how I have the form and entity configured:

image

image

Thanks.

Which database are you using?

I´m using PostgreSql and the model is the same as in jmix:

image

image

For some reason when using bigDecimal it cannot find it and the error appears when starting the form.

I added bigDecimal process variable to one of my processes and I got the same error as you, using Jmix 2.2.3. and Postgres.
The problem seems to be that InputDialogFormComponentsFactoryBean.java, when creating a component of type bigDecimal, can not get a proper definition for the bigDecimal data type.
This seems to be a bug, and I can’t help with this, it’s best to leave that to the Jmix team, you can also report this at Jmix github as a bug.

Can you use some other datatype instead of bigDecimal instead?

Kind regards,
Mladen

With the Double data type in the form and the entity it does allow me to perform the actions of starting the form and saving data in the entity.

It seems that the problem comes from bigDecimal, I will be waiting for a response,

Thanks.

Hello @daniel.merino,

This is a bug. Thank you for reporting a problem. I created an issuer - Datatype 'bigDecimal' is not found · Issue #3839 · jmix-framework/jmix · GitHub

As a workaround, you can add a bigDecimal data type.

@DatatypeDef(id = "bigDecimal", javaClass = BigDecimal.class, defaultForClass = true, value = "custom_BigDecimalDatatype")
@NumberFormat(
        pattern = "0.####",
        decimalSeparator = ".",
        groupingSeparator = ""
)
public class BigDecimalDatatype extends NumberDatatype implements Datatype<BigDecimal> {

    @Autowired
    protected FormatStringsRegistry formatStringsRegistry;
    @Autowired
    protected CoreProperties coreProperties;

    @Override
    protected java.text.NumberFormat createFormat() {
        java.text.NumberFormat format = super.createFormat();
        if (format instanceof DecimalFormat) {
            ((DecimalFormat) format).setParseBigDecimal(true);
        }
        return format;
    }

    @Override
    public String format(Object value) {
        return value == null ? "" : createFormat().format(value);
    }

    @Override
    public String format(Object value, Locale locale) {
        if (value == null) {
            return "";
        }

        FormatStrings formatStrings = formatStringsRegistry.getFormatStringsOrNull(locale);
        if (formatStrings == null) {
            return format(value);
        }

        DecimalFormatSymbols formatSymbols = formatStrings.getFormatSymbols();
        java.text.NumberFormat format = new DecimalFormat(formatStrings.getDecimalFormat(), formatSymbols);
        return format.format(value);
    }

    @Override
    public BigDecimal parse(String value) throws ParseException {
        if (StringUtils.isBlank(value)) {
            return null;
        }

        return (BigDecimal) parse(value, createFormat());
    }

    @Override
    public BigDecimal parse(String value, Locale locale) throws ParseException {
        if (StringUtils.isBlank(value)) {
            return null;
        }

        FormatStrings formatStrings = formatStringsRegistry.getFormatStringsOrNull(locale);
        if (formatStrings == null) {
            return parse(value);
        }

        DecimalFormatSymbols formatSymbols = formatStrings.getFormatSymbols();
        DecimalFormat format = new DecimalFormat(formatStrings.getDecimalFormat(), formatSymbols);
        format.setParseBigDecimal(true);
        return (BigDecimal) parse(value, format);
    }

    protected Number parse(String value, java.text.NumberFormat format) throws ParseException {
        BigDecimal result = (BigDecimal) super.parse(value, format);
        if (coreProperties.isRoundDecimalValueByFormat()) {
            int maximumFractionDigits = format.getMaximumFractionDigits();
            RoundingMode roundingMode = format.getRoundingMode();
            result = result.setScale(maximumFractionDigits, roundingMode);
        }
        return result;
    }

    @Override
    public String toString() {
        return getClass().getSimpleName();
    }

}

Regards,
Nikita

Thank you very much,

Something similar happens with the File field that I declare as a process variable which I am going to record in the entity that is of type FileRef.

image

image

Is there any way to solve this?

image

Thanks.

Hello @daniel.merino,

This is correct behavior because the file in the dialog is saved in byte[] format, and to save the entity you need the FileRef type.

We have an issuer:

You can replace the Data Entity Task with a Service Task and implement your own method for storing data with format conversion.

Or you can implement your own Jmix form and store the data directly in the FileRef entity.

Regards,
Nikita

The same problem occurs with Integer, there is no option to select an integer value when declaring the process variables and you have to declare it, for example, type Long, double or bigDecimal.

image

In my entity I have it declared as an integer type:

image

Is there any way to put it in? Or is it that integer types are not allowed in the BPM module?

Thanks.