use of life.genny.qwanda.message.QDataAttributeMessage in project rulesservice by genny-project.
the class QRules method sendAllAttributes.
/*
* Gets all the attributes and Publishes to the DATA channel
*/
public void sendAllAttributes() {
println("Sending all the attributes");
try {
QDataAttributeMessage msg = RulesUtils.loadAllAttributesIntoCache(getToken());
publishData(msg);
println("All the attributes sent");
} catch (Exception e) {
e.printStackTrace();
}
}
use of life.genny.qwanda.message.QDataAttributeMessage in project rulesservice by genny-project.
the class RulesUtils method loadAllAttributesIntoCache.
public static QDataAttributeMessage loadAllAttributesIntoCache(final String token) {
try {
JsonObject json = VertxUtils.readCachedJson("attributes");
if ("ok".equals(json.getString("status"))) {
println("LOADING ATTRIBUTES FROM CACHE!");
// VertxUtils.writeCachedJson("attributes", json.getString("value"));
attributesMsg = JsonUtils.fromJson(json.getString("value"), QDataAttributeMessage.class);
Attribute[] attributeArray = attributesMsg.getItems();
for (Attribute attribute : attributeArray) {
attributeMap.put(attribute.getCode(), attribute);
}
println("All the attributes have been loaded in " + attributeMap.size() + " attributes");
} else {
println("LOADING ATTRIBUTES FROM API");
String jsonString = QwandaUtils.apiGet(qwandaServiceUrl + "/qwanda/attributes", token);
VertxUtils.writeCachedJson("attributes", jsonString);
attributesMsg = JsonUtils.fromJson(jsonString, QDataAttributeMessage.class);
Attribute[] attributeArray = attributesMsg.getItems();
for (Attribute attribute : attributeArray) {
attributeMap.put(attribute.getCode(), attribute);
}
println("All the attributes have been loaded from api in" + attributeMap.size() + " attributes");
}
return attributesMsg;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Aggregations