Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

search criteria

 
ravi janap
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to give the criteria as
Origin='SFO',Destination='Any',Carrier='SpeedyAir'
instead of
Carrier='SpeedyAir',Origin='SFO',Destination='Any' ?
Thanks
Ravi
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi janapareddy,
I'm not sure what you're getting at here but you should implement your search algorithm so that the order of the criteria doesn't matter. You should also allow any valid field, including the ones you will never pass from your client, eg "Price='400.00'. As for the 'ANY', you should never even pass a criterion set to 'ANY'. Design the search with the assumption that all records match, then remove all records that don't match the supplied criteria. That way 'ANY' takes care of itself.
Hope this helps,
Michael Morris
 
ravindra janapreddy
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael
Currently I have built my search engine in such a way that I handle only three parameters search viz. origin, destination and carrier. I have provided for three drop downs in my GUI i.e origin, destination and carrier. These drop downs have a value "Any" in addition to valid values for the respective field.
I pass these three parameters to SearchCriteriaBuilder class which constructs the search criteria string in the form of
Origin='SFO',Destination='Any',Carrier='SpeedyAir'
which is submitted to criteriaFind method in Data class which breaks the criteria string into tokens and does the matching of criteria to the records in database and return all the records which match this criteria.
The search algorithm however handles any number of parameters which can be passed as part of the search criteria.
As far as "Any" is concerned, I treat Any as global value which I handle at Data class level.
Is my approach wrong ? I am getting my results correctly using the above approach. Will my submission be violating any of the sun's assignment specifications ?
Thanks
Ravi
 
Abhinav Anand
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
I designed the search engine in such a way that took care of all searching. The client simply passes a critera like:
origin='any',destination='any',day='sun'
The order of the criteria does not matters and word 'any' simply means that the criteria part x=y is to be ignored.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ravindra,
Sounds like you've got it all covered. So long as the search algorithm is generic enough to handle any valid field name, then it seems to me you've met the requirements.

Michael Morris
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vishal,

... The client simply passes a critera like:
origin='any',destination='any',day='sun'

I think you might want to reconsinder and use combo boxes, or at least specific text field for entering criteria. There are too many ways for users (even the rare intelligent ones) to make a mistake on entering a search in this manner. As a real world developer, you would get tons of hate mail from something like this.
The rest of your search scheme looks fine.
Michael Morris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic