Пример #1
0
  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");
    }
  }
  private void initGuiComponents() {
    this.setTitle(props.getProperty("title.text"));
    btnConfirm = ComponentFactory.createButton(confirmAction);
    btnCancel = ComponentFactory.createButton(cancelAction);

    txfImageURL = ComponentFactory.createTextField(20);
    txfDatabaseURL = ComponentFactory.createTextField(20);
    txfUserName = ComponentFactory.createTextField(20);
    txfPassword = new JPasswordField(20);
    txfFromMemberNo = ComponentFactory.createTextField(20);
    txfToMemberNo = ComponentFactory.createTextField(20);
    txfProfileDatabase = ComponentFactory.createTextField(20);
    txfMultimediaDatabase = ComponentFactory.createTextField(20);

    libraryList =
        NliUserManagementServiceProxy.getInstance().findAllWorkGroupsByType(LibraryUnit.class);

    tblLibrary = ComponentFactory.createTable();
    initTable(libraryList);

    cmbLocations = ComponentFactory.createComboBox();
    List list = NliProfileServiceProxy.getInstance().findLocationsAtFirstLevel();
    cmbLocations.setModel(new DefaultComboBoxModel(list.toArray()));
    cmbLocations.setRenderer(
        new DefaultListCellRenderer() {
          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Location location = (Location) value;
            Component listCellRendererComponent =
                super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (location != null) setText(location.getTitle());
            return listCellRendererComponent;
          }
        });

    cbUseUniqueNameToFindUser = new JCheckBox(props.getProperty("useUniqueNameToFindUser.text"));
    cbIsOrg = new JCheckBox(props.getProperty("isOrg.text"));
    cbIsUniversity = new JCheckBox(props.getProperty("isUniversity.text"));
    cbUseProfileSetting = new JCheckBox(props.getProperty("useProfileSetting.text"));

    txfDatabaseURL.setText(
        "jdbc:sqlserver://192.168.1.17:1433;databaseName=ParsProfile_ParsAzarakhsh;integratedSecurity=false");
    txfUserName.setText("digilibadminlogin");
    txfPassword.setText("manager");
    txfImageURL.setText("F:\\pimage");
    txfFromMemberNo.setText("1");
    txfToMemberNo.setText("10");
    txfProfileDatabase.setText("ParsLibrary_ParsAzarakhsh");
    txfMultimediaDatabase.setText("ParsMultimedia_ParsAzarakhsh");
  }
  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;
  }
  private void initTable(List list) {
    final int rowCount = list.size();
    String columnNames[] = {
      props.getProperty("library.text"), props.getProperty("loanGroup.text"), ""
    };
    String dataValues[][] = new String[list.size()][1];
    for (int i = 0; i < list.size(); i++) {
      dataValues[i][0] = ((LibraryUnit) list.get(i)).getName();
    }

    List<JComboBox> lstComboBox = new ArrayList<JComboBox>();
    editors = new ArrayList<TableCellEditor>(list.size());
    for (int i = 0; i < list.size(); i++) {
      List<LoanGroup> loanGrouplist =
          NliProfileServiceProxy.getInstance()
              .findAllLoanGroupsByLibrary((LibraryUnit) list.get(i));
      lstComboBox.add(new JComboBox());
      String[] strList = new String[loanGrouplist.size()];
      for (int j = 0; j < loanGrouplist.size(); j++)
        strList[j] = loanGrouplist.get(j).getFarsiTitle();

      lstComboBox.get(i).setModel(new DefaultComboBoxModel(strList));
      DefaultCellEditor dce = new DefaultCellEditor(lstComboBox.get(i));
      editors.add(dce);
    }
    DefaultTableModel model = new DefaultTableModel(dataValues, columnNames);
    tblLibrary =
        new JTable(model) {
          public TableCellEditor getCellEditor(int row, int column) {
            int modelColumn = convertColumnIndexToModel(column);

            if (modelColumn == 1 && row < rowCount) return editors.get(row);
            else return super.getCellEditor(row, column);
          }
        };

    TableColumn tc = tblLibrary.getColumnModel().getColumn(2);
    tc.setCellEditor(tblLibrary.getDefaultEditor(Boolean.class));
    tc.setCellRenderer(tblLibrary.getDefaultRenderer(Boolean.class));
  }
Пример #5
0
  public String doSave() {

    try {

      this.address.setLocation((Location) JsfUtils.getFromPageFlow("selectedLocation"));
      service.saveObjectService(this.address);

    } catch (Exception exp) {

      Util.processException(exp);
      return "";

    } finally {

      reset();
    }

    ////// If Request come from endUser the navigation should be changed....
    if (JsfUtils.getFromPageFlow("endUser") != null) return "endUser_goAddress";

    return Constants.USERINFO_ADDRESS_GOTO_VIEW;
  }
/**
 * 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();
  }
Пример #8
0
/**
 * Created by IntelliJ IDEA. User: Sadrinia Date: Sep 7, 2008 Time: 8:23:24 AM To change this
 * template use File | Settings | File Templates.
 */
public class CreateAddressBean extends BaseBean {

  private ProfileAddress address = new ProfileAddress();
  private NliProfileServiceProxy service = NliProfileServiceProxy.getInstance();
  private String selectedCountry;
  private String selectedProvince;
  private String selectedState;

