use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method publishCmd.
public void publishCmd(final List<BaseEntity> beList, final String parentCode, final String linkCode, String[] recipientCodes) {
QDataBaseEntityMessage msg = new QDataBaseEntityMessage(beList.toArray(new BaseEntity[0]));
msg.setParentCode(parentCode);
msg.setLinkCode(linkCode);
msg.setToken(getToken());
if (recipientCodes != null) {
msg.setRecipientCodeArray(recipientCodes);
}
publish("cmds", RulesUtils.toJsonObject(msg));
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method fireAttributeChanges.
public void fireAttributeChanges(QEventAttributeValueChangeMessage m) {
Answer a = m.getAnswer();
BaseEntity be = m.getBe();
for (EntityAttribute ea : be.getBaseEntityAttributes()) {
Answer pojo = new Answer(a.getSourceCode(), a.getTargetCode(), ea.getAttributeCode(), ea.getAsLoopString());
pojo.setWeight(ea.getWeight());
pojo.setInferred(ea.getInferred());
pojo.setExpired(a.getExpired());
pojo.setRefused(a.getRefused());
// pojo.setAskId(answer.getAskId());
QEventAttributeValueChangeMessage msg = new QEventAttributeValueChangeMessage(pojo, m.getOldValue(), m.getToken());
msg.getData().setCode(ea.getAttributeCode());
msg.getData().setId(-1L);
msg.setBe(be);
publish("events", JsonUtils.toJson(msg));
}
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method getBaseEntityValueAsLocalDateTime.
public LocalDateTime getBaseEntityValueAsLocalDateTime(final String baseEntityCode, final String attributeCode) {
BaseEntity be = getBaseEntityByCode(baseEntityCode);
Optional<EntityAttribute> ea = be.findEntityAttribute(attributeCode);
if (ea.isPresent()) {
return ea.get().getValueDateTime();
} else {
return null;
}
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method getBaseEntityValue.
public Object getBaseEntityValue(final String baseEntityCode, final String attributeCode) {
BaseEntity be = getBaseEntityByCode(baseEntityCode);
Optional<EntityAttribute> ea = be.findEntityAttribute(attributeCode);
if (ea.isPresent()) {
return ea.get().getObject();
} else {
return null;
}
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class RulesUtils method getBaseEntitysByAttributeAndValue.
/**
* @param qwandaServiceUrl
* @param decodedToken
* @param token
* @return baseEntity user for the decodedToken passed
*/
public static List<BaseEntity> getBaseEntitysByAttributeAndValue(final String qwandaServiceUrl, Map<String, Object> decodedToken, final String token, final String attributeCode, final String value) {
String beJson = getBaseEntityJsonByAttributeAndValue(qwandaServiceUrl, decodedToken, token, attributeCode, value, 1000);
QDataBaseEntityMessage be = fromJson(beJson, QDataBaseEntityMessage.class);
List<BaseEntity> items = null;
try {
items = new ArrayList<BaseEntity>(Arrays.asList(be.getItems()));
} catch (Exception e) {
println("Error: items is null");
}
return items;
}
Aggregations