Example usage for org.apache.solr.internal.csv CSVStrategy DEFAULT_STRATEGY

List of usage examples for org.apache.solr.internal.csv CSVStrategy DEFAULT_STRATEGY

Introduction

In this page you can find the example usage for org.apache.solr.internal.csv CSVStrategy DEFAULT_STRATEGY.

Prototype

CSVStrategy DEFAULT_STRATEGY

To view the source code for org.apache.solr.internal.csv CSVStrategy DEFAULT_STRATEGY.

Click Source Link

Usage

From source file:org.alfresco.solr.query.MimetypeGroupingQParserPlugin.java

License:Open Source License

private static synchronized void initMap(String mappingFile) {
    String solrHome = SolrResourceLoader.locateSolrHome().toString();
    File file = new File(solrHome, mappingFile);

    CSVParser parser;//from w w  w .j a  v a  2s .c  o  m
    try {
        parser = new CSVParser(new FileReader(file), CSVStrategy.DEFAULT_STRATEGY);
        // parse the fieldnames from the header of the file
        parser.getLine();

        // read the rest of the CSV file
        for (;;) {
            String[] vals = null;

            vals = parser.getLine();

            if (vals == null)
                break;

            mappings.put(vals[1], vals[2]);

            ArrayList<String> grouped = reverseMappings.get(vals[2]);
            if (grouped == null) {
                grouped = new ArrayList<>();
                reverseMappings.put(vals[2], grouped);
            }
            if (!grouped.contains(vals[1])) {
                grouped.add(vals[1]);
            }
        }
    } catch (FileNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
}