001/**
002 * Copyright 2016 Tampere University of Technology, Pori Department
003 * 
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * 
008 *   http://www.apache.org/licenses/LICENSE-2.0
009 * 
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package service.tut.pori.apilta.alerts.reference;
017
018import core.tut.pori.http.Response;
019import core.tut.pori.http.annotations.HTTPMethodParameter;
020import core.tut.pori.http.annotations.HTTPService;
021import core.tut.pori.http.annotations.HTTPServiceMethod;
022import core.tut.pori.http.parameters.DataGroups;
023import core.tut.pori.http.parameters.Limits;
024
025/**
026 * Generates example XML output
027 * 
028 */
029@HTTPService(name = Definitions.SERVICE_ALERTS_REFERENCE_EXAMPLE)
030public class ExampleService {
031  /**
032   * Generates example alert list
033   * 
034   * @param dataGroups 
035   * @param limits 
036   * @return alert list
037   * @see service.tut.pori.apilta.alerts.datatypes.AlertList
038   */
039  @HTTPServiceMethod(name = service.tut.pori.apilta.alerts.datatypes.Definitions.ELEMENT_ALERT_LIST)
040  public Response alertList(
041      @HTTPMethodParameter(name = DataGroups.PARAMETER_DEFAULT_NAME, required = false) DataGroups dataGroups,
042      @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits
043      ) 
044  {
045    Example example = new Example();
046    example.setAlertList(AlertsReferenceCore.generateAlertList(dataGroups, limits));
047    return new Response(example);
048  }
049  
050  /**
051   * Generates example alert
052   * 
053   * @param dataGroups 
054   * @return alert
055   * @see service.tut.pori.apilta.alerts.datatypes.Alert
056   */
057  @HTTPServiceMethod(name = service.tut.pori.apilta.alerts.datatypes.Definitions.ELEMENT_ALERT)
058  public Response alert(
059      @HTTPMethodParameter(name = DataGroups.PARAMETER_DEFAULT_NAME, required = false) DataGroups dataGroups
060      ) 
061  {
062    Example example = new Example();
063    example.setAlert(AlertsReferenceCore.generateAlert(dataGroups));
064    return new Response(example);
065  }
066}