• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Implement ANY to ANY flight search

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Terry Wang
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rajesh, your results would be all records.
Mark
 
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic