44
SCHOOL MATE - INSTRUCTOR FINDER _______________ A Thesis Presented to the Faculty of San Diego State University _______________ In Partial Fulfillment of the Requirements for the Degree Master of Science in Computer Science _______________ by Pankaj Puniani Summer 2011

SCHOOL MATE - INSTRUCTOR FINDER

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SCHOOL MATE - INSTRUCTOR FINDER

SCHOOL MATE - INSTRUCTOR FINDER

_______________

A Thesis

Presented to the

Faculty of

San Diego State University

_______________

In Partial Fulfillment

of the Requirements for the Degree

Master of Science

in

Computer Science

_______________

by

Pankaj Puniani

Summer 2011

Page 2: SCHOOL MATE - INSTRUCTOR FINDER
Page 3: SCHOOL MATE - INSTRUCTOR FINDER

iii

Copyright © 2011

by

Pankaj Puniani

All Rights Reserved

Page 4: SCHOOL MATE - INSTRUCTOR FINDER

iv

DEDICATION

I would like to dedicate this thesis work to my parents. It would not have been

possible without their boundless love, continuous motivation and support.

Page 5: SCHOOL MATE - INSTRUCTOR FINDER

v

ABSTRACT OF THE THESIS

School Mate - Instructor Finder by

Pankaj Puniani Master of Science in Computer Science

San Diego State University, 2011

In school we need to contact our professors all the time. It can be regarding doubt in ongoing courses, guidance in research work, advice in course selection and list goes on. In order to contact them, we need to find information like their office location, current office hours, email and phone number. In big universities, sometimes it’s even difficult to find department location especially for new students.

This thesis project includes an Android phone and Web application. Android phone application assists students to keep track of instructor’s office hours, find their office location and an easy way to contact professor through email/phone from within the application. Web application provides instructors with an interface to update their office hours which are visible to users of android phone application.

Page 6: SCHOOL MATE - INSTRUCTOR FINDER

vi

TABLE OF CONTENTS

PAGE

ABSTRACT ...............................................................................................................................v

LIST OF FIGURES ............................................................................................................... viii

ACKNOWLEDGEMENTS ..................................................................................................... ix

CHAPTER

1 INTRODUCTION .........................................................................................................1

2 TECHNOLOGY AND REQUIREMENTS ...................................................................3

2.1 Requirements .....................................................................................................3

2.2 Evolution of Mobile Wireless Networks (1G to 4G) .........................................3

2.3 Smart Phone Operating Systems ........................................................................4

2.3.1 Android .................................................................................................... 4

2.3.1.1 Application Components ................................................................ 5

2.3.1.2 Android Architecture ...................................................................... 7

2.3.1.3 The Manifest File ............................................................................ 9

2.3.2 iOS (iPhone OS) ...................................................................................... 9

2.3.3 RIM (BlackBerry OS) ............................................................................ 10

2.3.4 Symbian ................................................................................................. 10

2.3.5 Windows Mobile .................................................................................... 11

2.3.6 Smartphone Market Share...................................................................... 11

2.4 Java ..................................................................................................................12

2.5 Java Server Pages .............................................................................................13

2.6 Database ...........................................................................................................14

2.6.1 SQLite .................................................................................................... 14

2.6.2 MySQL .................................................................................................. 15

2.7 JSON ................................................................................................................16

3 ARCHITECTURE AND IMPLEMENTATION .........................................................18

3.1 Introduction ......................................................................................................18

3.2 Mobile Phone Application (Client) ..................................................................19

Page 7: SCHOOL MATE - INSTRUCTOR FINDER

vii

3.2.1 Search through Web Server Application ............................................... 19

3.2.2 Search through Application Directory ................................................... 22

3.2.3 Transition from One Screen to Another................................................. 22

3.3 Web Server Application (JSP) .........................................................................23

3.3.1 Handling Mobile Client Query .............................................................. 23

3.3.2 Updating Office Hours ........................................................................... 23

3.4 Database Schema .............................................................................................24

3.4.1 MySQL .................................................................................................. 24

3.4.2 SQLite .................................................................................................... 25

4 RESULTS ....................................................................................................................26

4.1 Android Application ........................................................................................26

4.2 JSP Web Application .......................................................................................30

5 CONCLUSION ............................................................................................................32

5.1 Limitation .........................................................................................................32

5.2 Future Enhancements .......................................................................................32

BIBLIOGRAPHY ....................................................................................................................34

Page 8: SCHOOL MATE - INSTRUCTOR FINDER

viii

LIST OF FIGURES

PAGE

Figure 1.1. School Mate welcome screen. .................................................................................1

Figure 1.2. Office hours modification web page. ......................................................................2

Figure 2.1. Android architecture. ...............................................................................................7

Figure 2.2. Smart phone market shares. ...................................................................................12

Figure 2.3. JSON object. ..........................................................................................................17

Figure 2.4. JSON array. ...........................................................................................................17

Figure 3.1. Architecture. ..........................................................................................................18

Figure 3.2. JSON response snippet. .........................................................................................20

Figure 3.3. School Mate application search results. ................................................................21

Figure 4.1. School Mate application welcome screen shot 1. ..................................................26

Figure 4.2. School Mate application welcome screen shot 2. ..................................................26

Figure 4.3. Search instructor screen. ........................................................................................27

Figure 4.4. Search results. ........................................................................................................28

Figure 4.5. Instructor detail screen. .........................................................................................28

Figure 4.6. Email screen. .........................................................................................................29

Figure 4.7. Call results. ............................................................................................................29

Figure 4.8. Office detail screen. ...............................................................................................29

Figure 4.9. Office location map. ..............................................................................................29

Figure 4.10. School Mate application directory screen shot 1. ................................................31

Figure 4.11. School Mate application directory screen shot 2. ................................................31

Figure 4.12. Office hours modification screen shot. ................................................................31

Page 9: SCHOOL MATE - INSTRUCTOR FINDER

ix

ACKNOWLEDGEMENTS

I take this opportunity to sincerely thank my thesis advisor, Dr. Joseph Lewis, for the

guidance, encouragement, and unrelenting support during every step of my research work.

Without his help it would not have been possible for me to accomplish this feat.

I would also like to thank Professor Carl Eckberg and Professor Michael O’Sullivan

