use of com.odysseusinc.arachne.portal.api.v1.dto.converters.SolrFieldExtractor 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;
}
Aggregations