private Response serveOneOrAll ( Map < String , Model > modelsMap ) { // returns empty sets if !this.find_compatible_frames Pair < Map < String , Frame > , Map < String , Set < String > > > frames_info = fetchFrames ( ) ; Map < String , Frame > all_frames = frames_info . getFirst ( ) ; Map < String , Set < String > > all_frames_cols = frames_info . getSecond ( ) ; Map < String , ModelSummary > modelSummaries = Models . generateModelSummaries ( null , modelsMap , find_compatible_frames , all_frames , all_frames_cols ) ; Map resultsMap = new LinkedHashMap ( ) ; resultsMap . put ( "models" , modelSummaries ) ; // If find_compatible_frames then include a map of the Frame summaries. Should we put this on a separate switch? if ( this . find_compatible_frames ) { Set < String > all_referenced_frames = new TreeSet < String > ( ) ; for ( Map . Entry < String , ModelSummary > entry : modelSummaries . entrySet ( ) ) { ModelSummary summary = entry . getValue ( ) ; all_referenced_frames . addAll ( summary . compatible_frames ) ; } Map < String , FrameSummary > frameSummaries = Frames . generateFrameSummaries ( all_referenced_frames , all_frames , false , null , null ) ; resultsMap . put ( "frames" , frameSummaries ) ; } // TODO: temporary hack to get things going String json = gson . toJson ( resultsMap ) ; JsonObject result = gson . fromJson ( json , JsonElement . class ) . getAsJsonObject ( ) ; return Response . done ( result ) ; }
Fetch all the Models from the KV store sumamrize and enhance them and return a map of them .