Courses/CS 491ab/Winter 2008/Yu Liu

From CSWiki

Jump to: navigation, search

Contents

[edit] 1 Week 1 - January 4, 2008

Introduction. My email: wangdi_weiwei@126.com

[edit] 2 Week 2 - January 11, 2008

[edit] 3 Week 3 - January 18, 2008

You should fill in this page every week. Also, look at Hibernate Annotations.

-- ~~~~

[edit] 4 Week 4 - January 25, 2008

[edit] 5 Week 5 - February 1, 2008

Pagination problem is very common. Every web developer will meet it.

This week I prepared a pagination demo. The idea is that firstly select all records from the database, and secondly compute the records we need to display on the page according to the number of current page and record's number in each page, and get the corresponding records from the result set and display them on the page.


The main code to compute:

public class PageControl 
{
	private int curpage;	//current page
	private int prepage;	//previous page
	private int nextpage;	//next page
	private int totalpage;	//total pages
	private int start;	//the record's start number of current page
	private int end;	//the record's end number of current page	
	private int totalnum;	//total number of records
	private int int_num = 5;//record's number in each page
	
	private int temp_curpage;
	private int temp_totalpage;
	private int temp_start;
	private int temp_end;
	private int temp_totalnum;
	
	public void init(int curpage,int totalnum)
	{
//		total number of records
		temp_totalnum = totalnum;
		
//		total pages
		temp_totalpage = (int)Math.ceil((double)totalnum/(double)int_num);
		
//		current page
		if (curpage > 1)
		{
			if (curpage > temp_totalpage)
			{
				temp_curpage = temp_totalpage;
			}
			else
			{
				temp_curpage = curpage;
			}
		}
		else
		{
			temp_curpage = 1;
		}
		
//		the record's start number of current page
		temp_start = (temp_curpage-1) * int_num + 1;
		
//		the record's end number of current page
		temp_end = temp_curpage * int_num;
		if (temp_end > temp_totalnum)
		{
			temp_end = temp_totalnum;
		}
		
		setCurpage();
		setPrepage();
		setNextpage();
		setTotalpage();
		setStart();
		setEnd();
		setTotalnum();
	}
	//get and set method......
}

The main code to operate result set:

