Search in sources :

Example 1 with BaseEntity

use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.

the class QRules method publishBaseEntitysByParentAndLinkCodeWithAttributes.

public void publishBaseEntitysByParentAndLinkCodeWithAttributes(final String parentCode, final String linkCode, Integer pageStart, Integer pageSize, Boolean cache) {
    BaseEntity[] beArray = RulesUtils.getBaseEntitysArrayByParentAndLinkCodeWithAttributes(qwandaServiceUrl, getDecodedTokenMap(), getToken(), parentCode, linkCode);
    QDataBaseEntityMessage msg = new QDataBaseEntityMessage(beArray, parentCode, linkCode);
    msg.setToken(getToken());
    publish("cmds", RulesUtils.toJsonObject(msg));
}
Also used : QDataBaseEntityMessage(life.genny.qwanda.message.QDataBaseEntityMessage) BaseEntity(life.genny.qwanda.entity.BaseEntity)

Example 2 with BaseEntity

use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.

the class QRules method processDimensions.

public void processDimensions(QEventAttributeValueChangeMessage msg) {
    Answer newAnswer = msg.getAnswer();
    BaseEntity load = getBaseEntityByCode(newAnswer.getTargetCode());
    println("The laod value is " + load.toString());
    String value = newAnswer.getValue();
    println("The load " + msg.getData().getCode() + " is    ::" + value);
    /* Get the sourceCode(Job code) for this LOAD */
    BaseEntity job = getParent(newAnswer.getTargetCode(), "LNK_BEG");
    Answer jobDimensionAnswer = new Answer(getUser().getCode(), job.getCode(), msg.getData().getCode(), value);
    saveAnswer(jobDimensionAnswer);
}
Also used : Answer(life.genny.qwanda.Answer) BaseEntity(life.genny.qwanda.entity.BaseEntity)

Example 3 with BaseEntity

use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.

the class QRules method getBaseEntityByCode.

public BaseEntity getBaseEntityByCode(final String code, Boolean withAttributes) {
    BaseEntity be = null;
    be = VertxUtils.readFromDDT(code, withAttributes, getToken());
    if (be == null) {
        println("ERROR - be (" + code + ") fetched is NULL ");
    } else {
        addAttributes(be);
    }
    return be;
}
Also used : BaseEntity(life.genny.qwanda.entity.BaseEntity)

Example 4 with BaseEntity

use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.

the class QRules method publishBaseEntityByCode.

public void publishBaseEntityByCode(final BaseEntity item, final String parentCode, final String linkCode, final String[] recipientCodes) {
    BaseEntity[] itemArray = new BaseEntity[1];
    itemArray[0] = item;
    QDataBaseEntityMessage msg = new QDataBaseEntityMessage(itemArray, parentCode, linkCode);
    msg.setRecipientCodeArray(recipientCodes);
    publishData(msg, recipientCodes);
}
Also used : QDataBaseEntityMessage(life.genny.qwanda.message.QDataBaseEntityMessage) BaseEntity(life.genny.qwanda.entity.BaseEntity)

Example 5 with BaseEntity

use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.

the class QRules method publishBE.

public void publishBE(final BaseEntity be, String[] recipientCodes) {
    addAttributes(be);
    if (recipientCodes == null || recipientCodes.length == 0) {
        recipientCodes = new String[1];
        recipientCodes[0] = getUser().getCode();
    }
    println("PUBLISHBE:" + be.getCode() + " with " + be.getBaseEntityAttributes().size() + " attribute changes");
    // for (EntityAttribute ea : be.getBaseEntityAttributes()) {
    // 
    // if
    // (ea.getAttribute().getDataType().getTypeName().equals("org.javamoney.moneta.Money"))
    // {
    // // Money mon = JsonUtils.fromJson(ea.getValueString(), Money.class);
    // println("Money=" + ea.getValueMoney());
    // // BigDecimal bd = new BigDecimal(mon.getNumber().toString());
    // // Money hacked = Money.of(bd, mon.getCurrency());
    // // ea.setValueMoney(hacked);
    // break;
    // }
    // }
    BaseEntity[] itemArray = new BaseEntity[1];
    itemArray[0] = be;
    QDataBaseEntityMessage msg = new QDataBaseEntityMessage(itemArray, null, null);
    msg.setRecipientCodeArray(recipientCodes);
    // String json = JsonUtils.toJson(msg);
    publishData(msg, recipientCodes);
}
Also used : QDataBaseEntityMessage(life.genny.qwanda.message.QDataBaseEntityMessage) 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