Search in sources :

Example 51 with BaseEntity

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

the class QRules method publishData.

public void publishData(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("data", RulesUtils.toJsonObject(msg));
}
Also used : QDataBaseEntityMessage(life.genny.qwanda.message.QDataBaseEntityMessage) BaseEntity(life.genny.qwanda.entity.BaseEntity)

Example 52 with BaseEntity

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

the class RulesUtils method getBaseEntitysByChildAndLinkCodeWithAttributes.

/**
 * @param qwandaServiceUrl
 * @param decodedToken
 * @param token
 * @param parentCode
 * @param linkCode
 * @return baseEntitys
 */
public static List<BaseEntity> getBaseEntitysByChildAndLinkCodeWithAttributes(final String qwandaServiceUrl, Map<String, Object> decodedToken, final String token, final String childCode, final String linkCode) {
    String beJson = getBaseEntitysJsonByChildAndLinkCodeWithAttributes(qwandaServiceUrl, decodedToken, token, childCode, linkCode);
    QDataBaseEntityMessage msg = JsonUtils.fromJson(beJson, QDataBaseEntityMessage.class);
    BaseEntity[] beArray = msg.getItems();
    ArrayList<BaseEntity> arrayList = new ArrayList<BaseEntity>(Arrays.asList(beArray));
    return arrayList;
}
Also used : QDataBaseEntityMessage(life.genny.qwanda.message.QDataBaseEntityMessage) BaseEntity(life.genny.qwanda.entity.BaseEntity) ArrayList(java.util.ArrayList)

Example 53 with BaseEntity

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

the class RulesUtils method getBaseEntitysByParentAndLinkCodeWithAttributesAndStakeholderCode.

/**
 * @param qwandaServiceUrl
 * @param decodedToken
 * @param token
 * @param parentCode
 * @param linkCode
 * @param stakeholderCode
 * @return baseEntitys
 */
public static List<BaseEntity> getBaseEntitysByParentAndLinkCodeWithAttributesAndStakeholderCode(final String qwandaServiceUrl, Map<String, Object> decodedToken, final String token, final String parentCode, final String linkCode, final String stakeholderCode) {
    if (parentCode.equalsIgnoreCase("GRP_NEW_ITEMS")) {
        println("Group New Items Debug");
    }
    String beJson = getBaseEntitysJsonByParentAndLinkCodeWithAttributesAndStakeholderCode(qwandaServiceUrl, decodedToken, token, parentCode, linkCode, stakeholderCode);
    QDataBaseEntityMessage msg = fromJson(beJson, QDataBaseEntityMessage.class);
    if (msg == null) {
        log.error("Error in fetching BE from Qwanda Service");
    } else {
        BaseEntity[] beArray = msg.getItems();
        ArrayList<BaseEntity> arrayList = new ArrayList<BaseEntity>(Arrays.asList(beArray));
        return arrayList;
    }
    // TODO get exception =s in place
    return null;
}
Also used : QDataBaseEntityMessage(life.genny.qwanda.message.QDataBaseEntityMessage) BaseEntity(life.genny.qwanda.entity.BaseEntity) ArrayList(java.util.ArrayList)

Example 54 with BaseEntity

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

the class RulesUtils method getUser.

/**
 * @param qwandaServiceUrl
 * @param decodedToken
 * @param token
 * @return baseEntity user for the decodedToken passed
 */
public static BaseEntity getUser(final String qwandaServiceUrl, Map<String, Object> decodedToken, final String token) {
    // try {
    String beJson = null;
    String username = (String) decodedToken.get("preferred_username");
    String uname = QwandaUtils.getNormalisedUsername(username);
    String code = "PER_" + uname.toUpperCase();
    // CHEAT TODO
    BaseEntity be = VertxUtils.readFromDDT(code, token);
    return be;
// } catch (IOException e) {
// e.printStackTrace();
// }
// return null;
}
Also used : 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