Using the Reservation Service
Creating a Reservation Object
Many of the reservation service APIs use a Reservation object to contain the parameters that describe a desired reservation.
When creating a Reservation object you must always specify a reference to a Reservable object. Other parameters are optional:
Reservation type (Default—ReservationType.MODIFY)
The user reserving the object (Default—Current user)
Number of minutes to hold the reservation before it expires (Default—120 minutes)
Enable or disable reservation enforcement by the reservation service (Default—Disabled)
Enable or disable administrator override of reservation enforcement (Default—Disabled)
Enable or disable workflow process override of reservation enforcement (Default—Disabled)
For more information, see the Windchill Javadoc description of the Reservation class.
Typical Reservation Service Implementation Steps
1. Reserve the object:
a. Call ReservationHelper.getService().requestReservation(…) to reserve the object.
b. Call the isGranted() method on the returned Reservation object to determine if the reservation was successful.
If not, then the getErrorMessage() method can be called to obtain a localizable message describing why the request failed.
For example, this step is performed when the change management Edit action is initialized.
2. If a reservation is granted, then the action can proceed. Otherwise, take appropriate steps to either wait and try again or inform the user that the action cannot proceed.
For example, the change management Edit action either allows the user to proceed with their modifications, or displays an error message:
3. If the action completes successfully:
a. To verify that the reservation still exists (for example, if the action has not expired or been revoked by an administrator), call the following:
ReservationHelper.getService().checkGranted(…)
If the reservation no longer exists, then it can be requested again or the action can be aborted. In order to prevent concurrent modifications, the object should not be modified without a granted reservation.
b. Make database updates for the reserved object.
c. To free the object for modification by another user, call the following:
ReservationHelper.getService().releaseReservation(…)
This call can be included in the same transaction used for the previous step (3b), and the reservation is not released until the transaction is fully committed. If the transaction fails to commit, then the reservation must be released separately.
For example, this step is performed when the user clicks Finish.
4. If the action is canceled or does not complete successfully:
a. To free the object for modification by another user, call the following:
ReservationHelper.getService().releaseReservation(…)
For example, this step is performed when the user clicks Cancel.
Isto foi útil?