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;
}
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");
}
}
}
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;
}
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);
}
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;
}
Aggregations