public ModelNode fromChangeSet ( ResourceAddress resourceAddress , Map < String , Object > changeSet ) { ModelNode define = new ModelNode ( ) ; define . get ( ADDRESS ) . set ( resourceAddress ) ; define . get ( OP ) . set ( WRITE_ATTRIBUTE_OPERATION ) ; ModelNode undefine = new ModelNode ( ) ; undefine . get ( ADDRESS ) . set ( resourceAddress ) ; undefine . get ( OP ) . set ( UNDEFINE_ATTRIBUTE ) ; ModelNode operation = new ModelNode ( ) ; operation . get ( OP ) . set ( COMPOSITE ) ; operation . get ( ADDRESS ) . setEmptyList ( ) ; List < ModelNode > steps = new ArrayList <> ( ) ; for ( String key : changeSet . keySet ( ) ) { Object value = changeSet . get ( key ) ; ModelNode step ; if ( value . equals ( FormItem . VALUE_SEMANTICS . UNDEFINED ) ) { step = undefine . clone ( ) ; step . get ( NAME ) . set ( key ) ; } else { step = define . clone ( ) ; step . get ( NAME ) . set ( key ) ; // set value, including type conversion ModelNode valueNode = step . get ( VALUE ) ; setValue ( valueNode , value ) ; } steps . add ( step ) ; } operation . get ( STEPS ) . set ( steps ) ; return operation ; }
Turns a change set into a composite write attribute operation .