A Web App For Identity Search - Part 2

Posted on Friday, May 29, 2009 by Anuj Mehta

Overview of the application

Let’s have a bird’s eye view of the application. To begin with the user enters the details of the person whom they are searching. Details include name, organization and locality.




Now the user presses Search button, which triggers the search operation on the internet. The application now fetches the matching information and displays it as shown below.





Life cycle of the application



It is a Ruby on Rails based application. Its life cycle is as follows

1. User enters the details of a person.

2. These details are sent to a LinkedIn ruby gem.

3. LinkedIn gem internally passes these details to Yahoo BOSS API.

4. Yahoo BOSS API searches the details on LinkedIn site and returns all the matching profiles.

5. The LinkedIn ruby gem now filters the returned profile based on the input details like name, organization and location. After filtering the profiles are sent to controller.

6. The controller now does parsing of the profiles it receives and stores relevant data. As part of parsing it also retrieves the URL’s associated with that person. These URL’s are sent to WebThumb web service.

7. WebThumb stores the snapshots as images and returns the URL of those images.

8. Finally controller sends all the details to view for rendering.



Details of the application

The application is written in Ruby and it runs on Rails. Rails is a framework for building web applications. Rails use MVC design pattern. The Model does all the “business logic”, it interacts with the database for various operations like persistence and retrieval of data, View renders output information and Controller ties everything together, it takes input from user, performs action based on user’s request and do all the co-ordination. For this application we don’t need to store data as based on user input we dynamically get details from internet, process it and display it. Hence for this application we had disabled the Model component. We will now dive into the details


Using Yahoo BOSS API and getting LinkedIn details

To start with, initially based on input details we need to search the web (for this application only the LinkedIn site) and get the detailed information. For performing these tasks I am using ‘ruby-linkedin-0.0.1’ ruby gem. This gem internally passes the inputs details to Yahoo BOSS API and restricts the search only to LinkedIn. The matching profiles from LinkedIn are in hResume microformat. It uses ‘mofo’ microformat parser for parsing and filtering the profiles.


Processing the people data obtained

The LinkedIn ruby gem returns an array of profiles that matches input details. We now need to save all the details of person in an instance variable of controller class as we can access only instance variables from the View files. Hence in controller module I had added a new class called person which contains access methods for summary, skills, and two inner class called Education and Experience.
Below is the code of class Person

  1. class Person  
  2.   def initialize  
  3.   end  
  4.   
  5.   attr_accessor :summary:skills  
  6.   
  7.   class Education  
  8.     attr_accessor :summary:start_year:end_year  
  9.   end  
  10.   
  11.   # Methods for create, set and get for an object  
  12.   # of Education class  
  13.   def init_edu_obj  
  14.     @edu_obj = Education.new  
  15.   end  
  16.   
  17.   def set_edu_summary summary  
  18.     @edu_obj.summary = summary  
  19.   end  
  20.   
  21.   def set_edu_start_year start_year  
  22.     @edu_obj.start_year = start_year  
  23.   end  
  24.   
  25.   def set_edu_end_year end_year  
  26.     @edu_obj.end_year = end_year  
  27.   end  
  28.   
  29.   def get_edu_obj  
  30.     @edu_obj  
  31.   end  
  32.   
  33.   # Methods for create, set and get for an array of Education  
  34.   # class objects  
  35.   def init_edu_obj_arry   
  36.     @education_obj_array = Array.new  
  37.   end  
  38.   
  39.   def add_element_to_edu_obj_array element  
  40.     @education_obj_array << element  
  41.   end  
  42.   
  43.   def get_edu_obj_array  
  44.     @education_obj_array  
  45.   end  
  46.   
  47.   class Experience  
  48.     attr_accessor :summary:description:start_year:end_year  
  49.   end  
  50.   
  51.   # Methods for create, set and get of Experince class object  
  52.   def init_exp_obj  
  53.     @exp_obj = Experience.new  
  54.   end  
  55.   
  56.   def get_exp_obj  
  57.     @exp_obj  
  58.   end  
  59.   
  60.   def set_exp_summary summary  
  61.     @exp_obj.summary = summary  
  62.   end  
  63.   
  64.   def set_exp_description description  
  65.     @exp_obj.description = description  
  66.   end  
  67.   
  68.   def set_exp_start_year start_year  
  69.     @exp_obj.start_year = start_year  
  70.   end  
  71.   
  72.   def set_exp_end_year end_year  
  73.     @exp_obj.end_year = end_year  
  74.   end  
  75.   
  76.   #Methods for create, get and set of an array of Experience  
  77.   # class objects  
  78.   
  79.   def init_exp_obj_array  
  80.     @exp_obj_array = Array.new  
  81.   end  
  82.   
  83.   def get_exp_obj_array  
  84.     @exp_obj_array  
  85.   end  
  86.   
  87.   def add_element_to_exp_obj_array element  
  88.     @exp_obj_array << element  
  89.   end  
  90.   
  91.   def init_snapshot_url_hash  
  92.     @snapshot_url_hash = Hash.new  
  93.   end  
  94.   
  95.   def get_snapshot_url_hash  
  96.     @snapshot_url_hash  
  97.   end  
  98.   
  99.   def add_url_to_snapshot_hash site_name, url  
  100.     @snapshot_url_hash[site_name] = url  
  101.   end  
  102. end  


Related posts
Part1
Part3

0 Responses to "A Web App For Identity Search - Part 2":