diff options
author | Harald Musum <musum@yahoo-inc.com> | 2018-02-21 23:43:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-21 23:43:02 +0100 |
commit | fdff142dab4a75ace0623c2c8bf513a0a4597aca (patch) | |
tree | 0101a275869dd270a1609d1199381e0137e5d1f6 /config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java | |
parent | 2238f0d8d3b8a07e5e9d0ce1a01fc7f3e149cece (diff) |
Revert "Bratseth/typecheck all 3"
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java')
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java b/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java index e7cd21ac834..762c0fec838 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java @@ -18,7 +18,6 @@ import com.yahoo.searchdefinition.parser.TokenMgrError; import com.yahoo.searchdefinition.processing.Processing; import com.yahoo.vespa.documentmodel.DocumentModel; import com.yahoo.vespa.model.container.search.QueryProfiles; -import com.yahoo.yolean.Exceptions; import java.io.File; import java.io.IOException; @@ -35,6 +34,7 @@ import java.util.List; * expressions, using the setRankXXX() methods, 3) invoke the {@link #build()} method, and 4) retrieve the built * search objects using the {@link #getSearch(String)} method. */ +// TODO: This should be cleaned up and more or maybe completely taken over by MockApplicationPackage public class SearchBuilder { private final DocumentTypeManager docTypeMgr = new DocumentTypeManager(); @@ -154,7 +154,7 @@ public class SearchBuilder { } catch (TokenMgrError e) { throw new ParseException("Unknown symbol: " + e.getMessage()); } catch (ParseException pe) { - throw new ParseException(stream.formatException(Exceptions.toMessageString(pe))); + throw new ParseException(stream.formatException(pe.getMessage())); } return importRawSearch(search); } @@ -196,7 +196,11 @@ public class SearchBuilder { * @throws IllegalStateException Thrown if this method has already been called. */ public void build() { - build(new BaseDeployLogger()); + build(new BaseDeployLogger(), new QueryProfiles()); + } + + public void build(DeployLogger logger) { + build(logger, new QueryProfiles()); } /** @@ -205,10 +209,12 @@ public class SearchBuilder { * * @throws IllegalStateException Thrown if this method has already been called. * @param deployLogger The logger to use during build + * @param queryProfiles The query profiles contained in the application this search is part of. */ - public void build(DeployLogger deployLogger) { - if (isBuilt) throw new IllegalStateException("Model already built"); - + public void build(DeployLogger deployLogger, QueryProfiles queryProfiles) { + if (isBuilt) { + throw new IllegalStateException("Searches already built."); + } List<Search> built = new ArrayList<>(); List<SDDocumentType> sdocs = new ArrayList<>(); sdocs.add(SDDocumentType.VESPA_DOCUMENT); @@ -234,7 +240,7 @@ public class SearchBuilder { for (Search search : new SearchOrderer().order(searchList)) { new FieldOperationApplierForSearch().process(search); // These two needed for a couple of old unit tests, ideally these are just read from app - process(search, deployLogger, new QueryProfiles(queryProfileRegistry)); + process(search, deployLogger, queryProfiles); built.add(search); } builder.addToModel(searchList); @@ -248,6 +254,8 @@ public class SearchBuilder { /** * Processes and returns the given {@link Search} object. This method has been factored out of the {@link * #build()} method so that subclasses can choose not to build anything. + * + * @param search The object to build. */ protected void process(Search search, DeployLogger deployLogger, QueryProfiles queryProfiles) { Processing.process(search, deployLogger, rankProfileRegistry, queryProfiles); @@ -344,7 +352,7 @@ public class SearchBuilder { rankProfileRegistry, queryprofileRegistry); builder.importFile(fileName); - builder.build(deployLogger); + builder.build(deployLogger, new QueryProfiles()); return builder; } @@ -360,7 +368,7 @@ public class SearchBuilder { for (Iterator<Path> i = Files.list(new File(dir).toPath()).filter(p -> p.getFileName().toString().endsWith(".sd")).iterator(); i.hasNext(); ) { builder.importFile(i.next()); } - builder.build(new BaseDeployLogger()); + builder.build(new BaseDeployLogger(), new QueryProfiles()); return builder; } |