sys_debug
sys_debug

Reputation: 4003

JAVA storage options

Ok I have a reservation object which stores all details of event for which the reservation is made. Now for an event to be approved, it has to be viewed by three different users. Each time a reservation is made, those three should be assigned. Now when the reservation request is reviewed by any of the three, and a response is given, that user has to be marked that he responded.

I need to store the following like

User1 ----> Response & Type & ID
User2 ----> Response & Type & ID
User3 ----> Response & Type & ID

So when user1 for example reviews and accepts, then i access this way

 reservationInstance.approvers.user1.response(true);

just an example of course and not practical code. What would the best suggestion be? and can there be code provided for clarification? I will work on its customization

Upvotes: 0

Views: 592

Answers (1)

Kent
Kent

Reputation: 195039

your Reservation doesn't have to have a List/Set of approvers, one is enough. since you mentioned:

Now when the reservation request is reviewed by any of the three, and a response is given, that user has to be marked that he responded.

Reservation could have an Approver attribute, which would be the Type User, to store which user has reviewed this reservation and gave response. In database layer, this can be a foreign key to User table.

If you want to find out which user (1,2 or3) has viewed. just reservationInstance.getApprover().getUserId() (Assume your User class has a userId property.)

EDIT

to make it clear based on comments:

you have a Reservation class:

Reservation:
- Integer id
- User approver
- String content
- List<User> recievers
- String (could be enum) status (created, approved...etc.)

You have User class

User:
- Integer id
- String name
- String foo
- ...

if I understood your requirement right:

when a reservation instance was created, a set of Users as recievers were set. which means, those users will recieve the reservation. in your case, maybe 3 users. here you sent email, fax, sms whatever to them.

Then, say user2 (id=2), opened it, and approved this reservation. The reservation.approver will be set as User object(id=2). and status of this reservation (if there was a status requirement) will be changed to "Approved" or "Responsed"...

I don't know what's your exact requirement, however hope this helps.

Upvotes: 1

Related Questions