Examples of PipelineContext


Examples of org.geomajas.service.pipeline.PipelineContext

*/
public class PipelineContextTest {

  @Test
  public void testPutGet() throws Exception {
    PipelineContext context = new PipelineContextImpl();
    context.put("text", "SomeText");
    context.put("int", 17);
    context.put("list", new ArrayList<String>());

    Assert.assertNull(context.getOptional("unknown"));
    try {
      context.get("unknown");
      Assert.fail("should have thrown an exception");
    } catch (GeomajasException ge) {
      Assert.assertEquals(ExceptionCode.PIPELINE_CONTEXT_MISSING, ge.getExceptionCode());
    }
    Assert.assertEquals("SomeText", context.get("text"));
    Assert.assertEquals(17, context.get("int"));
    Assert.assertEquals(0, ((List<?>)context.get("list")).size());

    Assert.assertEquals("SomeText", context.get("text", String.class));
    Assert.assertEquals(17, (int)context.get("int", Integer.class));
    Assert.assertEquals(0, context.get("list", List.class).size());
    Assert.assertEquals(0, context.get("list", ArrayList.class).size());

    Assert.assertEquals("SomeText", context.put("text", "someOtherText"));
    Assert.assertEquals("someOtherText", context.get("text"));
  }
View Full Code Here

Examples of org.geomajas.service.pipeline.PipelineContext

    Assert.assertEquals("someOtherText", context.get("text"));
  }
 
  @Test
  public void testcontainsKey() throws Exception {
    PipelineContext context = new PipelineContextImpl();
    context.put("text", "SomeText");
    context.put("int", null);
    Assert.assertTrue(context.containsKey("text"));
    Assert.assertTrue(context.containsKey("int"));
    Assert.assertFalse(context.containsKey("other"));
  }
View Full Code Here

