Scripts to Change Properties of ValueObjects
These examples demonstrate how to change ValueObject properties. ValueObjects (for example, LongValueObject,DoubleValueObject,and StringValueObject) all have these properties:
- Value
- Quality (0=good quality, all others are various levels of not good)
- Timestamp
- Color (usually null)
- Locale
- AlwaysSend (usually false, so the connector is in control of whether to pass the data or not)
Change the data quality of a value
//this changes the data quality of the incoming ValueObject to bad quality var ValueObjectInterface = Java.type("com.ergotech.valueobjects.ValueObjectInterface"); vo=incomingValue; vo.setQuality(ValueObjectInterface.QUALITY_BAD); //bad quality is 2000 vo;
Some data sources will generate valueobjects with AlwaysSend set to true which overrides settings on connectors. Sometimes this needs to be changed.
Change the AlwaysSend property of a ValueObject
//this changes the AlwaysSend of the incoming ValueObject to false vo=incomingValue; vo.setAlwaysSend(false); vo;
Convert the timestamp of the incoming value to a SQL Date/Time
new Date(incomingValue.getDate()).toISOString().slice(0, 19).replace('T', ' ');
The string can then be used to build a SQL statement