You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 2
Next »
The following example shows the activation of a subscription service given that you already have the installed items and the services on the subscription.
You have to retrieve all provisioning distributors that the installed item is distributed on, and then for each one, find the distributed services and activate.
@EJB private CRMProcessSubscriptionServiceActivationBean processSubscriptionServiceActivationBean;
public CRMDOSubscriptionAction activateService(CRMDOSubscription subscription,CRMDOInstalledItem installedItem){
ArrayList<CRMDOSubscriptionService> servicesToBeActivated = new ArrayList<CRMDOSubscriptionService>();
//create the subscription service activation data object
SubscriptionServiceActivation subscriptionServiceActivation= processSubscriptionServiceActivationBean.constructSubscriptionServiceActivation(subscription);
//the list of the product that will be activated from the subscription
//in this example the product that will be activated will be retrieve based on the installed item
Set<SubscriptionActionProduct> servicesToBeProcessed = new HashSet<SubscriptionActionProduct>();
//retrieve the subscription installed item.
CRMDOSubscriptionInstalledItem subscriptionInstalledItem = (CRMDOSubscriptionInstalledItem)subscriptionInstalledItemBean.load(subscription, installedItem);
//retrieve the related distributions of the installed item
ArrayList<CRMDO> installedItemDistributions = subProvisioningDistributionBean.load(subscriptionInstalledItem);
//retrieve all the service distributions
ArrayList<CRMDO> serviceDistributions = subProvisioningDistributionBean.loadServiceDistributions(subscription, null);
//retrieve all the subscription services which is distributed to same distributor as installed item
for (int i=0;i<installedItemDistributions.size();i++)
{
CRMDOSubProvisioningDistribution installedItemDistribution = (CRMDOSubProvisioningDistribution)installedItemDistributions.get(i);
for (int j=0;j<serviceDistributions.size();j++)
{
CRMDOSubProvisioningDistribution serviceDistribution = (CRMDOSubProvisioningDistribution)serviceDistributions.get(j);
if (serviceDistribution.getProvDistributor().equals(installedItemDistribution.getProvDistributor()))
{
if (!servicesToBeActivated.contains(serviceDistribution.getSubService()))
{
servicesToBeActivated.add(serviceDistribution.getSubService());
}
}
}
}
for (int i=0;i<servicesToBeActivated.size();i++)
{
CRMDOSubscriptionService subscriptionService =(CRMDOSubscriptionService)servicesToBeActivated.get(i);
//create a new subscription action product data object where you will define the product that will be process by the action
SubscriptionActionProduct subscriptionActionProduct =new SubscriptionActionProduct();
subscriptionActionProduct.setIsDeleted(new Integer(0));
subscriptionActionProduct.setProduct(subscriptionService.getProduct());
subscriptionActionProduct.setSubService(subscriptionService);
subscriptionActionProduct.setIsSelected(new Integer(1));
servicesToBeProcessed.add(subscriptionActionProduct);
}
subscriptionServiceActivation.setServicesToBeProcessed(servicesToBeProcessed);
//submit the subscription service activation data object in order to remove the product from subscription
//As a result is the subscription action data object.
//the subscription action data object is the object which contains all the information about the action you perform on the subscription
CRMDOSubscriptionAction subscriptionAction = processSubscriptionServiceDeactivationBean.submit(subscriptionServiceActivation);
}