Search in sources :

Example 1 with QDataSubLayoutMessage

use of life.genny.qwanda.message.QDataSubLayoutMessage in project rulesservice by genny-project.

the class QRules method sendSublayouts.

private void sendSublayouts(final String realm) throws ClientProtocolException, IOException {
    String subLayoutMap = RulesUtils.getLayout(realm + "/sublayouts");
    if (subLayoutMap != null) {
        JsonArray subLayouts = new JsonArray(subLayoutMap);
        if (subLayouts != null) {
            Layout[] layoutArray = new Layout[subLayouts.size()];
            for (int i = 0; i < subLayouts.size(); i++) {
                JsonObject sublayoutData = null;
                try {
                    sublayoutData = subLayouts.getJsonObject(i);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
                String url = sublayoutData.getString("download_url");
                String name = sublayoutData.getString("name");
                name = name.replace(".json", "");
                name = name.replaceAll("\"", "");
                if (url != null) {
                    /* grab sublayout from github */
                    println(i + ":" + url);
                    String subLayoutString = QwandaUtils.apiGet(url, null);
                    if (subLayoutString != null) {
                        try {
                            layoutArray[i] = new Layout(name, subLayoutString);
                        } catch (Exception e) {
                        }
                    }
                }
            }
            /* send sublayout to FE */
            QDataSubLayoutMessage msg = new QDataSubLayoutMessage(layoutArray, getToken());
            publishCmd(msg);
        }
    }
}
Also used : JsonArray(io.vertx.core.json.JsonArray) QDataSubLayoutMessage(life.genny.qwanda.message.QDataSubLayoutMessage) Layout(life.genny.qwanda.Layout) JsonObject(io.vertx.core.json.JsonObject) ClientProtocolException(org.apache.http.client.ClientProtocolException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) BadDataException(life.genny.qwanda.exception.BadDataException) ParseException(org.json.simple.parser.ParseException)

Example 2 with QDataSubLayoutMessage

use of life.genny.qwanda.message.QDataSubLayoutMessage in project rulesservice by genny-project.

the class QRules method sendNotification.

public void sendNotification(final String text, final String[] recipientCodes, final String style) {
    Layout notificationLayout = new Layout(text, style);
    QDataSubLayoutMessage data = new QDataSubLayoutMessage(notificationLayout, getToken());
    data.setRecipientCodeArray(recipientCodes);
    publishCmd(data);
}
Also used : QDataSubLayoutMessage(life.genny.qwanda.message.QDataSubLayoutMessage) Layout(life.genny.qwanda.Layout)

Aggregations

Layout (life.genny.qwanda.Layout)2 QDataSubLayoutMessage (life.genny.qwanda.message.QDataSubLayoutMessage)2 JsonArray (io.vertx.core.json.JsonArray)1 JsonObject (io.vertx.core.json.JsonObject)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ExecutionException (java.util.concurrent.ExecutionException)1 BadDataException (life.genny.qwanda.exception.BadDataException)1 ClientProtocolException (org.apache.http.client.ClientProtocolException)1 ParseException (org.json.simple.parser.ParseException)1