Deactivate Subscription Service
- g_sakkas (Unlicensed)
- Former user (Deleted)
Owned by g_sakkas (Unlicensed)
 The following example shows the deactivation 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 deactivate them.
Â
deactivateService.java Expand source
@EJB private CRMProcessSubscriptionServiceDeactivationBean processSubscriptionServiceDeactivationBean; public CRMDOSubscriptionAction deactivateService(CRMDOSubscription subscription,CRMDOInstalledItem installedItem){ ArrayList<CRMDOSubscriptionService> servicesToBeDeactivated = new ArrayList<CRMDOSubscriptionService>(); //create the subscription service deactivation data object SubscriptionServiceDeactivation subscriptionServiceDeactivation = processSubscriptionServiceDeactivationBean.constructSubscriptionServiceDeactivation(subscription); //the list of products that will be deactivated //in this example the product that will be deactivated 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 distributed on the same distributor as the 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 (!servicesToBeDeactivated.contains(serviceDistribution.getSubService())) { servicesToBeDeactivated.add(serviceDistribution.getSubService()); } } } } for (int i=0;i<servicesToBeDeactivated.size();i++) { CRMDOSubscriptionService subscriptionService =(CRMDOSubscriptionService)servicesToBeDeactivated.get(i); //create a new subscription action product data object where you will define the product that will be processed 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); } subscriptionServiceDeactivation.setServicesToBeProcessed(servicesToBeProcessed); //submit the subscription service deactivation data object in order to remove the product from subscription //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(subscriptionServiceDeactivation); return subscriptionAction; }