Search in sources :

Example 1 with DocumentManager

use of com.yahoo.vespa.configmodel.producers.DocumentManager in project vespa by vespa-engine.

the class InheritanceTestCase method requireThatStructTypesAreInheritedThroughDiamond.

@Test
public void requireThatStructTypesAreInheritedThroughDiamond() throws IOException, ParseException {
    String dir = "src/test/derived/inheritdiamond/";
    List<String> files = Arrays.asList("grandparent.sd", "mother.sd", "father.sd", "child.sd");
    File outDir = tmpDir.newFolder("out");
    for (int startIdx = 0; startIdx < files.size(); ++startIdx) {
        SearchBuilder builder = new SearchBuilder();
        for (int fileIdx = startIdx; fileIdx < startIdx + files.size(); ++fileIdx) {
            String fileName = files.get(fileIdx % files.size());
            builder.importFile(dir + fileName);
        }
        builder.build();
        DocumentmanagerConfig.Builder b = new DocumentmanagerConfig.Builder();
        DerivedConfiguration.exportDocuments(new DocumentManager().produce(builder.getModel(), b), outDir.getPath());
        DocumentmanagerConfig dc = new DocumentmanagerConfig(b);
        assertEquals(17, dc.datatype().size());
        assertNotNull(structType("child.body", dc));
        DocumentmanagerConfig.Datatype.Structtype childHeader = structType("child.header", dc);
        assertEquals(childHeader.field(0).name(), "foo");
        assertEquals(childHeader.field(1).name(), "bar");
        assertEquals(childHeader.field(2).name(), "baz");
        assertEquals(childHeader.field(3).name(), "cox");
        DocumentmanagerConfig.Datatype.Documenttype child = documentType("child", dc);
        assertEquals(child.inherits(0).name(), "document");
        assertEquals(child.inherits(1).name(), "father");
        assertEquals(child.inherits(2).name(), "mother");
        DocumentmanagerConfig.Datatype.Documenttype mother = documentType("mother", dc);
        assertEquals(mother.inherits(0).name(), "grandparent");
        assertEquals(mother.inherits(1).name(), "document");
    }
}
Also used : DocumentmanagerConfig(com.yahoo.document.config.DocumentmanagerConfig) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) DocumentManager(com.yahoo.vespa.configmodel.producers.DocumentManager) File(java.io.File) Test(org.junit.Test)

Example 2 with DocumentManager

use of com.yahoo.vespa.configmodel.producers.DocumentManager in project vespa by vespa-engine.

the class Deriver method deriveDocuments.

/**
 * Derives only document manager.
 *
 * @param sdFileNames The name of the search definition files to derive from.
 * @param toDir       The directory to write configuration to.
 * @return The list of Search objects, possibly "unproper ones", from sd files containing only document
 */
public static SearchBuilder deriveDocuments(List<String> sdFileNames, String toDir) {
    SearchBuilder builder = getUnprocessingSearchBuilder(sdFileNames);
    DocumentmanagerConfig.Builder documentManagerCfg = new DocumentManager().produce(builder.getModel(), new DocumentmanagerConfig.Builder());
    try {
        DerivedConfiguration.exportDocuments(documentManagerCfg, toDir);
    } catch (IOException e) {
        throw new IllegalArgumentException(e);
    }
    return builder;
}
Also used : DocumentmanagerConfig(com.yahoo.document.config.DocumentmanagerConfig) UnprocessingSearchBuilder(com.yahoo.searchdefinition.UnprocessingSearchBuilder) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) DocumentManager(com.yahoo.vespa.configmodel.producers.DocumentManager) IOException(java.io.IOException)

Example 3 with DocumentManager

use of com.yahoo.vespa.configmodel.producers.DocumentManager in project vespa by vespa-engine.

the class DocumentModelBuilderTestCase method testDocumentManagerSimple.

@Test
public void testDocumentManagerSimple() throws IOException, ParseException {
    DocumentModel model = createAndTestModel("src/test/configmodel/types/types.sd");
    DocumentmanagerConfig.Builder documentmanagerCfg = new DocumentManager().produce(model, new DocumentmanagerConfig.Builder());
    assertConfigFile("src/test/configmodel/types/documentmanager.cfg", new DocumentmanagerConfig(documentmanagerCfg).toString());
}
Also used : DocumentmanagerConfig(com.yahoo.document.config.DocumentmanagerConfig) DocumentManager(com.yahoo.vespa.configmodel.producers.DocumentManager) Test(org.junit.Test)

Example 4 with DocumentManager

use of com.yahoo.vespa.configmodel.producers.DocumentManager in project vespa by vespa-engine.

the class DocumentModelBuilderReferenceTypeTestCase method assertDocumentmanagerCfg.

private void assertDocumentmanagerCfg(DocumentModel model, String documentmanagerCfgFile) throws IOException {
    DocumentmanagerConfig.Builder documentmanagerCfg = new DocumentManager().produce(model, new DocumentmanagerConfig.Builder());
    assertConfigFile(TEST_FOLDER + documentmanagerCfgFile, new DocumentmanagerConfig(documentmanagerCfg).toString());
}
Also used : DocumentmanagerConfig(com.yahoo.document.config.DocumentmanagerConfig) DocumentManager(com.yahoo.vespa.configmodel.producers.DocumentManager)

Aggregations

DocumentmanagerConfig (com.yahoo.document.config.DocumentmanagerConfig)4 DocumentManager (com.yahoo.vespa.configmodel.producers.DocumentManager)4 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)2 Test (org.junit.Test)2 UnprocessingSearchBuilder (com.yahoo.searchdefinition.UnprocessingSearchBuilder)1 File (java.io.File)1 IOException (java.io.IOException)1