Search in sources :

Example 6 with BaseEntity

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

the class QRules method createBaseEntityByCode.

public BaseEntity createBaseEntityByCode(final String userCode, final String bePrefix, final String name) {
    BaseEntity beg = QwandaUtils.createBaseEntityByCode(QwandaUtils.getUniqueId(userCode, null, bePrefix, getToken()), name, qwandaServiceUrl, getToken());
    addAttributes(beg);
    VertxUtils.writeCachedJson(beg.getCode(), JsonUtils.toJson(beg));
    return beg;
}
Also used : BaseEntity(life.genny.qwanda.entity.BaseEntity)

Example 7 with BaseEntity

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

the class QRules method sendInternMatchLayoutsAndData.

public void sendInternMatchLayoutsAndData() {
    BaseEntity user = getUser();
    if (user != null) {
        String internValue = QRules.getBaseEntityAttrValueAsString(user, "PRI_IS_INTERN");
        Boolean isIntern = internValue != null && (internValue.equals("TRUE") || user.is("PRI_MENTOR"));
        /* Show loading indicator */
        showLoading("Loading your interface...");
        if (isIntern) {
            List<BaseEntity> root = getBaseEntitysByParentAndLinkCode("GRP_ROOT", "LNK_CORE", 0, 20, false);
            publishCmd(root, "GRP_ROOT", "LNK_CORE");
            List<BaseEntity> dashboard = getBaseEntitysByParentAndLinkCode("GRP_DASHBOARD", "LNK_CORE", 0, 20, false);
            publishCmd(dashboard, "GRP_DASHBOARD", "LNK_CORE");
            List<BaseEntity> internships = getBaseEntitysByParentAndLinkCode("GRP_INTERNSHIPS", "LNK_CORE", 0, 50, false);
            publishCmd(internships, "GRP_INTERNSHIPS", "LNK_CORE");
            List<BaseEntity> companies = getBaseEntitysByParentAndLinkCode("GRP_COMPANYS", "LNK_CORE", 0, 50, false);
            publishCmd(companies, "GRP_COMPANYS", "LNK_CORE");
            this.sendSublayout("intern-homepage", "homepage/dashboard_intern.json");
        }
    }
}
Also used : BaseEntity(life.genny.qwanda.entity.BaseEntity) AttributeBoolean(life.genny.qwanda.attribute.AttributeBoolean)

Example 8 with BaseEntity

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

the class QRules method getAllChildrens.

/*
	 * Get all childrens for the given source code with the linkcode and linkValue
	 */
public List<BaseEntity> getAllChildrens(final String sourceCode, final String linkCode, final String linkValue) {
    List<BaseEntity> childList = new ArrayList<BaseEntity>();
    try {
        String beJson = QwandaUtils.apiGet(getQwandaServiceUrl() + "/qwanda/entityentitys/" + sourceCode + "/linkcodes/" + linkCode + "/children/" + linkValue, getToken());
        Link[] linkArray = RulesUtils.fromJson(beJson, Link[].class);
        if (linkArray.length > 0) {
            ArrayList<Link> arrayList = new ArrayList<Link>(Arrays.asList(linkArray));
            for (Link link : arrayList) {
                // RulesUtils.println("The Child BaseEnity code is :: " + link.getTargetCode());
                childList.add(RulesUtils.getBaseEntityByCode(getQwandaServiceUrl(), getDecodedTokenMap(), getToken(), link.getTargetCode(), false));
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
    return childList;
}
Also used : BaseEntity(life.genny.qwanda.entity.BaseEntity) ArrayList(java.util.ArrayList) Link(life.genny.qwanda.Link) ClientProtocolException(org.apache.http.client.ClientProtocolException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) BadDataException(life.genny.qwanda.exception.BadDataException) ParseException(org.json.simple.parser.ParseException)

Example 9 with BaseEntity

use of life.genny.qwanda.entity.BaseEntity 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)

Example 10 with BaseEntity

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

the class QRules method getBaseEntitysByParentAndLinkCode.

public List<BaseEntity> getBaseEntitysByParentAndLinkCode(final String parentCode, final String linkCode, Integer pageStart, Integer pageSize, Boolean cache) {
    cache = false;
    List<BaseEntity> bes = new ArrayList<BaseEntity>();
    String key = parentCode + linkCode + "-" + pageStart + "-" + pageSize;
    if (cache) {
        Type listType = new TypeToken<List<BaseEntity>>() {
        }.getType();
        List<String> beCodes = VertxUtils.getObject(this.realm(), "LIST", key, (Class) listType);
        if (beCodes == null) {
            bes = RulesUtils.getBaseEntitysByParentAndLinkCodeWithAttributes(qwandaServiceUrl, getDecodedTokenMap(), getToken(), parentCode, linkCode, pageStart, pageSize);
            beCodes = new ArrayList<String>();
            for (BaseEntity be : bes) {
                VertxUtils.putObject(realm(), "", be.getCode(), JsonUtils.toJson(be));
                beCodes.add(be.getCode());
            }
            VertxUtils.putObject(this.realm(), "LIST", key, beCodes);
        } else {
            for (String beCode : beCodes) {
                BaseEntity be = VertxUtils.readFromDDT(beCode, true, getToken());
                bes.add(be);
            }
        }
    } else {
        bes = RulesUtils.getBaseEntitysByParentAndLinkCodeWithAttributes(qwandaServiceUrl, getDecodedTokenMap(), getToken(), parentCode, linkCode, pageStart, pageSize);
    }
    return bes;
}
Also used : Type(java.lang.reflect.Type) BaseEntity(life.genny.qwanda.entity.BaseEntity) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

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