use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method createUser.
public BaseEntity createUser() {
BaseEntity be = null;
String username = getAsString("preferred_username").toLowerCase();
String firstname = StringUtils.capitaliseAllWords(getAsString("given_name").toLowerCase());
String lastname = StringUtils.capitaliseAllWords(getAsString("family_name").toLowerCase());
String realm = StringUtils.capitaliseAllWords(getAsString("realm").toLowerCase());
String name = StringUtils.capitaliseAllWords(getAsString("name").toLowerCase());
String email = getAsString("email").toLowerCase();
String keycloakId = getAsString("sub").toLowerCase();
try {
be = QwandaUtils.createUser(qwandaServiceUrl, getToken(), username, firstname, lastname, email, realm, name, keycloakId);
VertxUtils.writeCachedJson(be.getCode(), JsonUtils.toJson(be));
be = getUser();
set("USER", be);
println("New User Created " + be);
} catch (IOException e) {
log.error("Error in Creating User ");
}
return be;
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method sendMentorMatchLayoutsAndData.
public void sendMentorMatchLayoutsAndData(Boolean forceQuestions) {
BaseEntity user = getUser();
if (user != null) {
String mentorValue = QRules.getBaseEntityAttrValueAsString(user, "PRI_MENTOR");
String menteeValue = QRules.getBaseEntityAttrValueAsString(user, "PRI_MENTEE");
Boolean isMentor = mentorValue != null && (mentorValue.equals("TRUE") || mentorValue.equals("true"));
Boolean isMentee = menteeValue != null && (menteeValue.equals("TRUE") || menteeValue.equals("true"));
String profile_completed = QRules.getBaseEntityAttrValueAsString(user, "PRI_MENTORMATCH_PROFILE_COMPLETED");
if (profile_completed == null && !isMentor && !isMentee) {
this.sendSelections("GRP_USER_ROLE", "LNK_CORE", 10);
this.askQuestions(getUser().getCode(), getUser().getCode(), "QUE_NEW_USER_PROFILE_GRP_MENTORMATCH");
} else {
if (isMentor || isMentee) {
/* Show loading indicator */
showLoading("Loading your interface...");
String mentor_profile_status = QRules.getBaseEntityAttrValueAsString(user, "PRI_MENTORMATCH_PROFILE_COMPLETED");
Boolean hasCompletedProfile = mentor_profile_status != null && (mentor_profile_status.equals("TRUE") || user.is("PRI_MENTORMATCH_PROFILE_COMPLETED"));
if (!hasCompletedProfile || (forceQuestions != null && forceQuestions == true)) {
// we send questions for mentors
if (isMentor && !isMentee) {
this.sendSelections("GRP_USER_ROLE", "LNK_CORE", 20);
this.sendSelections("GRP_YEARS_RANGE", "LNK_CORE", 20);
this.sendSelections("GRP_MEANS_CONTACT", "LNK_CORE", 20);
this.sendSelections("GRP_GUIDANCE_GRP", "LNK_CORE", 20);
this.sendSelections("GRP_MENTEES_ATTRIBUTES", "LNK_CORE", 20);
this.sendSelections("GRP_INDUSTRY_SELECTION", "LNK_CORE", 20);
this.sendSelections("GRP_FIELD_OF_WORK", "LNK_CORE", 20);
this.sendSelections("GRP_WORK_LOCATION_MELBOURNE", "LNK_CORE", 20);
this.sendSelections("GRP_WORKING_STATUS", "LNK_CORE", 20);
this.sendSelections("GRP_GENDERS", "LNK_CORE", 20);
this.askQuestions(getUser().getCode(), getUser().getCode(), "QUE_MENTOR_GRP");
} else // we send questions for mentees
if (isMentee && !isMentor) {
this.sendSelections("GRP_USER_ROLE", "LNK_CORE", 20);
this.sendSelections("GRP_YEARS_RANGE", "LNK_CORE", 20);
this.sendSelections("GRP_MEANS_CONTACT", "LNK_CORE", 20);
this.sendSelections("GRP_GUIDANCE_GRP", "LNK_CORE", 20);
this.sendSelections("GRP_MENTORS_ATTRIBUTES", "LNK_CORE", 20);
this.sendSelections("GRP_INDUSTRY_SELECTION", "LNK_CORE", 20);
this.sendSelections("GRP_FIELD_OF_WORK", "LNK_CORE", 20);
this.sendSelections("GRP_WORK_LOCATION_MELBOURNE", "LNK_CORE", 20);
this.sendSelections("GRP_WORKING_STATUS", "LNK_CORE", 20);
this.sendSelections("GRP_GENDERS", "LNK_CORE", 20);
this.askQuestions(getUser().getCode(), getUser().getCode(), "QUE_MENTEE_GRP");
} else // we send the super form
if (isMentee && isMentor) {
this.sendSelections("GRP_MENTEES_ATTRIBUTES", "LNK_CORE", 20);
this.sendSelections("GRP_USER_ROLE", "LNK_CORE", 20);
this.sendSelections("GRP_YEARS_RANGE", "LNK_CORE", 20);
this.sendSelections("GRP_MEANS_CONTACT", "LNK_CORE", 20);
this.sendSelections("GRP_GUIDANCE_GRP", "LNK_CORE", 20);
this.sendSelections("GRP_MENTORS_ATTRIBUTES", "LNK_CORE", 20);
this.sendSelections("GRP_INDUSTRY_SELECTION", "LNK_CORE", 20);
this.sendSelections("GRP_FIELD_OF_WORK", "LNK_CORE", 20);
this.sendSelections("GRP_WORK_LOCATION_MELBOURNE", "LNK_CORE", 20);
this.sendSelections("GRP_WORKING_STATUS", "LNK_CORE", 20);
this.sendSelections("GRP_GENDERS", "LNK_CORE", 20);
this.askQuestions(getUser().getCode(), getUser().getCode(), "QUE_MENTOR_MENTEE_GRP");
}
} else {
this.sendSublayout("finish", "dashboard_mentormatch.json");
}
} else {
this.sendSelections("GRP_USER_ROLE", "LNK_CORE", 10);
this.askQuestions(getUser().getCode(), getUser().getCode(), "QUE_NEW_USER_PROFILE_GRP_MENTORMATCH");
}
}
}
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method sortOffersInBeg.
/* Sorting Offers of a beg as per the price, lowest price being on top */
public void sortOffersInBeg(final String begCode) {
List<BaseEntity> offers = getAllChildrens(begCode, "LNK_BEG", "OFFER");
// println("All the Offers for the load " + begCode + " are: " + offers.toString());
if (offers.size() > 1) {
Collections.sort(offers, new Comparator<BaseEntity>() {
@Override
public int compare(BaseEntity offer1, BaseEntity offer2) {
println("The price value of " + offer1.getCode() + " is " + offer1.getValue("PRI_OFFER_OWNER_PRICE_INC_GST", null));
println("The price value of " + offer2.getCode() + " is " + offer2.getValue("PRI_OFFER_OWNER_PRICE_INC_GST", null));
Money offer1Money = offer1.getValue("PRI_OFFER_OWNER_PRICE_INC_GST", null);
Money offer2Money = offer2.getValue("PRI_OFFER_OWNER_PRICE_INC_GST", null);
Number offer1MoneyValue = offer1Money.getNumber().doubleValue();
Number offer2MoneyValue = offer2Money.getNumber().doubleValue();
return ((Double) offer1MoneyValue).compareTo((Double) (offer2MoneyValue));
}
});
}
// println("The offers in the descendinng order :: " + offers.toString());
// println("The size of list is :: " + offers.size());
double maxLinkWeightValue = offers.size();
double linkWeight = 1;
for (BaseEntity be : offers) {
if (linkWeight <= maxLinkWeightValue) {
updateLink(begCode, be.getCode(), "LNK_BEG", "OFFER", linkWeight);
linkWeight++;
}
}
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method triggerEmailForJobUpdate.
public void triggerEmailForJobUpdate(String jobCode) {
println("Job is already submitted, so the job is getting edited");
List<Link> links = getLinks(jobCode, "LNK_BEG");
List<String> offerList = new ArrayList<String>();
String ownerCode = null;
if (links != null) {
for (Link link : links) {
String linkValue = link.getLinkValue();
if (linkValue != null && linkValue.equals("OFFER")) {
offerList.add(link.getTargetCode());
}
if (linkValue != null && linkValue.equals("OWNER")) {
ownerCode = link.getTargetCode();
}
}
}
String[] recipientArr = new String[offerList.size()];
int i = 0;
for (String offer : offerList) {
BaseEntity offerBe = getBaseEntityByCode(offer);
String quoterCode = offerBe.getValue("PRI_QUOTER_CODE", null);
recipientArr[i] = quoterCode;
i++;
}
println("recipient array for edit job details email :" + Arrays.toString(recipientArr));
println("owner code ::" + ownerCode);
HashMap<String, String> contextMap = new HashMap<String, String>();
contextMap.put("JOB", jobCode);
contextMap.put("OWNER", ownerCode);
sendMessage("", recipientArr, contextMap, "MSG_CH40_JOB_EDITED", "EMAIL");
}
use of life.genny.qwanda.entity.BaseEntity in project rulesservice by genny-project.
the class QRules method sendAllOwners.
// Search and send all the Owners
public void sendAllOwners(String searchBeCode) throws ClientProtocolException, IOException {
println("Get All Drivers - The search BE is :: " + searchBeCode);
BaseEntity searchBE = new BaseEntity(searchBeCode, "Get All Owners");
JsonArray columnsArray = new JsonArray();
JsonObject columns = new JsonObject();
AttributeText attributeTextImage = new AttributeText("COL_PRI_IMAGE_URL", "Image");
JsonObject image = new JsonObject();
image.put("code", "PRI_IMAGE_URL");
columnsArray.add(image);
AttributeText attributeTextUserName = new AttributeText("COL_PRI_USERNAME", "User Name");
JsonObject userName = new JsonObject();
userName.put("code", "PRI_USERNAME");
columnsArray.add(userName);
AttributeText attributeTextFirstName = new AttributeText("COL_PRI_FIRSTNAME", "First Name");
JsonObject firstName = new JsonObject();
firstName.put("code", "PRI_FIRSTNAME");
columnsArray.add(firstName);
AttributeText attributeTextLastName = new AttributeText("COL_PRI_LASTNAME", "Last Name");
JsonObject lastName = new JsonObject();
lastName.put("code", "PRI_LASTNAME");
columnsArray.add(lastName);
AttributeText attributeTextMobile = new AttributeText("COL_PRI_MOBILE", "Mobile Number");
JsonObject mobile = new JsonObject();
mobile.put("code", "PRI_MOBILE");
columnsArray.add(mobile);
AttributeText attributeTextEmail = new AttributeText("COL_PRI_EMAIL", "Email");
JsonObject email = new JsonObject();
email.put("code", "PRI_EMAIL");
columnsArray.add(email);
println("The columnsArray is ::" + columnsArray);
// Sort Attribute
AttributeText attributeTextSortFirstName = new AttributeText("SRT_PRI_FIRSTNAME", "Sort By FirstName");
AttributeBoolean attributeIsDriver = new AttributeBoolean("PRI_OWNER", "=");
// Pagination Attribute
AttributeInteger attributePageStart = new AttributeInteger("SCH_PAGE_START", "PageStart");
AttributeInteger attributePageSize = new AttributeInteger("SCH_PAGE_SIZE", "PageSize");
try {
searchBE.addAttribute(attributeTextImage, 10.0);
searchBE.addAttribute(attributeTextUserName, 9.0);
searchBE.addAttribute(attributeTextFirstName, 8.0);
searchBE.addAttribute(attributeTextLastName, 7.0);
searchBE.addAttribute(attributeTextMobile, 6.0);
searchBE.addAttribute(attributeTextEmail, 5.0);
searchBE.addAttribute(attributeTextSortFirstName, 4.0, "ASC");
searchBE.addAttribute(attributeIsDriver, 3.0, "TRUE");
searchBE.addAttribute(attributePageStart, 3.0, "0");
searchBE.addAttribute(attributePageSize, 2.0, "20");
} catch (BadDataException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// println("The search BE is :: " + JsonUtils.toJson(searchBE));
String jsonSearchBE = JsonUtils.toJson(searchBE);
String result = QwandaUtils.apiPostEntity(qwandaServiceUrl + "/qwanda/baseentitys/search", jsonSearchBE, getToken());
System.out.println("The result :: " + result);
publishData(new JsonObject(result));
sendTableViewWithHeaders("SBE_GET_ALL_OWNERS", columnsArray);
}
Aggregations