SOLR-6129: DateFormatTransformer doesn't resolve dateTimeFormat

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1603209 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2014-06-17 16:10:18 +00:00
parent 2fe64e65ac
commit 280c297c9c
3 changed files with 6 additions and 1 deletions

View File

@ -187,6 +187,8 @@ Bug Fixes
* SOLR-6175: DebugComponent throws NPE on shard exceptions when using shards.tolerant.
(Tomás Fernández Löbbe via shalin)
* SOLR-6129: DateFormatTransformer doesn't resolve dateTimeFormat. (Aaron LaBella via shalin)
Other Changes
---------------------

View File

@ -58,6 +58,8 @@ public class DateFormatTransformer extends Transformer {
String fmt = map.get(DATE_TIME_FMT);
if (fmt == null)
continue;
VariableResolver resolver = context.getVariableResolver();
fmt = resolver.replaceTokens(fmt);
String column = map.get(DataImporter.COLUMN);
String srcCol = map.get(RegexTransformer.SRC_COL_NAME);
if (srcCol == null)

View File

@ -38,7 +38,7 @@ public class TestDateFormatTransformer extends AbstractDataImportHandlerTestCase
fields.add(createMap(DataImporter.COLUMN, "lastModified"));
fields.add(createMap(DataImporter.COLUMN,
"dateAdded", RegexTransformer.SRC_COL_NAME, "lastModified",
DateFormatTransformer.DATE_TIME_FMT, "MM/dd/yyyy"));
DateFormatTransformer.DATE_TIME_FMT, "${xyz.myDateFormat}"));
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy", Locale.ROOT);
Date now = format.parse(format.format(new Date()));
@ -47,6 +47,7 @@ public class TestDateFormatTransformer extends AbstractDataImportHandlerTestCase
VariableResolver resolver = new VariableResolver();
resolver.addNamespace("e", row);
resolver.addNamespace("xyz", createMap("myDateFormat", "MM/dd/yyyy"));
Context context = getContext(null, resolver,
null, Context.FULL_DUMP, fields, null);