Examples of SimpleHash


Examples of freemarker.template.SimpleHash

     * @exception Exception, a generic exception.
     */
    public void doBuild( RunData data )
        throws Exception
    {
         SimpleHash context = getContext(data);

        // First, generate the screen and put it in the context so we
        // can grab it the layout template.
        ConcreteElement results = ScreenLoader.getInstance()
            .eval(data, data.getScreen());
        String screenValue = "";
        if (results != null)
        {
            screenValue = results.toString();
        }
        context.put("screen_placeholder", new SimpleScalar(screenValue));

        // Variable to reference the navigation templates in the
        // layout template.
        context.put("navigation", new NavigationModel(data));

        // Grab the layout template set in the WebMacroSitePage.  If
        // null, then use the default layout template ( done by the
        // TemplateInfo object ).
        String templateName = data.getTemplateInfo().getLayoutTemplate();
View Full Code Here

Examples of freemarker.template.SimpleHash

    protected SimpleHash getContext(RunData data)
    {
        // Attempt to get it from the TemplateInfo first.  If it
        // doesn't exist, create it and then stuff it into the
        // TemplateInfo.
        SimpleHash context = (SimpleHash)data.getTemplateInfo()
            .getTemplateContext(FreeMarkerService.CONTEXT);
        if (context == null)
        {
            FreeMarkerService fm = (FreeMarkerService)TurbineServices
                .getInstance().getService(FreeMarkerService.SERVICE_NAME);
View Full Code Here

Examples of freemarker.template.SimpleHash

     * @exception Exception, a generic exception.
     */
    public ConcreteElement buildTemplate(RunData data)
        throws Exception
    {
        SimpleHash context = getContext(data);
        String templateName = TurbineTemplate.getScreenTemplateName(
            data.getTemplateInfo().getScreenTemplate() );

        // Template service adds the leading slash, but make it sure.
        if ((templateName.length() > 0) &&
View Full Code Here

Examples of freemarker.template.SimpleHash

    }
   
    public void renderHead(IHeaderResponse response) {
        try {
            //render css
            SimpleHash model = new SimpleHash();
            model.put("markupId", getMarkupId());
            response.renderString( renderTemplate("OL-css.ftl", model) );
           
            //TODO: point back to GeoServer
            response.renderJavascriptReference("http://openlayers.org/api/OpenLayers.js")
           
            model.put("layers", layer.getName());
            model.put("styles", style.getName());
           
            bbox(layer, model);
           
            //render
            model.put("ran", rand.nextInt());
            response.renderOnLoadJavascript(renderTemplate("OL-onload.ftl", model));
        }
        catch( Exception e ) {
            throw new RuntimeException(e);
        }
View Full Code Here

Examples of freemarker.template.SimpleHash

                //no style specified and layer did not change, do not change style
            }
        }
       
        try {
            SimpleHash model = new SimpleHash();
            model.put("markupId", getMarkupId());
            model.put("layers", layer.getName());
            model.put("styles", style.getName());
            bbox(layer, model);
            model.put("ran", rand.nextInt());
            model.put("layerChanged", !layer.equals(this.layer));
           
            target.appendJavascript(renderTemplate("OL-update.ftl", model));
           
            this.layer = layer;
            this.style = style;
View Full Code Here

Examples of freemarker.template.SimpleHash

    LayerAboutPage lap = new LayerAboutPage();
    lap.setCatalog((Catalog) GeoServerExtensions.bean("catalog"));
   
    Request request = new Request(new Method("GET"), "http://example.org/geoserver/rest/topp/states.html");
   
    SimpleHash context;
   
    //test if it fails the right way with bogus namespace
    boolean hadRestletException = false;
    try{
      context = lap.getContext("badNamespace","badType",request);
    } catch(RestletException e){
      hadRestletException = true;
    }
    assertTrue("getContext did not fail with RestletException when given bogus namespace and type",hadRestletException);
   
    RestletException re = null;
    try{
      context = lap.getContext("sf", "badType", request);
    } catch(RestletException e){
      re = e;
    }
    assertNotNull("getContext should fail when given bogus namespace but good type", re);
        assertEquals("the error code should be a 404", Status.CLIENT_ERROR_NOT_FOUND, re.getStatus());
   

        getFeatureTypeInfo(MockData.GENERICENTITY).getMetadata().put("indexingEnabled", true);
    context = lap.getContext("sf", "GenericEntity", request);   

    assertEquals("Unexpected value for 'name' in context", ((SimpleScalar) context.get("name")).getAsString(), "sf:GenericEntity");
    assertEquals("Unexpected value for 'title' in context", ((SimpleScalar) context.get("title")).getAsString(), "GenericEntity");   
    assertEquals("Unexpected value for 'abstract' in context", ((SimpleScalar) context.get("abstract")).getAsString(), "abstract about GenericEntity");
   
    //keywords
    assertEquals("Value of 'keywords' in context is not the right size", ((SimpleSequence) context.get("keywords")).size(),1);
    assertEquals("Unexpected value of first template model in 'keywords' of context", ((SimpleScalar) ((SimpleSequence) context.get("keywords")).get(0)).getAsString(), "GenericEntity");
   
    //width and height
    assertEquals("Unexpected value for 'width' in context", ((SimpleNumber) context.get("width")).getAsNumber(), 800);
    assertEquals("Unexpected value for 'height' in context", ((SimpleNumber) context.get("height")).getAsNumber(), 375);
   
    assertEquals("Unexpected value for 'srs' in context", ((SimpleScalar) context.get("srs")).getAsString(), "EPSG:4326")
    assertEquals("Unexpected value for 'bbox' in context", ((SimpleScalar) context.get("bbox")).getAsString(), "-198.0,-99.0,198.0,99.0");     
    assertEquals("Unexpected value for 'maxResolution' in context", ((SimpleNumber) context.get("maxResolution")).getAsNumber(), 1.546875);
  }
View Full Code Here

Examples of freemarker.template.SimpleHash

                    "Layer indexing disabled",
                    Status.CLIENT_ERROR_FORBIDDEN
                    );
        }
     
      SimpleHash map = new SimpleHash();
     
      //basic
      map.put("title", info.getTitle());
      map.put("abstract", info.getAbstract());
     
      //Metadata
      map.put("keywords", info.getKeywords());
    map.put("declaredCRS", info.getCRS());       
    map.put("metadataLinks", info.getMetadataLinks());
    try {
            Object o = info.getNativeCRS();
            if (o != null) {
                map.put("nativeCRS", info.getNativeCRS());
            } else {
                map.put("nativeCRS", "No native CRS configured for layer");
            }
    } catch (Exception e) {
            LOGGER.log(Level.WARNING,
                    "Error trying to get nativeCRS from "
                    + info.getName()
                    + "FeatureTypeInfo",
                    e
                    );
    }

    String baseUrl = RESTUtils.getBaseURL(request);
    map.put("base", baseUrl);         
   
    //general parameters for data requests
      map.put("name", info.getPrefixedName());
      map.put("srs", info.getSRS());
     
      ReferencedEnvelope bbox = getBBOX(info);
     
      String bboxString = bbox.getMinX() + "," + bbox.getMinY() + "," + bbox.getMaxX() + ","
        + bbox.getMaxY();     
      map.put("bbox", bboxString);
     
      map.put("tilesOrigin", bbox.getMinX()+","+bbox.getMinY());     
     
      int[] imageBox = getMapWidthHeight(bbox);
        map.put("width", imageBox[0]);
        map.put("height", imageBox[1]);
     
        map.put("maxResolution", getMaxResolution(bbox));
       
      try{         
          map.put("boundingBox", info.boundingBox());
          map.put("lonLatBoundingBox", info.getLatLonBoundingBox());
      } catch(Exception e) {
            LOGGER.log(Level.WARNING, "Error trying to access bounding box or lonLatBoundingBox for " + info.getName() + "FeatureTypeInfo", e);
     
     
      //Fields of Access
      map.put("gwc", isGWCAround() + "");
     
      String gwcLink = baseUrl.substring(0,baseUrl.length()-4) + "gwc/";
      map.put("gwcLink", gwcLink);
     
      map.put("attributes", info.getAttributes());
     
      return map;
    }
View Full Code Here

Examples of freemarker.template.SimpleHash

        final ObjectWrapper wrapper = configuration.getObjectWrapper();
        configuration.setObjectWrapper(new ObjectWrapper() {
            public TemplateModel wrap(Object obj) throws TemplateModelException {
                TemplateModel model = wrapper.wrap(obj);
                if ( model instanceof SimpleHash ) {
                    SimpleHash hash = (SimpleHash) model;
                    if ( hash.get( "page" ) == null ) {
                        PageInfo pageInfo = (PageInfo) request.getAttributes().get( PageInfo.KEY );
                        if ( pageInfo != null ) {
                            hash.put( "page", pageInfo );   
                        }
                    }
                }
                return model;
            }
View Full Code Here

Examples of freemarker.template.SimpleHash

            if ( object instanceof Collection ) {
                Collection c = (Collection) object;
                if (!c.isEmpty() ) {
                    Object o = c.iterator().next();
                    if ( clazz.isAssignableFrom( o.getClass() ) ) {
                        SimpleHash hash = new SimpleHash();
                        hash.put( "values", new CollectionModel( c, this ) );
                        return hash;
                    }   
                }
            }
           
            if ( object != null && clazz.isAssignableFrom( object.getClass() ) ) {
                HashMap map = new HashMap();
               
                ClassProperties cp = OwsUtils.getClassProperties(clazz);
                for ( String p : cp.properties() ) {
                    if ( "Class".equals( p ) ) continue;
                    Object value = OwsUtils.get(object, p);
                    if ( value == null ) {
                        value = "null";
                    }
                   
                    map.put( Character.toLowerCase(p.charAt(0)) + p.substring(1), value.toString());   
                   
                }
          
                SimpleHash model = new SimpleHash();
                model.put( "properties", new MapModel(map, this) );
                model.put( "className", clazz.getSimpleName() );
               
                wrapInternal(map, model, (T) object);
                return model;
            }
           
View Full Code Here

Examples of freemarker.template.SimpleHash

        if (object instanceof FeatureDiffReader[]) {
            HashMap map = new HashMap();
            map.put("queryDiffs",
                new SimpleSequence(Arrays.asList((FeatureDiffReader[]) object), this));

            return new SimpleHash(map);
        } else if (object instanceof FeatureDiffReader) {
            HashMap map = new HashMap();
            FeatureDiffReader reader = (FeatureDiffReader) object;
            map.put("differences", new CollectionModel(new FeatureDiffCollection(reader), this));
            map.put("fromVersion", reader.getFromVersion());
            map.put("toVersion", reader.getToVersion());
            map.put("typeName", reader.getSchema().getTypeName());

            return new SimpleHash(map);
        }

        return super.wrap(object);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.