for providing valuable suggestions and taking their time to review my thesis, as part of the

panel.

Page 10: SCHOOL MATE - INSTRUCTOR FINDER

1

CHAPTER 1

INTRODUCTION

According to Nielsen report, as of December 2010, nearly a third (31%) of all mobile

consumers in the United States owned cell phones with app-based, web-enabled operating

systems and it expects smart phones to become the majority by the end of 2011 [1]. These

smart phones support wide range of applications assisting user in their day to day activities

like banking, shopping, eating, medical etc. This thesis project “School Mate” is also based

on channelizing smart phones capabilities to help students to find out instructor’s office

hours/office location and their contact information.

The project constitutes of two parts:

1. Android phone application (School Mate): User need to install this application on their Android OS based cell phone. After the application is installed, user can search for the instructor by their last name, first name or department. Application then talks to web server to search for professor (see Figure 1.1).

Figure 1.1. School Mate welcome screen.

Once the instructor is found, application provides user with professor’s office info

like current office hours, office location on Google map and options to call and email the

instructor. It also provides user with an option to add professor’s info to directory i.e. adding

information in phone’s database. So next time when user needs information for the same

instructor, he can fetch it out from application’s directory list. It avoids the dependency on

Page 11: SCHOOL MATE - INSTRUCTOR FINDER

2

the network connection and provides faster access to information. For more detail

implementation and screen shots please refer to Chapter 3.

2. Web Application (Java Server Pages): It provides a web based interface where professors can log in with their SDSU email address and update their office hours. These modified hours get stored in web server database and are reflected when “School Mate” application user asks for them (see Figure 1.2). For more detail implementation and screen shots please refer to Chapters 3 and 4.

Figure 1.2. Office hours modification web page.

This book is organized as follows: Chapter 2’s purpose is to describe the various

Smartphone operating system options available for developing applications, describe

requirements and technology used. Chapter 3’s objective is to explain Architecture and

Implementation. In Chapter 4, results are presented and discussed. Finally, Chapter 5

presents the conclusions and future works.

Page 12: SCHOOL MATE - INSTRUCTOR FINDER

3

CHAPTER 2

TECHNOLOGY AND REQUIREMENTS

2.1 REQUIREMENTS Web Application Requirements (Server):

• Apache Tomcat Server – It requires apache tomcat server to host dynamic JSP web projects. Version used for this thesis project is apache-tomcat-6.0.18.

• MySQL – It is required to create and maintain database which holds instructor’s Information. Version used for this thesis project is MySQL Server 5.1.

• Eclipse Java EE – It is IDE used to create JSP web projects. The version used is Helios.

• Java SDK (jdk1.6.0_20)

Android Application Requirements (Client):

• Mobile phone supporting Android OS with firmware 1.6 or above.

• Android SDK to develop android phone applications.

• Eclipse Galileo with ADT (Android Development Tools) plugin installed.

• The language used in Android OS is Java. Hence, Java SDK is also required to develop software on Android OS.

• Database used for mobile devices is primarily SQLite. Unlike most other SQL databases, SQLite does not have a separate server process. SQLite reads and writes directly to ordinary disk files.

2.2 EVOLUTION OF MOBILE WIRELESS NETWORKS (1G TO 4G)

Mobile Wireless Networks have witnessed a rapid growth in past 30 years. The

Mobile era started in 1980 with advent of First generation (1G) mobile systems. They used

analog transmission for speech services. However one of major drawbacks of 1G network is

inability to interoperate between different countries. Then Second Generation (2G) network

arrived at the end of 1980’s. It had higher spectrum efficiency, better data services and

international roaming capability. But still the standards of developing network were different

in different part of world. This led to Third Generation (3G) networks for which International

Telecommunication Union (ITU) defined the demands with the IMT-2000 Standard.

Page 13: SCHOOL MATE - INSTRUCTOR FINDER

4

3G networks has provided improved spectral efficiency and services like wireless voice

telephony, video calls, broadband wireless data with data transmission capabilities able to

deliver speeds up to 14.4 Mbps (downlink) and 5.8Mbps (uplink). The ever increasing

growth of user demand and emerging new technologies have triggered the Fourth generation

mobile network. It plans to accomplish new levels of user experience by integrating all

existing mobile technologies, providing peak data rate of 1 Gbps (downlink) and 500 Mbps

(uplink) [2].

2.3 SMART PHONE OPERATING SYSTEMS There are number of smart phone OS available today. However the most prominent

are:

• Android

• iOS (iPhone OS)

• RIM (BlackBerry OS)

• Symbian

• Windows Mobile

2.3.1 Android The Android operating system was released in 2008. Android is an open source

platform backed by Google, along with major hardware and software developers (such as

Intel, HTC, ARM, Motorola and Samsung, to name a few), that form the Open Handset

Alliance. Acc. to thesis paper submitted by “Benjamin Speckmann”, an open mobile

platform is a software stack, including an operating system, middleware and key applications

allowing users to develop additional software and change or replace functionality without

limitations. All these functionalities have to be free of charge [3]. Android is based upon a

modified version of the Linux kernel. Android includes an operating system, middleware and

key applications. The Android SDK provides the tools and APIs necessary to begin

developing applications on the Android platform using the Java programming language.

The Android SDK tools compile the code—along with any data and resource files—

into an Android package, an archive file with an .apk suffix. All the code in a single .apk file

is considered to be one application and is the file that Android-powered devices use to install

the application.

Page 14: SCHOOL MATE - INSTRUCTOR FINDER

5

Once installed on a device, each Android application lives in its own security

sandbox:

• The Android operating system treats each application as a different Linux user.

• Each process has its own virtual machine (VM), so an application’s code runs in isolation from other applications.

• By default, the system assigns each application a unique Linux user ID (the ID is used only by the system and is unknown to the application). The system sets permissions for all the files in an application so that only the user ID assigned to that application can access them.

• Every application runs in its own Linux process. Android starts the process when any of the application’s components need to be executed, then shuts down the process when it’s no longer needed or when the system must recover memory for other applications.

Android’s application-level security framework is based on permission labels. A

permission label is unique text string that can be defined by both the OS and third party

developers. Application developers specify a list of permission labels the application requires

in its package manifest [4].

2.3.1.1 APPLICATION COMPONENTS Application components are the essential building blocks of an Android application.

