aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Retrieval of record should be based on Key or Flight number ?. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Retrieval of record should be based on Key or Flight number ?." Watch "Retrieval of record should be based on Key or Flight number ?." New topic
Author

Retrieval of record should be based on Key or Flight number ?.

Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
Hi reader,
I am in confusion regarding the retrieval of records. I had implemented a record search facility based on record Number. The user simply enters the number of record in between 1 and 24 and record is retrieved. But when I studied Robert and Heller. It states the retrieval of record should be based on KEY. If this is the case then shall I use criteriaFind() method or give a call to find(toMatch) method for retrieval of record based on KEY ?.
Secondly, for the retrieval of records I had one search class facility which retrieves only carrier matching records by using criteriaFind() method. On the other hand I also have Carrier,Origin,Destination Multiple Search record retrieval facility. Which already has the function of retrieving all the carrier matched records. That is done when user selects "All origins" and "All destinations" it retrieves all the carrier matching records. Now, you can see I have two things for same functionality. Please do suggest me shall I abort the first one which is exclusivly retrieving records based only on carrier selection or shall retain it ?.
Thank you,
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
It is as simple as this: use criteriaFind() to search records based on origin and destination (for the search requirement), and use find(toMatch) to pinpoint the record for which you want to book (for the booking requirement). The rest is transparent.
Eugene.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451

and use find(toMatch) to pinpoint the record for which you want to book (for the booking requirement).

Actually there is never a need to make a direct call to find(toMatch) for booking since modify makes the call for you. You can just call getRecord (since we know the record number is unique) for your read which is considerably faster than find.
Hope this helps,
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
Hi morris and konovo,
What you both suggest I am only implementing that. Tell me shall I implement another record search facility on KEY ie (SA001 ..etc), which will make call on find(toMatch) method through interface as morris suggested once in my earlier post. Secondly, I said that I had already two search facilities for retrieving carrier matched objects, same functionalities but two different search facilities. Shall I abort the first one ?. Because I think there is no need for first one. What you have to say ?.
Thank you,
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Gurpreet,
Not knowing exactly what you have in mind, it's hard to say. All I did was create the criteriaFind method as it was a requirement. It was publically available in my DataAccess interface. For the criteriaFind implementation, I just looped through all the records (using gerRecord) and if a particular record did not match the criteria I did not include it in the DataInfo[]. Now for booking as I said before, I just re-read the record with getRecord before comitting the booking, but the find method would work just as well albeit somewhat slower.
If your design in some way requires you to implement something other than find or getRecord, then do it. Just be certain that it is a necessity.
Hope this helps,
Michael Morris
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

Secondly, I said that I had already two search facilities for retrieving carrier matched objects, same functionalities but two different search facilities. Shall I abort the first one ?.

Here is your plan:
1. Implement criteriaFind(String criteria) such that it can accept a generic criteria (any number of field-value pairs).
2. Use the implemented criteriaFind(String criteria) method to search flights, by passing origin and destination (and possibly carrier) as a criteria.
3. Use either find() or getRecord() (or combination) to book a flight.
That's all there is to it.
Eugene.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Ditto what Eugene said. I guess I just "pussy-footed" around and wouldn't come out and just say what needed to be said.
Michael Morris
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Retrieval of record should be based on Key or Flight number ?.