@ Override @ Path ( "/{dataType}" ) public JSONObject get ( String path , Map < String , String > headers ) throws ServiceException , JSONException { String dataType = getSegment ( path , 1 ) ; if ( dataType == null ) throw new ServiceException ( "Missing path segment: {dataType}" ) ; try { BaselineData baselineData = DataAccess . getBaselineData ( ) ; if ( dataType . equals ( "VariableTypes" ) ) { List < VariableType > variableTypes = baselineData . getVariableTypes ( ) ; JSONArray jsonArray = new JSONArray ( ) ; for ( VariableType variableType : variableTypes ) jsonArray . put ( variableType . getJson ( ) ) ; return new JsonArray ( jsonArray ) . getJson ( ) ; } else if ( dataType . equals ( "TaskCategories" ) ) { List < TaskCategory > taskCats = new ArrayList < TaskCategory > ( ) ; taskCats . addAll ( baselineData . getTaskCategories ( ) . values ( ) ) ; Collections . sort ( taskCats ) ; JSONArray jsonArray = new JSONArray ( ) ; for ( TaskCategory taskCat : taskCats ) jsonArray . put ( taskCat . getJson ( ) ) ; return new JsonArray ( jsonArray ) . getJson ( ) ; } else { throw new ServiceException ( "Unsupported dataType: " + dataType ) ; } } catch ( Exception ex ) { throw new ServiceException ( ex . getMessage ( ) , ex ) ; } }
Retrieve variableTypes or taskCategories .