public String checkEmployer() {

    User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();

    //	employerSearchList = searchService.findAllEmployer(search);
    employerSearchList1 = searchService.findAllEmployerList(search);
    profiles = searchService.findListOfEmployeeProfiles(profile, user.getId());
    if (profiles.size() != 0) {
      currentProfile = employeeProfileService.getDefaultProfileForUser(user.getId());
      contactTypesList = privacygroupService.loadAllPrivacyGroupsOfUser(currentProfile.getId());
    }
    Iterator<Employer> it = employerSearchList1.iterator();
    try {
      while (it.hasNext()) {
        // Get element
        emplrProfileImages = it.next();

        if (emplrProfileImages.getPicture() != null) {
          image = (String) emplrProfileImages.getAmazonFileURL().get(0);
        }
        if (emplrProfileImages.getResizedMidPicture() != null) {
          resizedMidPicture = (String) emplrProfileImages.getAmazonFileURL().get(1);
          emplrProfileImages.setResizedMidPicture(resizedMidPicture);
        }
        if (emplrProfileImages.getResizedMinPicture() != null) {
          resizedMinPicture = (String) emplrProfileImages.getAmazonFileURL().get(2);
          emplrProfileImages.setResizedMinPicture(resizedMinPicture);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return "success";
  }
  public String searchAllEmployers() {
    LOGGER.info("Entered searchAllEmployers");

    User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();

    employerSearchList = searchService.findListOfEmployers(employerName, employerLocation);

    profiles = searchService.findListOfEmployeeProfiles(profile, user.getId());

    if (profiles.size() != 0) {
      currentProfile = employeeProfileService.getDefaultProfileForUser(user.getId());
      contactTypesList = privacygroupService.loadAllPrivacyGroupsOfUser(currentProfile.getId());
    }
    return "success";
  }
  public String listAllProfileFeedbacks() {

    user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    allProfilesFeedback = feedbackService.findAllProfilesFeedback(feedback, user.getId());
    allProfilesFeedbackCount = allProfilesFeedback.size();

    return "success";
  }
示例#4
0
  public String validateEmailForEdit() {
    LOGGER.info("Inside validateEmailForEdit");
    User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();

    String result = "success";
    users = employeeAccountService.findByEmailValidationForEdit(getEmail());

    Iterator it = users.iterator();

    while (it.hasNext()) {
      User emailOwner = (User) it.next();

      if (user.getId() == emailOwner.getId()) {
        result = "success";
      } else {
        result = "failure";
      }
    }
    return result;
  }
示例#5
0
  public int ageCalculator(User user) {

    /*
     * String temp = user.getDob().toString(); System.out.println("year : " +
     * user.getDob()); int index = temp.lastIndexOf("T") + 1; String strAge =
     * temp.substring(index).trim(); LOGGER.info("year : " + strAge); year =
     * Integer.parseInt(strAge); Calendar cd = Calendar.getInstance(); long
     * yr = cd.get(Calendar.YEAR); int age = (int) ((int) yr - year);
     * LOGGER.info("age is :" + age); //user.setAge(age); return age;
     */

    String[] daysOfWeek = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
    String[] months = {
      "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
    };
    System.out.println(user.getDob());
    String temp = user.getDob().toString();
    Calendar gDob;
    int age = 0;
    int day = 0;
    int month = 0;
    int year = 0;
    int date = 0;
    Calendar gToday = new GregorianCalendar();
    System.out.println(
        "today is :"
            + gToday.get(GregorianCalendar.YEAR)
            + ","
            + gToday.get(GregorianCalendar.DAY_OF_WEEK)
            + ","
            + gToday.get(GregorianCalendar.MONTH)
            + ","
            + gToday.get(GregorianCalendar.DATE)
            + ","
            + gToday.get(GregorianCalendar.DAY_OF_MONTH));
    String strDay = temp.substring(0, 3);
    System.out.println("day " + strDay);
    String strMonth = temp.substring(3, 7).trim();
    System.out.println("month " + strMonth);
    String strDate = temp.substring(7, 10).trim();
    System.out.println("date " + strDate);
    int index = temp.lastIndexOf("T") + 1;
    String strYear = temp.substring(index).trim();
    System.out.println("year " + strYear);
    for (int i = 0; i < daysOfWeek.length; i++) {
      if (daysOfWeek[i].equalsIgnoreCase(strDay)) {
        System.out.println("day is:" + i);
        day = i;
      }
    } // end of for loon for getting index of day of the week

    for (int j = 0; j < months.length; j++) {
      if (months[j].equalsIgnoreCase(strMonth)) {
        System.out.println("month is:" + j);
        month = j;
      }
    } // end of for loon for getting index of month
    try {
      year = Integer.parseInt(strYear);
      date = Integer.parseInt(strDate);
      gDob = new GregorianCalendar(year, month, date);

      age = gToday.get(GregorianCalendar.YEAR) - gDob.get(GregorianCalendar.YEAR);
      System.out.println("age" + age);
      gToday.set(GregorianCalendar.YEAR, gDob.get(GregorianCalendar.YEAR));
      if (gDob.after(gToday)) {
        System.out.println("inside condition");
        age--;
      }

      System.out.println("age is:" + age);
    } catch (NumberFormatException e) {
      e.printStackTrace();
    }

    return age;
  }
示例#6
0
  public String create() {
    LOGGER.info("Inside create");

    try {
      Role employeeRole = new Role();
      employeeRole.setName(RoleNames.ROLE_EMPLOYEE.name());
      List<Role> roles = this.roleService.findByExample(employeeRole);
      Set<Role> userRoles = new HashSet<Role>();
      userRoles.addAll(roles);
      user.setRoles(userRoles);

      // user.setAge(ageCalculator(user));
      user.setPassword(encrypt(user.getPassword()));
      System.out.println("dobCheckbox" + dobCheckbox);
      // if(dobCheckbox.equals("true")){
      // user.setCheckDOBYR(true);
      //	}else{
      // user.setCheckDOBYR(false);
      //	}
      this.userManagement.registerUser(user);

      user = employerAccountService.findByUserName(user, user.getEmail());

      try {
        String msg = "Your Account has been created";
        msgingService.sendEmail(
            "*****@*****.**",
            new String[] {user.getEmail()},
            "Registration to MyOwnBriefcase",
            msg);

      } catch (MessagingException e) {
        e.printStackTrace();
      }
      if (this.upload != null && upload.length() > 0) {
        this.userManagement.updateUserPicture(user, this.upload.getAbsolutePath(), uploadFileName);
      }

      // log newUser in automatically

      UsernamePasswordAuthenticationToken auth =
          new UsernamePasswordAuthenticationToken(
              user,
              "user.getPassword()",
              new GrantedAuthority[] {new GrantedAuthorityImpl(RoleNames.ROLE_EMPLOYEE.name())});

      System.out.println("Setting auth details");
      SecurityContext context = SecurityContextHolder.getContext();
      context.setAuthentication(auth);
      System.out.println("auth" + auth.getClass());
      getSession().put("ACEGI_SECURITY_CONTEXT", context);

      /*
       * SwitchUserProcessingFilter filter = new
       * SwitchUserProcessingFilter(); filter.setUserDetailsService(new
       * MockAuthenticationDaoUserJackLord());
       */
      System.out.println("Done");
    } catch (Exception e) {
      e.printStackTrace();
      return "error";
    }
    return Action.SUCCESS;
  }
示例#7
0
  public List<Group> findAllGroupsFromSearch(String search, User user) {

    SessionFactory sessionFactory = getHibernateTemplate().getSessionFactory();
    Session session = sessionFactory.openSession();
    String queryString =
        "select distinct (g) from Group g where g.name like? and g.name is not null order by g.name asc";
    Query query = session.createQuery(queryString);
    query.setString(0, "%" + search + "%");
    List<Group> result = query.list();

    List<Group> groupList = new ArrayList<Group>();
    if (result != null && result.size() != 0) {

      for (Group group : result) {
        long GroupMember = 0;
        long groupPrivateMember = 0;
        if (group.getGroupUsersProfiles() != null && group.getGroupUsersProfiles().size() != 0) {

          String queryStringForGroup =
              "select distinct (g) from Group g left join fetch g.groupUsersProfiles gp "
                  + "where g.id=:groupId and gp.profileOwner.id=:profileOwnerId";
          List<Group> newgroupList =
              getHibernateTemplate()
                  .findByNamedParam(
                      queryStringForGroup,
                      new String[] {"groupId", "profileOwnerId"},
                      new Object[] {group.getId(), user.getId()});
          if (newgroupList != null && newgroupList.size() != 0) {
            GroupMember = 1;
            // group.setGroupMember(GroupMember);
            // groupList.add(group);
          }
        } else {

          if (group.getGroupInvitationProfiles() != null
              && group.getGroupInvitationProfiles().size() != 0) {

            String queryStringForGroupInvitation =
                "select distinct (gi) from Group gi left join fetch gi.groupInvitationProfiles gpi "
                    + "where gi.id=:groupId and gpi.profileOwner.id=:profileOwnerId";
            List<Group> inviGroupList =
                getHibernateTemplate()
                    .findByNamedParam(
                        queryStringForGroupInvitation,
                        new String[] {"groupId", "profileOwnerId"},
                        new Object[] {group.getId(), user.getId()});
            if (inviGroupList != null && inviGroupList.size() != 0) {
              groupPrivateMember = 1;
              // group.setGroupPrivateMember(groupPrivateMember);
              System.out.println("Groprivate member" + groupPrivateMember);
              // groupList.add(group);
            }
          }
        }

        group.setGroupPrivateMember(groupPrivateMember);
        group.setGroupMember(GroupMember);
        groupList.add(group);
      }
    }

    session.close();
    return groupList;
  }