aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/docproc/DomDocprocChainBuilder.java
blob: d4393b2cd9e6c0c08bc941da69a3c33403f0278c (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.builder.xml.dom.chains.docproc;

import com.yahoo.collections.Pair;
import com.yahoo.component.chain.model.ChainSpecification;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.builder.xml.dom.chains.ComponentsBuilder;
import com.yahoo.vespa.model.builder.xml.dom.chains.DomChainBuilderBase;
import com.yahoo.vespa.model.container.docproc.DocprocChain;
import com.yahoo.vespa.model.container.docproc.DocumentProcessor;
import org.w3c.dom.Element;
import java.util.List;
import java.util.Map;

/**
 * Builds a docproc chain from xml
 *
 * @author gjoranv
 */
public class DomDocprocChainBuilder extends DomChainBuilderBase<DocumentProcessor, DocprocChain> {

    public DomDocprocChainBuilder(Map<String, ComponentsBuilder.ComponentType<?>> outerComponentTypeByComponentName) {
        super(List.of(ComponentsBuilder.ComponentType.documentprocessor), outerComponentTypeByComponentName);
    }

    @Override
    protected DocprocChain buildChain(DeployState deployState, AbstractConfigProducer<?> ancestor, Element producerSpec,
                                      ChainSpecification specWithoutInnerComponents) {
        Map<Pair<String, String>, String> fieldNameSchemaMap = DocumentProcessorModelBuilder.parseFieldNameSchemaMap(producerSpec);
        return new DocprocChain(specWithoutInnerComponents, fieldNameSchemaMap);
    }

}