protected Variant process ( Variant value ) { final Map<String, Variant> primaryAttributes = new HashMap<String, Variant> ( this.primaryAttributes ); for ( final ChainProcessEntry entry : getChainCopy () ) { if ( entry.getWhen ().contains ( IODirection.OUTPUT ) ) { final Variant newValue = entry.getWhat ().process ( value, primaryAttributes ); if ( newValue != null ) { value = newValue; } } } this.secondaryAttributes.set ( null, primaryAttributes ); return value; }
@Override public NotifyFuture<WriteResult> startWriteValue ( Variant value, final OperationParameters operationParameters ) { synchronized ( this ) { final Collection<ChainProcessEntry> chain = getChainCopy (); final Map<String, Variant> primaryAttributes = new HashMap<String, Variant> ( this.primaryAttributes ); for ( final ChainProcessEntry entry : chain ) { if ( entry.getWhen ().contains ( IODirection.OUTPUT ) ) { final Variant newValue = entry.getWhat ().process ( value, primaryAttributes ); if ( newValue != null ) { value = newValue; } } } } // FIXME: for the moment output chain item don't show up in the attribute list // secondaryAttributes.set ( primaryAttributes ); return startWriteCalculatedValue ( value, operationParameters ); }
@Override protected void process () { Variant newSecondaryValue = Variant.valueOf ( this.primaryValue ); final Map<String, Variant> newAttributes = new HashMap<String, Variant> ( this.primaryAttributes ); for ( final ChainProcessEntry entry : getChainCopy () ) { if ( entry.getWhen ().contains ( IODirection.INPUT ) ) { final Variant newValue = entry.getWhat ().process ( newSecondaryValue, newAttributes ); if ( newValue != null ) { newSecondaryValue = newValue; } } } Variant newValue = null; if ( !this.secondaryValue.equals ( newSecondaryValue ) ) { newValue = this.secondaryValue = Variant.valueOf ( newSecondaryValue ); } this.secondaryAttributes.set ( newValue, newAttributes ); }