SOLR-2444: Change Map<String,String> to SolrParams

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1133534 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan McKinley 2011-06-08 19:54:47 +00:00
parent 1d2d790bc3
commit 4f98807406
6 changed files with 15 additions and 22 deletions

View File

@ -16,11 +16,8 @@
*/
package org.apache.solr.response.transform;
import java.util.Map;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.request.SolrQueryRequest;
/**
@ -30,11 +27,7 @@ import org.apache.solr.request.SolrQueryRequest;
public class DocIdAugmenterFactory extends TransformerFactory
{
@Override
public DocTransformer create(String field, Map<String,String> args, SolrQueryRequest req) {
if( !args.isEmpty() ) {
throw new SolrException( ErrorCode.BAD_REQUEST,
"DocIdAugmenter does not take any arguments" );
}
public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) {
return new DocIdAugmenter( field );
}
}

View File

@ -17,12 +17,12 @@
package org.apache.solr.response.transform;
import java.io.IOException;
import java.util.Map;
import org.apache.lucene.search.Explanation;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.util.SolrPluginUtils;
@ -64,8 +64,8 @@ public class ExplainAugmenterFactory extends TransformerFactory
}
@Override
public DocTransformer create(String field, Map<String,String> args, SolrQueryRequest req) {
String s = args.get("style");
public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) {
String s = params.get("style");
Style style = (s==null)?defaultStyle:getStyle(s);
return new ExplainAugmenter( field, style );
}

View File

@ -16,9 +16,8 @@
*/
package org.apache.solr.response.transform;
import java.util.Map;
import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.request.SolrQueryRequest;
@ -29,7 +28,7 @@ import org.apache.solr.request.SolrQueryRequest;
public class ShardAugmenterFactory extends TransformerFactory
{
@Override
public DocTransformer create(String field, Map<String,String> args, SolrQueryRequest req) {
public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) {
String v = req.getParams().get(ShardParams.SHARD_URL);
if( v == null ) {
if( req.getParams().getBool(ShardParams.IS_SHARD, false) ) {

View File

@ -20,6 +20,7 @@ package org.apache.solr.response.transform;
import java.util.HashMap;
import java.util.Map;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.util.plugin.NamedListInitializedPlugin;
@ -37,7 +38,7 @@ public abstract class TransformerFactory implements NamedListInitializedPlugin
defaultUserArgs = (String)args.get( "args" );
}
public abstract DocTransformer create(String field, Map<String,String> args, SolrQueryRequest req);
public abstract DocTransformer create(String field, SolrParams params, SolrQueryRequest req);
public static final Map<String,TransformerFactory> defaultFactories = new HashMap<String,TransformerFactory>();
static {

View File

@ -16,11 +16,10 @@
*/
package org.apache.solr.response.transform;
import java.util.Map;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.DateUtil;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
@ -60,15 +59,15 @@ public class ValueAugmenterFactory extends TransformerFactory
}
@Override
public DocTransformer create(String field, Map<String,String> args, SolrQueryRequest req) {
public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) {
Object val = value;
if( val == null ) {
String v = args.get("v");
String v = params.get("v");
if( v == null ) {
val = defaultValue;
}
else {
val = getObjectFrom(v, args.get("t"));
val = getObjectFrom(v, params.get("t"));
}
if( val == null ) {
throw new SolrException( ErrorCode.BAD_REQUEST,

View File

@ -226,7 +226,8 @@ public class ReturnFields
TransformerFactory factory = req.getCore().getTransformerFactory( augmenterName );
if( factory != null ) {
augmenters.addTransformer( factory.create(disp, augmenterArgs, req) );
MapSolrParams augmenterParams = new MapSolrParams( augmenterArgs );
augmenters.addTransformer( factory.create(disp, augmenterParams, req) );
}
else {
// unknown transformer?