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; }
protected WriteAttributeResults processSetAttributes ( final Map<String, Variant> attributes, final OperationParameters operationParameters ) { final WriteAttributeResults writeAttributeResults = new WriteAttributeResults (); for ( final ChainProcessEntry chainEntry : this.chain ) { final ChainItem chainItem = chainEntry.getWhat (); final WriteAttributeResults partialResult = chainItem.setAttributes ( attributes ); if ( partialResult != null ) { for ( final Map.Entry<String, WriteAttributeResult> entry : partialResult.entrySet () ) { if ( entry.getValue ().isError () ) { attributes.remove ( entry.getKey () ); } writeAttributeResults.put ( entry.getKey (), entry.getValue () ); } } } process (); return handleUnhandledAttributes ( writeAttributeResults, attributes ); }
@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 ); }