Expert Spring MVC and Web Flow

(Dana P.) #1

Use Case #2


The second use case is more complicated because it returns a list of flights based on the user’s
search conditions. For this service method, we will encapsulate the search criteria inside a
FlightSearchCriteriaclass. We will call the method findFlights()(Listing 4-6), and it will
return a list of Flightobjects.
The use case in Listing 4-3 defines the parameters for the FlightSearchCriteriaclass,
mentioning that the user can search by arrival and departure information.


Listing 4-3.SearchFlights Class


public class FlightSearchCriteria {


private String departFrom;
private Date departOn;
private String arriveAt;
private Date returnOn;

public Date getReturnOn() {
return returnOn;
}
public void setReturnOn(Date arriveOn) {
this.returnOn = arriveOn;
}
public Date getDepartOn() {
return departOn;
}
public void setDepartOn(Date departOn) {
this.departOn = departOn;
}
public String getArriveAt() {
return arriveAt;
}
public void setArriveAt(String arriveAt) {
this.arriveAt = arriveAt;
}
public String getDepartFrom() {
return departFrom;
}
public void setDepartFrom(String departFrom) {
this.departFrom = departFrom;
}

}


We’ve made a conscious decision not to use the Airportclass for the departFromand
arriveAtfields. This class represents search criteria, and searching for arrival cities isn’t always
an exact science. A user might misspell the city name or forget the airport code, for example.


CHAPTER 4 ■JUMP INTO SPRING MVC 45
Free download pdf