use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class VertxUtils method readFromDDT.
public static BaseEntity readFromDDT(final String code, final String token) {
BaseEntity be = null;
JsonObject json = readCachedJson(code);
if ("ok".equals(json.getString("status"))) {
be = JsonUtils.fromJson(json.getString("value"), BaseEntity.class);
} else {
// fetch normally
System.out.println("Cache MISS for " + code);
try {
// getBaseEntityByCodeWithAttributes
be = QwandaUtils.getBaseEntityByCode(code, token);
} catch (Exception e) {
// Okay, this is bad. Usually the code is not in the database but in keycloak
// So lets leave it to the rules to sort out... (new user)
log.error("BE " + code + " is NOT IN CACHE OR DB " + e.getLocalizedMessage());
return null;
}
if ((cachedEnabled) || (System.getenv("GENNY_DEV") != null)) {
writeCachedJson(code, JsonUtils.toJson(be));
}
}
return be;
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class VertxUtils method readFromDDT.
public static BaseEntity readFromDDT(final String code, final boolean withAttributes, final String token) {
BaseEntity be = null;
JsonObject json = readCachedJson(code);
if ("ok".equals(json.getString("status"))) {
be = JsonUtils.fromJson(json.getString("value"), BaseEntity.class);
} else {
// fetch normally
System.out.println("Cache MISS for " + code);
try {
if (withAttributes) {
be = QwandaUtils.getBaseEntityByCodeWithAttributes(code, token);
} else {
be = QwandaUtils.getBaseEntityByCode(code, token);
}
} catch (Exception e) {
// Okay, this is bad. Usually the code is not in the database but in keycloak
// So lets leave it to the rules to sort out... (new user)
log.error("BE " + code + " is NOT IN CACHE OR DB " + e.getLocalizedMessage());
return null;
}
if ((cachedEnabled) || (System.getenv("GENNY_DEV") != null)) {
writeCachedJson(code, JsonUtils.toJson(be));
}
}
return be;
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class VertxUtils method subscribe.
public static void subscribe(final String realm, final List<BaseEntity> watchList, final String userCode) {
final String SUB = "SUB";
// Subscribe to a code
for (BaseEntity be : watchList) {
Set<String> subscriberSet = getSetString(realm, SUB, be.getCode());
subscriberSet.add(userCode);
putSetString(realm, SUB, be.getCode(), subscriberSet);
}
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method getBaseEntityValueAsLocalDate.
public LocalDate getBaseEntityValueAsLocalDate(final String baseEntityCode, final String attributeCode) {
BaseEntity be = getBaseEntityByCode(baseEntityCode);
Optional<EntityAttribute> ea = be.findEntityAttribute(attributeCode);
if (ea.isPresent()) {
return ea.get().getValueDate();
} else {
return null;
}
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method publishBaseEntityByCode.
public void publishBaseEntityByCode(final String be, final String parentCode, final String linkCode, final String[] recipientCodes) {
BaseEntity item = getBaseEntityByCode(be);
BaseEntity[] itemArray = new BaseEntity[1];
itemArray[0] = item;
QDataBaseEntityMessage msg = new QDataBaseEntityMessage(itemArray, parentCode, linkCode);
msg.setRecipientCodeArray(recipientCodes);
publishData(msg, recipientCodes);
}
Aggregations