use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method getMapOfAllAttributesValuesForBaseEntity.
/*
* Gets all the attribute and their value for the given basenentity code
*/
public Map<String, String> getMapOfAllAttributesValuesForBaseEntity(String beCode) {
BaseEntity be = getBaseEntityByCode(beCode);
println("The load is ::" + be);
Set<EntityAttribute> eaSet = be.getBaseEntityAttributes();
println("The set of attributes are :: " + eaSet);
Map<String, String> attributeValueMap = new HashMap<String, String>();
for (EntityAttribute ea : eaSet) {
String attributeCode = ea.getAttributeCode();
println("The attribute code is :: " + attributeCode);
String value = ea.getAsLoopString();
attributeValueMap.put(attributeCode, value);
}
return attributeValueMap;
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method generateLayout.
public JsonObject generateLayout(final String reportGroupCode) {
Map<String, Object> map = getMap("GRP", reportGroupCode);
println(map);
Integer cols = 1;
Integer rows = map.size();
JsonObject layout = new JsonObject();
JsonObject grid = new JsonObject();
grid.put("cols", cols);
grid.put("rows", rows);
layout.put("Grid", grid);
JsonArray children = new JsonArray();
grid.put("children", children);
for (String key : map.keySet()) {
BaseEntity searchBe = (BaseEntity) map.get(key);
JsonObject button = generateGennyButton(key, searchBe.getName());
children.add(button);
}
return layout;
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method getBaseEntityByCodeWithAttributes.
public BaseEntity getBaseEntityByCodeWithAttributes(final String code) {
BaseEntity be = null;
be = VertxUtils.readFromDDT(code, true, getToken());
if (be == null) {
println("ERROR - be (" + code + ") fetched is NULL ");
} else {
if (be.getBaseEntityAttributes().isEmpty()) {
try {
be = QwandaUtils.getBaseEntityByCodeWithAttributes(code, getToken());
VertxUtils.writeCachedJson(code, JsonUtils.toJson(be));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
addAttributes(be);
}
return be;
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method getBaseEntityValueAsLocalTime.
public LocalTime getBaseEntityValueAsLocalTime(final String baseEntityCode, final String attributeCode) {
BaseEntity be = getBaseEntityByCode(baseEntityCode);
Optional<EntityAttribute> ea = be.findEntityAttribute(attributeCode);
if (ea.isPresent()) {
return ea.get().getValueTime();
} else {
return null;
}
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method processLoadTypeAnswer.
public void processLoadTypeAnswer(QEventAttributeValueChangeMessage m) {
/* Collect load code from answer */
Answer answer = m.getAnswer();
println("The created value :: " + answer.getCreatedDate());
println("Answer from QEventAttributeValueChangeMessage :: " + answer.toString());
String targetCode = answer.getTargetCode();
String sourceCode = answer.getSourceCode();
String loadCategoryCode = answer.getValue();
String attributeCode = m.data.getCode();
println("The target BE code is :: " + targetCode);
println("The source BE code is :: " + sourceCode);
println("The attribute code is :: " + attributeCode);
println("The load type code is :: " + loadCategoryCode);
// no attributes
BaseEntity loadType = getBaseEntityByCode(loadCategoryCode, false);
/* creating new Answer */
Answer newAnswer = new Answer(answer.getSourceCode(), answer.getTargetCode(), "PRI_LOAD_TYPE", loadType.getName());
newAnswer.setInferred(true);
saveAnswer(newAnswer);
}
Aggregations