Supervisor: Victor Kulikov Oded Duek Aviv Grinblat Final presentation Spring 2010.

23
Supervisor: Victor Kulikov Supervisor: Victor Kulikov Oded Duek Oded Duek Aviv Grinblat Aviv Grinblat Final presentation Spring 2010

Transcript of Supervisor: Victor Kulikov Oded Duek Aviv Grinblat Final presentation Spring 2010.

Supervisor: Victor KulikovSupervisor: Victor Kulikov

Oded DuekOded Duek Aviv GrinblatAviv Grinblat

Final presentation Spring 2010

MotivationMotivation Business owners often want to advertise their

business to people that are located near their businesses.

It would be nice if there was an easy way to check the

efficiency of the advertisements.

In order to improve their services, business owners

might want to do surveys.

GoalsGoals Gain experience in programming a complex

and varied application.

Learn to program in JAVA

Make GUI, work with SQL based database

Use different kind of API’s

Learn to work with Web Service

Use Design Patterns to solve common problems

TechnologiesTechnologies JAVA

Java DB (Derby)

Soap Web Services

Netbeans

API (JXMapKit, JFreeCharts and more)

GUIGUI

BLLBusiness logic layer

BLLBusiness logic layer

DALData access layer

DALData access layer

DatabaseDerby DB

N-tiersN-tiers

Keeps tables with data neutral and independent from application.

Database Layer:

GUI Layer:

Business Logic Layer:

Data Access Layer:

Controls an application’s functionality by performing detailed processing.

Displays and receive information related toBLL layer.

Manages the communication with Database layer.

Application DescriptionApplication Description

Comunication:Soap messages using JAX-WS

Client side: GUI Most of BLL Getting maps from OpenStreetMap Geocoding from Yahoo

Server side: Small part of BLL DAL Database

DatabaseDatabase

On Delete Cascade - specifies whether you want rows to be deleted in a child table when corresponding rows are deleted in the parent table

BUSINESSOWNER

USERNAME ( VACHAR)

ADDRESS ( VACHAR)

PHONE (VACHAR)

EMAIL ( VACHAR)

SEX (VACHAR)

AGE (INTEGER)

USER

USERNAME ( VACHAR)

PASSWORD ( VACHAR)

BUSINESS

BUSINESSID (BIGINT )

LATITUDE (DOUBLE)

LONGITUDE (DOUBLE)

BUSINESSNAME (VACHAR)

OWNERNAME (VACHAR)

ADDRESS ( VACHAR)

BUSINESSEVENT

EVENTNAME (VACHAR)

EVENTEXPIRATION (VACHAR)

ID ( BIGINT )

EVENTBEGIN (VACHAR)

BUSINESSID (BIGINT )

EVENTAREA (INTEGER)

CLIENTS_IN_BEGIN (INTEGER)

CLIENS _OUT_BEGIN (INTEGER)

CLIENTS_IN_END (INTEGER)

CLIENTS_OUT_END (INTEGER)

YESANSWER (DOUBLE)

NOANSWER (DOUBLE)

FEEDBACK

FEEDBACKID (BIGINT )

EVENTID (BIGINT )

FEEDBACKSTRING(VACHAR)

DalDal

CreateStatement:Creates a Statement object for sending SQL statements to the database.

Interface Connection: A connection (session) with a specific database. SQL statements are executed and results are returned within the context of a connection.

MAX Function: Returns the largest value of the selected column

JOIN Operation:Combines records from two or more tables

BLLBLLClient Side Class Diagram:

Business-_ businessID:long-_ businessName:String-_ ownerName:String-_ businessPoint:Point-_ businessAddress:String-_ eventSet:TreeSet<Event>

+Business()+getAddress():String+getBusinessPoint():Point+getOwnerName():String+getEventList(): TreeSet<Event>+getBusinessID():long+getBusinessName():String+setAddress()+setBusinessPoint()+setOwnerName()+setEventList()+setBusinessID()+setBusinessName()+compareTo():int+equals():boolean+toString():String

User-_ userName:String-_password:String-_ businessList:List<Business>-_ isBusinessLoaded:boolean

+User()+addBusiness()+removeBusiness()+getBusinessList():List<Business>+findBusinessByID():Business+getPassword():String+getUserName():String+isBusinessLoaded():boolean+setBusinessLoaded()+checkPassword():boolean+setPassword()+compareTo():int+toString():String

BusinessOwner-_address:String-_phone:String-_email:String-_age:int-chooseButton:enum-_sex: chooseButton-_age:int

