/*
 * Copyright 2016 SEARCH-The National Consortium for Justice Information and Statistics
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.search.nibrs.report.service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tomcat.util.buf.StringUtils;
import org.search.nibrs.model.reports.ReturnAForm;
import org.search.nibrs.report.AppProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class StagingDataRestClient {

	private static final Log log = LogFactory.getLog(StagingDataRestClient.class);

	private RestTemplate restTemplate;
	@Autowired
	private AppProperties appProperties;

	public StagingDataRestClient() {
		super();
		restTemplate = new RestTemplate(); 
		restTemplate.setMessageConverters(getMessageConverters());
	}
	
	public ReturnAForm getReturnAForm(String ori, String year, String month) {
		List<String> urlParts = Arrays.asList(appProperties.getStagingDataRestServiceBaseUrl(), 
				"returnAForm/", ori, year, month); 
		String url = StringUtils.join(urlParts, '/');
		log.info("Getting the ReturnAForm object from the url " + url);

		ReturnAForm returnAForm = restTemplate.getForObject( url, ReturnAForm.class);
		log.info("returnAForm: " + returnAForm);
		return returnAForm;
	}

	private List<HttpMessageConverter<?>> getMessageConverters() {
	    List<HttpMessageConverter<?>> converters = 
	      new ArrayList<HttpMessageConverter<?>>();
	    converters.add(new MappingJackson2HttpMessageConverter());
	    return converters;
	}
}

@@ -947,16 +947,68 @@
 nAForm;%0A
+import org.search.nibrs.model.reports.asr.AsrAdult;%0A
 import o
@@ -2191,16 +2191,462 @@
 rm;%0A%09%7D%0A%0A
+%09public AsrAdult getAsrAdult(String ori, String year, String month) %7B%0A%09%09List%3CString%3E urlParts = Arrays.asList(appProperties.getStagingDataRestServiceBaseUrl(), %0A%09%09%09%09%22asrAdult%22, ori, year, month); %0A%09%09String url = StringUtils.join(urlParts, '/');%0A%09%09log.info(%22Getting the ReturnAForm object from the url %22 + url);%0A%09%09%0A%09%09AsrAdult asrAdult = restTemplate.getForObject( url, AsrAdult.class);%0A%09%09log.info(%22asrAdult: %22 + asrAdult);%0A%09%09return asrAdult;%0A%09%7D%0A%09%0A
 %09private

Add a rest method to return AsrAdult.