Each component is a different point through which the system can enter your application.

Not all components are actual entry points for the user and some depend on each other, but

each one exists as its own entity and plays a specific role—each one is a unique building

block that helps define your application’s overall behavior.

There are four different types of application components:

2.3.1.1.1 Activities An activity represents a single screen with a user interface. For example, an email

application might have one activity that shows a list of new emails, another activity to

compose an email, and another activity for reading emails. Although the activities work

together to form a cohesive user experience in the email application, each one is independent

of the others. As such, a different application can start any one of these activities (if the email

application allows it). For example, a camera application can start the activity in the email

application that composes new mail, in order for the user to share a picture.

Page 15: SCHOOL MATE - INSTRUCTOR FINDER

6

2.3.1.1.2 Services A service is a component that runs in the background to perform long-running

operations or to perform work for remote processes. A service does not provide a user

interface. For example, a service might play music in the background while the user is in a

different application, or it might fetch data over the network without blocking user

interaction with an activity. Another component, such as an activity, can start the service and

let it run or bind to it in order to interact with it.

2.3.1.1.3 Content providers A content provider manages a shared set of application data. You can store the data in

the file system, a SQLite database, on the web, or any other persistent storage location your

application can access. Through the content provider, other applications can query or even

modify the data (if the content provider allows it). For example, the Android system provides

a content provider that manages the user’s contact information. As such, any application with

the proper permissions can query part of the content provider to read and write information

about a particular person.

2.3.1.1.4 Broadcast Receivers A broadcast receiver is a component that responds to system-wide broadcast

announcements. Many broadcasts originate from the system—for example, a broadcast

announcing that the screen has turned off, the battery is low, or a picture was captured.

Applications can also initiate broadcasts—for example, to let other applications know that

some data has been downloaded to the device and is available for them to use. Although

broadcast receivers don’t display a user interface, they create a status bar notification to alert

the user when a broadcast event occurs. More commonly, though, a broadcast receiver is just

a “gateway” to other components and is intended to do a very minimal amount of work. For

instance, it might initiate a service to perform some work based on the event.

A unique aspect of the Android system design is that any application can start another

application’s component. For example, if you want the user to capture a photo with the

device camera, there’s probably another application that does that and your application can

use it, instead of developing an activity to capture a photo yourself. You don’t need to

incorporate or even link to the code from the camera application. Instead, you can simply

Page 16: SCHOOL MATE - INSTRUCTOR FINDER

7

start the activity in the camera application that captures a photo. When complete, the photo is

even returned to your application so you can use it. To the user, it seems as if the camera is

actually a part of your application [5].

2.3.1.2 ANDROID ARCHITECTURE Figure 2.1 shows the android architecture. Each layer of architecture is explained

below [6].

Figure 2.1. Android architecture.

2.3.1.2.1 Applications Android will ship with a set of core applications including an email client, SMS

program, calendar, maps, browser, contacts, and others. All applications are written using the

Java programming language.

Page 17: SCHOOL MATE - INSTRUCTOR FINDER

8

2.3.1.2.2 Application Framework Underlying all applications is a set of services and systems, including:

• A rich and extensible set of Views that can be used to build an application, including lists, grids, text boxes, buttons, and even an embeddable web browser.

• Content Providers that enable applications to access data from other applications (such as Contacts), or to share their own data.

• A Resource Manager, providing access to non-code resources such as localized strings, graphics, and layout files.

• A Notification Manager that enables all applications to display custom alerts in the status bar.

• An Activity Manager that manages the lifecycle of applications and provides a common navigation backstack.

2.3.1.2.3 Libraries Android includes a set of C/C++ libraries used by various components of the Android

system. These capabilities are exposed to developers through the Android application

framework. Some of the core libraries are:

• System C library - a BSD-derived implementation of the standard C system library (libc), tuned for embedded Linux-based devices.

• Media Libraries - based on PacketVideo’s OpenCORE; the libraries support playback and recording of many popular audio and video formats, as well as static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.

• Surface Manager - manages access to the display subsystem and seamlessly composites 2D and 3D graphic layers from multiple applications.

• LibWebCore - a modern web browser engine which powers both the Android browser and an embeddable web view.

• SGL - the underlying 2D graphics engine.

• 3D libraries - an implementation based on OpenGL ES 1.0 APIs; the libraries use either hardware 3D acceleration (where available) or the included, highly optimized 3D software rasterizer.

• FreeType - bitmap and vector font rendering.

• SQLite - a powerful and lightweight relational database engine available to all applications.

Page 18: SCHOOL MATE - INSTRUCTOR FINDER

9

2.3.1.2.4 Linux Kernel Android relies on Linux version 2.6 for core system services such as security,

memory management, process management, network stack, and driver model. The kernel

also acts as an abstraction layer between the hardware and the rest of the software stack.

2.3.1.3 THE MANIFEST FILE Before the Android system can start an application component, the system must know

that the component exists by reading the application’s AndroidManifest.xml file (the

“manifest” file). Your application must declare all its components in this file, which must be

at the root of the application project directory [5].

The manifest does a number of things in addition to declaring the application’s

components, such as:

• Identify any user permissions the application requires, such as Internet access or read-access to the user’s contacts.

• Declare the minimum API Level required by the application, based on which APIs the application uses.

• Declare hardware and software features used or required by the application, such as a camera, Bluetooth services, or a multi touch screen.

• API libraries the application needs to be linked against (other than the Android framework APIs), such as the Google Maps library.

2.3.2 iOS (iPhone OS) iOS (iPhone OS) is Apple’s mobile operating system and is used to run applications

natively on devices, such as iPad, iPhone, and iPod touch. The iOS SDK supports the

creation of graphically-oriented applications that run natively in iOS. The key components of

the SDK include:

• Xcode Tools—the tools that support iOS application development, including the following key applications:

• Xcode—an integrated development environment that manages your application projects and lets you edit, compile, run, and debug your code. Xcode integrates with many other tools and is the main application we use during development.

• Interface Builder—a tool to assemble user interface visually. The interface objects created are saved to a special type of resource file and loaded into your application at runtime.

Page 19: SCHOOL MATE - INSTRUCTOR FINDER

10

• Instruments—a runtime performance analysis and debugging tool. It can be used to collect information about application’s runtime behavior and identifying potential problems.

