Priority Logic for Feature Consumption

There can be scenarios where the same feature exists in multiple entitlements of a customer. In such scenarios, an entitlement is retrieved for the feature consumption based on the following criteria (in the order of decreasing priority):

>The entitlements are first sorted based on their status.

>Next, sorting is done based on the state of the duplicate feature.

>If feature state is same, the feature in the Grace state gets the priority. Note that for a feature in Grace, the state is either Expired or Exhausted.

>Next level of priority is the entitlement type - named or unnamed. Note that if a user is associated with two entitlements, named and unnamed, the named entitlement has higher priority. If another user is not assigned in named entitlement, then the unnamed entitlement has higher priority.

>At last, the feature is picked for from the latest entitlement.

Example

Suppose, there are two entitlements, E1 and E2, for a customer, where:

>E1 is a named entitlement with two named users U1 and U2.

>E2 is an unnamed entitlement.

The same product P1 is included in both entitlements. P1 contains the following three features: F1, F2, and F3.

Creation Order: E1 is created before E2.

Case 1: E2 is disabled, E1 is enabled.

If user U1 requests for F1, the feature will be served from E1 though E2 was created last. This is because the priority of the enabled status is higher than the disabled status.

Case 2: E1 and E2 are enabled, features are in active state in E1 and features are in not active state in E2. The assumption is that E2 is created because E1 is going to expire in near future.

If user U1 requests for F1, the feature will be served from E1 though E2 was created last since active state has higher priority over not active state.

Case 3: E1 and E2 are enabled, feature F1 is expired in both E1 and E2, and is in grace period in E2.

If user U1 requests for F1, in this case it will be served from E2 because with both features in same state, the feature with grace period has higher priority over feature with no grace.

Note that for a feature in grace, the state is either Expired or Exhausted.

Case 4: E1 and E2 are enabled, and features are in active state in both entitlements.

If user U1 requests for F1, in this case it will be served from E1 though E2 was created last. If states are same, then feature in named entitlement has higher priority over feature in unnamed entitlement if the requested user exists in the named entitlement.

Case 5: E1 and E2 are enabled, and features are in active state in both entitlements.

If user U5 requests for F1, it will be served from E2. Since E2 was created last and if states are same, then feature created last has higher priority. Also note that U5 does not exist in E1, so unnamed feature has higher priority here over named. So creation date is not considered. If everything matches then last entitlement is picked according to creation date because entitlement created last has higher priority.