use of life.genny.qwanda.Link in project rulesservice by genny-project.
the class QRules method getRecipientCodes.
public String[] getRecipientCodes(final QEventAttributeValueChangeMessage msg) {
String[] results = null;
Set<EntityEntity> links = msg.getBe().getLinks();
Set<String> recipientCodesSet = new HashSet<String>();
for (EntityEntity ee : links) {
Link link = ee.getLink();
String[] recipientArray = VertxUtils.getSubscribers(realm(), link.getTargetCode());
if (recipientArray != null) {
recipientCodesSet.addAll(Sets.newHashSet(recipientArray));
}
String[] recipientArray2 = VertxUtils.getSubscribers(realm(), link.getSourceCode());
if (recipientArray2 != null) {
recipientCodesSet.addAll(Sets.newHashSet(recipientArray2));
}
}
results = (String[]) FluentIterable.from(recipientCodesSet).toArray(String.class);
return results;
}
use of life.genny.qwanda.Link in project rulesservice by genny-project.
the class QRules method getParent.
/*
* Get user's company code
*/
public BaseEntity getParent(final String targetCode, final String linkCode) {
try {
String beJson = QwandaUtils.apiGet(getQwandaServiceUrl() + "/qwanda/entityentitys/" + targetCode + "/linkcodes/" + linkCode + "/parents", getToken());
Link[] linkArray = RulesUtils.fromJson(beJson, Link[].class);
if (linkArray.length > 0) {
ArrayList<Link> arrayList = new ArrayList<Link>(Arrays.asList(linkArray));
Link first = arrayList.get(0);
RulesUtils.println("The parent code is :: " + first.getSourceCode());
return RulesUtils.getBaseEntityByCode(getQwandaServiceUrl(), getDecodedTokenMap(), getToken(), first.getSourceCode(), false);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of life.genny.qwanda.Link 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.Link in project rulesservice by genny-project.
the class QRules method getRecipientCodes.
public String[] getRecipientCodes(final QEventLinkChangeMessage msg) {
String[] results = null;
Link link = msg.getLink();
Set<String> recipientCodesSet = new HashSet<String>();
if (link != null) {
String[] recipientArray = VertxUtils.getSubscribers(realm(), link.getTargetCode());
if (recipientArray != null) {
recipientCodesSet.addAll(Sets.newHashSet(recipientArray));
}
String[] recipientArray2 = VertxUtils.getSubscribers(realm(), link.getSourceCode());
if (recipientArray2 != null) {
recipientCodesSet.addAll(Sets.newHashSet(recipientArray2));
}
}
Link oldlink = msg.getOldLink();
if (oldlink != null) {
String[] recipientArrayOld = VertxUtils.getSubscribers(realm(), oldlink.getTargetCode());
if (recipientArrayOld != null) {
recipientCodesSet.addAll(Sets.newHashSet(recipientArrayOld));
}
String[] recipientArray2Old = VertxUtils.getSubscribers(realm(), oldlink.getSourceCode());
if (recipientArray2Old != null) {
recipientCodesSet.addAll(Sets.newHashSet(recipientArray2Old));
}
}
results = (String[]) FluentIterable.from(recipientCodesSet).toArray(String.class);
return results;
}
use of life.genny.qwanda.Link in project rulesservice by genny-project.
the class QRules method sendRating.
public void sendRating(String data) throws ClientProtocolException, IOException {
if (data != null) {
JsonObject dataJson = new JsonObject(data);
String begCode = dataJson.getString("itemCode");
String userCode = getUser().getCode();
String driverCode = null;
/* we get all the linked BEs to beg */
List<Link> links = getLinks(begCode, "LNK_BEG");
if (links != null) {
for (Link link : links) {
String linkValue = link.getLinkValue();
if (linkValue != null && linkValue.equals("DRIVER")) {
driverCode = link.getTargetCode();
}
}
}
if (begCode != null && driverCode != null) {
/*
* we save the BEG code as an attribute in order to track what job a driver is
* being currently rated against. if this comment does not make sense please
* refer to the french man.
*/
updateBaseEntityAttribute(userCode, userCode, "STT_JOB_IS_RATING", begCode);
/* we send the questions */
sendQuestions(userCode, driverCode, "QUE_USER_RATING_GRP", true);
/* we send the layout */
sendSublayout("driver-rating", "rate-driver.json", driverCode, true);
}
}
}
Aggregations