protected String evaluateMapping( ParameterMappingContext mappingContext, ParameterMapping mapping) { String value; if (mapping instanceof ParameterMappingDefaultValue) { value = ((ParameterMappingDefaultValue) mapping).getDefaultValue(); } else if (mapping instanceof ParameterMappingExpressionValue) { value = ((ParameterMappingExpressionValue) mapping).evaluate(mappingContext); } else if (mapping instanceof ParameterMappingBlockValue) { value = null; } else { throw new IllegalArgumentException( "Unknown StoredQueryParameterMapping: " + mapping.getClass()); } return value; } }
public ParameterMappingDefaultValue(String name, boolean forcible, String defaultValue) { setParameterName(name); setForcible(forcible); setDefaultValue(defaultValue); }
mockConfiguration.getStoredQueryParameterMappings().add(param1); ParameterMappingDefaultValue param2 = new ParameterMappingDefaultValue(); param2.setParameterName("timestep"); param2.setDefaultValue("720"); mockConfiguration.getStoredQueryParameterMappings().add(param2);
} else if (mapping instanceof ParameterMappingDefaultValue) { ParameterMappingDefaultValue pmdv = (ParameterMappingDefaultValue) mapping; if (pmdv.isForcible()) { type = ParameterMappingType.STATIC; } else { type = ParameterMappingType.DEFAULT; value = pmdv.getDefaultValue(); } else if (mapping instanceof ParameterMappingExpressionValue) { ParameterMappingExpressionValue pmev = (ParameterMappingExpressionValue) mapping;
(ParameterMappingDefaultValue) configuration.getStoredQueryParameterMappings().get(1); assertEquals("timestep", map2.getParameterName()); assertEquals("720", map2.getDefaultValue());
static StoredQueryConfiguration createStoredQueryConfiguration( List<StoredQueryParameterAttribute> items, String storedQueryId) { StoredQueryConfiguration ret = new StoredQueryConfiguration(); ret.setStoredQueryId(storedQueryId); for (StoredQueryParameterAttribute i : items) { ParameterMapping mapping; String name = i.getParameterName(); switch (i.getMappingType()) { case BLOCKED: mapping = new ParameterMappingBlockValue(name); break; case DEFAULT: mapping = new ParameterMappingDefaultValue(name, false, i.getValue()); break; case STATIC: mapping = new ParameterMappingDefaultValue(name, true, i.getValue()); break; case EXPRESSION_CQL: mapping = new ParameterMappingExpressionValue(name, "CQL", i.getValue()); break; case NONE: default: mapping = null; } if (mapping != null) { ret.getStoredQueryParameterMappings().add(mapping); } } return ret; }
public ParameterMappingDefaultValue(String name, boolean forcible, String defaultValue) { setParameterName(name); setForcible(forcible); setDefaultValue(defaultValue); }
protected String evaluateMapping( ParameterMappingContext mappingContext, ParameterMapping mapping) { String value; if (mapping instanceof ParameterMappingDefaultValue) { value = ((ParameterMappingDefaultValue) mapping).getDefaultValue(); } else if (mapping instanceof ParameterMappingExpressionValue) { value = ((ParameterMappingExpressionValue) mapping).evaluate(mappingContext); } else if (mapping instanceof ParameterMappingBlockValue) { value = null; } else { throw new IllegalArgumentException( "Unknown StoredQueryParameterMapping: " + mapping.getClass()); } return value; } }