+businessOwner()+getAdress():String+getPhone():String+getEmail():String+getSex(): chooseButton+getAge():int+setAddress()+setPhone()+setEmail()+setSex()+setAge()

Event-_ eventID:long-_ businessID:long-_name:String-_ beginTime:Date-_ expireTime:Date-_ eventArea:int-_ myFeedback:feedback-_ clientInBegin:int-_ clientBegin:int-_ clientInEnd:int-_ clientEnd:int-_ yesAnswer:double-_ noAnswer:double-_formatter:SimpleDateFormat

+Event()+getEventID():long+getBusinessID():long+getName():String+getBeginTime():Date+getExpireTime():Date+getEventArea():int+getFeedback():Feedback+getCounterInBegin():int+getCounterBegin():int+getCounterInEnd():int+getCounterEnd():int+getYesAnswer():double+getNoAnswer():double+getNotAnswered():double+setEventId()+setBusinessId()+setName()+setBeginTime()+setExpireTime()+setEventArea()+setMyFeedback()+setCounterInBegin()+setCounterBegin()+setCounterInEnd()+setCounterEnd()+setYesAnswer()+setNoAnswer()+compareDates():int+toString():string+compareTo():int

Feedback-_ feedbackID:long-_ eventID:long-_ feedbackQuestion:String

+Feedback()+getFeedbackID():long+getEventID():long+getFeedbackQuestion():String+setFeedbackID()+setEventID()+setFeedbackQuestion()

Point-_latitude:double-_longitude:double

+Point()+getLatitude():double+getLongitude():double+setLatitude()+setLongitude()+toString():String+equals():boolean

Manager-_loaded:boolean-_ userSet:TreeSet<User>

+manager()+removeUser():boolean+addUser():boolean+getUserSet():Set<User>+isExist():boolean+isLoaded():boolean+getUser():user+identifyUser():boolean+setLoaded()

Encrypt-_key:String-_Encrypt:Encrypt

-Encrypt()+getInstance():Encrypt+encryptString():String+decryptString():String

*

*

1

1

1

1

*

BLLBLLServer Side Class Diagram:

Dal

-dbUrl:String-_ conn:Connection-_ stmt:Statement-_formatter: SimpleDateFormat

+createConnectionDal()+getObjectsDal():List<String>+getBusinessOwnerDal():List<String>+insertBusinessOwnerDal()+insertBusinessDal()+insertBusinessEventDal()+updateBusinessDal()+updateUserDal()+insertUsersDal()+updateEventDal()+updateAnswersDal()+getStatisticsDal():List<String>+getMaxDal():long+updateRowsDal()+removeRowDal()+shutDownDal()

Encrypt

-_key:String-_Encrypt:Encrypt

-Encrypt()+getInstance():Encrypt+encryptString():String+decryptString():String

Point

-_latitude:double-_longitude:double

+Point()+getLatitude():double+getLongitude():double+setLatitude()+setLongitude()+equals():boolean

Listener

-_ eventID:long-_ businessID:long-_ ownerName:String-_ businessName:String-_ beginTime:Date-_ expireTime:Date-_ eventArea:int-_ feedbackQuestion:String-_ eventText:String-_ businessLocation:Point-_counter:int-_ answeredYes:int-_ answeredNo:int-_ notAnswered:int-_ answeredPercentYes:double-_ answeredPercentNo:double-_ clientInAreaSet:Set<Client>-_ clientInBusinessSet:Set<Client>

+Listener()+update()+setAnswer()+getEventID():long+getBusinessID():long+getUserName():String+getBusinessName():String+getBusinessLocation():Point+getEventText():String+getFeedbackQuestion():String+getAccumulateCounter():int+getYesAnswer():double+getNoAnswer():double+getNotAnswered():double~getClientInAreaSet():Set<Client>~isInArea():boolean~isInBusiness():boolean-distance():double-deg2rad():double-rad2deg():double~getClient():Client~setBusinessInfo()~setEventInfo()~setCounter()

ListenerList

-_ listenerList:List<Listener>-_formatter: SimpleDateFormat-list:ListenerList

-ListenerList()+getInstance(): ListenerList~addListener()+getListSize():int+getListener():Listener+setEventAnswer()~updateListenerByBusinessID()~updateListenerByEventID()~DeleteAndRemoveListenerByEventID()~DeleteAndRemoveListenerByBusinessID()~DeleteAndRemoveListenerByUsername()+getListenerByEventID():Listener+getLocation():List<String>

Connector

-_formatter: SimpleDateFormat

+addListener()+getClientLocation():List<String>

*

1

1

1

1

1

1

