use of com.serotonin.m2m2.web.mvc.rest.v1.model.publisher.AbstractPublishedPointModel in project ma-core-public by infiniteautomation.
the class PublishedPointModelDeserializer method deserialize.
/* (non-Javadoc)
* @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext)
*/
@Override
public AbstractPublishedPointModel<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
ObjectMapper mapper = (ObjectMapper) jp.getCodec();
JsonNode tree = jp.readValueAsTree();
// Get the model type which is of the form PUB-POINT-{publisher type name}
String typeName = tree.get("modelType").asText();
if (typeName != null)
typeName = typeName.split("PUB-POINT-")[1];
PublisherDefinition definition = ModuleRegistry.getPublisherDefinition(typeName);
if (definition == null)
throw new ModelNotFoundException("PUB-POINT-" + typeName);
return (AbstractPublishedPointModel<?>) mapper.treeToValue(tree, definition.getPublishedPointModelClass());
}
Aggregations