• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[NX] Question about the findByCriteria.

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I get one question about the findByCriteria(URLyBird).
According to the instructions, the client can search by either one or both of "name", "location" fields.
But my question is what about server side ?!
cos the interface DBAceess looks like this:
//return an array of record numbers that match the specified criteria.
//Field n in the database file is described by criteria[n].
//A null value in criteria[n] matches any field value. A non-null value
//in criteria[n] matches any field value that begins with criteria[n].
public long[] findByCriteria(String[] criteria)
Should I implement search on the server-side as I did in client-side or in a different way searching throught all fields which might be cubersome?!
Thanks in advance.
Best,
FRank
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kai,

Should I implement search on the server-side as I did in client-side or in a different way searching throught all fields which might be cubersome?!


Server-side and client-side requirements are different and both are *must* requirements.
(1) Server-side : search on all fields possibly, wilcard matches.
(2) Client-side : search on location and/or name fields only, exact matches.
And ideally, implementation of (2) should make use of (1).
Regards,
Phil.
 
Kai Liu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, pill.
I get it.
But now I am thinking the efficient way to implement search on server-side.
Coz I want to write GUI on SERVER-SIDE too.
So how can I do that in a easy way?!
I mean what kind of the swing components I need to use in order to search throught all fields?!
(i.e: how does the user specify which field(s) to compare)
What I can imagine is to use "textbox" allowing user to enter the criteria, and ComboBox to indicate which fields to compare but it's not ideal for multiple fields. Or I just search all fields no matter what kind the criteria is.
Please advise.
Thanks in advance.
Best
FRank
[ December 23, 2003: Message edited by: Kai Liu ]
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Kai and Philippe,
Can you please explain the difference between "search on client" and "search on server"?
I thought I understood the search requirement very well until I read this thread!
Thank you very much!
Seid
 
Kai Liu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The client can search by name, location fields (either one or both).
But what about the the Non-network mode which is on the server-side?!
Can the user on the server side search by all of the fields or just two fields as client did?!
Otherwise, we won't have the findByCriteria singnature like this :
public long[] findByCriteria(String[] criteria)
( We can just pass two string for name, location fields)
What do you think?!
FRank
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kai and Seid,

Kai:
Coz I want to write GUI on SERVER-SIDE too.


What do you mean there ?!

Can you please explain the difference between "search on client" and "search on server"?


Yes, this thread is a bit confusing. What I tried to explain to Kai above, is that the global search process uses two *pieces* of software, one server-side and one client-side. Both are defined in our instructions (Data.findByCriteria() and search requirements for the client) and *seem* to be incompatible at first sight (Data.findByCriteria() must use wildcards while client search must work on exact matches). The challenge is to find a way to :
  • make those two pieces of code work *together*
  • though respecting the specific requirements we have for each of them


  • Best,
    Phil.
    [ December 23, 2003: Message edited by: Philippe Maquet ]
     
    Seid Myadiyev
    Ranch Hand
    Posts: 196
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hello Philippe,
    In my specs I have 2 statements:
    1.
    // Returns an array of record numbers that match the specified
    // criteria ...
    // criteria[n] matches any field value that begins with criteria[n]...
    public long[] findByCriteria(String[] criteria);

    2.
    - 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.
    My question is: how is one not compatible with the other? Could you please clarify these points?
    Thank you again!
    Seid
     
    Ranch Hand
    Posts: 619
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Seid Myadiyev:
    In my specs I have 2 statements:
    1.
    // Returns an array of record numbers that match the specified
    // criteria ...
    // criteria[n] matches any field value that begins with criteria[n]...
    public long[] findByCriteria(String[] criteria);

    2.
    - 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.
    My question is: how is one not compatible with the other? Could you please clarify these points?


    Is "begins with" the same as "exactly match?" My DBMain interface describes the find method as follows:


    // Returns an array of record numbers that match the specified
    // criteria. Field n in the database file is described by
    // criteria[n]. A null value in criteria[n] matches any field
    // value. A non-null value in criteria[n] matches any field
    // value that begins with criteria[n]. (For example, "Fred"
    // matches "Fred" or "Freddy".)


    That sounds like it's doing a wildcard match (specifically a starts-with match). In an exact match would "Fred" match "Freddy?"
    How to handle this discrepancy? One way is to filter the results on the client-side. Your client calls find("Fred") and gets back two records: "Fred" and "Freddy." The first record is an exact match so it is displayed to the user, while the second record is not displayed to the user because it is not an exact match. (Note: of course the find method actually takes a String[] and returns a long[], but I'm simplifying things here to make a point.) In this way both the requirements of the find specification and the requirements for an exact match are satisfied.
    Philippe has earlier explained a clever alternative that involves right- padding the search criteria. You can pursue that here: https://coderanch.com/t/184550/java-developer-SCJD/certification/NX-Search-Criteria-GUI
    The assignment instructions appear to have a lot of contradictions in them and I think this may have been on purpose. Your job is to resolve these contradictions in your mind (and thereby hopefully in the mind of the grader as well). How can I let the user perform exact match searches when the DBMain spec I've been given doesn't really do an exact match? How can I use RMI when the DBMain spec contains methods that don't throw the required RemoteException?
    Hope this helps,
    George
    [ December 23, 2003: Message edited by: George Marinkovich ]
     
    Seid Myadiyev
    Ranch Hand
    Posts: 196
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thank you so much, George!
    Your explanation is very clear! I can continue with my design now.
    Seid
     
    Ranch Hand
    Posts: 75
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    My requirement states:


    // Returns an array of record numbers that match the specified
    // criteria. Field n in the database file is described by
    // criteria[n]. A null value in criteria[n] matches any field
    // value. A non-null value in criteria[n] matches any field
    // value that begins with criteria[n]. (For example, "Fred"
    // matches "Fred" or "Freddy".)
    public long[] findByCriteria(String[] criteria);


    I have made my search to be case sensitive, and the matches any field that begins with the criteria value as asked... am I missing anything?
    Sanjay
     
    George Marinkovich
    Ranch Hand
    Posts: 619
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Sanjay,

    Originally posted by Sanjay Joshi:
    I have made my search to be case sensitive, and the matches any field that begins with the criteria value as asked... am I missing anything?


    I think you've correctly implemented the findByCriteria method on the server. The question is whether this implementation also satisfies the part of the assignment instructions that states:

    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.


    So if your client merely calls the findByCriteria method will he really be getting an "exact match"? Many people seem to feel that the findByCriteria method doesn't really implement an exact match (but rather a starts-with match). Is it OK if the user enters "Fred" as the name search criterion and gets back a record with a name of "Freddy"? Many people seem to feel that this would not be meeting the "exact match" criteria. One solution is to filter the results returned by findByCriteria to get rid of matches that are not exact. So if you search for "Fred", and you get back from findByCriteria "Fred" and "Freddy", you filter out "Freddy" because it doesn't exactly match "Fred", and so you would return to the client only "Fred".
     
    reply
      Bookmark Topic Watch Topic
    • New Topic