protected DataItemValue processHandler ( DataItemValue value ) { logger.debug ( "Processing handlers" ); final ArrayList<HandlerEntry> handler; synchronized ( this.itemHandler ) { handler = new ArrayList<HandlerEntry> ( this.itemHandler ); } final Map<String, Object> context = new HashMap<String, Object> (); final DataItemValue.Builder builder = new Builder ( value ); for ( final HandlerEntry entry : handler ) { logger.debug ( "Process: {} -> {}", new Object[] { entry.getPriority (), entry.getHandler () } ); entry.getHandler ().dataUpdate ( context, builder ); } if ( this.debug ) { builder.setAttribute ( "master.debug.handlerCount", Variant.valueOf ( handler.size () ) ); value = builder.build (); } return builder.build (); }
protected void handlePerformNotifySubscriptionChange ( final SubscriptionState subscriptionState, final Throwable subscriptionError ) { final DataItemValue.Builder newValue = new DataItemValue.Builder ( this.value ); newValue.setSubscriptionState ( subscriptionState ); newValue.setSubscriptionError ( subscriptionError ); final DataItemValue oldValue = this.value; this.value = newValue.build (); setChanged (); try { notifyObservers ( this.value ); this.propertySupport.firePropertyChange ( PROP_VALUE, oldValue, this.value ); } catch ( final Throwable e ) { logger.warn ( "Failed to notify subscription change", e ); } }
protected void handlePerformNotifySubscriptionChange ( final SubscriptionState subscriptionState, final Throwable subscriptionError ) { final DataItemValue.Builder newValue = new DataItemValue.Builder ( this.value ); newValue.setSubscriptionState ( subscriptionState ); newValue.setSubscriptionError ( subscriptionError ); final DataItemValue oldValue = this.value; this.value = newValue.build (); setChanged (); try { notifyObservers ( this.value ); this.propertySupport.firePropertyChange ( PROP_VALUE, oldValue, this.value ); } catch ( final Throwable e ) { logger.warn ( "Failed to notify subscription change", e ); } }
this.value = newValue.build ();
this.value = newValue.build ();
@Override protected synchronized void stateChanged ( final DataItemValue value ) { logger.debug ( "state change: {}", value ); if ( value != null ) { if ( value.isConnected () || this.dontOverrideSubscription ) { this.sourceValue = value; } else { final Builder builder = new Builder ( value ); builder.setSubscriptionState ( SubscriptionState.CONNECTED ); this.sourceValue = builder.build (); } } else { final Builder builder = new Builder (); builder.setAttribute ( "master.source.error", Variant.TRUE ); builder.setAttribute ( "master.datasource.id", Variant.valueOf ( this.dataSourceId ) ); this.sourceValue = builder.build (); } reprocess (); }
private DataItemValue applyAutoTimestamp ( DataItemValue value ) { if ( value != null && value.getTimestamp () == null ) { try { if ( !this.lastValue.equals ( value.getValue () ) ) { this.lastTimestamp = Calendar.getInstance (); } } catch ( final Exception e ) { // nothing logger.info ( "Failed to update timestamp", e ); } final DataItemValue.Builder builder = new DataItemValue.Builder ( value ); builder.setTimestamp ( this.lastTimestamp ); value = builder.build (); } return value; }
private DataItemValue applyAutoTimestamp ( DataItemValue value ) { if ( value != null && value.getTimestamp () == null ) { try { if ( !this.lastValue.equals ( value.getValue () ) ) { this.lastTimestamp = Calendar.getInstance (); } } catch ( final Exception e ) { // nothing logger.info ( "Failed to update timestamp", e ); } final DataItemValue.Builder builder = new DataItemValue.Builder ( value ); builder.setTimestamp ( this.lastTimestamp ); value = builder.build (); } return value; }
private static DataItemValue initValue () { final DataItemValue.Builder builder = new Builder (); builder.setAttribute ( "master.uninitialized", Variant.TRUE ); return builder.build (); }
@Override public String toString () { return build ().toString (); } }
@Override public String toString () { return build ().toString (); } }