This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- FlexNet Operations
- :
- FlexNet Operations Knowledge Base
- :
- How to get entitlements with the latest Activation IDs using FlexNet Operations On-Premises Web Serv...
Subscribe
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
How to get entitlements with the latest Activation IDs using FlexNet Operations On-Premises Web Services API?
How to get entitlements with the latest Activation IDs using FlexNet Operations On-Premises Web Services API?
Summary
How to get entitlements with the latest Activation IDs using FlexNet Operations On-Premises Web Services API?Question
How to get entitlements with the latest Activation IDs using FlexNet Operations On-Premises Web Services API?Answer
The following is an example demonstrating how to use "getEntitlementsQuery":Product Manuals 12.11.zip\Product Manuals 12.11\FlexNetOperationsWebServices12_11_0_2.zip\
FlexNetOperationsWebServices12_11_0_2\SamplePrograms\EntitlementOrder\GetEntitlementsQueryTest.java
As the query results contain line item objects, from which type "EntitlementLineItemDataType" element "createdOnDateTime" can be accessed.
Use "createdOnDateTime" to sort queried entitlements and locate the one which has the latest line item creation date.
The following code demonstrates how entitlement query results are sorted.
(A complete example is available in the attachment.)
===
// "simpleEntitlements" is the result extracted from "getEntitlementsQuery" response.
// Sort simple entitlements based on latest line item creation date.
Collections.sort(simpleEntitlements, new Comparator<SimpleEntitlementDataType>()
{
// Compare line item by their created datetime.
private int compareLineItems(EntitlementLineItemDataType lineItem1, EntitlementLineItemDataType lineItem2)
{
Calendar createdDateTime1 = lineItem1.getCreatedOnDateTime();
Calendar createdDateTime2 = lineItem2.getCreatedOnDateTime();
return createdDateTime1.compareTo(createdDateTime2);
}
// Get last created line item.
private EntitlementLineItemDataType getLastCreatedLineItem(EntitlementLineItemDataType[] lineItems)
{
EntitlementLineItemDataType lastCreatedLineItem = null;
for (EntitlementLineItemDataType lineItem : lineItems)
{
if (lastCreatedLineItem == null)
{
lastCreatedLineItem = lineItem;
}
else
{
if (this.compareLineItems(lastCreatedLineItem, lineItem) < 0)
{
lastCreatedLineItem = lineItem;
}
}
}
return lastCreatedLineItem;
}
@Override
public int compare(SimpleEntitlementDataType simpleEntitlement1, SimpleEntitlementDataType simpleEntitlement2)
{
EntitlementLineItemDataType[] lineItems1 = simpleEntitlement1.getLineItems();
EntitlementLineItemDataType[] lineItems2 = simpleEntitlement2.getLineItems();
EntitlementLineItemDataType lastCreatedLineItem1 = this.getLastCreatedLineItem(lineItems1);
EntitlementLineItemDataType lastCreatedLineItem2 = this.getLastCreatedLineItem(lineItems2);
// Convert positive to negative and vice versa as we want to list the latest first.
return -1 * this.compareLineItems(lastCreatedLineItem1, lastCreatedLineItem2);
}
}
);
===
No ratings