This interface imposes a total ordering on the objects of each class thatimplements it. This ordering is being performed using compareTo method.

BLLBLL

Comparable:

Containers: TreeSet List Set

Security:Each bit or character from the password plaintext is encrypted by a XOR operation with a bit or character from a secret key resulting in a cipher text.

str key cipher

BLLBLL

Problem: How the clients get the advertisements and feedbacks? How to get the positions and feedback answers from clients?

Solution:API based on Observer Design Pattern.

Communication with client objects:

<<interface>>

Observer

+update()

Observable

+addObserver(Observer)+deleteObserver(Observer)+notify()

Listener

-_ eventID-_ businessLocation-_ eventText-_ feedbackQuestion

+update()+getBusinessLocation()+getFeedbackQuestion()+getEventText()+getEventID()+setAnswer()

Client

+getState()+setState()

*observers

subject

BLLBLLAdd Event use case:

BLLBLLWeb Services:

Web Services models fall into two categories: REST based SOAP/WSDL-based

Used to integrate computer applications that are written in different languages and run on different platforms. Web services are language and platform independent because vendors have agreed on common web service standards.

JAX-WS: The Java API for XML Web Services is the current model for SOAP-based web services in Metro (web services stack).

GUIGUI

JXMapKit - An open source Swing component created by the developers at SwingLabs.

JXMapKit is preconfigured with 2 default providers: OpenStreetMap NASA’s Blue Marble satellite images

Customizing the Map: Re-Centering Adding Waypoints to a set Using a custom Waypoint Renderer Drawing static text Adding polygon overlay using formula: X+latitudeDist∙cos(w∙t) + Y+longitudeDist∙sin(w∙t) Adding legend image

Map API:

JFreeChart- a free chart library for the Java platform. It is designed for use in applications,applets, servlets and JSP

Charts API:

Creating charts with JFreeChart is a three step process: create a dataset containing the data to be displayed in the chart. create a JFreeChart object that will be responsible for drawing the chart. draw the chart to some output target.

GridBagLayout-flexible layout manager that aligns components vertically and horizontally, without requiring that the components be of the same size.

GUIGUI

BalloonTip API - Allows adding to swing componentdifferent types of balloons that shows informationWe wrote the text in HTML

JOptionPane - makes it easy to pop up a standard dialog box that prompts users for a value or informs them of something

JClock - A simple clock consists of SpinnerNumberModel components arranged with FlowLayout

JCalendar - JCalendar is a Java date chooser bean for graphically picking a date

GUIGUI

Design PatternsDesign Patterns

Singleton One instance of a class or one value accessible globally in an application. (Encrypt, ListenerList )

State An object's behavior change is represented by its member classes, which share the same super class.

Observer One object changes state, all of its dependents are updated automatically.

StatFram

+showEvents()

DashBoard

+showEvents()

EventsMenu

+showEvents()

EventsDetails

SUMMARYSUMMARYGain experience in programming a complex

and varied application

GUIGUI

BLLBusiness logic layer BLL

Business logic layer

DALData access layer DAL

Data access layer

DatabaseDerby DB

Business-_ businessID:long-_ businessName:String-_ ownerName:String-_ businessPoint:Point-_ businessAdress:String-_ eventList:TreeSet

+Business()+getAddress():String+getPoint():Point+getOwnerName():String+getEventLisr():TreeSet+getBusinessId():long+getBusinessName():String+setAddress()+setPoint()+setOwnerName()+setEventLisr()+setBusinessId()+setBusinessName()+compareTo()+toString()

User

-_ userName:String-_password:String-_ businessList:List-_ isBusinessLoaded:boolean

+User()+addBusiness()+removeBusiness()+getBusinessList():List+findBusinessByID():Business+getPassword():String+getUserName():String+isBusinessLoaded():boolean+setBusinessLoaded()+checkPassword():boolean+setPassword()+compareTo():int+toString():String

BusinessOwner

-_address:String-_phone:String-_email:String-_age:int-chooseButton:enum-_sex:chooseButton-_age:int

+businessOwner()+getAdress():String+getPhone():String+getEmail():chooseButton+getAge():int+setAddress()+setPhone()+setEmail()+setSex()+setAge()

Event-_ eventID:long-_ businessID:long-_name:String-_ beginTime:Date-_ expireTime:Date-_ eventArea:int-_ myFeedback:feedback-_ clientInBegin:int-_ clientBegin:int-_ clientInEnd:int-_ clientEnd:int-_ yesAnswer:double-_ noAnswer:double-_formatter: SimpleDateFormat

