public void fillMapping ( Model mo , JSONObject o ) throws JSONConverterException { Mapping c = mo . getMapping ( ) ; for ( Node u : newNodes ( mo , o , "offlineNodes" ) ) { c . addOfflineNode ( u ) ; } for ( VM u : newVMs ( mo , o , "readyVMs" ) ) { c . addReadyVM ( u ) ; } JSONObject ons = ( JSONObject ) o . get ( "onlineNodes" ) ; for ( Map . Entry < String , Object > e : ons . entrySet ( ) ) { int id = Integer . parseInt ( e . getKey ( ) ) ; Node u = mo . newNode ( id ) ; if ( u == null ) { throw JSONConverterException . nodeAlreadyDeclared ( id ) ; } JSONObject on = ( JSONObject ) e . getValue ( ) ; c . addOnlineNode ( u ) ; for ( VM vm : newVMs ( mo , on , "runningVMs" ) ) { c . addRunningVM ( vm , u ) ; } for ( VM vm : newVMs ( mo , on , "sleepingVMs" ) ) { c . addSleepingVM ( vm , u ) ; } } }
Create the elements inside the model and fill the mapping .