use of com.odysseusinc.arachne.portal.service.impl.solr.SolrField in project ArachneCentralAPI by OHDSI.
the class BaseSolrServiceImpl method getValuesByEntity.
@Override
public Map<T, Object> getValuesByEntity(final SolrEntity entity) {
final Map<T, Object> values = new HashMap<>();
final FieldList<T> fieldList = getFieldsOfClass(entity.getClass());
for (final T solrField : fieldList) {
final Object fieldValue;
final Field field = solrField.getField();
final SolrFieldExtractor extractor = solrField.getExtractor();
if (extractor != null) {
fieldValue = extractor.extract(entity);
} else if (field != null) {
field.setAccessible(true);
fieldValue = getFieldValue(entity, field);
} else {
throw new NullPointerException("FieldValue cannot be null");
}
values.put(solrField, fieldValue);
}
if (entity.getId() != null) {
final T idField = newSolrField(ID);
idField.setDataType(Long.class);
idField.setPostfixNeeded(false);
values.put(idField, entity.getId());
}
addBreadcrumbsIfNeeded(entity, values);
return values;
}
use of com.odysseusinc.arachne.portal.service.impl.solr.SolrField in project ArachneCentralAPI by OHDSI.
the class BaseSolrServiceImpl method getFieldsOfClass.
public FieldList<T> getFieldsOfClass(final Class<?> entity) {
final FieldList<T> result = new FieldList<>();
final List<Field> fields = getDeclaredFields(entity);
for (final Field field : fields) {
final T solrField = getSolrField(field);
if (solrField != null) {
result.add(solrField);
}
}
result.addAll(gatherClassSolrAnnotations(entity));
return result;
}
use of com.odysseusinc.arachne.portal.service.impl.solr.SolrField in project ArachneCentralAPI by OHDSI.
the class SearchDTOToSolrQuery method setSorting.
protected void setSorting(SearchDTO source, SolrQuery result, FieldList solrFields) {
if (source.getSort() != null && source.getOrder() != null) {
// Check if such field exists in Solr index and retrieve it
SolrField sortSolrSolrField = solrFields.getByName(source.getSort());
if (sortSolrSolrField != null) {
String sortFieldName = sortSolrSolrField.isMultiValuesType() ? sortSolrSolrField.getMultiValuesTypeFieldName() : sortSolrSolrField.getSolrName();
result.setSort(sortFieldName, SolrQuery.ORDER.valueOf(source.getOrder()));
}
}
}
use of com.odysseusinc.arachne.portal.service.impl.solr.SolrField in project ArachneCentralAPI by OHDSI.
the class SearchDTOToSolrQuery method setFilters.
protected void setFilters(SearchDTO source, SolrQuery result, FieldList solrFields) {
Map<String, Object> filterInput = source.getFilter();
if (filterInput != null) {
for (Map.Entry<String, Object> filterEntry : filterInput.entrySet()) {
String filterName = filterEntry.getKey();
Object filterValue = filterEntry.getValue();
SolrField solrField = solrFields.getByName(filterName);
if (solrField != null && solrField.getFaceted()) {
result.addFilterQuery(getExcludedTag(solrField.getSolrName()) + solrField.getSolrName() + ":" + filterValue);
}
}
}
}
Aggregations