Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014, The OpenNMS Group
   * 
   * 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.opennms.newts.gsod;
 
 
 import static spark.Spark.get;
 import static spark.Spark.staticFileLocation;
 
 import java.util.Map;
 
 import spark.Request;
 import spark.Response;
 
 
 
 public class Web {
 
     private static final Map<StringStringSTATION_IDS = Maps.newHashMap();
     private static final Map<StringStringSTATION_NAMES = Maps.newTreeMap();
 
     static {
         .put("ksat""722530");         // San Antonio
         .put("kdal""722585");         // Dallas
         .put("kelp""722700");         // El Paso
         .put("kiah""722430");         // Houston
         .put("kaus""722545");         // Austin
         .put("klbb""722670");         // Lubbock
         
         .put("ksat""San Antonio");
         .put("kdal""Dallas");
         .put("kelp""El Paso");
         .put("kiah""Houston");
         .put("kaus""Austin");
         .put("klbb""Lubbock");
     }
 
     public static void main(String... args) {
 
         staticFileLocation("/static");
 
         get(new VelocityRoute("/stations") {
 
             @Override
             public Object handle(Request requestResponse response) {
                 Map<StringObjectmodel = Maps.newHashMap();
                 model.put("stationsMap");
                 return modelAndView(model"index.wm");
             }
         });
 
         get(new VelocityRoute("/summer88") {
 
             @Override
             public Object handle(Request arg0Response arg1) {
                 Map<StringObjectmodel = Maps.newHashMap();
                 model.put("stationIds");
                 return modelAndView(model"summer.wm");
             }
         });
 
         get(new VelocityRoute("/stations/:stationName") {
 
             @Override
             public Object handle(Request requestResponse response) {
 
                 String stationName = request.params(":stationName");
                 String id = .get(stationName);
 
                 if (id == null) {
                     halt(404, "No such station");
                 }
 
                 Map<StringStringmodel = Maps.newHashMap();
                 model.put("location".get(stationName));
                 model.put("id"id);
                 model.put("start"request.queryParams("start"));
                 model.put("end"request.queryParams("end"));
                 model.put("resolution"request.queryParams("resolution"));
 
                 return modelAndView(model"station.wm");
             }
         });
 
     }
New to GrepCode? Check out our FAQ X