use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project snow-owl by b2ihealthcare.
the class BundleEntryDeserializer method deserialize.
@Override
public Entry deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException, JsonProcessingException {
TreeNode node = parser.readValueAsTree();
ObjectCodec objectCodec = parser.getCodec();
// Select the concrete class based on the resource type header
TreeNode resourceTypeNode = node.path("resource").path("resourceType");
if (resourceTypeNode instanceof TextNode) {
TextNode textNode = (TextNode) resourceTypeNode;
if (node.get("request") != null) {
if (textNode.textValue().equals("Parameters")) {
return objectCodec.treeToValue(node, ParametersRequestEntry.class);
} else {
return objectCodec.treeToValue(node, ResourceRequestEntry.class);
}
} else if (node.get("response") != null) {
if (textNode.textValue().equals("Parameters")) {
return objectCodec.treeToValue(node, ParametersResponseEntry.class);
} else if (textNode.textValue().equals("OperationOutcome")) {
return objectCodec.treeToValue(node, OperationOutcomeEntry.class);
} else {
return objectCodec.treeToValue(node, ResourceResponseEntry.class);
}
}
}
return objectCodec.treeToValue(node, RequestEntry.class);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project snow-owl by b2ihealthcare.
the class FhirResourceDeserializer method deserialize.
@Override
public FhirResource deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
TreeNode node = p.readValueAsTree();
TreeNode resourceTypeNode = node.get("resourceType");
if (resourceTypeNode instanceof TextNode) {
TextNode resourceTypeTextNode = (TextNode) resourceTypeNode;
switch(resourceTypeTextNode.textValue()) {
case CodeSystem.RESOURCE_TYPE_CODE_SYSTEM:
return p.getCodec().treeToValue(node, CodeSystem.class);
case ValueSet.RESOURCE_TYPE_VALUE_SET:
return p.getCodec().treeToValue(node, ValueSet.class);
case ConceptMap.RESOURCE_TYPE_CONCEPT_MAP:
return p.getCodec().treeToValue(node, ConceptMap.class);
case StructureDefinition.RESOURCE_TYPE_STRUCTURE_DEFINITION:
return p.getCodec().treeToValue(node, StructureDefinition.class);
case Bundle.RESOURCE_TYPE_BUNDLE:
return p.getCodec().treeToValue(node, Bundle.class);
case OperationOutcome.RESOURCE_TYPE_OPERATION_OUTCOME:
return p.getCodec().treeToValue(node, OperationOutcome.class);
default:
break;
}
}
throw new IllegalArgumentException("Unknown resource type for '" + node.toString() + "'.");
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project snow-owl by b2ihealthcare.
the class FhirBatchRequestProcessor method processClientErrorException.
private void processClientErrorException(ArrayNode arrayNode, HttpClientErrorException hcee) throws JsonMappingException, JsonProcessingException {
// HttpClientErrorException can return an OperationOutcome in the response body
ObjectNode resourceNode = (ObjectNode) objectMapper.readTree(hcee.getResponseBodyAsString());
TreeNode resourceTypeNode = resourceNode.path("resource").path("resourceType");
if (resourceTypeNode instanceof TextNode) {
TextNode textNode = (TextNode) resourceTypeNode;
if (textNode.textValue().equals("OperationOutcome")) {
addResponse(arrayNode, resourceNode, String.valueOf(hcee.getStatusCode().value()));
return;
}
}
processHttpException(arrayNode, hcee);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project Rosetta by HubSpot.
the class StoredAsJsonTest method itHandlesSubTypes.
@Test
public void itHandlesSubTypes() throws JsonProcessingException {
ConcreteStoredAsJsonList typeInfoBean = new ConcreteStoredAsJsonList();
typeInfoBean.setInnerBeans(Collections.singletonList(inner));
TextNode expectedList = TextNode.valueOf("[{\"stringProperty\":\"value\"}]");
JsonNode node = Rosetta.getMapper().valueToTree(typeInfoBean);
assertThat(node.get("innerBeans")).isEqualTo(expectedList);
assertThat(Rosetta.getMapper().treeToValue(node, StoredAsJsonListTypeInfoBean.class).getInnerBeans().get(0).getStringProperty()).isEqualTo("value");
assertThat(Rosetta.getMapper().treeToValue(node, ConcreteStoredAsJsonList.class).getInnerBeans().get(0).getStringProperty()).isEqualTo("value");
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project jsonschema2pojo by joelittlejohn.
the class TypeRuleTest method applyGeneratesDate.
@Test
public void applyGeneratesDate() {
JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put("type", "string");
TextNode formatNode = TextNode.valueOf("date-time");
objectNode.set("format", formatNode);
JType mockDateType = mock(JType.class);
FormatRule mockFormatRule = mock(FormatRule.class);
when(mockFormatRule.apply(eq("fooBar"), eq(formatNode), any(), Mockito.isA(JType.class), isNull())).thenReturn(mockDateType);
when(ruleFactory.getFormatRule()).thenReturn(mockFormatRule);
JType result = rule.apply("fooBar", objectNode, null, jpackage, null);
assertThat(result, equalTo(mockDateType));
}
Aggregations