Search in sources :

Example 11 with Link

use of life.genny.qwanda.Link in project rulesservice by genny-project.

the class QRules method updateLink.

public Link updateLink(String groupCode, String targetCode, String linkCode, Double weight) {
    log.info("UPDATING LINK between " + groupCode + "and" + targetCode);
    Link link = new Link(groupCode, targetCode, linkCode);
    link.setWeight(weight);
    try {
        QwandaUtils.apiPutEntity(qwandaServiceUrl + "/qwanda/links", RulesUtils.toJson(link), getToken());
    } catch (IOException e) {
        e.printStackTrace();
    }
    return link;
}
Also used : IOException(java.io.IOException) Link(life.genny.qwanda.Link)

Example 12 with Link

use of life.genny.qwanda.Link in project rulesservice by genny-project.

the class QRules method getOfferBaseEntity.

public BaseEntity getOfferBaseEntity(String groupCode, String linkCode, String linkValue, String quoterCode, String token) {
    List linkList = getLinkList(groupCode, linkCode, linkValue, token);
    String quoterCodeForOffer = null;
    BaseEntity offer = null;
    if (linkList != null) {
        for (Object linkObj : linkList) {
            Link link = JsonUtils.fromJson(linkObj.toString(), Link.class);
            BaseEntity offerBe = getBaseEntityByCode(link.getTargetCode());
            if (offerBe != null) {
                quoterCodeForOffer = offerBe.getValue("PRI_QUOTER_CODE", null);
                if (quoterCode.equals(quoterCodeForOffer)) {
                    offer = offerBe;
                    return offerBe;
                }
            }
        }
    }
    return offer;
}
Also used : BaseEntity(life.genny.qwanda.entity.BaseEntity) ArrayList(java.util.ArrayList) List(java.util.List) JsonObject(io.vertx.core.json.JsonObject) JSONObject(org.json.simple.JSONObject) Link(life.genny.qwanda.Link)

Aggregations

Link (life.genny.qwanda.Link)12 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 BaseEntity (life.genny.qwanda.entity.BaseEntity)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 HashMap (java.util.HashMap)3 ExecutionException (java.util.concurrent.ExecutionException)3 BadDataException (life.genny.qwanda.exception.BadDataException)3 ClientProtocolException (org.apache.http.client.ClientProtocolException)3 ParseException (org.json.simple.parser.ParseException)3 JsonObject (io.vertx.core.json.JsonObject)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 QEventLinkChangeMessage (life.genny.qwanda.message.QEventLinkChangeMessage)2 List (java.util.List)1 Answer (life.genny.qwanda.Answer)1 EntityEntity (life.genny.qwanda.entity.EntityEntity)1 JSONObject (org.json.simple.JSONObject)1