aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Implement ANY to ANY flight search Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Implement ANY to ANY flight search" Watch "Implement ANY to ANY flight search" New topic
Author

Implement ANY to ANY flight search

Lijun An
Greenhorn

Joined: Feb 05, 2002
Posts: 15
Hi friends,
What do you think of implementing flight search from ANY origin to ANY destination? How do you do that?
Please comments.
Thanks with regards,
Lijun
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

The only this that I did was to add an entry to my array that had the lists, as the first item to say "All Airlines", or "All Departure Cities", then in my building of the criteriaString I made sure not to include the fields that had Al selected.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Terry Wang
Ranch Hand

Joined: Aug 27, 2001
Posts: 102
i don't have my code with me, but here's roughly what i did:
1) first i tokenized the criteria string and put the key/value pairs into a hashtable, which is basically all my criteriaFind()'s duty.
2) then in another method, i go through the hashtable and grab the values out, if a value is "any"(ignore case), then i just ignore it, so for example, if you have "any" for carrier, "sfo" for origin and "any" for destination, i only need to find those DataInfo objects which have "sfo" as the origin from db.db. in another case, if all values are "any", just return all DataInfo objects.


scjp/jd/wcd/mcad/scea 1
Terry Wang
Ranch Hand

Joined: Aug 27, 2001
Posts: 102
forgot to say, i also have a criteria counter to check if all criteria have been matched. for example, if you have carrier, origin, destination, time(only for example), then before searching/returned any DataInfo objects, the counter should be 4, which means the no errors occur during the process of getting the criteria values.
if you specify "any" for any of them, the counter will increment by one automatically, so i don't totally "ignore" it.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

If the user select "Any, you don't need to include that field in the criteriaString passed to the criteriaFind method.
example
Airlines - Any
Origin Airport SFX
Arrival Airport Any
your criteria string would be "Origin Airport = 'SFX'"
there shouldn't need to have any of the other two fields in the string.
Just my opinion too.
Mark
Rajesh Matti
Ranch Hand

Joined: Jan 07, 2002
Posts: 121
Mark - What was your approach on 'Any Origin' and 'Any Destination'. Did you use Data.getRecord() or you implemented a wild card search in the Data.criteriaFind() ? I have implemented the later.
-Rajesh
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Like I said above, "any" was not passed or added to the criteria String in any way. No Pun there.
Meaning I only would put a specific query if one existed.
To quote myself
example
Airlines - Any
Origin Airport SFX
Arrival Airport Any
your criteria string would be "Origin Airport = 'SFX'"

So if, while looping through records, if the Origin Airport was "SFX" Then it was added to the found Hash.
Mark
Lijun An
Greenhorn

Joined: Feb 05, 2002
Posts: 15
Sorry to reply to you lately.
Actually, I meant implementing the search from ANY origin to ANY destination. I know it's easy to implement searching ANY origin or ANY destination.
Do you really think it is appropriate to implement ANY to ANY search in criteriaFind()? I don't think so. criteriaFind() should be generic, and it should search for results with exact match.
To implement ANY to ANY, I think it's just as simple as to get whole data records from database. So I agree with An Wang's approach. But, I'm not sure where to get it done. Should it be in criteriaFind() or some other method?
Please comment.
Thanks,
Lijun
Terry Wang
Ranch Hand

Joined: Aug 27, 2001
Posts: 102
now i'm looking at my code. i have a private parseCriteria method to do the parsing, and then criteriaFind() to do the search. sorry i said criteriaFind() did the parsing earlier.
Rajesh Matti
Ranch Hand

Joined: Jan 07, 2002
Posts: 121
Mark - My question was actually on
Airlines - Any
Origin Airport Any
Arrival Airport Any
in which case your criterai will be empty and what is the result ?.
-Rajesh
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Rajesh, your results would be all records.
Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Implement ANY to ANY flight search