try
		{
			conn = DBConnection.getConnection();
 
			//the point can move back and forth
			ps = conn.prepareStatement(sql.toString(),ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
			rs = ps.executeQuery();
			//get the total number of records 
			rs.absolute(-1);
			sumNote = rs.getRow();
			//get records we need
			if (dto.getRecordC()!=null && !"".equals(dto.getRecordC()))
			{
				pageControl.setInt_num(Integer.parseInt(dto.getRecordC()));
			}
			
			pageControl.init(Integer.parseInt(curpage),sumNote);
			if (pageControl.getStart() < 1)
			{
				rs.absolute(1);
			}
			else
			{
				rs.absolute(pageControl.getStart());
			}
			if (sumNote>0)
			{
				do
				{
					dtoTemp = new FYDto();
					dtoTemp.setStudentId(Integer.toString(rs.getInt("studentId")));
					dtoTemp.setStudentName(rs.getString("studentName"));
					dtoTemp.setStudentAge(Integer.toString(rs.getInt("studentAge")));
					dtoTemp.setStudentPhone(rs.getString("studentPhone"));
					dtoTemp.setStudentAddress(rs.getString("studentAddress"));
					dtoTemp.setStudentClass(rs.getString("studentClass"));
					list.add(dtoTemp);
					if (!rs.next())
					{
						break;
					}
				}while(rs.getRow() < pageControl.getEnd() + 1);
			}
		}

[edit] 6 Week 6 - February 8, 2008

This week I prepare my project summary and design tables for my project.

So far I decide to do this project with struts+hibernate. Some page may include some Ajax technology.

Project Requirement Document

Current company status

Business general information

HuiRui Company is one of the most famous pharmaceutical factory in America. From 1992, this company began to set up a joint venture in China and its distribution network has already extends all over the provinces and cities. The company already has 4000 customers and 300 salesmen. It is hard for headquarters to manage the work situation of salesmen and to comprehend the status of customers in time, because most of salesmen are employed at respective provincial capital. The company has ever asked for salesmen to send their work report forms to headquarters from email, but due to the limited number manager, it is hard to have a comprehensive analysis on all work report forms and then, it is close to lose control to manage customers and salesmen.

Along with the business expansion, the difficulty of managing customers and salesmen increases. The company decides to develop a customer management system to enhance the management level.


Personnel general information

There are manager and salesmen. The manager in headquarters is in charge of all salesmen. The salesmen are divided into manager and representative two level. Each manager is in charge of sale and management in an appointed region(take a province as the unit). Each representative is in charge of sale in an appointed region(take a city as the unit).


Production of Company

name price

xx xx

xx xx


Main function about this system: 1. All salesmen can fill in their work report forms directly by the Internet at their work place. 2. Manager can know the information about customers and work situation about salesmen by this system. 3. Manager can look over work of salesmen.


The report forms that sale representative need to fill in

1 customer archives table content

customer name place (province, city, district, street number)

customer level (important, common, small customer)

general manager name telephone(office, home)

business principal name telephone(office, home)

finance principal name telephone(office, home)

annual sale amount(include all companies)

annual sale amount for our company

credit level(1,2,3)

visit times each month(important 4, common 2, small 1)

sale representative name telephone

report time

2 important person archives

name

sex

age

marriage

birthday

id

company name

business

home address

telephone(office, home)

interest

support level(good, common, bad)

(General manager, business and finance principal must be included)

3 daily report

name

date

customer name

visited person name

talk content

result

customer storage

4 work plan

name

date

visited customer name

visited person name

5 sale statement of accounts

customer name

sale production

time

amount

price

total money

receivable money

receivable money over three month

customer storage



The page (Requirement Specification)we look over

1 customer

@ look over summary information about customer

@ there is a link 'specific' after every information so that you can look over specific information (include customer archives and medicine storage )

@ select information by compositive or specific

@ there is a link that used to look over visit record(manager can look over all information and sale reprensentative only can look over themselves')

2 salesmen

@ look over summary information about salesmen

@ there is a link 'specific' after every information so that you can look over specific information(include his all customers )(manager can look over all information and sale reprensentative only can look over themselves')

3 work looking over

@ look over daily report

input start and end time to look over daily report. default is from Monday to Friday this week. manager can select personnel list that did not submit report forms in time and delay times.(manager can look over all information and sale reprensentative only can look over themselves')

@ look over work plan

salesmen should submit next week work plan at this weekend.

@ look over the frequence to visit customer

input start and end time to look over the frequence. default is from 30 days ago to now.

manager can select personnel information under appointed times(manager can look over all information and sale reprensentative only can look over themselves')

@ look over the content of report forms

the page will display all salesmen.click on their names and entry next page.

input start and end time and default is from 26th last month to 25th this month.

and then it will display types and date of report forms and click on links to look over specific content.

[edit] 7 Week 7 - February 15, 2008

This week I try to find a project , but I still can not find a proper project to start till now.

Spring is a integrated framework that supports solution to web application. I understand that one of Spring applications in web development is that we can manage java objects flexiblly with Spring. Dependency Injection is a characteristic of Spring. There are 3 methods to implement Dependency Injection .

1. interface injection

public class Type1Demo {	
	public void fun(ExInterface ex){
		ex.doSomthing();
	}
 
}

2.set value injection(by set method)

public class Type2Demo {
	
	private MyClass myObject;
	
	public MyClass getMyObject() {
		return myObject;
	}
	
	public void setMyObject(MyClass myObject) {
		this.myObject = myObject;
	}
}

3.constructor injection

public class Type3Demo {
	
	private MyClass myObject;
	
	public Type3Demo(MyClass myObject){
		
		this.myObject = myObject;
	}
}

I integrated spring and struts into one project to show how spring manages java objects in web application. And maybe I will use this technology in my future project.

beans-config.xml

...
 <bean id="testService"
         class="hello.service.TestServ">
      <property name="testDAO">
         <ref bean="myDAO"/>
      </property>   
   </bean>
 
    <bean name="/HelloWorld" 
          class="hello.action.HelloAction"
          singleton="false"
          >
          
        <property name="bo">
            <ref bean="testService"/>
        </property>
    </bean>
...

struts-config.xml

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
        <set-property property="contextConfigLocation" value="/WEB-INF/config/beans-config.xml"/>
    </plug-in>

[edit] 8 Week 8 - February 22, 2008

[edit] 9 Week 9 - February 29, 2008

My project summary:

Project name: Beijing Star Longda Economic Development Company Ltd Automobile Exhibition System


1. Introduction

GuangZhou Honda Asian Games Village Agency is a automobile store Beijing Star Longda Economic Development Company Ltd owned. To reveal automobiles better , enhance the reputation of company and sale performance, this company decides to develop a online exhibition system.

2. System Summary

2.1 Function Introduction

This system is designed to reveal automobiles, public news and manage messages left by customers.

2.2 User’s characteristic

The users of this system devided into 2 kinds : visitors and backstage administrators. Visitors can look through various parameters of automobiles and leave messages in the system. Backstage administrators can add automobiles, news and manage messages.

3. “about us” Module

3.1 Introduction

This module is used to reveal the introduction of company, employees and general manager’s speech.

3.2 Introduction of company

Reveal the introduction of company. The introduction is added by administrators from backstage.

3.3 People

Reveal the personal pictures of staffs and together working pictures.

4. “about us” Module

4.1 Introduction

This module mainly operates functions of the automobile sale.

4.2 Online Order

After visitors click on “online order”, they can fill in order

information and contact method. Administrators can view order information and then give responds.

4.3 Type of automobiles

According to automobile model, pictures and specified parameter that administrators add from backstage, customers can search conveniently.

4.4 Automobile purchase guide

After visitors click on “Automobile purchase guide”, they can learn how to choose automobiles according to articles administrators uploaded.

4.5 Sale flow After visitors click on “Sale flow”, they can learn how to purchase automobiles according to articles administrators uploaded.

5. “News Center” Module

5.1 Introduction

This module aims to reveal company’s news.

5.2 Industry News

Reveal automobile news in the list form.

6. “After service” Module

6.1 Introduction

Reveal maintenance material to visitors.

6.2 Warranty policy

Reveal warranty policy to visitors.

6.3 Maintenance details

Reveal articles that guide customers to maintain their automobiles.

6.4 Service flow

Reveal the after service flow to customers in the form of articles.

7. “Hot spot activity” Module

7.1 Introduction

Publicize activities for sales promotion and reward.

7.2 Activities

Reveal hot spot activities in the news form.

8. “Wanted” Module

8.1 Introduction

Invite people to apply for jobs.

8.2 Self-recommendation

After visitors click on “self-recommendation”, they can submit a resume including name, telephone number and so on.

8.3 Job application information

Reveal the information of talented person company need.

9. “Contact us” Module

9.1 Introduction

Reveal contact method of company.

9.2 Contact method

Reveal detailed contact method of company including address, telephone number and fax.

9.3 Complaint and Suggestion

This function is implemented by leaving messages. Customers can submit problems and fill in telephone numbers and emails. Administrators can view messages. If needed, administrators can respond from email or telephone.


I prepare to implement this system with Struts and Hibernate. I also want to internationalize this web project in Chinese and English.


[edit] Final - March 14, 2008

Brief project description

OpenSocial is a set of common APIs for building social applications across many websites. In my project, I will use this API to develop some social applications like widget of iGoogle and Google Gadgets on Orkut, a container support OpenSocial. Now, I want to develop social applications that can play music, flash and online-TV.


Anticipated users

Orkut users and then users of other websites supporting OpenSocial.


Main conceptual (i.e., user-level) objects

Social applications can be used in any OpenSocial-enabled website.


Primary conceptual (i.e., user-level) operations

Users can add these applications or gadgets into their pages on Orkut.

Why I am interested in this project

It is a trend that web community became more social and OpenSocial aims to popularize SNS(Social Networking Services). OpenSocial is new. Developers only have to learn the APIs once in order to build applications that work with any OpenSocial-enabled website. And also OpenSocial only requires standard JavaScript, HTML and XML. We do not need to learn new languages for SNS websites.


Status

Right now, the social applications are just available for developers in the Orkut sandbox. I am waiting for a confirmation email to start my OpenSocial application.