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


class Person
def initialize
end

attr_accessor :summary, :skills

class Education
attr_accessor :summary, :start_year, :end_year
end

# Methods for create, set and get for an object
# of Education class
def init_edu_obj
@edu_obj = Education.new
end

def set_edu_summary summary
@edu_obj.summary = summary
end

def set_edu_start_year start_year
@edu_obj.start_year = start_year
end

def set_edu_end_year end_year
@edu_obj.end_year = end_year
end

def get_edu_obj
@edu_obj
end

# Methods for create, set and get for an array of Education
# class objects
def init_edu_obj_arry
@education_obj_array = Array.new
end

def add_element_to_edu_obj_array element
@education_obj_array << element
end

def get_edu_obj_array
@education_obj_array
end

class Experience
attr_accessor :summary, :description, :start_year, :end_year
end

# Methods for create, set and get of Experince class object
def init_exp_obj
@exp_obj = Experience.new
end

def get_exp_obj
@exp_obj
end

def set_exp_summary summary
@exp_obj.summary = summary
end

def set_exp_description description
@exp_obj.description = description
end

def set_exp_start_year start_year
@exp_obj.start_year = start_year
end

def set_exp_end_year end_year
@exp_obj.end_year = end_year
end

#Methods for create, get and set of an array of Experience
# class objects

def init_exp_obj_array
@exp_obj_array = Array.new
end

def get_exp_obj_array
@exp_obj_array
end

def add_element_to_exp_obj_array element
@exp_obj_array << element
end

def init_snapshot_url_hash
@snapshot_url_hash = Hash.new
end

def get_snapshot_url_hash
@snapshot_url_hash
end

def add_url_to_snapshot_hash site_name, url
@snapshot_url_hash[site_name] = url
end
end


Related posts
Part1
Part3

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