• iOS Simulator—a Mac OS X application that simulates the iOS technology stack, allowing to test iOS applications locally on Intel-based Macintosh computer.

• iOS Developer Library—the reference and conceptual documentation that teaches about iOS technologies and the application-development process [7], [8].

2.3.3 RIM (BlackBerry OS) BlackBerry OS is a proprietary mobile operating system, developed by Research In

Motion for its BlackBerry line of smart phone handheld devices. The operating system

provides multitasking and supports specialized input devices that have been adopted by RIM

for use in its handhelds, particularly the track wheel, trackball, and most recently, the track

pad and touch screen.

The BlackBerry platform is perhaps best known for its native support for corporate

email, through MIDP 1.0 and, more recently, a subset of MIDP 2.0, which allows complete

wireless activation and synchronization with Microsoft Exchange, Lotus Domino, or Novell

GroupWise email, calendar, tasks, notes, and contacts, when used in conjunction with

BlackBerry Enterprise Server.

BlackBerry provides BlackBerry® Java® SDK to develop application in Java using

rich set of BlackBerry APIs. It also provides support for developing applications using web

standard technologies like HTML/HTML5, CSS and JavaScript [9], [10].

2.3.4 Symbian Symbian is an open source operating system (OS) and software platform designed for

smart phones and maintained by Nokia. Software platform for mobile phones that runs on

Symbian OS is S60. From 2010, Symbian switched to using standard C++ with Qt as the

SDK, which can be used with either Qt Creator or Carbide. Qt supports the older Symbian

S60 3rd and 5th editions, as well as the new Symbian platform. It also supports Windows,

Linux and Mac OS X.

The All over Model contains the following layers, from top to bottom:

• UI Framework Layer

• Application Services Layer

Page 20: SCHOOL MATE - INSTRUCTOR FINDER

11

• Java ME

• OS Services Layer

• generic OS services

• communications services

• multimedia and graphics services

• connectivity services

• Base Services Layer

• Kernel Services and Hardware Interface Layer

The Base Services Layer is the lowest level reachable by user-side operations;

it includes the File Server and User Library, a Plug-In Framework which manages all

plug-ins, Store, Central Repository, DBMS and cryptographic services. It also

includes the Text Window Server and the Text Shell: the two basic services from which

a completely functional port can be created without the need for any higher layer services

[11].

2.3.5 Windows Mobile Windows Mobile is a mobile operating system developed by Microsoft that

was used in smart phones and mobile devices, but is being currently phased out to

specialized markets. It is superseded by Windows Phone 7. Microsoft typically releases

Windows Phone software development kits (SDKs) that work in conjunction with their

Visual Studio development environment. The SDK contains the API header and library

files needed to access Windows Mobile functionality as well as documentation,

sample application projects, and emulators that allow deploying and debugging the

application [12].

2.3.6 Smartphone Market Share Acc. to Canalys report [13], in Q4 2010 the Android O.S. was the world’s best-selling

smartphone platform. Shipments of Android-based smart phones reached 32.9 million, while

devices running Nokia’s Symbian platform trailed slightly at 31.0 million worldwide [14].

See Figure 2.2.

Java technology is an object-oriented, platform-independent, multithreaded

programming environment.

Page 21: SCHOOL MATE - INSTRUCTOR FINDER

12

Figure 2.2. Smart phone market shares.

2.4 JAVA Acc. to white paper written by James Gosling and Henry McGilton in May 1996 [15]:

The Java programming language originated as part of a research project to develop advanced software for a wide variety of network devices and embedded systems. The goal was to develop a small, reliable, portable, distributed, real-time operating platform. When the project started, C++ was the language of choice. But over time the difficulties encountered with C++ grew to the point where the problems could best be addressed by creating an entirely new language platform. Design and architecture decisions drew from a variety of languages such as Eiffel, SmallTalk, Objective C, and Cedar/Mesa. The result is a language platform that has proven ideal for developing secure, distributed, network-based end-user applications in environments ranging from network-embedded devices to the World-Wide Web and the desktop.

Design goals include:

• Object Oriented: The Java programming language is designed to be object oriented from the ground up. Java technology provides a clean and efficient object-based development platform. Programmers using the Java programming language can access existing libraries of tested objects that provide functionality ranging from basic data types through I/O and network interfaces to graphical user interface toolkits. These libraries can be extended to provide new behavior.

Page 22: SCHOOL MATE - INSTRUCTOR FINDER

13

• Robust and Secure: Java technology is designed to operate in distributed environments, which means that security is of paramount importance. With security features designed into the language and run-time system, Java technology lets you construct applications that can’t be invaded from outside. In the network environment, applications written in the Java programming language are secure from intrusion by unauthorized code attempting to get behind the scenes and create viruses or invade file systems.

• Architecture Neutral and Portable: The architecture-neutral and portable language platform of Java technology is known as the Java virtual machine. It’s the specification of an abstract machine for which Java programming language compilers can generate code. Specific implementations of the Java virtual machine for specific hardware and software platforms then provide the concrete realization of the virtual machine.

• High Performance: Performance is always a consideration. The Java platform achieves superior performance by adopting a scheme by which the interpreter can run at full speed without needing to check the run-time environment. The automatic garbage collector runs as a low-priority background thread, ensuring a high probability that memory is available when required, leading to better performance

• Interpreted, Threaded, and Dynamic: The Java interpreter can execute Java bytecodes directly on any machine into which the interpreter and run-time system have been ported. In an interpreted platform such as Java technology-based system, the link phase of a program is simple, incremental, and lightweight. Java technology’s multithreading capability provides the means to build applications with many concurrent threads of activity. Multithreading thus results in a high degree of interactivity for the end user. While the Java Compiler is strict in its compile-time static checking, the language and run-time system are dynamic in their linking stages. Classes are linked only as needed. New code modules can be linked in on demand from a variety of sources, even from sources across a network. In the case of the HotJava Browser and similar applications, interactive executable code can be loaded from anywhere, which enables transparent updating of applications. The result is on-line services that constantly evolve; they can remain innovative and fresh, draw more customers, and spur the growth of electronic commerce on the Internet.

2.5 JAVA SERVER PAGES Java Server Pages technology allows web developers and designers to easily develop

and maintain dynamic web pages that leverage existing business systems. As part of the Java

