Search in sources :

Example 1 with ConceptElementId

use of com.bakdata.conquery.models.identifiable.ids.specific.ConceptElementId in project conquery by bakdata.

the class ConceptsProcessor method resolveConceptElements.

public ResolvedConceptsResult resolveConceptElements(TreeConcept concept, List<String> conceptCodes) {
    List<ConceptElementId<?>> resolvedCodes = new ArrayList<>();
    List<String> unknownCodes = new ArrayList<>();
    if (concept == null) {
        return new ResolvedConceptsResult(null, null, conceptCodes);
    }
    for (String conceptCode : conceptCodes) {
        ConceptTreeChild child;
        try {
            child = concept.findMostSpecificChild(conceptCode, new CalculatedValue<>(Collections::emptyMap));
            if (child != null) {
                resolvedCodes.add(child.getId());
            } else {
                unknownCodes.add(conceptCode);
            }
        } catch (ConceptConfigurationException e) {
            log.error("Error while trying to resolve " + conceptCode, e);
        }
    }
    return new ResolvedConceptsResult(resolvedCodes, null, unknownCodes);
}
Also used : ConceptElementId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptElementId) ArrayList(java.util.ArrayList) ConceptTreeChild(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeChild) CalculatedValue(com.bakdata.conquery.util.CalculatedValue) ToString(lombok.ToString) Collections(java.util.Collections) ConceptConfigurationException(com.bakdata.conquery.models.exceptions.ConceptConfigurationException)

Aggregations

ConceptTreeChild (com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeChild)1 ConceptConfigurationException (com.bakdata.conquery.models.exceptions.ConceptConfigurationException)1 ConceptElementId (com.bakdata.conquery.models.identifiable.ids.specific.ConceptElementId)1 CalculatedValue (com.bakdata.conquery.util.CalculatedValue)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 ToString (lombok.ToString)1