  public CreateAddressBean() {}

  public ProfileAddress getAddress() {

    ProfilePerson person = (ProfilePerson) JsfUtils.getFromSession("profilePerson");

    if (person != null) {
      this.address.setProfilePerson(person);
    }

    return address;
  }

  public void setAddress(ProfileAddress address) {
    this.address = address;
  }

  public String getSelectedCountry() {
    return selectedCountry;
  }

  public void setSelectedCountry(String selectedCountry) {
    this.selectedCountry = selectedCountry;
  }

  public String getSelectedProvince() {
    return selectedProvince;
  }

  public void setSelectedProvince(String selectedProvince) {
    this.selectedProvince = selectedProvince;
  }

  public String getSelectedState() {
    return selectedState;
  }

  public void setSelectedState(String selectedState) {
    this.selectedState = selectedState;
  }

  public String goSelectLocation() {
    return Constants.SELECT_LOCATION;
  }

  public void returnFromLocation(ReturnEvent event) {

    Location location = (Location) event.getReturnParameters().get("location");
    //  this.address.setLocation(location);
    JsfUtils.storeOnPageFlow("selectedLocation", location);
  }

  public String doSave() {

    try {

      this.address.setLocation((Location) JsfUtils.getFromPageFlow("selectedLocation"));
      service.saveObjectService(this.address);

    } catch (Exception exp) {

      Util.processException(exp);
      return "";

    } finally {

      reset();
    }

    ////// If Request come from endUser the navigation should be changed....
    if (JsfUtils.getFromPageFlow("endUser") != null) return "endUser_goAddress";

    return Constants.USERINFO_ADDRESS_GOTO_VIEW;
  }

  public String doCancel() {

    ////// If Request come from endUser the navigation should be changed....
    if (JsfUtils.getFromPageFlow("endUser") != null) return "endUser_goAddress";

    return Constants.USERINFO_ADDRESS_GOTO_VIEW;
  }

  private void reset() {

    this.address = new ProfileAddress();
  }
}
Пример #9
0
/**
 * 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;
  }
}
  private boolean isValidData() {
    errorMessage = props.getProperty("fill-field.text");
    if (StringUtils.isEmpty(txfDatabaseURL.getText())) {
      errorMessage = errorMessage + "\n " + props.getProperty("database-url.text");
      txfDatabaseURL.requestFocus();
      return false;
    }
    if (StringUtils.isEmpty(txfProfileDatabase.getText())) {
      errorMessage = errorMessage + "\n " + props.getProperty("profile-database.text");
      txfDatabaseURL.requestFocus();
      return false;
    }
    if (StringUtils.isEmpty(txfImageURL.getText())) {
      errorMessage = errorMessage + "\n " + props.getProperty("image-url.text");
      txfImageURL.requestFocus();
      return false;
    }
    if (StringUtils.isEmpty(txfFromMemberNo.getText())) {
      errorMessage = errorMessage + "\n " + props.getProperty("from-member-no.text");
      txfFromMemberNo.requestFocus();
      return false;
    }
    if (StringUtils.isEmpty(txfToMemberNo.getText())) {
      errorMessage = errorMessage + "\n " + props.getProperty("to-membership-no.text");
      txfToMemberNo.requestFocus();
      return false;
    }
    if (StringUtils.isEmpty(txfUserName.getText())) {
      errorMessage = errorMessage + "\n " + props.getProperty("username.text");
      txfUserName.requestFocus();
      return false;
    }
    if (StringUtils.isEmpty(txfPassword.getText())) {
      errorMessage = errorMessage + "\n " + props.getProperty("password.text");
      txfPassword.requestFocus();
      return false;
    }

    librarySelectedList = new ArrayList<LibraryUnit>();
    loanGroupSelectedList = new ArrayList<LoanGroup>();
    for (int intRow = 0; tblLibrary.getRowCount() > intRow; intRow++) {
      if ((Boolean) tblLibrary.getValueAt(intRow, 2) == Boolean.TRUE) {
        if (((String) tblLibrary.getValueAt(intRow, 1)) != null) {
          List<LoanGroup> loanGroup =
              NliProfileServiceProxy.getInstance()
                  .findAllLoanGroupsByCodeTitleLibrary(
                      "",
                      (String) tblLibrary.getValueAt(intRow, 1),
                      "",
                      (LibraryUnit) libraryList.get(intRow),
                      0,
                      10000,
                      new GridFilter())
                  .getResult();

          if (loanGroup.get(0).getLoanGroupSetting() != null) {
            loanGroupSelectedList.add(loanGroup.get(0));
            librarySelectedList.add((LibraryUnit) libraryList.get(intRow));
          } else {
            errorMessage =
                props.getProperty("LoanGroupSetting.text")
                    + " : "
                    + ((LibraryUnit) libraryList.get(intRow)).getFarsiItemName();
            return false;
          }
        } else {
          errorMessage =
              props.getProperty("LoanGroupSetting.text")
                  + " : "
                  + ((LibraryUnit) libraryList.get(intRow)).getFarsiItemName();
          return false;
        }
      }
    }

    return true;
  }