technology family, JSP enables rapid development of web-based applications that are

platform-independent. JSP separates user interfaces from content generation, enabling

designers to change the overall page layout without altering the underlying dynamic content.

So what exactly is a Java Server Page? In its basic form, a JSP page is simply an

HTML web page that contains additional bits of code that execute application logic to

Page 23: SCHOOL MATE - INSTRUCTOR FINDER

14

generate dynamic content. This application logic may involve JavaBeans, JDBC objects,

Enterprise Java Beans (EJB), and Remote Method Invocation (RMI) objects, all of which can

be easily accessed from a JSP page. For example, a JSP page may contain HTML code that

displays static text and graphics, as well as a method call to a JDBC object that accesses a

database; when the page is displayed in a user’s browser, it will contain both the static

HTML content and dynamic information retrieved from the database.

The separation of user interface and program logic in a JSP page allows for a very

convenient delegation of tasks between web content authors and developers. It also allows

developers to create flexible code that can easily be updated and reused. Because JSP pages

are automatically compiled as needed, web authors can make changes to presentation code

without recompiling application logic. This makes JSP a more flexible method of generating

dynamic web content than Java servlets, whose functionality Java Server Pages extend.

JSP syntax is a fluid mix of two basic content forms: scriptlet elements and markup.

Markup is typically standard HTML or XML, while scriptlet elements are delimited blocks

of Java code which may be intermixed with the markup. When the page is requested the Java

code is executed and its output is added, in situ, with the surrounding markup to create the

final page.

If you are looking for a convenient way to create web applications that connect to

server-side Java components, JavaServer Pages is the way to go. Besides the inherent

portability of Java and JSP’s ready access to technologies like EJB, RMI, JDBC, and

JavaBeans, the separation of HTML presentation code and application logic makes JSP pages

very easy for organizations to work with [16].

2.6 DATABASE This thesis project involves two different database technologies. SQLite Database is

used in Android phones application and it stores of instructor’s information kept in phone

directory. MySQL database is used on server side and stores information about all instructors

who can be searched through android application.

2.6.1 SQLite SQLite is an in-process library that implements a self-contained, serverless,

zero-configuration, transactional SQL database engine. SQLite, like any other SQL

Page 24: SCHOOL MATE - INSTRUCTOR FINDER

15

Databases, does not have a separate server process. SQLite reads and writes directly to

ordinary disk files. A complete SQL database with multiple tables, indices, triggers, and

views, is contained in a single disk file. It is not accessed from the client application but is an

integral part of it. It has a small core and is much faster than other databases making it useful

for embedded systems. Android uses SQLite as it’s built in embedded database. It is basically

used to store local application data.

SQLite is an ACID-compliant embedded relational database management system

contained in a relatively small C programming library. The SQLite library can be called

dynamically. The application program uses SQLite’s functionality through simple function

calls, which reduce latency in database access - function calls within a single process are

more efficient than inter-process communication. SQLite stores the entire database

(definitions, tables, indices, and the data itself) as a single cross-platform file on a host

machine. It implements this simple design by locking the entire database file during writing

[17].

Some of the distinctive features of SQLite are as follows:

• Zero-Configuration: SQLite does not have to be configured or installed; instead it just works without setup. In case of Android, it is an inbuilt database.

• Serverless: In SQLite, there is not interprocess communication to send requests to the server and to receive results back. With SQLite, the process that wants to access the database reads and writes directly from the database files on disk. There is no intermediary server process.

• Stable Cross-Platform Database File: The SQLite file format is cross-platform. A database file written on one machine can be copied to and used on a different machine with a different architecture.

• Compact: SQLite library is very compact in size which makes it useful for mobile devices thereby making applications compact in size.

• Variable-length records: SQLite uses only the amount of disk space actually needed to store the information in a row. It results in smaller database files thereby making database run faster. The use of variable-length records makes it possible for SQLite to employ manifest typing instead of static typing.

2.6.2 MySQL The MySQL database has become the world’s most popular open source database

because of its high performance, high reliability and ease of use. Many of the world’s largest

and fastest-growing organizations including Facebook, Google, Adobe, Alcatel Lucent and

Page 25: SCHOOL MATE - INSTRUCTOR FINDER

16

Zappos rely on MySQL to save time and money powering their high-volume Web sites,

business-critical systems and packaged software. MySQL runs on more than 20 platforms

including Linux, Windows, Mac OS, Solaris, HP-UX, IBM AIX, giving you the kind of

flexibility that puts you in control [18], [19].

Features include:

Scalability and Flexibility: Run anything from deeply embedded applications with a

footprint of just 1MB to massive data warehouses holding terabytes of information.

High Performance: MySQL Database has high performance which is illustrated

through following features:

• Table and Index Partitioning

• Ultra-fast load utilities

• Distinctive memory caches

• Full-text indexes, and more

High Availability

• Run high-speed master/slave replication configurations with Row-Based and Hybrid Replication

• Specialized Cluster servers offering instant failover.

Robust Transactional Support

• Complete ACID (atomic, consistent, isolated, durable) transaction support.

• Unlimited row-level locking, Distributed transaction capability, and Multi-version transaction support

Strong Data Protection

• Powerful mechanisms for ensuring only authorized users have access.

• SSH and SSL support safe and secure connections.

• Powerful data encryption and decryption functions.

Comprehensive Application Development

• Support for stored procedures, triggers, functions, views, cursors, ANSI-standard SQL, and more.

• Plug-in libraries to embed MySQL database support into nearly any application.

2.7 JSON JSON stands for “JavaScript Object Notation”. It is lightweight data-interchange

format which is easy to read and write and easy for machines to parse and generate.

Page 26: SCHOOL MATE - INSTRUCTOR FINDER

17

JSON is built on two structures:

1. A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.

2. An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

An object is an unordered set of name/value pairs. An object begins with { (left

brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value

pairs are separated by , (comma). See Figure 2.3.

Figure 2.3. JSON object.

An array is an ordered collection of values. An array begins with [ (left bracket) and

ends with ] (right bracket). Values are separated by , (comma). A value can be a string in

double quotes, or a number, or true or false or null, or an object or an array. These structures

can be nested [20]. See Figure 2.4.

Figure 2.4. JSON array.

Page 27: SCHOOL MATE - INSTRUCTOR FINDER

18

CHAPTER 3

ARCHITECTURE AND IMPLEMENTATION

3.1 INTRODUCTION Figure 3.1 represents the abstract architecture for this project. Mobile phone

application sends query request to web server (JSP application) through network. Web server

application forwards the query to its database (MySQL). After obtaining query results from

database, it formats them and sends results back to phone application. Mobile phone

application also has its own database which can be used to store instructor’s information.

There is also a web interface which assists instructor in updating their office hours. This web

interface and mobile phone application talks to same database. So once office hours are

updated, it is visible to application users.

Figure 3.1. Architecture.

Page 28: SCHOOL MATE - INSTRUCTOR FINDER

19

3.2 MOBILE PHONE APPLICATION (CLIENT) Mobile phone platform used in this project is Android. Hence we have an android

phone application which acts a client and communicates with web server. This application is

written in Java with the help of eclipse IDE and android sdk.

Mobile phone user provides their input through this application. User can either opt to

look for professor through network i.e., Web server application database or in their own

phone’s database.

3.2.1 Search through Web Server Application When user decides to search for professor through web server application, there are

three options for user input. User can search instructor by:

• Last name

• First name

• Department

Note: User does not need to know complete last/first/department name. Entering only

some initial letters can bring up desired search results. However in that case search result will

contain all instructors which satisfy the search criteria. For example searching for instructor

by “Jo” as first name will return all those instructors who have “Jo” in their first name and

then user can select desired instructor from the list.

When user inputs the search criteria, application constructs a query in form of URL.

For example user decides to search instructor by their department name, let’s say Computer

Science. Then URL constructed will be:

http://43.148.19.188:8080/DBConnection/retrieveByDepartment.jsp?dept=Computer+Science

This query is then send to web server application using apache HttpClient object.

Here is the code snippet taken from GetNetworkData class of this application.

HttpClient httpclient = new DefaultHttpClient(); HttpGet getAdd = new HttpGet(mainUrl); try { ResponseHandler<String> responseHandler = new

BasicResponseHandler(); String responseBody = httpclient.execute(getAdd,responseHandler); reqData = new JSONObject(responseBody); } catch (Throwable t) {

Page 29: SCHOOL MATE - INSTRUCTOR FINDER

20

Log.i("test", "Connection error" + t.getMessage()); } httpclient.getConnectionManager().shutdown();

Here mainUrl is

http://43.148.19.188:8080/DBConnection/retrieveByDepartment.jsp?dept=Computer+Science

All the server communication is performed on separate Java thread, so that the main

application doesn’t get crashed in case of connection failure. Specifically, if everything is

happening in the UI thread, performing long operations such as network access or database

queries will block the whole UI. When the thread is blocked, no events can be dispatched,

including drawing events. From the user’s perspective, the application appears to hang.

Hence we create a new thread to handle the network operation.

Web server application on receiving this URL extracts the query and forwards it to its

database (MySQL). It then sends response to mobile phone application in JSON format. For

example snippet of response send for above mentioned query is shown in Figure 3.2.

Figure 3.2. JSON response snippet.

Page 30: SCHOOL MATE - INSTRUCTOR FINDER

21

As it is clear from Figure 3.2, JSON response for user search by Computer Science

gives list of instructors with their relevant information. This JSON response is parsed by

mobile client and presented to the user in form of readable list (Figure 3.3).

Figure 3.3. School Mate application search results.

Now if user selects one of these instructors from list then one more URL will be

constructed and send to web server application. For example user selects professor “Joseph

Lewis” the URL send will be:

http://43.148.19.188:8080/DBConnection/[email protected]

Web server application responds to this URL by sending instructor’s detail

information which enables application user to perform these functions

• Send email to instructor from within application.

• Call instructor at their office number.

• Determine their office hours and look their office location on Google Map.

• Add instructor’s information to their application’s directory. So they don’t need to search for the same instructor’s information again through network.

Page 31: SCHOOL MATE - INSTRUCTOR FINDER

22

3.2.2 Search through Application Directory Application directory is basically a list of instructors whose information is stored by

user himself while searching for them through web server application. The advantage of this

option is that user doesn’t need to be connected to Internet to figure out instructor’s office

hours, email or phone number because that information is already stored in phone’s database.

So when user selects instructor from directory list, query is generated and send to phone’s

database (SQLite).

Here is the code snippet from ListDetails.java class file:

DatabaseHelper qryData = new DatabaseHelper(this); SQLiteDatabase nameDb = qryData.getReadableDatabase(); Cursor c = nameDb.rawQuery("SELECT * FROM PROFESSORS WHERE _id = ?",new String[] { val });

Here val is unique row id of professor selected from directory list. It is used to query

table named “PROFESSORS” present in mobile phone’s database (SQLite). Cursor c

contains all information necessary to perform functions like email, call or figuring out office

hours.

3.2.3 Transition from One Screen to Another Each screen in application represents an activity. Typically, one activity in an

application is specified as the “main” activity, which is presented to the user when launching

the application for the first time (Figure 3.1). Each activity can then start another activity in

order to perform different actions. Each time a new activity starts, the previous activity is

stopped, but the system preserves the activity in a stack (the “back stack”). When a new

activity starts, it is pushed onto the back stack and takes user focus. The back stack abides to

the basic “last in, first out” queue mechanism, so, when the user is done with the current

activity and presses the BACK key, it is popped from the stack (and destroyed) and the

previous activity resumes. While moving from one screen to another, calling activity (current

screen) creates Intent with package information about the called activity (next screen). Also

for successful transition each activity must be present in application AndroidManifest.xml

file.

Page 32: SCHOOL MATE - INSTRUCTOR FINDER

23

3.3 WEB SERVER APPLICATION (JSP) There are two JSP based web projects hosted by tomcat server. One project handles

queries generated by mobile phone application and other project provides a web interface

assisting instructor’s in modifying their office hours.

3.3.1 Handling Mobile Client Query When a mobile client hits the server with URL, server extracts query from url and

sends it to MySQL Database through JDBC. For example if URL is

http://43.148.19.188:8080/DBConnection/[email protected]

Project “DBConnection” on server side has JSP page “retrieveByEmail” which

handles this request. Here is snippet from retrieveByEmail.jsp.

String email = request.getParameter("mail"); try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); connection =

DriverManager.getConnection(connectionUrl,"root","influence"); statement = connection.createStatement(); String query = "Select * from professorInfo where email LIKE '%" +

email + "'"; rs = statement.executeQuery(query); while(rs.next()){ JSONObject professorInfo = new JSONObject(); String mail = rs.getString(1); String location = rs.getString(2); ………

This code snippet extracts value from mail parameter i.e. [email protected] ,

connects to JDBC and queries MySQL database for professor’s information whose mail

address matches extracted parameter value.

This project then extracts the database response, converts it into JSON format and

sends it back to mobile client.

3.3.2 Updating Office Hours There is also a JSP based web interface which assists instructor in updating their

office hours. When instructor visits a JSP web page, it asks for username and password.

Username is instructor’s SDSU email address and password is sdsu. Web server uses this

email address to identify instructor and pull up his office hours from database. When

Page 33: SCHOOL MATE - INSTRUCTOR FINDER

24

instructor modifies the office hours and hit submit button, web server updates the office

hours in MySQL database. Here is code snippet taken from SetHours.jsp file in project

ModifyDirectory.

String current_hours = request.getParameter("updatedHours"); String email = request.getParameter("emailId"); String connectionUrl = "jdbc:mysql://43.148.19.188:3306/directory"; Connection connection = null; Statement statement = null; ResultSet rs = null; try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); connection =

DriverManager.getConnection(connectionUrl,"root","influence"); statement = connection.createStatement(); String qry = "UPDATE professorInfo SET officehours = \"" +

current_hours + "\", dateValue = CURDATE() Where email = '" + email + "'";

statement.executeUpdate(qry); session.setAttribute("check",email); statement.close(); connection.close(); } catch(Exception e){ out.println("Exception : "+ e.getMessage()); }

