<commit_before>/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2011 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the GNU Affero
 * General Public License. All contributions in this program are covered
 * by the Geomajas Contributors License Agreement. For full licensing
 * details, see LICENSE.txt in the project root.
 */

package org.geomajas.plugin.rasterizing.step;

import org.geomajas.geometry.Coordinate;
import org.geomajas.global.GeomajasException;
import org.geomajas.layer.pipeline.GetTileContainer;
import org.geomajas.layer.tile.InternalTile;
import org.geomajas.layer.tile.TileMetadata;
import org.geomajas.plugin.caching.service.CacheCategory;
import org.geomajas.plugin.caching.step.AbstractSecurityContextCachingInterceptor;
import org.geomajas.plugin.caching.step.CacheStepConstant;
import org.geomajas.plugin.caching.step.TileCacheContainer;
import org.geomajas.plugin.rasterizing.api.RasterizingContainer;
import org.geomajas.plugin.rasterizing.api.RasterizingPipelineCode;
import org.geomajas.service.TestRecorder;
import org.geomajas.service.pipeline.PipelineCode;
import org.geomajas.service.pipeline.PipelineContext;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Rasterizing version of {@link org.geomajas.plugin.caching.step.GetTileCachingInterceptor} which also stores the
 * raster in the cache.
 * 
 * @author <NAME>
 * @author <NAME>
 */
public class GetRasterizedTileAllCachingInterceptor extends 
	AbstractSecurityContextCachingInterceptor<GetTileContainer> {

	@Autowired
	private TestRecorder recorder;

	private static final String[] KEYS = { PipelineCode.LAYER_ID_KEY, PipelineCode.TILE_METADATA_KEY,
			PipelineCode.FEATURE_INCLUDES_KEY };

	public ExecutionMode beforeSteps(PipelineContext context, GetTileContainer response) throws GeomajasException {
		clearPanOrigin(context);
		TileCacheContainer cc = getContainer(CacheStepConstant.CACHE_TILE_KEY, CacheStepConstant.CACHE_TILE_CONTEXT,
				KEYS, CacheCategory.TILE, context, TileCacheContainer.class);
		if (cc != null) {
			recorder.record(CacheCategory.TILE, "Got item from cache");
			response.getTile().setFeatures(cc.getTile().getFeatures());
			response.getTile().setFeatureContent(cc.getTile().getFeatureContent());
			response.getTile().setContentType(cc.getTile().getContentType());
			return ExecutionMode.EXECUTE_NONE;
		}
		return ExecutionMode.EXECUTE_ALL;
	}

	public void afterSteps(PipelineContext context, GetTileContainer response) throws GeomajasException {<commit_msg>GBE-161 fix, no FEATURE-INCLUDES key any more...<commit_after>/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2011 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the GNU Affero
 * General Public License. All contributions in this program are covered
 * by the Geomajas Contributors License Agreement. For full licensing
 * details, see LICENSE.txt in the project root.
 */

package org.geomajas.plugin.rasterizing.step;

import org.geomajas.geometry.Coordinate;
import org.geomajas.global.GeomajasException;
import org.geomajas.layer.pipeline.GetTileContainer;
import org.geomajas.layer.tile.InternalTile;
import org.geomajas.layer.tile.TileMetadata;
import org.geomajas.plugin.caching.service.CacheCategory;
import org.geomajas.plugin.caching.step.AbstractSecurityContextCachingInterceptor;
import org.geomajas.plugin.caching.step.CacheStepConstant;
import org.geomajas.plugin.caching.step.TileCacheContainer;
import org.geomajas.plugin.rasterizing.api.RasterizingContainer;
import org.geomajas.plugin.rasterizing.api.RasterizingPipelineCode;
import org.geomajas.service.TestRecorder;
import org.geomajas.service.pipeline.PipelineCode;
import org.geomajas.service.pipeline.PipelineContext;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Rasterizing version of {@link org.geomajas.plugin.caching.step.GetTileCachingInterceptor} which also stores the
 * raster in the cache.
 * 
 * @author <NAME>
 * @author <NAME>
 */
public class GetRasterizedTileAllCachingInterceptor extends 
	AbstractSecurityContextCachingInterceptor<GetTileContainer> {

	@Autowired
	private TestRecorder recorder;

	private static final String[] KEYS = { PipelineCode.LAYER_ID_KEY, PipelineCode.TILE_METADATA_KEY};

	public ExecutionMode beforeSteps(PipelineContext context, GetTileContainer response) throws GeomajasException {
		clearPanOrigin(context);
		TileCacheContainer cc = getContainer(CacheStepConstant.CACHE_TILE_KEY, CacheStepConstant.CACHE_TILE_CONTEXT,
				KEYS, CacheCategory.TILE, context, TileCacheContainer.class);
		if (cc != null) {
			recorder.record(CacheCategory.TILE, "Got item from cache");
			response.getTile().setFeatures(cc.getTile().getFeatures());
			response.getTile().setFeatureContent(cc.getTile().getFeatureContent());
			response.getTile().setContentType(cc.getTile().getContentType());
			return ExecutionMode.EXECUTE_NONE;
		}
		return ExecutionMode.EXECUTE_ALL;
	}

	public void afterSteps(PipelineContext context, GetTileContainer response) throws GeomajasException {
{'fraction_non_alphanumeric': 0.09487375669472073, 'fraction_numerical': 0.0036342769701606732, 'mean_word_length': 6.066216216216216, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6726941', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1556, 'n_words': 325}