use of com.serotonin.m2m2.web.mvc.rest.v1.model.publisher.AbstractPublisherModel in project ma-core-public by infiniteautomation.
the class PublisherModelDeserializer method deserialize.
/* (non-Javadoc)
* @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext)
*/
@Override
public AbstractPublisherModel<?, ?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
ObjectMapper mapper = (ObjectMapper) jp.getCodec();
JsonNode tree = jp.readValueAsTree();
String typeName = tree.get("modelType").asText();
PublisherDefinition definition = ModuleRegistry.getPublisherDefinition(typeName);
if (definition == null)
throw new ModelNotFoundException(typeName);
AbstractPublisherModel<?, ?> model = (AbstractPublisherModel<?, ?>) mapper.treeToValue(tree, definition.getPublisherModelClass());
// Set the definition here
model.setDefinition(definition);
return model;
}
Aggregations