use of com.bakdata.conquery.models.exceptions.JSONException in project conquery by bakdata.
the class FilterTest method importConcepts.
private void importConcepts(StandaloneSupport support) throws JSONException, IOException {
Dataset dataset = support.getDataset();
concept = new TreeConcept();
concept.setLabel("concept");
concept.setValidator(support.getValidator());
concept.setDataset(support.getDataset());
rawConnector.put("name", "connector");
rawConnector.put("table", "table");
((ObjectNode) rawConnector.get("filters")).put("name", "filter");
connector = parseSubTree(support, rawConnector, ConceptTreeConnector.class, conn -> conn.setConcept(concept));
concept.setConnectors(Collections.singletonList((ConceptTreeConnector) connector));
support.getDatasetsProcessor().addConcept(dataset, concept);
}
use of com.bakdata.conquery.models.exceptions.JSONException in project conquery by bakdata.
the class ConqueryTestSpec method parseSubTreeList.
public static <T> List<T> parseSubTreeList(StandaloneSupport support, ArrayNode node, Class<?> expectedType, Consumer<T> modifierBeforeValidation) throws IOException, JSONException {
ObjectMapper mapper = support.getDataset().injectIntoNew(new SingletonNamespaceCollection(support.getNamespace().getStorage().getCentralRegistry()).injectIntoNew(Jackson.MAPPER.copy().addHandler(new DatasetPlaceHolderFiller(support))));
List<T> result = new ArrayList<>(node.size());
for (var child : node) {
T value;
try {
value = mapper.readerFor(expectedType).readValue(child);
} catch (Exception e) {
if (child.isValueNode()) {
String potentialPath = child.textValue();
try {
value = mapper.readerFor(expectedType).readValue(IntegrationTest.class.getResource(potentialPath));
} catch (Exception e2) {
throw new RuntimeException("Could not parse value " + potentialPath, e2);
}
} else {
throw e;
}
}
if (modifierBeforeValidation != null) {
modifierBeforeValidation.accept(value);
}
result.add(value);
ValidatorHelper.failOnError(log, support.getValidator().validate(value));
}
return result;
}
Aggregations