Search in sources :

Example 31 with BaseEntity

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;
}
Also used : EntityAttribute(life.genny.qwanda.attribute.EntityAttribute) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) BaseEntity(life.genny.qwanda.entity.BaseEntity)

Example 32 with BaseEntity

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;
}
Also used : AttributeInteger(life.genny.qwanda.attribute.AttributeInteger) JsonArray(io.vertx.core.json.JsonArray) BaseEntity(life.genny.qwanda.entity.BaseEntity) JsonObject(io.vertx.core.json.JsonObject) JsonObject(io.vertx.core.json.JsonObject) JSONObject(org.json.simple.JSONObject)

Example 33 with BaseEntity

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;
}
Also used : BaseEntity(life.genny.qwanda.entity.BaseEntity) IOException(java.io.IOException)

Example 34 with BaseEntity

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;
    }
}
Also used : EntityAttribute(life.genny.qwanda.attribute.EntityAttribute) BaseEntity(life.genny.qwanda.entity.BaseEntity)

Example 35 with BaseEntity

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);
}
Also used : Answer(life.genny.qwanda.Answer) BaseEntity(life.genny.qwanda.entity.BaseEntity)

Aggregations

BaseEntity (life.genny.qwanda.entity.BaseEntity)54 QDataBaseEntityMessage (life.genny.qwanda.message.QDataBaseEntityMessage)13 ArrayList (java.util.ArrayList)11 JsonObject (io.vertx.core.json.JsonObject)9 Answer (life.genny.qwanda.Answer)8 EntityAttribute (life.genny.qwanda.attribute.EntityAttribute)8 BadDataException (life.genny.qwanda.exception.BadDataException)7 IOException (java.io.IOException)6 AttributeInteger (life.genny.qwanda.attribute.AttributeInteger)6 JsonArray (io.vertx.core.json.JsonArray)5 HashMap (java.util.HashMap)5 LinkedHashMap (java.util.LinkedHashMap)5 AttributeBoolean (life.genny.qwanda.attribute.AttributeBoolean)5 Link (life.genny.qwanda.Link)4 AttributeMoney (life.genny.qwanda.attribute.AttributeMoney)4 AttributeText (life.genny.qwanda.attribute.AttributeText)4 Money (org.javamoney.moneta.Money)3 HashSet (java.util.HashSet)2 List (java.util.List)2 JSONObject (org.json.simple.JSONObject)2