blob: cf9d46ae985c7d2f19b6c49b46e29a66f3f76ada (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.derived;
import com.yahoo.document.config.DocumenttypesConfig;
import com.yahoo.document.config.DocumentmanagerConfig;
import com.yahoo.searchdefinition.ApplicationBuilder;
import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.vespa.configmodel.producers.DocumentManager;
import com.yahoo.vespa.configmodel.producers.DocumentTypes;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
/**
* Facade for deriving configs from schemas
*
* @author bratseth
*/
public class Deriver {
public static ApplicationBuilder getSchemaBuilder(List<String> schemas) {
ApplicationBuilder builder = new ApplicationBuilder();
try {
for (String schema : schemas)
builder.add(schema);
} catch (ParseException | IOException e) {
throw new IllegalArgumentException(e);
}
builder.build();
return builder;
}
public static DocumentmanagerConfig.Builder getDocumentManagerConfig(String sd) {
return getDocumentManagerConfig(Collections.singletonList(sd));
}
public static DocumentmanagerConfig.Builder getDocumentManagerConfig(List<String> schemas) {
return new DocumentManager().produce(getSchemaBuilder(schemas).getModel(), new DocumentmanagerConfig.Builder());
}
public static DocumentmanagerConfig.Builder getDocumentManagerConfig(List<String> schemas, boolean useV8DocManagerCfg) {
return new DocumentManager()
.useV8DocManagerCfg(useV8DocManagerCfg)
.produce(getSchemaBuilder(schemas).getModel(), new DocumentmanagerConfig.Builder());
}
public static DocumenttypesConfig.Builder getDocumentTypesConfig(String schema) {
return getDocumentTypesConfig(Collections.singletonList(schema));
}
public static DocumenttypesConfig.Builder getDocumentTypesConfig(List<String> schemas) {
return new DocumentTypes().produce(getSchemaBuilder(schemas).getModel(), new DocumenttypesConfig.Builder());
}
}
|