Example usage for org.apache.solr.client.solrj.beans BindingException BindingException

List of usage examples for org.apache.solr.client.solrj.beans BindingException BindingException

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.beans BindingException BindingException.

Prototype

public BindingException(String message) 

Source Link

Usage

From source file:edu.vt.vbi.patric.common.DocumentMapBinder.java

License:Apache License

public SolrInputDocument toSolrInputDocument(Object obj) {
    List<DocField> fields = getDocFields(obj.getClass());
    if (fields.isEmpty()) {
        throw new BindingException("class: " + obj.getClass() + " does not define any fields.");
    }//from   w w  w  .j  a va  2s .c  o m

    SolrInputDocument doc = new SolrInputDocument();
    for (DocField field : fields) {
        if (field.dynamicFieldNamePatternMatcher != null && field.get(obj) != null && field.isContainedInMap) {
            Map<String, Object> mapValue = (Map<String, Object>) field.get(obj);

            for (Map.Entry<String, Object> e : mapValue.entrySet()) {
                doc.setField(e.getKey(), e.getValue(), 1.0f);
            }
        } else {
            doc.setField(field.name, field.get(obj), 1.0f);
        }
    }
    return doc;
}