package gw.solr.mapper uses gw.entity.TypeKey uses gw.solr.utils.PLSolrUtils uses gw.xsd.config.solr_search_config.DataProperty uses gw.xsd.config.solr_search_config.ResultField uses java.util.List @ReadOnly class Copy implements ISolrIndexMapper, ISolrQueryMapper, ISolrQueryResultMapper { /** * Map scalar value to a json encoded, but not quoted field. */ override function mapIndex(inputDataProperties : List, dataHolder : IDataHolder) : String { PLSolrUtils.validate(inputDataProperties.Count == 1, "Copy index mapper only supports a single target field.") var rawValue = dataHolder.lookup(inputDataProperties.get(0)) return rawValue typeis TypeKey ? rawValue.Code : rawValue != null ? rawValue as String : null } /** * Map query value to json encoded, but not quoted field. */ override function mapQuery(queryDataProperties : List, dataHolder : IDataHolder) : String { PLSolrUtils.validate(queryDataProperties.Count == 1, "Copy query mapper only supports a single criterion.") var rawValue = dataHolder.lookup(queryDataProperties.get(0)) return rawValue typeis TypeKey ? rawValue.Code : rawValue != null ? rawValue as String : "" } /** * Map single property column name to a single solr field name. */ override function mapSortColumn(resultFields : List, criteriaProperties : List, dataHolder : IDataHolder) : String { PLSolrUtils.validate(resultFields.Count == 1, "Copy sort column mapper only supports a single target field.") return resultFields.get(0).SortFieldName } /** * Map a scalar result from solr into a single field for the result row instance */ override function mapQueryResult(resultFields : List, criteriaProperties : List, dataHolder : IDataHolder, solrResult : IResultHolder) : Object { PLSolrUtils.validate(resultFields.Count == 1, "Copy query result mapper only supports a single target field.") var returnedValue = "" var elem = solrResult.lookup(resultFields.get(0)) if(elem != null) { if(!(elem typeis List)) { returnedValue = elem as String } else { PLSolrUtils.validate(false, "Copy mapper encountered multi-valued result for mapped field ${resultFields.get(0).Name}") } } return returnedValue } }