As we see in this code snippet, it updates the office hours in table professorInfo. It is

the same table which is used by another web application to handle instructor detail query

from mobile client. So once office hours are updated in this table, it is visible to mobile

phone application users who query for instructor’s information.

3.4 DATABASE SCHEMA This section explains database schema used in web application (MySQL) and mobile

phone application (SQLite).

3.4.1 MySQL It has two tables on server side which are responsible for storing professor’s

Information.

Page 34: SCHOOL MATE - INSTRUCTOR FINDER

25

Professors: This table stores instructor’s basic information like first name, last name,

department, email address.

Id lname fname department email

ProfessorInfo: This table has detail info about instructor such as room number,

phone, office hours, and Office location latitude and longitude. Office Coordinates are useful

in drawing office location on Google map.

email location phone Officehours latitude longitude

3.4.2 SQLite Professors: It is one table in Android phone database which stores data about

instructors which are listed in the directory of application user.

_id name email phone location department officehours latitude longitude

Page 35: SCHOOL MATE - INSTRUCTOR FINDER

26

CHAPTER 4

RESULTS

This chapter talks about the step by step implementation of both android phone

application and web application.

4.1 ANDROID APPLICATION Following steps explain the execution of android mobile phone application with help

of screen shots:

1. When application is launched, there is a welcome screen (Figure 4.1) which stays for three seconds or until user touches the screen. Then screen (Figure 4.2) appears which provides user with two options (Search or Directory). Search option allows user to search for instructor by his/her first name, last name or department name. Directory option provides user with list of instructors which were looked before and saved by user in phone database.

Figure 4.1. School Mate application welcome screen shot 1.

Figure 4.2. School Mate application welcome screen shot 2.

Page 36: SCHOOL MATE - INSTRUCTOR FINDER

27

2. When user presses a search button screen (Figure 4.3) appears. This screen has a drop down list (called spinner in android) which enables user to search by one of following options:

• Last name

• First name

• Department

Figure 4.3. Search instructor screen.

Once the option is selected and user has pressed the search button, query is generated

in form of URL and is send to Web server.

Application after receiving JSON response from web server, parses it to extract

professor name and department information. This information is then inserted into string

array. List activity then displays a list of professors by binding to this array. Figure 4.4 shows

the List Activity.

3. When user selects one of the instructors from the list, a URL is constructed again which queries the server for detail information regarding the selected instructor.

Application then parses web server response and displays screen (Figure 4.5) with

following options:

Page 37: SCHOOL MATE - INSTRUCTOR FINDER

28

Figure 4.4. Search results. Figure 4.5. Instructor detail screen.

• Email

• Call

• Office

• Add to Directory

These options are buttons which are set up to instantiate different activities depending

upon the button selected by user.

4. Selecting email option will launch the Android email client compose mail activity (mail provider depends upon user email settings) with professor’s email address (Figure 4.6). Application uses Intent.SEND_ACTION for email (Intent is a passive data structure holding an abstract description of an operation to be performed).

Similarly Call option uses INTENT.ACTION_DIAL to trigger phone call at

professor’s office phone number (Figure 4.7).

5. Office option will bring the screen with information regarding instructor’s office location, office room number, current office hours and a map button to look at office department on Google map (Figure 4.8). When map button is pressed, longitude and latitude are passed to activity which uses MapView to render office location on map (red pin in Figure 4.9).

Page 38: SCHOOL MATE - INSTRUCTOR FINDER

29

Figure 4.6. Email screen. Figure 4.7. Call results.

Figure 4.8. Office detail screen. Figure 4.9. Office location map.

Page 39: SCHOOL MATE - INSTRUCTOR FINDER

30

MapView displays a map with data obtained from the Google Maps service. When

the MapView has focus, it will capture keypresses and touch gestures to pan and zoom the

map automatically; including handling network requests for additional maps tiles. It also

provides all of the UI elements necessary for users to control the map. Also there is a blue

dot on map which represents user’s current location. This feature can be very helpful in

universities with huge campus especially for new students. User can compare his current

position with desired destination. For example Figure 4.9 displays user current location (Life

Science North) and desired location (GMCS). Map zoom control appears when user taps on

screen and pressing “S” button on key pad toggles between map view and satellite view.

Office hours displayed on screen can be changed by professor through another web

application. These updated hours are reflected whenever user searches for professor.

6. Add to Directory option enables user to add professor’s information on mobile phones database. If the professor’s information already exists in phone database, then it overwrites the information to make sure phone database always have current information. For more information regarding phone’s database schema please refer to Section 3.4. Storing instructor’s information in phone’s database prevents unnecessary server calls and enables user to extract information without being connected to network.

