Package org.eurekaj.api.datatypes.basic

Examples of org.eurekaj.api.datatypes.basic.BasicAlert


    this.db = db;
  }

  @Override
  public void persistAlert(Alert alert) {
    db.put(bytes(alertBucketKey + alert.getAccountName() + ";" + alert.getAlertName()), bytes(gson.toJson(new BasicAlert(alert))));
  }
View Full Code Here


  }

  @Override
  public Alert getAlert(String alertName, String accountName) {
    String json = asString(db.get(bytes(alertBucketKey + accountName + ";" + alertName)));
    BasicAlert alert = gson.fromJson(json, BasicAlert.class);
    return alert;
  }
View Full Code Here

    List<Alert> alertList = new ArrayList<>();

    DBIterator iterator = db.iterator();
    iterator.seek(bytes(alertBucketKey + accountName));
    while (iterator.hasNext() && asString(iterator.peekNext().getKey()).startsWith(alertBucketKey + accountName)) {
      BasicAlert alert = gson.fromJson(asString(iterator.next().getValue()), BasicAlert.class);
      alertList.add(alert);
    }

    return alertList;
  }
View Full Code Here

        }
    }

    @Override
    public Alert getAlert(String alertName, String accountName) {
        BasicAlert alert = null;

        Bucket myBucket = null;
        try {
            myBucket = riakClient.fetchBucket("Alert;" + accountName).execute();
            alert = myBucket.fetch(alertName, BasicAlert.class).execute();
View Full Code Here

              triggeredAlert.setWarningValue(alert.getWarningValue());
              logger.info("Persisitng triggered alert for alert: " + alert.getAlertName() + " for account: " + alert.getAccountName());
             
              dbPlugin.getAlertDao().persistTriggeredAlert(triggeredAlert);
             
              BasicAlert basicAlert = new BasicAlert(alert);
              basicAlert.setStatus(newStatus);
              logger.info("Persisitng new status for alert: " + basicAlert.getAlertName() + " for account: " + basicAlert.getAccountName() + " new status: " + basicAlert.getStatus().getStatusName());
              dbPlugin.getAlertDao().persistAlert(basicAlert);
            } else {
              logger.info("Alert status remains: " + newStatus.getStatusName());
            }
          } else {
View Full Code Here

*/
public class ParseJsonObjects {
  private static Logger log = Logger.getLogger(ParseJsonObjects.class.getName());
 
    public static Alert parseAlertJson(JSONObject jsonAlert, String id, String accountName) throws JSONException {
        BasicAlert parsedAlert = null;

        /*
         * {"alertWarningValue":15,"alertDelay":5,"alertType":null,"alertErrorValue":12,"alertActivated":true,"alertName":"Test"}
         */
        if (jsonAlert.has("alert")) {
            parsedAlert = new BasicAlert();
            JSONObject alert = jsonAlert.getJSONObject("alert");
            if (id == null || id.length() == 0) {
                parsedAlert.setAlertName(parseStringFromJson(alert, "id"));
            } else {
                parsedAlert.setAlertName(id);
            }

            parsedAlert.setWarningValue(parseDoubleFromJson(alert, "alertWarningValue"));
            parsedAlert.setErrorValue(parseDoubleFromJson(alert, "alertErrorValue"));
            parsedAlert.setGuiPath(parseStringFromJson(alert, "alertSource"));
           
            Integer alertDelay = parseIntegerFromJson(alert, "alertDelay");
            if (alertDelay == null) { alertDelay = 0; }
            parsedAlert.setAlertDelay(alertDelay.longValue());
           
            parsedAlert.setActivated(parseBooleanFromJson(alert, "alertActivated"));
            parsedAlert.setSelectedAlertType(AlertType.fromValue(parseStringFromJson(alert, "alertType")));
            parsedAlert.setSelectedEmailSenderList(getStringArrayFromJson(alert, "alertNotifications"));
            parsedAlert.setSelectedAlertPluginList(getStringArrayFromJson(alert, "alertPlugins"));
            parsedAlert.setAccountName(accountName);
        }

        log.info("alertName: " + parsedAlert.getAlertName() + " account: " + parsedAlert.getAccountName());
        return parsedAlert;
    }
View Full Code Here

TOP

Related Classes of org.eurekaj.api.datatypes.basic.BasicAlert

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.