summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java
Publish
Diffstat (limited to 'config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java')
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java b/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java
new file mode 100644
index 00000000000..1fbd72599fe
--- /dev/null
+++ b/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java
@@ -0,0 +1,53 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.config.model.deploy;
+
+import com.yahoo.searchdefinition.SearchBuilder;
+import com.yahoo.vespa.documentmodel.DocumentModel;
+import com.yahoo.vespa.model.search.SearchDefinition;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Internal helper class to retrieve document model and search definitions.
+ *
+ * @author lulf
+ * @since 5.1
+ */
+public class SearchDocumentModel {
+
+ private final DocumentModel documentModel;
+ private final List<SearchDefinition> searchDefinitions;
+
+ public SearchDocumentModel(DocumentModel documentModel, List<SearchDefinition> searchDefinitions) {
+ this.documentModel = documentModel;
+ this.searchDefinitions = searchDefinitions;
+
+ }
+
+ public DocumentModel getDocumentModel() {
+ return documentModel;
+ }
+
+ public List<SearchDefinition> getSearchDefinitions() {
+ return searchDefinitions;
+ }
+
+ public static SearchDocumentModel fromBuilderAndNames(SearchBuilder builder, Map<String, String> names) {
+ List<SearchDefinition> ret = new ArrayList<>();
+ for (com.yahoo.searchdefinition.Search search : builder.getSearchList()) {
+ ret.add(new SearchDefinition(names.get(search.getName()), search));
+ }
+ return new SearchDocumentModel(builder.getModel(), ret);
+ }
+
+ public static SearchDocumentModel fromBuilder(SearchBuilder builder) {
+ List<SearchDefinition> ret = new ArrayList<>();
+ for (com.yahoo.searchdefinition.Search search : builder.getSearchList()) {
+ ret.add(new SearchDefinition(search.getName(), search));
+ }
+ return new SearchDocumentModel(builder.getModel(), ret);
+ }
+
+}