7. If user selects “Directory” button (Figure 4.2), then another activity is started which queries phone’s database to bring list of professors whose names are stored there (Figure 4.10). When one of the list items is selected, control moves to screen (Figure 4.11). This screen is similar to Figure 4.5 however in this case information is extracted from phone’s database instead of Web server.

4.2 JSP WEB APPLICATION The purpose of this application is to enable instructor to modify their office hours.

Because office hours are more prone to change every semester, this application provides an

interface to update office hours. This application has a log in page which requires username

and password. When the instructor is logged in, he can modify office hours (Figure 4.12).

Also there is an option “Comment” in front of office hours to insert some extra information

about that particular office hours. For example sometimes instructors have special office

hours reserved for thesis students or a particular course.

Page 40: SCHOOL MATE - INSTRUCTOR FINDER

31

Figure 4.10. School Mate application directory screen shot 1.

Figure 4.11. School Mate application directory screen shot 2.

Figure 4.12. Office hours modification screen shot.

Page 41: SCHOOL MATE - INSTRUCTOR FINDER

32

CHAPTER 5

CONCLUSION

In this research, I have implemented the mobile phone application “School Mate” as a

client which communicates with JSP based web application (Server). The client is

responsible for sending queries i.e. instructor’s first/last name or department information to

server, server then communicates with database and sends query result back to client in

JSON format. These results are then parsed by phone application and presented to user. The

user can save these results into application’s phone directory so that the information can be

retrieved later without connecting to network. Also there is a web interface which enables

client to modify database contents (office hours) on server side.

5.1 LIMITATION The phone application currently supports search for instructors in limited number of

departments because database only contains information about instructors teaching under

those departments. This thesis purpose is to study the feasibility of this application

implementation. That’s why database constructed has limited number of entries. In order to

support search for every instructor in university, this application needs to communicate with

SDSU database. If this application is officially approved, it can directly communicate with

SDSU database broadening its search range to all instructors teaching in San Diego State

University.

5.2 FUTURE ENHANCEMENTS This application presents the effective communication between phone application and

customized network server. It can be further modified to integrate more functionality. The

possible features which can be included are:

• Enable the user to search the location of various buildings like departments and conference halls inside university.

• Improve web application interface for office hours update by providing a temporary cancellation button which can remove office hours for certain pre decided dates.

Page 42: SCHOOL MATE - INSTRUCTOR FINDER

33

• Display courses taught by the instructor along with their class locations. Even enabling users to share reviews/requirements about courses and helping other application users in course selection.

• Display office locations on map using campus shape files instead of Google Map.

Page 43: SCHOOL MATE - INSTRUCTOR FINDER

34

BIBLIOGRAPHY

[1] Nielsen. Among Mobile Phone Users, Hispanics, Asians are Most-Likely Smartphone Owners in the U.S., 2011. http://blog.nielsen.com/nielsenwire/consumer/among-mobile-phone-users-hispanics-asians-are-most-likely-smartphone-owners-in-the-u-s/, accessed Mar. 2011.

[2] Amit Kumar, Yunfei Liu, Jyotsna Sengupta, and Divya. Evolution of Mobile Wireless Communication Networks: 1G to 4G. International J. of Elect. and Comm. Tech., 1:68-72, 2010.

[3] Benjamin Speckmann. The Android mobile platform. Master’s thesis, Eastern Michigan University, Ypsilanti, MI, 2008.

[4] Machigar Ongtang, Stephen McLaughlin, William Enck and Patrick McDaniel. Semantically Rich Application-Centric Security in Android. Proceedings of the 25th Annual Computer Security Applications Conference (ACSAC), Honolulu, HI, 2009.

[5] Android Developers. Fundamentals, 2011. http://developer.android.com/guide/topics/fundamentals.html, accessed Mar. 2011.

[6] Android Developers. What is Android, 2011. http://developer.android.com/guide/basics/what-is-android.html, accessed Mar. 2011.

[7] Wikipedia.org. Apple iOS, 2011. http://en.wikipedia.org/wiki/IOS_(Apple), accessed Mar. 2011.

[8] Apple iOS Developer. iOS Overview, 2010. http://developer.apple.com/library/ios/#referencelibrary/GettingStarted/URL_iPhone_OS_Overview/index.html, accessed Mar. 2011.

[9] Wikipedia.org. Blackberry OS, 2011. http://en.wikipedia.org/wiki/BlackBerry_OS, accessed Mar. 2011.

[10] Blackberry. Application Development, 2011. http://us.blackberry.com/developers/, accessed Mar. 2011.

[11] Wikipedia.org. Symbian, 2011. http://en.wikipedia.org/wiki/Symbian, accessed Mar. 2011.

[12] Wikipedia.org. Windows Mobile, 2011. http://en.wikipedia.org/wiki/Windows_mobile, accessed Mar. 2011.

[13] Canalys. Google’s Android Becomes the World’s Leading Smartphone Platform, 2011. http://www.canalys.com/pr/2011/r2011013.html, accessed Mar. 2011.

[14] Wikipedia.org. Smartphone Share, 2011. http://en.wikipedia.org/wiki/File:Smartphone_share_current.png, accessed Mar. 2011.

Page 44: SCHOOL MATE - INSTRUCTOR FINDER

35

[15] James Gosling and Henry McGilton. The Java Language Environment: Contents, 1996. http://java.sun.com/docs/white/langenv/index.html, accessed Mar. 2011.

[16] Oracle. JavaServer Pages: A Developer’s Perspective, 2000. http://java.sun.com/developer/technicalArticles/Programming/jsp/, accessed Mar. 2011.

[17] SQLite.org. Categorical Index of SQLite Documents, 2011. http://www.sqlite.org/docs.html, accessed Mar. 2011.

[18] MySQL.com. Why MySQL, 2010. http://www.mysql.com/why-mysql/, accessed Mar. 2011.

[19] MySQL.com. Top Ten Reasons to Use MySQL, 2011. http://www.mysql.com/why-mysql/topreasons.html, accessed Mar. 2011.

[20] JSON.org. Introducing JSON, 2011. http://www.json.org/, accessed Mar. 2011.