Search in sources :

Example 1 with QDataBaseEntityMessage

use of life.genny.qwanda.message.QDataBaseEntityMessage 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 QDataBaseEntityMessage

use of life.genny.qwanda.message.QDataBaseEntityMessage 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 3 with QDataBaseEntityMessage

use of life.genny.qwanda.message.QDataBaseEntityMessage in project rulesservice by genny-project.

the class QRules method publishData.

public void publishData(final BaseEntity be, final String[] recipientsCode) {
    QDataBaseEntityMessage msg = new QDataBaseEntityMessage(be, null);
    msg.setRecipientCodeArray(recipientsCode);
    msg.setToken(getToken());
    publish("data", RulesUtils.toJsonObject(msg));
}
Also used : QDataBaseEntityMessage(life.genny.qwanda.message.QDataBaseEntityMessage)

Example 4 with QDataBaseEntityMessage

use of life.genny.qwanda.message.QDataBaseEntityMessage 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)

Example 5 with QDataBaseEntityMessage

use of life.genny.qwanda.message.QDataBaseEntityMessage in project rulesservice by genny-project.

the class QRules method clearBaseEntityAttr.

public void clearBaseEntityAttr(String userCode) {
    BaseEntity be = getBaseEntityByCode(userCode);
    println("be   ::   " + be);
    Set<EntityAttribute> attributes = be.getBaseEntityAttributes();
    println("Size all   ::   " + attributes.size());
    Set<EntityAttribute> removeAttributes = new HashSet<EntityAttribute>();
    for (EntityAttribute attribute : attributes) {
        switch(attribute.getAttributeCode()) {
            case ("PRI_UUID"):
                removeAttributes.add(attribute);
                break;
            case ("PRI_FIRSTNAME"):
                removeAttributes.add(attribute);
                break;
            case ("PRI_LASTNAME"):
                removeAttributes.add(attribute);
                break;
            case ("PRI_EMAIL"):
                removeAttributes.add(attribute);
                break;
            case ("PRI_USERNAME"):
                removeAttributes.add(attribute);
                break;
            case ("PRI_KEYCLOAK_UUID"):
                removeAttributes.add(attribute);
                break;
            case ("PRI_FB_BASIC"):
                removeAttributes.add(attribute);
                break;
        }
    }
    println("before removing   ::   " + attributes.toString());
    println("Size toRemove   ::   " + removeAttributes.size());
    println("Removing attrs   ::   " + removeAttributes.toString());
    attributes.removeAll(removeAttributes);
    println("after removing   ::   " + attributes.toString());
    println("Size afterRemoved   ::   " + attributes.size());
    be.setBaseEntityAttributes(attributes);
    QDataBaseEntityMessage beMsg = new QDataBaseEntityMessage(be);
    beMsg.setDelete(true);
    publishData(beMsg);
}
Also used : QDataBaseEntityMessage(life.genny.qwanda.message.QDataBaseEntityMessage) EntityAttribute(life.genny.qwanda.attribute.EntityAttribute) BaseEntity(life.genny.qwanda.entity.BaseEntity) HashSet(java.util.HashSet)

Aggregations

QDataBaseEntityMessage (life.genny.qwanda.message.QDataBaseEntityMessage)20 BaseEntity (life.genny.qwanda.entity.BaseEntity)13 ArrayList (java.util.ArrayList)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 EntityAttribute (life.genny.qwanda.attribute.EntityAttribute)2 JsonParseException (com.google.gson.JsonParseException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Answer (life.genny.qwanda.Answer)1 AttributeBoolean (life.genny.qwanda.attribute.AttributeBoolean)1 AttributeMoney (life.genny.qwanda.attribute.AttributeMoney)1 Money (org.javamoney.moneta.Money)1