+Event()+getEventId():long+getBusinessId():long+getName():String+getBeginTime():Date+getExpireTimr():Date+getEventArea():int+getFeedback():feedback+getCounterInBegin():int+getCounterInEnd():int+getCounterEnd():int+getYesAnswer():double+getNoAnswer():double+getNotAnswered():double+setEventId()+setBusinessId()+setName()+setBeginTime()+setExpireTime()+setEventArea()+setMyFeedback()+setCounterInBegin()+setCounterInEnd()+setCounterEnd()+setYesAnswer()+setNoAnswer()+compareDates():int+toString():string+compareTo():int

Feedback

-_ feedbackId:long-_ eventId:long-_ feedbackQuestion:String

+feedback()+getFeedbackID():long+getEventID():long+getFeedbackQuestion():String+setFeedbackId()+setEventId()+setFeedbackQuestion()

Point

-_latitude:double-_longitude:double

+Point()+getLatitude():double+getLongitude():double+setLatitude()+setLongitude()+toString():String+equals():boolean+hashCode():int

Manager

-_loaded:boolean-_ userSet:TreeSet-_pass:String

+manager()+removeUser():boolean+addUser():boolean+getUserSet():Set+isExist():boolean+getUser():user+indentifyUser():boolean+setLoaded()

Encrypt

-_key:String-_Encrypt:Encrypt

-Encrypt()+_ getInstance():Encrypt+_ encryptString():String+decryptString():STring

*1

*1

11

1

1

1

1

1

1

Dal

-dbUrl:String-UserTable :String-BusinessOwnerTable :String-BusinessTable :String-BusinessEventTable :String-FeedbackTable :String-_ conn:Connection-_ stmt:Statement-_formatter :SimpleDateFormat

+createConnectionDal ()+getObjectsDal ():List<String>+getBusinessOwnerDal ():List<String>+insertBusinessOwnerDal ()+insertBusinessDal ()+insertBusinessEventDal ()+updateBusinessDal ()+insertFeedbackDal ()+updateUserDal ()+insertUsersDal ()+updateEventDal ()+updateAnswersDal ()+getStatisticsDal ():List<String>+getMaxDal ():long+updateRowsDal ()+removeRowDal ()+shutDownDal ()

Encrypt

-_key:String-_Encrypt :Encrypt

-Encrypt()+_ getInstance ():Encrypt+_ encryptString ():String+decryptString (): STring

Point

-_latitude:double-_longitude:double

+Point()+getLatitude ():double+getLongitude ():double+setLatitude ()+setLongitude ()+distFrom():float+toString():String+equals():boolean+hashCode():int

Listener

-_ eventID :long-_ businessID :long-_ ownerName :String-_ businessName :String-_ beginTime :Date- _ expireTime :Date-_ eventArea :int-_ feedbackQuestion :String-_ eventName :String-_ businessLocation :Point-_counter:int-_ answeredYes :int-_ answeredNo :int-_ notAnswered :int-_ answeredPercentYes :double-_ clientInAreaSet :Set<client>-_ clientInBusinessSet :Set<client>

+listener()+update()+setAnswer ()+getEventID ():long+getBusinessID ():long+getUserName ():String+getBusinessName ():String+getBusinessLocation ():Point+getEventName ():String+getFeedbackQuestion ():String+getAccumulateCounter ():int+getYesAnswer ():double+getNoAnswer ():double+getNotAnswered ():double~getClientInAreaSet ():Set<client>~isInArea ():boolean~isInBusiness ():boolean-distance():double-deg2rad ():double-rad2deg ():double~getClient ():client~setBusinessInfo ()~setEventInfo ()~setCounter ()

ListenerList

-_ listenerList :List<listener>-_formatter :SimpleDateFormat-list:listenerList

-listenerList ()-getInstance (): listenerList+addListener ()+getListSize ()+getListener ():listener+setEventAnswer ()+updateListenerByBusinessID ()+updateListenerByEventID ()+DeleteAndRemoveListenerByEventID ()+DeleteAndRemoveListenerByBusinessID ()+DeleteAndRemoveListenerByUsername ()+getListenerByEventID ()

Connector

-_formatter :SimpleDateFormat

+addListener ()

*

1

1

1

1

1

1

1 1

EnterWindow

-_ userFrame : NewUserFrame-_ businessScreen :BusinessOwnerWindow

+EnterWindow ()-main ()

AdminMenu

-_ parentScreen : enterWindow

+showUsers ()DashBoard

-_ businessDetailsScreen :BusinessDetails-_ eventWindowScreen :EventsMenu-_ enterBusinessDetailes :NewBusinessWindow-_ parentScreen :enterWindow-_map:map

