public static AlertContext fromJsonString(String json) { ObjectMapper objectMapper = new ObjectMapper(); try { Map m = objectMapper.readValue(json, Map.class); AlertContext c = new AlertContext(); c.addAll(m); return c; } catch (Exception ex) { LOG.error("fail converting string into alertcontext", ex); return null; } }
public static AlertContext fromJsonString(String json){ ObjectMapper objectMapper = new ObjectMapper(); try{ Map m = objectMapper.readValue(json, Map.class); AlertContext c = new AlertContext(); c.addAll(m); return c; }catch(Exception ex){ LOG.error("fail converting string into alertcontext", ex); return null; } }
@Override public AlertContext deserialize(byte[] bytes) { AlertContext context = new AlertContext(); Map<String, String> properties = new HashMap<String, String>(); final int length = bytes.length; if (length < 4) { return context; } int size = Bytes.toInt(bytes, 0, 4); int offset = 4; for (int i = 0; i < size; i++) { int keySize = Bytes.toInt(bytes, offset, 4); offset += 4; int valueSize = Bytes.toInt(bytes, offset, 4); offset += 4; String key = Bytes.toString(bytes, offset, keySize); offset += keySize; String value =Bytes.toString(bytes, offset, valueSize); offset += valueSize; properties.put(key, value); } context.addAll(properties); return context; }
private AlertEmailComponent getEventComponent(AlertContext context) { AlertContext eventFieldsContext = new AlertContext(); String eventFields = context.getProperty(Constants.ALERT_EVENT_FIELDS); String[] fields = eventFields.split(EVENT_FIELDS_SPLITTER); for (String key : fields) { eventFieldsContext.addProperty(key, context.getProperty(key)); } AlertEmailComponent component = new AlertEmailComponent(); component.setAlertContext(eventFieldsContext); return component; } }
String alertExecutorId = siddhiAlertContext.alertExecutor.getExecutorId(); AlertAPIEntity entity = new AlertAPIEntity(); AlertContext context = new AlertContext(); String sourceStreams = evaluator.getAdditionalContext().get(Constants.SOURCE_STREAMS); String[] sourceStreamsArr = sourceStreams.split(",");
AlertContext context = new AlertContext();