• 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Bodgitt & Scarper contractor booking  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am working on B&S version 2.2.1 and have a few questions about booking of contractors. At the moment, I have a table of contractors from the database, and a client is able to select a particular row and click 'Book', which then generates a random long (representing the CSR number), and updates the table, displaying this long in the 'Owner' column. The book() method uses a lock(), update(), unlock() sequence of operations, synchronized on a hashmap of currently locked records.

My question is this -- are other clients able to book contractors which are already booked? So if Client1 books contractor 5, is Client2 then allowed to overwrite this booking? If not, should a message be shown to the client that the contractor is already booked???

Thanks for any tips...

joe
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe,

I have assumed that it is not allowed to book an already booked client. What would be the purpose of booking if the booking can be overwritten?

I made the book functionality perform the sequence lock - read - update - unlock, where the read call is to verify that the contractor is not booked yet. If the contractor is already booked, the booking is aborted of course.

IMHO, this sequence is the primary reason why we need to have lock/unlock methods to begin with: only when the record is locked can we be certain that no other client has just booked the contractor.

Frans.
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe,

Just make sure that the first thread to book a record gets to book the record. The rest of the thread which wants to book the record afterwards should be denied.

Regards,
Clivant
 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

which then generates a random long (representing the CSR number),

I am slightly off topic, but I noticed this and wondered why you decided to generate a random number instead of letting the user enter one in. My instructions state

Note that for this application, you should assume that customers and CSRs know their customer ids.

I would hate to see you lose any unneccessary points.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!