private void writeObject(ObjectOutputStream out) throws IOException { out.writeInt(version); out.writeObject(textRenderer); out.writeObject(chartRenderer); out.writeObject(pointLocator); out.writeDouble(discardLowLimit); out.writeDouble(discardHighLimit); SerializationHelper.writeSafeUTF(out, chartColour); out.writeInt(plotType); }
public DataSourceVO<?> mapRow(ResultSet rs, int rowNum) throws SQLException { DataSourceVO<?> ds = (DataSourceVO<?>) SerializationHelper.readObjectInContext(rs.getBlob(5).getBinaryStream()); ds.setId(rs.getInt(1)); ds.setXid(rs.getString(2)); ds.setName(rs.getString(3)); ds.setDefinition(ModuleRegistry.getDataSourceDefinition(rs.getString(4))); return ds; }
private void updatePoints() { // Get the points List<DataPointVO> dps = query( "select dp.id, dp.xid, dp.dataSourceId, dp.data, ds.name, " // + "ds.xid, ds.dataSourceType " // + "from dataPoints dp join dataSources ds on ds.id = dp.dataSourceId ", new DataPointRowMapper()); // Resave for (DataPointVO dp : dps) ejt.update( "update dataPoints set xid=?, name=?, deviceName=?, enabled=?, loggingType=?, " // + "intervalLoggingPeriodType=?, intervalLoggingPeriod=?, intervalLoggingType=?, " // + "tolerance=?, purgeType=?, purgePeriod=?, defaultCacheSize=?, discardExtremeValues=?, " // + "engineeringUnits=?, data=? where id=?", // new Object[] { dp.getXid(), dp.getName(), dp.getDeviceName(), boolToChar(dp.isEnabled()), dp.getLoggingType(), dp.getIntervalLoggingPeriodType(), dp.getIntervalLoggingPeriod(), dp.getIntervalLoggingType(), dp.getTolerance(), dp.getPurgeType(), dp.getPurgePeriod(), dp.getDefaultCacheSize(), boolToChar(dp.isDiscardExtremeValues()), dp.getEngineeringUnits(), SerializationHelper.writeObject(dp), dp.getId() }, // new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.CHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.DOUBLE, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.CHAR, Types.INTEGER, Types.BLOB, Types.INTEGER }); }
public void _updateDataSource(DataSourceVO<?> vo) { ejt.update( "update dataSources set xid=?, name=?, dataSourceType=?, data=? where id=?", new Object[] { vo.getXid(), vo.getName(), vo.getDefinition().getDataSourceTypeName(), SerializationHelper.writeObject(vo), vo.getId() }, new int[] {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BLOB, Types.INTEGER}); }
private void insertDataSource(final DataSourceVO<?> vo) { vo.setId( doInsert( "insert into dataSources (xid, name, dataSourceType, data) values (?,?,?,?)", new Object[] { vo.getXid(), vo.getName(), vo.getDefinition().getDataSourceTypeName(), SerializationHelper.writeObject(vo) }, new int[] {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BLOB})); AuditEventType.raiseAddedEvent(AuditEventType.TYPE_DATA_SOURCE, vo); }
@Override public DataPointVO mapRow(ResultSet rs, int rowNum) throws SQLException { DataPointVO dp = (DataPointVO) SerializationHelper.readObjectInContext(rs.getBlob(4).getBinaryStream()); dp.setId(rs.getInt(1)); dp.setXid(rs.getString(2)); dp.setDataSourceId(rs.getInt(3)); // Data source information. dp.setDataSourceName(rs.getString(5)); dp.setDataSourceXid(rs.getString(6)); dp.setDataSourceTypeName(rs.getString(7)); return dp; }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { int ver = in.readInt(); // Switch on the version of the class so that version changes can be elegantly handled. if (ver == 1) { name = SerializationHelper.readSafeUTF(in); deviceName = null; enabled = in.readBoolean(); loggingType = in.readInt(); intervalLoggingPeriodType = in.readInt(); intervalLoggingPeriod = in.readInt(); intervalLoggingType = in.readInt(); tolerance = in.readDouble(); purgeOverride = true; purgeType = in.readInt(); purgePeriod = in.readInt(); textRenderer = (TextRenderer) in.readObject(); chartRenderer = (ChartRenderer) in.readObject(); pointLocator = (PointLocatorVO) in.readObject(); defaultCacheSize = in.readInt(); discardExtremeValues = in.readBoolean(); discardLowLimit = in.readDouble(); discardHighLimit = in.readDouble(); engineeringUnits = in.readInt(); chartColour = null; plotType = PlotTypes.STEP; } else if (ver == 2) { name = SerializationHelper.readSafeUTF(in); deviceName = null; enabled = in.readBoolean(); loggingType = in.readInt(); intervalLoggingPeriodType = in.readInt(); intervalLoggingPeriod = in.readInt(); intervalLoggingType = in.readInt(); tolerance = in.readDouble(); purgeOverride = true; purgeType = in.readInt(); purgePeriod = in.readInt(); textRenderer = (TextRenderer) in.readObject(); chartRenderer = (ChartRenderer) in.readObject(); pointLocator = (PointLocatorVO) in.readObject(); defaultCacheSize = in.readInt(); discardExtremeValues = in.readBoolean(); discardLowLimit = in.readDouble(); discardHighLimit = in.readDouble(); engineeringUnits = in.readInt(); chartColour = SerializationHelper.readSafeUTF(in); plotType = PlotTypes.STEP; } else if (ver == 3) { name = SerializationHelper.readSafeUTF(in); deviceName = SerializationHelper.readSafeUTF(in); enabled = in.readBoolean(); loggingType = in.readInt(); intervalLoggingPeriodType = in.readInt(); intervalLoggingPeriod = in.readInt(); intervalLoggingType = in.readInt(); tolerance = in.readDouble(); purgeOverride = true; purgeType = in.readInt(); purgePeriod = in.readInt(); textRenderer = (TextRenderer) in.readObject(); chartRenderer = (ChartRenderer) in.readObject(); pointLocator = (PointLocatorVO) in.readObject(); defaultCacheSize = in.readInt(); discardExtremeValues = in.readBoolean(); discardLowLimit = in.readDouble(); discardHighLimit = in.readDouble(); engineeringUnits = in.readInt(); chartColour = SerializationHelper.readSafeUTF(in); plotType = PlotTypes.STEP; } else if (ver == 4) { name = SerializationHelper.readSafeUTF(in); deviceName = SerializationHelper.readSafeUTF(in); enabled = in.readBoolean(); loggingType = in.readInt(); intervalLoggingPeriodType = in.readInt(); intervalLoggingPeriod = in.readInt(); intervalLoggingType = in.readInt(); tolerance = in.readDouble(); purgeOverride = true; purgeType = in.readInt(); purgePeriod = in.readInt(); textRenderer = (TextRenderer) in.readObject(); chartRenderer = (ChartRenderer) in.readObject(); pointLocator = (PointLocatorVO) in.readObject(); defaultCacheSize = in.readInt(); discardExtremeValues = in.readBoolean(); discardLowLimit = in.readDouble(); discardHighLimit = in.readDouble(); engineeringUnits = in.readInt(); chartColour = SerializationHelper.readSafeUTF(in); plotType = in.readInt(); } else if (ver == 5) { textRenderer = (TextRenderer) in.readObject(); chartRenderer = (ChartRenderer) in.readObject(); pointLocator = (PointLocatorVO) in.readObject(); discardLowLimit = in.readDouble(); discardHighLimit = in.readDouble(); chartColour = SerializationHelper.readSafeUTF(in); plotType = in.readInt(); } // Check the purge type. Weird how this could have been set to 0. if (purgeType == 0) purgeType = Common.TimePeriods.YEARS; // Ditto for purge period if (purgePeriod == 0) purgePeriod = 1; }
public void savePersistentData(int id, Object data) { ejt.update( "update dataSources set rtdata=? where id=?", new Object[] {SerializationHelper.writeObject(data), id}, new int[] {Types.BLOB, Types.INTEGER}); }