Win a copy of Spring Boot in Practice this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

AND or OR in search criteria

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
This is what my requirements have to say.
"It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user."
What did you all implement (those who had similar requirement ofcourse). Did you assume AND or an OR or provide an UI flag to choose between the two ?
The problem is that I have created a Criteria.java class that encapsulates to some extent all the filteration rules and it only supports AND, but I do not know how to create a generic AND/OR expression for example
(parm1 == A OR parm2 == B) AND parm3 == C
The reason to think in this manner is that the find(String[] criteria) in DBMain.java is pretty much useless to capture any nuance and the requirements want this to be extensible. I cannot assume that only location and name fields will be in the expression such as
location == X AND name == Y
location == X OR name == Y

It could be any combination of the 7 DB columns.
Any clues
Thanks
-- Rag
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I assumed AND.
"records where the name and/or location fields exactly match values specified by the user"
I think that the use of "and/or" here is just a nod to the fact that either name or location could be left blank, and so might need to search for
(records where name matches)
OR (records where location matches)
OR (record where name AND location match)
This interpretation was influenced by the description of the find() method, which implicitly ANDs all criteria specified (not left blank). It's certainly possible to add an OR button - but I don't think it's necessary. IMO of course.
 
Rag Srinivasan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jim. That was my initial impl, but I started to second guess myself.
regards
-- Rag

Originally posted by Jim Yingst:
I assumed AND.
"records where the name and/or location fields exactly match values specified by the user"
I think that the use of "and/or" here is just a nod to the fact that either name or location could be left blank, and so might need to search for
(records where name matches)
OR (records where location matches)
OR (record where name AND location match)
This interpretation was influenced by the description of the find() method, which implicitly ANDs all criteria specified (not left blank). It's certainly possible to add an OR button - but I don't think it's necessary. IMO of course.

 
Rag Srinivasan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jim. That was my initial impl, but I started to second guess myself.
regards
-- Rag

Originally posted by Jim Yingst:
I assumed AND.
"records where the name and/or location fields exactly match values specified by the user"
I think that the use of "and/or" here is just a nod to the fact that either name or location could be left blank, and so might need to search for
(records where name matches)
OR (records where location matches)
OR (record where name AND location match)
This interpretation was influenced by the description of the find() method, which implicitly ANDs all criteria specified (not left blank). It's certainly possible to add an OR button - but I don't think it's necessary. IMO of course.

reply
    Bookmark Topic Watch Topic
  • New Topic