Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

search criteria

 
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
 
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
 
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
 
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
 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic