private boolean fetchModelsForService ( Service svc ) { boolean result = true ; Set < URI > modelUris = obtainReferencedModelUris ( svc ) ; for ( URI modelUri : modelUris ) { // Only fetch those that are not there and have not been unsucessfully fetched in the last 24 hours if ( ! this . graphStoreManager . containsGraph ( modelUri ) ) { boolean fetch = true ; // If it was previously unreachable we need to check how long ago we tried if ( this . unreachableModels . containsKey ( modelUri ) ) { Date now = new Date ( ) ; Date lastAttempt = this . unreachableModels . get ( modelUri ) ; long diffHours = ( now . getTime ( ) - lastAttempt . getTime ( ) ) / ( 60 * 60 * 1000 ) % 24 ; fetch = ( diffHours >= 24 ? true : false ) ; } if ( fetch ) { boolean isStored = this . graphStoreManager . fetchAndStore ( modelUri ) ; if ( ! isStored ) { this . unreachableModels . put ( modelUri , new Date ( ) ) ; } else { this . getEventBus ( ) . post ( new OntologyCreatedEvent ( new Date ( ) , modelUri ) ) ; } result = result & isStored ; } } } return result ; }
Given a service this method will fetch and upload the models referred to by the service . This is a synchronous implementation that will therefore wait until its fetched and uploaded .