Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Flipbook not loading images, image type 1 for jpg not loaded from database


  • Retrieving images from the database seems to be broken in 1.12.4.

    The query returns:

    select pv.dataType, pv.pointValue, pva.textPointValueShort, pva.textPointValueLong, pv.ts, pva.sourceType, pva.sourceId from pointValues pv left join pointValueAnnotations pva on pv.id = pva.pointValueId where pv.id=9467

    DATATYPE: 5
    POINTVALUE: 1
    TEXTPOINTVALUESHORT: 9467
    TEXTPOINTVALUELONG: null
    TS: 1342218110819
    SOURCETYPE: null
    SOURCEID: null

    The new ImageValue constructor uses the textpointvalueshort of 9467 to determine the filename, and the pointvalue 1 to determine the file extension.

    
    public class ImageValue extends MangoValue implements Comparable<ImageValue> {
        private static final String FILENAME_PREFIX = "img";
    
        public static final int TYPE_JPG = 1;
        private static final String[] TYPES = { "", "jpg" };
    
        private long id = Common.NEW_ID;
        private int type;
        private byte[] data;
    
        public ImageValue(long id, int type) {
            this.id = id;
            this.type = type;
        }
    
        public ImageValue(byte[] data, int type) {
            this.data = data;
            this.type = type;
        }
    ...
    
    

    Therefore in PointValueDao.java

    
        MangoValue createMangoValue(ResultSet rs, int firstParameter) throws SQLException {
            int dataType = rs.getInt(firstParameter);
            MangoValue value;
            switch (dataType) {
            case (DataTypes.NUMERIC):
                value = new NumericValue(rs.getDouble(firstParameter + 1));
                break;
            case (DataTypes.BINARY):
                value = new BinaryValue(rs.getDouble(firstParameter + 1) == 1);
                break;
            case (DataTypes.MULTISTATE):
                value = new MultistateValue(rs.getInt(firstParameter + 1));
                break;
            case (DataTypes.ALPHANUMERIC):
                String s = rs.getString(firstParameter + 2);
                if (s == null)
                    s = rs.getString(firstParameter + 3);
                value = new AlphanumericValue(s);
                break;
            case (DataTypes.IMAGE):
                value = new ImageValue(Integer.parseInt(rs.getString(firstParameter + 2)), rs.getInt(firstParameter + 3));
                break;
            default:
                value = null;
            }
            return value;
        }
    
    

    should be

    
    ...
            case (DataTypes.IMAGE):
                value = new ImageValue(Integer.parseInt(rs.getString(firstParameter + 2)), rs.getInt(firstParameter + 1));
    
    

    changing the column used to load the image type from the fourth column to the 2nd gives the image the correct type (1 for jpg) and subsequently the correct file extension is used when loading images for the flipbook, otherwise "img9467." is loaded by the imageValueServlet, which doesn't exist, and 0 byte images are returned result.


  • Yes, this is the correct fix. It already made it into 1.13.x, but didn't make it back into 1.12.x.