public DisplayLegalMemberBean() { GeneralProfile profile = (GeneralProfile) RequestContext.getCurrentInstance().getPageFlowScope().get("generalProfile"); if (profile != null) { this.generalProfile = profile; this.legalPerson = NliProfileServiceProxy.getInstance() .findLegalProfilePersonByProfilePersonId( profile.getRegisterationUnit().getProfilePerson().getId()); this.unitStr = this.generalProfile.getRegisterationUnit().getWorkGroup().getName(); if (this.generalProfile instanceof LoanProfile) { this.selectUnitLabel = JsfUtils.getStringFromBundle("library"); this.selectedRequestType = UserManagementDataMap.Request_type.SafeKeeping.getValue(); } else if (this.generalProfile instanceof ProberProfile) { this.selectUnitLabel = JsfUtils.getStringFromBundle("unit"); this.selectedRequestType = UserManagementDataMap.Request_type.Scholar.getValue(); } else { this.selectUnitLabel = JsfUtils.getStringFromBundle("library"); this.selectedRequestType = UserManagementDataMap.Request_type.Exchange.getValue(); } this.unitStr = this.generalProfile.getRegisterationUnit().getWorkGroup() == null ? " " : this.generalProfile.getRegisterationUnit().getWorkGroup().getName(); if (this.legalPerson.getImage() != null && this.legalPerson.getImage().length > 0) this.imageSource = JsfUtils.getVirtualImageUrl(this.legalPerson.getImage(), "personImage"); } }
/** * Created by IntelliJ IDEA. User: Sadrinia Date: Aug 24, 2008 Time: 4:06:31 PM To change this * template use File | Settings | File Templates. */ public class RealPersonMembershipBean extends BaseBean { public static String MEMBER_PROFILE_TYPE = "profile_type"; private static SelectItem[] requestTypes = new SelectItem[] { new SelectItem( UserManagementDataMap.Request_type.SafeKeeping.getValue(), JsfUtils.getStringFromBundle( UserManagementDataMap.Request_type.SafeKeeping.getMessageId())), new SelectItem( UserManagementDataMap.Request_type.Exchange.getValue(), JsfUtils.getStringFromBundle( UserManagementDataMap.Request_type.Exchange.getMessageId())), new SelectItem( UserManagementDataMap.Request_type.Scholar.getValue(), JsfUtils.getStringFromBundle(UserManagementDataMap.Request_type.Scholar.getMessageId())) }; private static SelectItem[] gender = new SelectItem[] { new SelectItem(Gender.Male.getValue(), JsfUtils.getStringFromBundle("male")), new SelectItem(Gender.Female.getValue(), JsfUtils.getStringFromBundle("female")) }; private static SelectItem[] educationTypes; private String imageSource = "/images/defaultPic.gif"; private int selectedRequestType; private int counter = 0; private AbstractWorkGroup selectedUnitOrLib; private NliProfileServiceProxy service = NliProfileServiceProxy.getInstance(); private RealProfilePerson realPerson = new RealProfilePerson(); private String membershipNumber; private String email; private String userName; private String password; private String confirmPassword; private Nationality nationality; public RealPersonMembershipBean() {} public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getConfirmPassword() { return confirmPassword; } public void setConfirmPassword(String confirmPassword) { this.confirmPassword = confirmPassword; } public Nationality getNationality() { return nationality; } public void setNationality(Nationality nationality) { this.nationality = nationality; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public SelectItem[] getRequestTypes() { return requestTypes; } public void setRequestTypes(SelectItem[] requestTypes) { RealPersonMembershipBean.requestTypes = requestTypes; } public SelectItem[] getGender() { return gender; } public void setGender(SelectItem[] gender) { RealPersonMembershipBean.gender = gender; } public int getSelectedRequestType() { return selectedRequestType; } public void setSelectedRequestType(int selectedRequestType) { this.selectedRequestType = selectedRequestType; } public String getImageSource() { byte[] picture = (byte[]) this.realPerson.getImage(); if (picture != null) { this.imageSource = JsfUtils.getVirtualImageUrl(picture, "realMember" + (counter++)); } return imageSource; } public void setImageSource(String imageSource) { this.imageSource = imageSource; } public RealProfilePerson getRealPerson() { return realPerson; } public void setRealPerson(RealProfilePerson realPerson) { this.realPerson = realPerson; } public SelectItem[] getEducationTypes() { if (educationTypes == null) { List<BaseInfo> list = service.findAllBaseInfo(EducationClass.class); educationTypes = new SelectItem[list.size()]; int i = 0; for (BaseInfo temp : list) { EducationClass education = (EducationClass) temp; educationTypes[i++] = new SelectItem(education, education.getTitle()); } } return educationTypes; } public void setEducationTypes(SelectItem[] educationTypes) { RealPersonMembershipBean.educationTypes = educationTypes; } public void returnFromSelectLibrary(ReturnEvent event) { JsfUtils.removeFromPageFlow(MEMBER_PROFILE_TYPE); AbstractWorkGroup selectedUnitLib = (AbstractWorkGroup) event.getReturnParameters().get(UserManagementConstants.SELECTED_UNIT_LIB_OBJECT_NAME); if (selectedUnitLib == null) return; this.selectedUnitOrLib = selectedUnitLib; } public void uploadAndReturn(ReturnEvent event) { if (event.getReturnValue() == null) return; String imageType = (String) event.getReturnValue(); byte[] picture = (byte[]) event.getReturnParameters().get("picture"); if (picture != null) { this.realPerson.setImage(picture); this.imageSource = JsfUtils.getVirtualImageUrl(picture, "realPic" + (counter++)); } } public String doSave() { try { if (StringUtils.isEmpty(membershipNumber)) { ErrorReportingUtils.getInstance().reportErrors("membership-number-is-missing"); return ""; } if (selectedUnitOrLib instanceof LibraryUnit && selectedRequestType == UserManagementDataMap.Request_type.Scholar.getValue()) { ErrorReportingUtils.getInstance().reportErrors("select-valid-unit-library"); return ""; } if (selectedUnitOrLib instanceof OrganizationUnit && selectedRequestType != UserManagementDataMap.Request_type.Scholar.getValue()) { ErrorReportingUtils.getInstance().reportErrors("select-valid-unit-library"); return ""; } if (this.realPerson.getProfile() == null) this.realPerson.setProfile(new ProfilePerson()); ProfilePerson profile = this.realPerson.getProfile(); profile.setNationality(getNationality()); profile.setTitle(this.realPerson.getFirstName() + " " + this.realPerson.getLastName()); profile.setMembershipNo(this.membershipNumber); profile.setUserType(ProfilePerson.BOTH); profile.setRegisterType(Byte.valueOf(JsfUtils.getFromPageFlow("registerType").toString())); profile.setUserName(this.userName); profile.setPassword(WebApplication.getInstance().encodePassword(this.password)); profile.setEmail(this.email); this.realPerson.setUniqeName(this.realPerson.createPersonIdentifierKey()); if (this.selectedRequestType == UserManagementDataMap.Request_type.SafeKeeping.getValue()) { service.saveRealLoanProfileRequest(this.realPerson, this.selectedUnitOrLib); } else if (this.selectedRequestType == UserManagementDataMap.Request_type.Exchange.getValue()) { service.saveRealExchangeProfileRequest(this.realPerson, this.selectedUnitOrLib); } else if (this.selectedRequestType == UserManagementDataMap.Request_type.Scholar.getValue()) { service.saveRealProberProfileRequest(this.realPerson, this.selectedUnitOrLib); } this.realPerson = service.findRealProfilePersonByProfilePersonId(profile.getId()); NliMailDefinitionServiceProxy.getInstance() .sendMessage( this.email, JsfUtils.getStringFromBundle("userNamePassEmailSubject"), "body", Constants.UTF8); Map map = RequestContext.getCurrentInstance().getPageFlowScope(); map.put("realPerson", this.realPerson); map.put("selectedUnit", this.selectedUnitOrLib); map.put("requestType", this.selectedRequestType); } catch (DuplicateMembershipNoException exp) { ErrorReportingUtils.getInstance() .reportErrors(JsfUtils.getStringFromBundle("duplicateMembershipNoException")); return ""; } catch (DuplicateMemberException e) { ErrorReportingUtils.getInstance() .reportErrors(JsfUtils.getStringFromBundle("duplicateMemberException")); return ""; } catch (DuplicateNationalCodeException e) { ErrorReportingUtils.getInstance() .reportErrors(JsfUtils.getStringFromBundle("duplicateNationalCodeException")); return ""; } catch (DuplicateUserNameException e) { ErrorReportingUtils.getInstance() .reportErrors(JsfUtils.getStringFromBundle("duplicateUsernameException")); return ""; } catch (DuplicateLoanProfileException exp) { return processException(exp, 0); } catch (DuplicateExchangeProfileException exp) { return processException(exp, 1); } catch (DuplicateProberProfileException exp) { return processException(exp, 2); } catch (Exception exp) { exp.printStackTrace(); return ""; } finally { } return goBackList(); } public String doCancel() { return goBackList(); } public String selectOneLibrary() { JsfUtils.storeOnPageFlow(MEMBER_PROFILE_TYPE, Integer.valueOf(selectedRequestType)); return Constants.GENERAL_SELECT_UNIT; } public String goUpload() { return Constants.GENERAL_File_UPLOAD; } private void resetBean() { this.imageSource = "/images/defaultPic.gif"; this.counter = 0; this.realPerson = new RealProfilePerson(); this.selectedUnitOrLib = null; this.selectedRequestType = 0; this.email = ""; this.userName = ""; this.password = ""; this.confirmPassword = ""; this.nationality = null; this.membershipNumber = null; } private String processException(Exception exp, int flag) { String message = ""; String type = ""; Date requestDate = null; Date reviewDate = null; switch (flag) { case 0: LoanProfile loanProfile = ((DuplicateLoanProfileException) exp).getLoanProfile(); type = loanProfile.getProfileState().getCode(); requestDate = loanProfile.getRequestDate(); reviewDate = loanProfile.getReviewDate(); break; case 1: ExchangeProfile exchangeProfile = ((DuplicateExchangeProfileException) exp).getExchangeProfile(); type = exchangeProfile.getProfileState().getCode(); requestDate = exchangeProfile.getRequestDate(); reviewDate = exchangeProfile.getReviewDate(); break; case 2: ProberProfile proberProfile = ((DuplicateProberProfileException) exp).getProberProfile(); type = proberProfile.getProfileState().getCode(); requestDate = proberProfile.getRequestDate(); reviewDate = proberProfile.getReviewDate(); break; } if (type.equalsIgnoreCase(ProfileState.NEW_REQUEST_STATE)) { message = JsfUtils.getStringFromBundle("yourRequestForUnit") + " " + JsfUtils.getStringFromBundle(this.selectedUnitOrLib.getName()) + JsfUtils.getStringFromBundle("andMembershipAt") + " " + JsfUtils.getStringFromBundle( UserManagementDataMap.convertRequestType(this.selectedRequestType)) + JsfUtils.getStringFromBundle("inDate") + " " + String.valueOf(requestDate) + JsfUtils.getStringFromBundle("isRegisteredAndCurrentlyIsUnderProcessing"); } else if (type.equalsIgnoreCase(ProfileState.CONFIRMED_REQUEST_STATE)) { message = JsfUtils.getStringFromBundle("yourRequestForUnit") + " " + JsfUtils.getStringFromBundle(this.selectedUnitOrLib.getName()) + JsfUtils.getStringFromBundle("andMembershipAt") + " " + JsfUtils.getStringFromBundle( UserManagementDataMap.convertRequestType(this.selectedRequestType)) + JsfUtils.getStringFromBundle("inDate") + " " + String.valueOf(requestDate) + JsfUtils.getStringFromBundle("isRegisteredAndInDate") + " " + String.valueOf(reviewDate) + JsfUtils.getStringFromBundle("havebeenRejected") + JsfUtils.getStringFromBundle("wouldYouLikeToSubmitANewRequest"); } else if (type.equalsIgnoreCase(ProfileState.REJECTED_REQUEST_STATE)) { message = JsfUtils.getStringFromBundle("yourRequestForUnit") + " " + JsfUtils.getStringFromBundle(this.selectedUnitOrLib.getName()) + JsfUtils.getStringFromBundle("andMembershipAt") + " " + JsfUtils.getStringFromBundle( UserManagementDataMap.convertRequestType(this.selectedRequestType)) + JsfUtils.getStringFromBundle("inDate") + " " + String.valueOf(requestDate) + JsfUtils.getStringFromBundle("isConfirmed"); } else assert true : "Invalid Profile State!!!"; FacesContext context = FacesContext.getCurrentInstance(); ViewHandler viewHandler = context.getApplication().getViewHandler(); UIViewRoot dialog = viewHandler.createView(context, "/usermanagement/generalPages/showMessagePage.jspx"); Map properties = new HashMap(); properties.put("width", new Integer(300)); properties.put("height", new Integer(400)); Map params = new HashMap(); params.put(UserManagementConstants.DIALOG_MESSAGE, message); RequestContext requestContext = RequestContext.getCurrentInstance(); requestContext.launchDialog(dialog, params, null, true, properties); return ""; } public void updateSelectedRequestType(ValueChangeEvent vce) { selectedRequestType = (Integer) vce.getNewValue(); } private String goBackList() { String action; byte type = (Byte) JsfUtils.getFromPageFlow("registerType"); if (ProfilePerson.REAL == type) action = Constants.REAL_PROFILE_DISPLAY; else action = Constants.STAFF_PROFILE_DISPLAY; resetBean(); JsfUtils.removeFromPageFlow("registerType"); return action; } public String getMembershipNumber() { return membershipNumber; } public void setMembershipNumber(String membershipNumber) { this.membershipNumber = membershipNumber; } }
public String doSave() { try { if (StringUtils.isEmpty(membershipNumber)) { ErrorReportingUtils.getInstance().reportErrors("membership-number-is-missing"); return ""; } if (selectedUnitOrLib instanceof LibraryUnit && selectedRequestType == UserManagementDataMap.Request_type.Scholar.getValue()) { ErrorReportingUtils.getInstance().reportErrors("select-valid-unit-library"); return ""; } if (selectedUnitOrLib instanceof OrganizationUnit && selectedRequestType != UserManagementDataMap.Request_type.Scholar.getValue()) { ErrorReportingUtils.getInstance().reportErrors("select-valid-unit-library"); return ""; } if (this.realPerson.getProfile() == null) this.realPerson.setProfile(new ProfilePerson()); ProfilePerson profile = this.realPerson.getProfile(); profile.setNationality(getNationality()); profile.setTitle(this.realPerson.getFirstName() + " " + this.realPerson.getLastName()); profile.setMembershipNo(this.membershipNumber); profile.setUserType(ProfilePerson.BOTH); profile.setRegisterType(Byte.valueOf(JsfUtils.getFromPageFlow("registerType").toString())); profile.setUserName(this.userName); profile.setPassword(WebApplication.getInstance().encodePassword(this.password)); profile.setEmail(this.email); this.realPerson.setUniqeName(this.realPerson.createPersonIdentifierKey()); if (this.selectedRequestType == UserManagementDataMap.Request_type.SafeKeeping.getValue()) { service.saveRealLoanProfileRequest(this.realPerson, this.selectedUnitOrLib); } else if (this.selectedRequestType == UserManagementDataMap.Request_type.Exchange.getValue()) { service.saveRealExchangeProfileRequest(this.realPerson, this.selectedUnitOrLib); } else if (this.selectedRequestType == UserManagementDataMap.Request_type.Scholar.getValue()) { service.saveRealProberProfileRequest(this.realPerson, this.selectedUnitOrLib); } this.realPerson = service.findRealProfilePersonByProfilePersonId(profile.getId()); NliMailDefinitionServiceProxy.getInstance() .sendMessage( this.email, JsfUtils.getStringFromBundle("userNamePassEmailSubject"), "body", Constants.UTF8); Map map = RequestContext.getCurrentInstance().getPageFlowScope(); map.put("realPerson", this.realPerson); map.put("selectedUnit", this.selectedUnitOrLib); map.put("requestType", this.selectedRequestType); } catch (DuplicateMembershipNoException exp) { ErrorReportingUtils.getInstance() .reportErrors(JsfUtils.getStringFromBundle("duplicateMembershipNoException")); return ""; } catch (DuplicateMemberException e) { ErrorReportingUtils.getInstance() .reportErrors(JsfUtils.getStringFromBundle("duplicateMemberException")); return ""; } catch (DuplicateNationalCodeException e) { ErrorReportingUtils.getInstance() .reportErrors(JsfUtils.getStringFromBundle("duplicateNationalCodeException")); return ""; } catch (DuplicateUserNameException e) { ErrorReportingUtils.getInstance() .reportErrors(JsfUtils.getStringFromBundle("duplicateUsernameException")); return ""; } catch (DuplicateLoanProfileException exp) { return processException(exp, 0); } catch (DuplicateExchangeProfileException exp) { return processException(exp, 1); } catch (DuplicateProberProfileException exp) { return processException(exp, 2); } catch (Exception exp) { exp.printStackTrace(); return ""; } finally { } return goBackList(); }
/** * Created by IntelliJ IDEA. User: Sadrinia Date: Oct 5, 2008 Time: 1:29:57 PM To change this * template use File | Settings | File Templates. */ public class DisplayLegalMemberBean extends BaseBean { private static SelectItem[] requestTypes = new SelectItem[] { new SelectItem( UserManagementDataMap.Request_type.SafeKeeping.getValue(), JsfUtils.getStringFromBundle( UserManagementDataMap.Request_type.SafeKeeping.getMessageId())), new SelectItem( UserManagementDataMap.Request_type.Exchange.getValue(), JsfUtils.getStringFromBundle( UserManagementDataMap.Request_type.Exchange.getMessageId())), new SelectItem( UserManagementDataMap.Request_type.Scholar.getValue(), JsfUtils.getStringFromBundle(UserManagementDataMap.Request_type.Scholar.getMessageId())) }; private String imageSource = "/images/defaultPic.gif"; private int selectedRequestType; private int counter = 0; private AbstractWorkGroup selectedWorkGroup; private NliProfileServiceIF service = NliProfileServiceProxy.getInstance(); private LegalProfilePerson legalPerson; private GeneralProfile generalProfile; private String unitStr; private String selectUnitLabel; private JSFTable addressList; private JSFTable contactList; private JSFTable contactPartyList; private JSFTable descriptionList; public DisplayLegalMemberBean() { GeneralProfile profile = (GeneralProfile) RequestContext.getCurrentInstance().getPageFlowScope().get("generalProfile"); if (profile != null) { this.generalProfile = profile; this.legalPerson = NliProfileServiceProxy.getInstance() .findLegalProfilePersonByProfilePersonId( profile.getRegisterationUnit().getProfilePerson().getId()); this.unitStr = this.generalProfile.getRegisterationUnit().getWorkGroup().getName(); if (this.generalProfile instanceof LoanProfile) { this.selectUnitLabel = JsfUtils.getStringFromBundle("library"); this.selectedRequestType = UserManagementDataMap.Request_type.SafeKeeping.getValue(); } else if (this.generalProfile instanceof ProberProfile) { this.selectUnitLabel = JsfUtils.getStringFromBundle("unit"); this.selectedRequestType = UserManagementDataMap.Request_type.Scholar.getValue(); } else { this.selectUnitLabel = JsfUtils.getStringFromBundle("library"); this.selectedRequestType = UserManagementDataMap.Request_type.Exchange.getValue(); } this.unitStr = this.generalProfile.getRegisterationUnit().getWorkGroup() == null ? " " : this.generalProfile.getRegisterationUnit().getWorkGroup().getName(); if (this.legalPerson.getImage() != null && this.legalPerson.getImage().length > 0) this.imageSource = JsfUtils.getVirtualImageUrl(this.legalPerson.getImage(), "personImage"); } } public SelectItem[] getRequestTypes() { return requestTypes; } public String getImageSource() { return imageSource; } public void setImageSource(String imageSource) { this.imageSource = imageSource; } public int getSelectedRequestType() { return selectedRequestType; } public void setSelectedRequestType(int selectedRequestType) { this.selectedRequestType = selectedRequestType; } public int getCounter() { return counter; } public void setCounter(int counter) { this.counter = counter; } public String getUnitStr() { return unitStr; } public void setUnitStr(String unitStr) { this.unitStr = unitStr; } public String getSelectUnitLabel() { return selectUnitLabel; } public void setSelectUnitLabel(String selectUnitLabel) { this.selectUnitLabel = selectUnitLabel; } public AbstractWorkGroup getSelectedWorkGroup() { return selectedWorkGroup; } public void setSelectedWorkGroup(AbstractWorkGroup selectedWorkGroup) { this.selectedWorkGroup = selectedWorkGroup; } public LegalProfilePerson getLegalPerson() { return legalPerson; } public void setLegalPerson(LegalProfilePerson legalPerson) { this.legalPerson = legalPerson; } public GeneralProfile getGeneralProfile() { return generalProfile; } public void setGeneralProfile(GeneralProfile generalProfile) { this.generalProfile = generalProfile; } public JSFTable getAddressList() { if (this.addressList == null) { ProfileAddressRowData.ProfileAddressDataFetcher fetcher = new ProfileAddressRowData.ProfileAddressDataFetcher( this.legalPerson.getProfile(), JsfUtils.getInstance().getLocale()); this.addressList = Util.makeTableFromRowData(ProfileAddressRowData.class, fetcher, 100); } return addressList; } public void setAddressList(JSFTable addressList) { this.addressList = addressList; } public JSFTable getContactList() { if (this.contactList == null) { ProfileContactRowData.ProfileContactDataFetcher fetcher = new ProfileContactRowData.ProfileContactDataFetcher( this.legalPerson.getProfile(), JsfUtils.getInstance().getLocale()); this.contactList = Util.makeTableFromRowData(ProfileContactRowData.class, fetcher, 100); } return contactList; } public void setContactList(JSFTable contactList) { this.contactList = contactList; } public JSFTable getDescriptionList() { if (this.descriptionList == null) { ProfileAttachmentRowData.ProfileAttachmentDataFetcher fetcher = new ProfileAttachmentRowData.ProfileAttachmentDataFetcher( this.legalPerson.getProfile(), JsfUtils.getInstance().getLocale()); this.descriptionList = Util.makeTableFromRowData(ProfileAttachmentRowData.class, fetcher, 100); } return descriptionList; } public void setDescriptionList(JSFTable descriptionList) { this.descriptionList = descriptionList; } public JSFTable getContactPartyList() { if (this.contactPartyList == null) { LegalContactRowData.LegalContactDataFetcher fetcher = new LegalContactRowData.LegalContactDataFetcher( this.legalPerson, JsfUtils.getInstance().getLocale()); this.contactPartyList = Util.makeTableFromRowData(LegalContactRowData.class, fetcher, 100); } return contactPartyList; } public void setContactPartyList(JSFTable contactPartyList) { this.contactPartyList = contactPartyList; } public String doCancel() { // JsfUtils.clearPageFlow(); JsfUtils.deleteGridDataFromPageFlow(); return Constants.MEMBERPROFILE_GO_BACK_LEGAL; } }