@RequestMapping(value = "/connect", method = RequestMethod.POST, consumes = "application/json")
  public ResponseEntity newUser(@RequestBody String data) {
    Gson gson = new Gson();
    User user = gson.fromJson(data, User.class);

    LOGGER.info(user.toString());

    if (userRepository.findByFacebookId(user.getFacebookId()) != null) {

      return new ResponseEntity<>(
          userRepository.findByFacebookId(user.getFacebookId()), HttpStatus.OK);

    } else {

      User newUser = userRepository.save(User.newUser(user));
      ArrayList<Profession> profession = new ArrayList<Profession>();

      for (Occupation occupation : occupationRepository.findAll()) {
        profession.add(new Profession(occupation, -1.0 /* myCareerUtils.randInt(-1, 5)*/));
      }

      newUser.setProfessions(profession);

      return new ResponseEntity<>(userRepository.save(newUser), HttpStatus.OK);
    }
  }
  /* initiate user*/
  @RequestMapping(value = "/updateOcuppation", method = RequestMethod.GET)
  public ResponseEntity updateOccupation(
      @RequestParam String id, @RequestParam String occupationId) {

    User updatedUser = userRepository.findOne(id);

    /* search for occupation and updates it */
    userRepository.save(updatedUser);

    return new ResponseEntity<>(userRepository.findOne(id).toString(), HttpStatus.OK);
  }
  /* update Personality*/
  @RequestMapping(
      value = "/updatePersonality",
      method = RequestMethod.POST,
      consumes = "application/json")
  public ResponseEntity updatePersonality(@RequestParam String id, @RequestBody String data) {
    User updatedUser = userRepository.findOne(id);

    Gson gson = new Gson();
    Personality personality = gson.fromJson(data, Personality.class);
    updatedUser.setPersonality(personality);

    return new ResponseEntity<>(userRepository.save(updatedUser), HttpStatus.OK);
  }
  /* update Rating*/
  @RequestMapping(value = "/updateRating", method = RequestMethod.GET)
  public ResponseEntity updateRating(
      @RequestParam String id, @RequestParam String occupationId, @RequestParam double rating) {

    User updatedUser = userRepository.findOne(id);
    for (int i = 0; i <= updatedUser.getProfessions().size(); i++) {
      if (updatedUser.getProfessions().get(i).getOccupation().getOnet_soc().equals(occupationId)) {
        updatedUser.getProfessions().get(i).setRating(rating);
        break;
      }
    }

    return new ResponseEntity<>(userRepository.save(updatedUser), HttpStatus.OK);
  }
  @RequestMapping(
      value = "/ocuppations",
      method = RequestMethod.POST,
      consumes = "application/json")
  public ResponseEntity updateOccupations(@RequestParam String id, @RequestBody String data) {

    Gson gson = new Gson();
    /* teste */
    Occupation[] occupation = gson.fromJson(data.toString(), Occupation[].class);
    ArrayList<Profession> profession = new ArrayList<Profession>();

    for (int i = 0; (i <= occupation.length - 1); i++) {
      profession.add(new Profession(occupation[i], (double) myCareerUtils.randInt(-1, 5)));
    }

    User updatedUser = userRepository.findOne(id);
    updatedUser.setProfessions(profession);
    userRepository.save(updatedUser);

    return new ResponseEntity<>(userRepository.findOne(id).toString(), HttpStatus.OK);
  }