+BusinessOwnerWindow ()+addBusinessToJList ()+removeBusinessFromJList ()+showBusiness ()+showEvents ()

BusinessDetails

-parentBusinessOwnerScreen :businessOwnerWindow

+BusinessDetails ()+showDetailsToScreen ()

EventsMenu

-_ eventDetailsScreen :eventDetails-_ parentScreen :businessOwnerWindow

+EventsMenu()+ClearList ()+ShowEvents ()+addEventToJList ()+removeEventFromJList ()

EventsDetails

-_calendar:Calendar-_ adQuesions :String []-_ parentScreen :statFrame

+EventDetails ()+showDetailsToScreen ()+SetBeginTime ()+SetEndTime ()

Time

-formatter: SimpleDateFormat-_ parentScreen :Frame-Calendar: gui.JCalendar

+calendar()

Map

_mapScreen :map_parentScreen :businessOwnerWindow

+map()+showLocationOnMap ()+paintWaypoint ():boolean-distance()-deg2rad()-rad2deg ()

StatFrame

+showEvents ()

StatisticsWindow

-_ parentFrame :JFrame-barChart :BarChart-pieChart :PieChart

+statitsticsWindow ()-showStatistics ()-refreshAction ()-returnAction ()

BarChart

+BarChart ()+createDataset (): DefaultCategoryDataset+createChart (): ChartPanel

JCalender JClock

-spinnerHour : JSpinner-spinnerMinute :JSpinner

+JCLock ()-initComponents ()

ViewUser

-_ parentFrame :JFrame

+viewUser()+showDetailsToScreen ()

Controler

-_formatter: SimpleDateFormat-_curBusiness :business-_curUser :String-_beginDate :Date-_endDate:Date-chooser :int-buttonChooser:enum-button:buttonChooser-_curEven t:Event-_ businessID :long-_ eventID :long-_ feedbsckID :long

+setDates ()+setDatesNul l()+toDate()+stringToDate ():Date+getUser():String+setUser()+getBusiness ():business+setBusiness ()+getBeginDate ():Date+getEndDate ():Date+getEvent():Event+setEvent()+dateAndTimeToString ():String+dateAndTimeToStringDate ():String+dateAndTimeToStringTime ():String+currentDateString ():String+currentDate ():Date+setBusinessID ()+setEventID ()+setFeedbackID ()+getFeedbackID ():long+getEventID ():long+getFeedbackID ():long+incBusinessID ()+incEventID ()+incFeedbackID ()

PieChart

attributes

+PieChart()+createDataset (): PieDataset+createChart (): ChartPanel

SUMMARYSUMMARY Make GUI, Use different kind of API’s

SUMMARYSUMMARYWork with SQL based database

BUSINESSOWNER

USERNAME ( VACHAR)

ADDRESS ( VACHAR)

PHONE (VACHAR)

EMAIL ( VACHAR)

SEX ( VACHAR)

AGE (INTEGER)

USER

USERNAME ( VACHAR)

PASSWORD ( VACHAR)

BUSINESS

BUSINESID (BIGINT )

LATITUDE (DOUBLE)

LONGITUDE (DOUBLE)

BUSINESSNAME (VACHAR)

OWNERNAME (VACHAR)

ADDRESS ( VACHAR)

BUSINESSEVENT

EVENTNAME (VACHAR)

BUSINESSID (BIGINT )

ID ( BIGINT )

EVENTBEGIN (VACHAR)

EVENTEXPIRATION (VACHAR)

EVENTAREA (INTEGER)

CLIENTS_IN_BEGIN (INTEGER)

CLIENS _OUT_BEGIN (INTEGER)

CLIENTS_IN_END (INTEGER)

CLIENTS_OUT_END (INTEGER)

YESANSWER (DOUBLE)

NOANSWER (DOUBLE)

FEEDBACK

FEEDBACKID (BIGINT )

EVENTID (BIGINT )

FEEDBACKSTRING(VACHAR)

Learn to work with Web Service

SUMMARYSUMMARYUse Design Patterns to solve common problems

StatFram

+showEvents()

DashBoard

+showEvents()

EventsMenu

+showEvents()

EventsDetails

<<interface>>

Observer

+update()

Observable

+addObserver(Observer)+deleteObserver(Observer)+notify()

Listener

-_ eventID-_ businessLocation-_ eventText-_ feedbackQuestion

+update()+getBusinessLocation()+getFeedbackQuestion()+getEventText()+getEventID()+setAnswer()

Client

+getState()+setState()

*observers

subject

singleton

All in JAVA