Milton resource for a single voucher, reached as a child of its VoucherTypeFolder using the voucher's id. Renders the voucher for viewing, printing or PDF export, and handles the redeem, allocate and status-change actions posted from the voucher management and redemption pages. On a website root folder it serves the customer-facing voucher view; on an organisation root folder it serves the admin management view.
Group: Resources
Extends: AbstractResource
Implements: GetableResource, PostableResource, TitledPage, IVoucherResource, TextResource
Properties
| Property | Returns | Description |
|---|---|---|
| allocated | boolean | Whether the voucher's current status is allocated. |
| allocatedToId | String | The identifier the voucher is allocated to, as entered when it was allocated. This may match a Kademi profile's id or username, or may be an external identifier for a customer who has no Kademi profile. |
| availableWebsites | Map<Website,List<Branch>> | The websites and branches belonging to this voucher's organisation on which the vouchers app is active, keyed by website. Hidden branches are excluded. Used to offer links to view the voucher on a live site. |
| breadCrumbs | Map<String,String> | Breadcrumb links shown above this voucher page, mapping each link's path to its display label. |
| changedBy | ProfileBean | The profile that made the most recent status change to this voucher. |
| changeLog | List<StatusChangeBean> | The full history of status changes for this voucher, oldest first, as recorded on the voucher entity. |
| createdBy | ProfileBean | The profile that created this voucher. |
| createdDate | Date | The date this voucher was created. |
| customFields | List<ExtraField> | All custom field definitions configured for this voucher's voucher type. |
| expired | boolean | Whether this voucher has passed its expiry date. Note that the current implementation returns false whenever an expiry date is set, and throws a NullPointerException when no expiry date is set, so callers should not rely on it. |
| expiryDate | Date | The date after which this voucher can no longer be redeemed. |
| extraFieldHistory | List<Map<String,String>> | The history of this voucher's custom field values, one map per saved revision, each including a formatted createdDate entry alongside the field values at that point in time. |
| id | long | The voucher's database identifier. |
| name | String | The voucher's unique voucher id, used as this resource's name in the URL path. |
| parent | CommonCollectionResource | The collection resource this voucher page is a child of - the voucher type folder it belongs to. |
| pending | boolean | Whether the voucher's current status is pending, meaning it has not yet been allocated or redeemed. |
| redeemed | boolean | Whether the voucher's current status is redeemed. |
| status | String | The voucher's current status code (one of P, R, A, C for pending, redeemed, allocated or cancelled). |
| statusChangedForOrg | OrgData | The organisation the voucher's most recent status change was recorded against. |
| statusDate | Date | The date the voucher's status was last changed. |
| statuses | Map<String,String> | The voucher status codes (P, R, A, C) mapped to their display labels (Pending, Redeemed, Allocated, Cancelled). Used to populate a status drop-down in the UI. |
| statusText | String | Human-readable label for the voucher's current status code, as shown to users in the UI. |
| textContent | String | The voucher's rendered content wrapped in a minimal html document, used when this resource is served as plain text content. |
| thisVoucher | Voucher | The underlying Voucher entity backing this page. |
| title | String | Page title for this voucher, built from its voucher id. |
| voucher | VoucherBean | A read-only bean view of this voucher, for use in templates and JSON responses. |
| voucherContent | String | The rendered content for this voucher, evaluated from its voucher type's content template. Templates containing MVEL expression markers are evaluated in a sandboxed context with the voucher and formatter available as local variables; templates without markers are returned unchanged. |
| voucherTypeName | String | Code name of the voucher type this voucher belongs to. |
| voucherTypeTitle | String | Display title of the voucher type this voucher belongs to. |
Inherited from AbstractResource
Properties
| Property | Returns | Description |
|---|---|---|
| accessControlList | Map<Principal,List<Priviledge>> | The access control list of allowed privileges per principal for this resource. This implementation is not populated; access is instead resolved dynamically via the security manager, so this always returns null. |
| asList | ResourceList | This resource wrapped as a single-element ResourceList, convenient for scripts that want to treat a single resource the same way as a list of resources. |
| attributes | Map<String,Object> | A mutable, request-scoped map of arbitrary attributes attached to this resource instance, for passing values between code that shares a reference to the same resource. |
| createDate | Date | The date this resource was created. This base implementation always returns null; subclasses that track creation dates override it. |
| dir | boolean | Whether this resource is a collection (folder-like) resource rather than a single item. |
| href | String | The URL-encoded path to this resource, suitable for use as a browser or WebDAV href. Collection resources get a trailing slash. |
| link | String | A ready-to-use HTML anchor tag linking to this resource's href, using its name as the link text. |
| modifiedDate | Date | The date this resource was last modified. This base implementation always returns null; subclasses that track modification dates override it. |
| oAuth2Providers | Map<String,OAuth2Provider> | The OAuth2 login providers available for this resource, combining the providers configured on the social login app with the platform's built-in social posting services mapped onto their OAuth2 provider templates. |
| path | Path | The path of this resource within its resource tree, built by appending this resource's name to its parent's path, as a Path object with convenient path manipulation methods. |
| principalCollectionHrefs | HrefList | The hrefs of the collections that contain principals, so a WebDAV client can discover where to list users. This base implementation always returns the single href "/users/". |
| principalURL | String | The href of the owning principal resource for this resource, found by walking up the parent chain to the nearest principal resource. |
| public | boolean | Whether this resource is readable by anonymous, unauthenticated users. This base implementation always returns false; subclasses override it where public content is allowed. |
| readable | boolean | Whether the current user, who may be null for an anonymous request, has READ_CONTENT permission on this resource. |
| realm | String | The HTTP authentication realm used for digest and basic authentication challenges on this resource. |
| uniqueId | String | A unique identifier for this resource. This base implementation always returns null; resource types that need a stable id (for example content resources) override it. |
| writable | boolean | Whether the current user, who may be null for an anonymous request, has WRITE_CONTENT permission on this resource. |
Methods
getUniqueId() · getRealm() · getPrincipalURL() · getPrincipalCollectionHrefs() · getPath() · getHref() · getLink() · isPublic() · find(String path) · find(Path p) · isDir() · getContentType(String accepts) · getModifiedDate() · getCreateDate() · getAccessControlList() · closest(String type) · closest(Class<T> c) · isReadable() · isWritable() · getAsList() · getOAuth2Providers() · getAttributes()
getUniqueId()
Returns: String
A unique identifier for this resource. This base implementation always returns null; resource types that need a stable id (for example content resources) override it.
getRealm()
Returns: String
The HTTP authentication realm used for digest and basic authentication challenges on this resource.
getPrincipalURL()
Returns: String
The href of the owning principal resource for this resource, found by walking up the parent chain to the nearest principal resource.
getPrincipalCollectionHrefs()
Returns: HrefList
The hrefs of the collections that contain principals, so a WebDAV client can discover where to list users. This base implementation always returns the single href "/users/".
getPath()
Returns: Path
The path of this resource within its resource tree, built by appending this resource's name to its parent's path, as a Path object with convenient path manipulation methods.
getHref()
Returns: String
The URL-encoded path to this resource, suitable for use as a browser or WebDAV href. Collection resources get a trailing slash.
getLink()
Returns: String
A ready-to-use HTML anchor tag linking to this resource's href, using its name as the link text.
isPublic()
Returns: boolean
Whether this resource is readable by anonymous, unauthenticated users. This base implementation always returns false; subclasses override it where public content is allowed.
find(String path)
Returns: Resource
Finds a resource within the website by its path. A relative path is evaluated relative to this resource; an absolute path is evaluated from the website root. For example find("/programs/p1") looks up the program p1 from the root, and find("../p1") looks up p1 in the folder above this resource.
| Parameter | Description |
|---|---|
path | the relative or absolute path to resolve |
find(Path p)
Returns: Resource
Finds a resource by walking a Path object one part at a time, following "." and ".." segments and looking up each remaining part as a child of the current resource.
| Parameter | Description |
|---|---|
p | the path to resolve, relative to this resource or absolute |
isDir()
Returns: boolean
Whether this resource is a collection (folder-like) resource rather than a single item.
getContentType(String accepts)
Returns: String
The content type this resource should be served as. This base implementation always returns "text/html; charset=UTF-8" for getable resources (regardless of the accepts header, since XHTML is not used because of CKEditor compatibility) and an empty string otherwise. Subclasses override this where a different content type is needed.
| Parameter | Description |
|---|---|
accepts | the client's Accept header value, currently not used to vary the result |
getModifiedDate()
Returns: Date
The date this resource was last modified. This base implementation always returns null; subclasses that track modification dates override it.
getCreateDate()
Returns: Date
The date this resource was created. This base implementation always returns null; subclasses that track creation dates override it.
getAccessControlList()
Returns: Map<Principal,List<Priviledge>>
The access control list of allowed privileges per principal for this resource. This implementation is not populated; access is instead resolved dynamically via the security manager, so this always returns null.
closest(String type)
Returns: CommonResource
Finds the closest resource, starting from this one and walking up through its parents, whose is(type) returns true.
| Parameter | Description |
|---|---|
type | the type name to match, as used by is(String) |
closest(Class<T> c)
Returns: T
Finds the closest resource, starting from this one and walking up through its parents, that is an instance of the given class.
| Parameter | Description |
|---|---|
c | the class to match against |
isReadable()
Returns: boolean
Whether the current user, who may be null for an anonymous request, has READ_CONTENT permission on this resource.
isWritable()
Returns: boolean
Whether the current user, who may be null for an anonymous request, has WRITE_CONTENT permission on this resource.
getAsList()
Returns: ResourceList
This resource wrapped as a single-element ResourceList, convenient for scripts that want to treat a single resource the same way as a list of resources.
getOAuth2Providers()
Returns: Map<String,OAuth2Provider>
The OAuth2 login providers available for this resource, combining the providers configured on the social login app with the platform's built-in social posting services mapped onto their OAuth2 provider templates.
getAttributes()
Returns: Map<String,Object>
A mutable, request-scoped map of arbitrary attributes attached to this resource instance, for passing values between code that shares a reference to the same resource.
Methods
getStatuses() · getAvailableWebsites() · isRedeemed() · isPending() · getTitle() · getStatus() · getStatusDate() · getCreatedBy() · getCreatedDate() · getExpiryDate() · getAllocatedToId() · getVoucher() · getThisVoucher() · isAllocated() · isExpired() · getChangedBy() · getStatusText() · statusText(String status) · getChangeLog() · getExtraFieldHistory() · getParent() · getName() · getVoucherTypeTitle() · getVoucherTypeName() · getVoucherContent() · getStatusChangedForOrg() · getCustomFields() · customFieldValue(String name) · getId() · getTextContent() · getBreadCrumbs()
getStatuses()
Returns: Map<String,String>
The voucher status codes (P, R, A, C) mapped to their display labels (Pending, Redeemed, Allocated, Cancelled). Used to populate a status drop-down in the UI.
getAvailableWebsites()
Returns: Map<Website,List<Branch>>
The websites and branches belonging to this voucher's organisation on which the vouchers app is active, keyed by website. Hidden branches are excluded. Used to offer links to view the voucher on a live site.
isRedeemed()
Returns: boolean
Whether the voucher's current status is redeemed.
isPending()
Returns: boolean
Whether the voucher's current status is pending, meaning it has not yet been allocated or redeemed.
getTitle()
Returns: String
Page title for this voucher, built from its voucher id.
getStatus()
Returns: String
The voucher's current status code (one of P, R, A, C for pending, redeemed, allocated or cancelled).
getStatusDate()
Returns: Date
The date the voucher's status was last changed.
getCreatedBy()
Returns: ProfileBean
The profile that created this voucher.
getCreatedDate()
Returns: Date
The date this voucher was created.
getExpiryDate()
Returns: Date
The date after which this voucher can no longer be redeemed.
getAllocatedToId()
Returns: String
The identifier the voucher is allocated to, as entered when it was allocated. This may match a Kademi profile's id or username, or may be an external identifier for a customer who has no Kademi profile.
getVoucher()
Returns: VoucherBean
A read-only bean view of this voucher, for use in templates and JSON responses.
getThisVoucher()
Returns: Voucher
The underlying Voucher entity backing this page.
isAllocated()
Returns: boolean
Whether the voucher's current status is allocated.
isExpired()
Returns: boolean
Whether this voucher has passed its expiry date. Note that the current implementation returns false whenever an expiry date is set, and throws a NullPointerException when no expiry date is set, so callers should not rely on it.
getChangedBy()
Returns: ProfileBean
The profile that made the most recent status change to this voucher.
getStatusText()
Returns: String
Human-readable label for the voucher's current status code, as shown to users in the UI.
statusText(String status)
Returns: String
Human-readable label for the given voucher status code.
| Parameter | Description |
|---|---|
status | the status code to look up (one of P, R, A, C) |
getChangeLog()
Returns: List<StatusChangeBean>
The full history of status changes for this voucher, oldest first, as recorded on the voucher entity.
getExtraFieldHistory()
Returns: List<Map<String,String>>
The history of this voucher's custom field values, one map per saved revision, each including a formatted createdDate entry alongside the field values at that point in time.
getParent()
Returns: CommonCollectionResource
The collection resource this voucher page is a child of - the voucher type folder it belongs to.
getName()
Returns: String
The voucher's unique voucher id, used as this resource's name in the URL path.
getVoucherTypeTitle()
Returns: String
Display title of the voucher type this voucher belongs to.
getVoucherTypeName()
Returns: String
Code name of the voucher type this voucher belongs to.
getVoucherContent()
Returns: String
The rendered content for this voucher, evaluated from its voucher type's content template. Templates containing MVEL expression markers are evaluated in a sandboxed context with the voucher and formatter available as local variables; templates without markers are returned unchanged.
getStatusChangedForOrg()
Returns: OrgData
The organisation the voucher's most recent status change was recorded against.
getCustomFields()
Returns: List<ExtraField>
All custom field definitions configured for this voucher's voucher type.
customFieldValue(String name)
Returns: String
The value of one of this voucher's custom fields.
| Parameter | Description |
|---|---|
name | the custom field name to look up |
getId()
Returns: long
The voucher's database identifier.
getTextContent()
Returns: String
The voucher's rendered content wrapped in a minimal html document, used when this resource is served as plain text content.
getBreadCrumbs()
Returns: Map<String,String>
Breadcrumb links shown above this voucher page, mapping each link's path to its display label.