private void writeToLogger(Value<?> value) { Parameter<?> parameter = value.getParameter(); logger.info( "-----| parameter: " + parameter + " = " + value.getValue() + " [" + parameter.getUnit() + "] |-----"); }
private void writeToDatabase(Date time, Value<?> value) { try { Parameter<?> parameter = value.getParameter(); if (!parameter.isNumeric()) { throw new IllegalArgumentException("The value '" + value.toString() + "' is not numeric!"); } BigDecimal decimalValue = null; BigInteger integerValue = null; if (Long.class.isAssignableFrom(parameter.getType())) { integerValue = BigInteger.valueOf((Long) value.getValue()); } else { decimalValue = BigDecimal.valueOf((Double) value.getValue()); } preparedStatement.setTime(1, new Time(time.getTime())); preparedStatement.setString(2, server); preparedStatement.setString(3, parameter.getName()); preparedStatement.setString(4, parameter.getUnit()); preparedStatement.setString(5, parameter.getType().getName()); preparedStatement.setString(6, parameter.getDescription()); preparedStatement.setBigDecimal(7, decimalValue); preparedStatement.setLong(8, integerValue.longValue()); preparedStatement.setString(9, parameter.getLevelOfMeasurement().name()); preparedStatement.execute(); } catch (SQLException e) { throw new RuntimeException("Could not insert event into event log.", e); } }