Examples of org.geomajas.service.pipeline.PipelineContext

  @Autowired
  private PipelineService<RasterizingContainer> pipelineService;

  public void writeMap(OutputStream stream, ClientMapInfo clientMapInfo) throws GeomajasException {
    PipelineContext context = pipelineService.createContext();
    DefaultMapContext mapContext = new DefaultMapContext();
    mapContext.setCoordinateReferenceSystem(geoService.getCrs2(clientMapInfo.getCrs()));
    MapRasterizingInfo mapInfo = (MapRasterizingInfo) clientMapInfo.getWidgetInfo(MapRasterizingInfo.WIDGET_KEY);
    mapContext.setAreaOfInterest(new ReferencedEnvelope(dtoConverterService.toInternal(mapInfo.getBounds()),
        mapContext.getCoordinateReferenceSystem()));
    RenderingHints renderingHints = new Hints();
    renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    RasterizingContainer response = new RasterizingContainer();
    context.put(RasterizingPipelineCode.CLIENT_MAP_INFO_KEY, clientMapInfo);
    context.put(RasterizingPipelineCode.RENDERING_HINTS, renderingHints);
    context.put(RasterizingPipelineCode.MAP_CONTEXT_KEY, mapContext);
    pipelineService.execute(RasterizingPipelineCode.PIPELINE_RASTERIZING_GET_MAP_IMAGE, null, context, response);
    mapContext.dispose();
    try {
      stream.write(response.getImage());
    } catch (IOException e) {
View Full Code Here

Examples of org.geomajas.service.pipeline.PipelineContext

      throw new RasterException(RasterException.IMAGE_WRITING_FAILED, e);
    }
  }

  public void writeLegend(OutputStream stream, ClientMapInfo clientMapInfo) throws GeomajasException {
    PipelineContext context = pipelineService.createContext();
    DefaultMapContext mapContext = new DefaultMapContext();
    mapContext.setCoordinateReferenceSystem(geoService.getCrs2(clientMapInfo.getCrs()));
    MapRasterizingInfo mapInfo = (MapRasterizingInfo) clientMapInfo.getWidgetInfo(MapRasterizingInfo.WIDGET_KEY);
    mapContext.setAreaOfInterest(new ReferencedEnvelope(dtoConverterService.toInternal(mapInfo.getBounds()),
        mapContext.getCoordinateReferenceSystem()));
    RenderingHints renderingHints = new Hints();
    renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    RasterizingContainer response = new RasterizingContainer();
    context.put(RasterizingPipelineCode.CLIENT_MAP_INFO_KEY, clientMapInfo);
    context.put(RasterizingPipelineCode.RENDERING_HINTS, renderingHints);
    context.put(RasterizingPipelineCode.MAP_CONTEXT_KEY, mapContext);
    pipelineService.execute(RasterizingPipelineCode.PIPELINE_RASTERIZING_GET_LEGEND_IMAGE, null, context, response);
    mapContext.dispose();
    try {
      stream.write(response.getImage());
    } catch (IOException e) {
View Full Code Here

Examples of org.geomajas.service.pipeline.PipelineContext

  @Test
  public void testRestoreSecurityContext() throws Exception {
    String key;
    StringContainer container;
    PipelineContext context;

    // set the stage

    login("luc");
    recorder.clear();
    context = pipelineService.createContext();
    context.put(PipelineCode.LAYER_ID_KEY, LAYER_ID);
    context.put(PipelineCode.FILTER_KEY, "blabla-luc");
    container = new StringContainer();
    pipelineService.execute(PIPELINE, LAYER_ID, context, container);
    Assert.assertEquals("blabla-luc", container.getString());
    org.junit.Assert.assertEquals("", recorder.matches(CacheCategory.BOUNDS,
        "Put item in cache"));
    key = context.get(SecurityTestInterceptor.CACHE_KEY, String.class);

    checkLuc();
    org.junit.Assert.assertEquals("", recorder.matches(CacheCategory.BOUNDS,
        "Put item in cache"));
    Assert.assertEquals("luc", securityContext.getUserId());

    login("marino");
    recorder.clear();
    context = pipelineService.createContext();
    context.put(PipelineCode.LAYER_ID_KEY, LAYER_ID);
    context.put(PipelineCode.FILTER_KEY, "blabla-marino");
    container = new StringContainer();
    pipelineService.execute(PIPELINE, LAYER_ID, context, container);
    Assert.assertEquals("blabla-marino", container.getString());
    org.junit.Assert.assertEquals("", recorder.matches(CacheCategory.BOUNDS,
        "Put item in cache"));

    checkMarino();
    org.junit.Assert.assertEquals("", recorder.matches(CacheCategory.BOUNDS,
        "Put item in cache"));

    // now try to get luc's stuff from the cache, restoring the security context

    recorder.clear();
    context = pipelineService.createContext();
    context.put(SecurityTestInterceptor.CACHE_KEY, key);
    context.put(PipelineCode.LAYER_ID_KEY, LAYER_ID);
    container = new StringContainer();
    pipelineService.execute(PIPELINE, LAYER_ID, context, container);
    Assert.assertEquals("blabla-luc", container.getString());
    org.junit.Assert.assertEquals("", recorder.matches(CacheCategory.BOUNDS,
        "Got item from cache"));
View Full Code Here

Examples of org.geomajas.service.pipeline.PipelineContext

  public List<RasterTile> getTiles(String layerId, CoordinateReferenceSystem crs, Envelope bounds, double scale)
      throws GeomajasException {
    log.debug("getTiles start on layer {}", layerId);
    long ts = System.currentTimeMillis();
    PipelineContext context = pipelineService.createContext();
    context.put(PipelineCode.LAYER_ID_KEY, layerId);
    RasterLayer layer = getRasterLayer(layerId);
    context.put(PipelineCode.LAYER_KEY, layer);
    context.put(PipelineCode.CRS_KEY, crs);
    context.put(PipelineCode.BOUNDS_KEY, bounds);
    context.put(PipelineCode.SCALE_KEY, scale);
    List<RasterTile> response = new ArrayList<RasterTile>();
    pipelineService.execute(PipelineCode.PIPELINE_GET_RASTER_TILES, layerId, context, response);
    log.debug("getTiles done on layer {}, time {}s", layerId, (System.currentTimeMillis() - ts) / 1000.0);
    return response;
  }
View Full Code Here

Examples of org.geomajas.service.pipeline.PipelineContext

  public void testGetCacheContextAndKey() throws Exception {
    String key1 = "key1";
    String key2 = "key2";
    String key3 = "key3";
    String key4 = "key4";
    PipelineContext pipelineContext = new PipelineContextImpl();
    pipelineContext.put(key1, key1);
    pipelineContext.put(key3, key3);
    GeometryFactory geometryFactory = new GeometryFactory();
    pipelineContext.put(key4, new GeometryCollection(new Geometry[] {}, geometryFactory));

    // a context
    CacheContext cacheContext1 = cacheKeyService.getCacheContext(pipelineContext, new String[] {key1, key2, key4});
    Assert.assertEquals(key1, cacheContext1.get(key1));
    Assert.assertNull(cacheContext1.get(key2));
View Full Code Here

Examples of org.geomajas.service.pipeline.PipelineContext

      RasterizingContainer rasterizeContainer = cacheManagerService.get(layer, CacheCategory.RASTER, key,
          RasterizingContainer.class);
      // if not in cache, try the rebuild cache and invoke the pipeline directly
      if (rasterizeContainer == null) {
        GetTileContainer tileContainer = new GetTileContainer();
        PipelineContext context = pipelineService.createContext();
        context.put(RasterizingPipelineCode.IMAGE_ID_KEY, key);
        context.put(PipelineCode.LAYER_ID_KEY, layerId);
        context.put(PipelineCode.LAYER_KEY, layer);

        // get data from rebuild cache
        RebuildCacheContainer rebuildCacheContainer = cacheManagerService.get(layer, CacheCategory.REBUILD, key,
            RebuildCacheContainer.class);
        if (null == rebuildCacheContainer) {
          log.error("Data to rebuild the raster image is no longer available for key " + key);
          response.sendError(HttpServletResponse.SC_NO_CONTENT);
          return;
        }
        recorder.record(CacheCategory.REBUILD, "Got rebuild info from cache");
        TileMetadata tileMetadata = rebuildCacheContainer.getMetadata();
        context.put(PipelineCode.TILE_METADATA_KEY, tileMetadata);
        Crs crs = geoService.getCrs2(tileMetadata.getCrs());
        context.put(PipelineCode.CRS_KEY, crs);
        CrsTransform layerToMap = geoService.getCrsTransform(layer.getCrs(), crs);
        context.put(PipelineCode.CRS_TRANSFORM_KEY, layerToMap);
        Envelope layerExtent = dtoConverterService.toInternal(layer.getLayerInfo().getMaxExtent());
        Envelope tileExtent = geoService.transform(layerExtent, layerToMap);
        context.put(PipelineCode.TILE_MAX_EXTENT_KEY, tileExtent);
        // can't stop here, we have only prepared the context, not built the tile !
        InternalTile tile = new InternalTileImpl(tileMetadata.getCode(), tileExtent, tileMetadata.getScale());
        tileContainer.setTile(tile);
        securityContextAdder.restoreSecurityContext(rebuildCacheContainer.getContext());

        pipelineService.execute(RasterizingPipelineCode.PIPELINE_GET_VECTOR_TILE_RASTERIZING, layerId, context,
            tileContainer);
        rasterizeContainer = context.get(RasterizingPipelineCode.CONTAINER_KEY, RasterizingContainer.class);
      } else {
        recorder.record(CacheCategory.RASTER, "Got item from cache");
      }
      // Prepare the response:
      CacheFilter.configureNoCaching(response);
View Full Code Here

Examples of org.geomajas.service.pipeline.PipelineContext

    log.debug("saveOrUpdate start on layer {}", layerId);
    long ts = System.currentTimeMillis();
    VectorLayer layer = getVectorLayer(layerId);
    CrsTransform mapToLayer = geoService.getCrsTransform(crs, layer.getCrs());
    CrsTransform layerToMap = geoService.getCrsTransform(layer.getCrs(), crs);
    PipelineContext context = pipelineService.createContext();
    context.put(PipelineCode.LAYER_ID_KEY, layerId);
    context.put(PipelineCode.LAYER_KEY, layer);
    context.put(PipelineCode.CRS_TRANSFORM_KEY, mapToLayer);
    context.put(PipelineCode.CRS_BACK_TRANSFORM_KEY, layerToMap);
    context.put(PipelineCode.OLD_FEATURES_KEY, oldFeatures);
    context.put(PipelineCode.NEW_FEATURES_KEY, newFeatures);
    context.put(PipelineCode.CRS_KEY, crs);
    pipelineService.execute(PipelineCode.PIPELINE_SAVE_OR_UPDATE, layerId, context, null);
    log.debug("saveOrUpdate done on layer {}, time {}s", layerId, (System.currentTimeMillis() - ts) / 1000.0);
  }
View Full Code Here

Examples of org.geomajas.service.pipeline.PipelineContext

    CrsTransform transformation = null;
    if ((featureIncludes & FEATURE_INCLUDE_GEOMETRY) != 0 && crs != null && !crs.equals(layer.getCrs())) {
      transformation = geoService.getCrsTransform(layer.getCrs(), crs);
    }
    GetFeaturesContainer container = new GetFeaturesContainer();
    PipelineContext context = pipelineService.createContext();
    context.put(PipelineCode.LAYER_ID_KEY, layerId);
    context.put(PipelineCode.LAYER_KEY, layer);
    context.put(PipelineCode.CRS_TRANSFORM_KEY, transformation);
    context.put(PipelineCode.CRS_KEY, crs);
    context.put(PipelineCode.FILTER_KEY, queryFilter);
    context.put(PipelineCode.STYLE_KEY, style);
    context.put(PipelineCode.FEATURE_INCLUDES_KEY, featureIncludes);
    context.put(PipelineCode.OFFSET_KEY, offset);
    context.put(PipelineCode.MAX_RESULT_SIZE_KEY, maxResultSize);
    pipelineService.execute(PipelineCode.PIPELINE_GET_FEATURES, layerId, context, container);
    log.debug("getFeatures done on layer {}, time {}s", layerId, (System.currentTimeMillis() - ts) / 1000.0);
    return container.getFeatures();
  }
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.