private void checkManualSearchUserInput(AbstractWrappedCallbackContext<Inbox> ctx) {
Inbox inbox = ctx.getWrappedBusinessObject();
CommonTextProviderLocal textProvider = new CommonTextProvider();
textProvider.initializeInboxResourceBundle(ctx.getLocale());
// If the search help fields is not empty
if (StringUtils.isNotBlank(inbox.getSubstitution_NewRule_User())) {
// First remove privious validation messages
removeOldValidationResult(ctx.getBusinessObject().getValidationResult(), InboxFieldsEnum.SUBSTITUTION_NEWRULE_USER.getName());
// Get the attribute of the search help fields
Attribute attr = ctx.getBusinessObject().getAttribute(InboxFieldsEnum.SUBSTITUTION_NEWRULE_USER.getName());
// Create a transient BO of the search help dialog (this is necessary since there is no actual search help opened within the UI)
if (attr.getChildBusinessObjects() == null || attr.getChildBusinessObjects().size() == 0) {
BusinessObjectMetaData bomd = attr.getAttributeMetaData().getBusinessObjectMetaData();
BusinessObjectMetaData childBOMD = bomd.getChildBusinessObjectMetaData(attr.getTechnicalName());
BusinessObject childBo;
try {
childBo = BORemoteControl.createChildBO(attr.getOwner(), childBOMD.getTechnicalName());
childBo.setLifecyleState(BusinessObjectLifecycle.TRANSIENT);
attr.getOwner().addBusinessObjectChild(childBo, attr.getTechnicalName());
} catch (BOMetaDataNotFoundException e) {
SimpleLogger.trace(Severity.ERROR, logger, "Error when creating child bo inside checkManualSearchUserInput()", e);
}
}
//The search help BO
Substitution_NewRule_User sh = new Substitution_NewRule_User(attr.getChildBusinessObjects().get(0));
// Separate first and last name from manual user input
String[] nameArray = StringUtils.splitByWholeSeparator(inbox.getSubstitution_NewRule_User(), " ");
String lastname = nameArray[nameArray.length - 1];
String firstname = "";
for (int i = 0; i < nameArray.length - 1; i++) {
firstname = firstname + " " + nameArray[i];
}
// Fill first and last name in search help BO
sh.setSubstitution_NewUser_FirstName(firstname);
sh.setSubstitution_NewUser_LastName(lastname);
// Execute user search
searchForUsers(ctx);
// Evaluate result
// If there are zero hits filled within the result table -> validation message
if (sh.getSubstitution_NewUser_Result().size() == 0) {
inbox.addValidationError(InboxFieldsEnum.SUBSTITUTION_NEWRULE_USER.getName(), textProvider.getInboxText(InboxText.INBOX_RULE_USERNOTFOUND));
// If there is more than one hit filled within the result table -> validation message, multiple user found
} else if (sh.getSubstitution_NewUser_Result().size() > 1) {
inbox.addValidationError(InboxFieldsEnum.SUBSTITUTION_NEWRULE_USER.getName(), textProvider.getInboxText(InboxText.INBOX_RULE_MULTIPLEUSERSFOUND));
// If there is exactly one hit filled within the result table -> distinct user could be found and will be used for further processing
} else {
User selectedUser = userProvider.getUserByUniqueName(sh.getSubstitution_NewUser_Result().get(0).getSubstitution_NewUser_ResultUser());
inbox.setSubstitution_NewRule_User(selectedUser.getFullname());
inbox.setSubstitution_NewRule_UserView(selectedUser.getLdapID());
}
}
}
if (InboxActionEnum.SELECT_USER.matches(event.getEventName())) {
// Initialize the result table BO with the selected BO in the event object
Substitution_NewUser_Result userBo = new Substitution_NewUser_Result(event.getSelectedBusinessObject());
// Set the result to your respective search help field
User selectedUser = userProvider.getUserByUniqueName(userBo.getSubstitution_NewUser_ResultUser());
inboxBo.setSubstitution_NewRule_User(selectedUser.getFullname());
inboxBo.setSubstitution_NewRule_UserView(userBo.getSubstitution_NewUser_ResultUser());
// Remove old validation messages
removeOldValidationResult(ctx.getBusinessObject().getValidationResult(), InboxFieldsEnum.SUBSTITUTION_NEWRULE_USER.getName());
// Close the search help dialog
SimpleOption op = new SimpleOption(null, true, null);
op.setCloseDialog(true);
return op;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
16 | |
11 | |
8 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |