• 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

criteriaFind() doubt

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai,
In this method, the user will have the options of selecting just the origin and destination. So, will the 'criteria' string be like this -
"Column1 = 'value1' , Column2 = 'value2',... this can go on, right?
Can I just match it against the origin & destination (of the user's choice)alone? What else can I match it against, since the user's choices are limited to Origin and Destn alone?
Thanks
 
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What else can I match it against
How about
Regular Expressions?
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nandini

Can I just match it against the origin & destination (of the user's choice)alone? What else can I match it against, since the user's choices are limited to Origin and Destn alone?


The instructions tell us to do Origin and Destination, and give an example which also has Carrier. So for my submission, I allowed the user to match in those three columns.
But there is nothing in the criteriaFind method that limits user code to only those two (or three) columns. I wrote my criteriaFind method so that a program written by someone else could do searches on any columns.
Regards, Andrew
[ July 09, 2003: Message edited by: Andrew Monkhouse ]
 
Nandini Sriram
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I got this doubt when I was reviewing my assignment.
In my criteriaFind() inside the Data class, I am not handling the "any" part of origin, destination and carrier. Only when all three are specific (say, SFO DEN SpeedyAir), I pass the call to criteriaFind(). Else if it is going to be something like this:

Origin: SFO
Dest: DEN
Carrier: *any*

or any other combination like this, I am handling it on the client side (in my table model class)itself using while and if loops. Is this ok?
Thanks
Nandini
[ September 11, 2003: Message edited by: Nandini Sriram ]
 
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
Unfortunately that isn't ok. The criteria search should be completely functional on the serverside. So if the user selects "any" for any field, it still calls criteriaFind on the data class.
And as regards to the criteriaFind method, what Andrew said is absolutely correct, it should be able to handle any field sent to it, even though your GUI only has the three fields.
Mark
 
Nandini Sriram
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
Thankyou very much. It could have cost me a lot.
Here's what I have done. I have a model class (extends AbstractTableModel) on the clientside, which does the following:
criteria string building, handling 'any' cases, passing the call to criteriaFind (only in 'specific' cases).
Should the 'any' condition be handled inside the criteriaFind method itself? I thought the method should not cater to anything specific. So I defined them in the client introducing some constants that represent the origin and destination fields.
It's something like this when a specific origin alone is chosen.

where fieldONE is a constant representing the origin field, values is the String[] and v is a vector.
and if specific origin and destination are chosen, it is like this:

Is my concept of having the model class and making use of constants this way correct?
Please guide me.
Thanks
Nandini
[ September 11, 2003: Message edited by: Nandini Sriram ]
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nandini,

Should the 'any' condition be handled inside the criteriaFind method itself?


The instructions only tell us that the GUI has to allow the user to enter "any", not that the criteriaFind method has to handle it. So in my GUI, if the user chose "Origin:any, Destination:SFO" then I would only send the "Destination='SFO'" to criteriaFind - the any option was stripped off in my GUI.
Regarding your use of the constant "*Any*". I have two issues:
  • Technically this is not what Sun asked for: (the string value "any")
  • If you are going to have this in your Data class, why not make it a global constant? That way your GUI can also use the same constant and you don't have to worry about typos or the two classes ever getting different values.


  • Regards, Andrew
     
    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
    True, "Any" is only an option in the JCombobox for the search. Yuo just don't need to add it to the criteria string.
    Mark
     
    Ranch Hand
    Posts: 493
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hello Andrew/Mark,
    I have the URLy Bird assignment. But going through earlier threads I understand that Sun has tried to create roughly the same amount of work in each of the categories, e.g., find, which is the topic of discussion here.
    I could have asked this question in a new thread, but it is the same as Nandini is asking. Here are the "must" requirements that I could find in my assignment:


    The new application, using the existing data file format, must allow the CSRs to generate a list of accomodations that match a customer's criteria.



    A data access system that provides record locking and a flexible search mechanism.



    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.


    Here is what I have done:
    1. My application has two combo boxes. One for name and another for location.
    2. My application has a search button.
    3. Initially, when the application is started, it presents all the data in the JTable display except the deleted records. At the same time, it loads the name and location combo boxes with an alphabetic listing of the unique values contained in these columns, plus a null (or blank) value at the top. Therefore, both the combo boxes have a blank value at the top ALWAYS.
    4. Now, the user (client) can either select from the name combo box, or the location combo box, or both. Based on the selection. A criteria array which is as long as the number of columns, is created and populated with selected values and nulls in other cells. This is passed on to the server which invokes Sun provided find method defined in the Data class specified in DBMain interface. This method returns an array of record numbers, which is used to retrieve these records (still on the server side using the DataAdapter class) and eventually return it to the client.
    5. Anytime the user selects both "blank" or "null" values in both drop-down combo boxes (name and location) and presses the search button, all records (except the deleted records) are returned AND the combo boxes' lists are refreshed with an alphabetic listing of the unique values contained in these columns, plus a null (or blank) value at the top.
    My question is: does it meet the must criteria above? Does the UI meet the requirements?
    Regards.
    Bharat
     
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Bharat,
    This URLy bird project looks cryptic to me. U state that u do not allow the client to view any deleted records. My concern is
    1. Can u explain what happens to the deleted record. Do we compress the file or mark it deleted and reuse. And if we do delete, how does this record ever get re-used since the requirement states that the update method throws RecordNotFoundException, meaning if trying to update deleted record , throw an e!
    There is talk of adding new records to this database. Does this mean:
    2. we can willy nilly add new records to the database, and if we can under what conditions do we do so, do we add a record as long as we have keep the hotel name and location or are there other factors.
    I am really puzzled about this.
    Thanks.
    [ September 12, 2003: Message edited by: Jim Brown ]
    [ September 12, 2003: Message edited by: Jim Brown ]
     
    Bharat Ruparel
    Ranch Hand
    Posts: 493
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hello Jim,
    I am going to start a new thread for you which will explain the questions that you are asking in this thread. I had the same questions when I started, gradually, the fog began to lift, primarily with the help of fellow ranchers. I will do the same for you. The thread that I will start will be titled:
    NX: URLy Bird - Deleted Records
    Look for it in next 15-30 minutes.
    Regards.
    Bharat
     
    Andrew Monkhouse
    author and jackaroo
    Posts: 12200
    280
    Mac IntelliJ IDE Firefox Browser Oracle C++ Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Bharat,

    the combo boxes have a blank value at the top ALWAYS


    This is my only concern with what you described. Personally I dont find having a blank is very intuitive. Do people realise that they can select "nothing"? I prefer the early suggestion that you have a special value (such as "«all»") which makes it a bit more obvious.
    Otherwise this all sounds like you are meeting the requirements, and should be easy to use.
    Regards, Andrew
     
    Bharat Ruparel
    Ranch Hand
    Posts: 493
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hello Andrew,
    Thanks for taking time to review my design:


    This is my only concern with what you described. Personally I dont find having a blank is very intuitive. Do people realise that they can select "nothing"? I prefer the early suggestion that you have a special value (such as "�all�") which makes it a bit more obvious.


    I will substitute "<all>" for the blanks to make it more obvious.
    Regards.
    Bharat
     
    this llama doesn't want your drama, he just wants this tiny ad for his mama
    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