Search in sources :

Example 1 with FiltersPipeline

use of de.tblsoft.solr.pipeline.bean.FiltersPipeline in project solr-cmd-utils by tblsoft.

the class ForkDocumentFilter method readFiltersFromYamlFile.

protected FiltersPipeline readFiltersFromYamlFile(String fileName) {
    try {
        InputStream input = new FileInputStream(new File(fileName));
        Yaml yaml = new Yaml(new Constructor(FiltersPipeline.class));
        FiltersPipeline filters = (FiltersPipeline) yaml.load(input);
        input.close();
        return filters;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Constructor(org.yaml.snakeyaml.constructor.Constructor) FiltersPipeline(de.tblsoft.solr.pipeline.bean.FiltersPipeline) File(java.io.File) FileInputStream(java.io.FileInputStream) Yaml(org.yaml.snakeyaml.Yaml)

Example 2 with FiltersPipeline

use of de.tblsoft.solr.pipeline.bean.FiltersPipeline in project solr-cmd-utils by tblsoft.

the class ForkDocumentFilter method initPipelineFilters.

protected void initPipelineFilters() {
    String includeFilters = getProperty("include", null);
    String absoluteFile = IOUtils.getAbsoluteFile(getBaseDir(), includeFilters);
    FiltersPipeline filtersPipeline = readFiltersFromYamlFile(absoluteFile);
    // init
    FilterIF lastFilter = null;
    FilterIF filterInstance = null;
    try {
        for (int i = 0; i < filtersPipeline.getFilter().size(); i++) {
            Filter filter = filtersPipeline.getFilter().get(i);
            if (filter.getDisabled() != null && filter.getDisabled()) {
                continue;
            }
            filterInstance = PipelineExecuter.createFilterInstance(filter);
            filterInstance.setBaseDir(getBaseDir());
            filterInstance.setVariables(variables);
            if (lastFilter == null) {
                lastFilter = filterInstance;
                continue;
            }
            lastFilter.setNextFilter(filterInstance);
            filterList.add(lastFilter);
            lastFilter = filterInstance;
        }
        filterInstance.setNextFilter(new LastFilter());
        filterList.add(filterInstance);
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    filterList.get(0).init();
}
Also used : Filter(de.tblsoft.solr.pipeline.bean.Filter) AbstractFilter(de.tblsoft.solr.pipeline.AbstractFilter) FiltersPipeline(de.tblsoft.solr.pipeline.bean.FiltersPipeline) FilterIF(de.tblsoft.solr.pipeline.FilterIF)

Aggregations

FiltersPipeline (de.tblsoft.solr.pipeline.bean.FiltersPipeline)2 AbstractFilter (de.tblsoft.solr.pipeline.AbstractFilter)1 FilterIF (de.tblsoft.solr.pipeline.FilterIF)1 Filter (de.tblsoft.solr.pipeline.bean.Filter)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Yaml (org.yaml.snakeyaml.Yaml)1 Constructor (org.yaml.snakeyaml.constructor.Constructor)1