...
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.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
@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 theproducts product that will be deactivated from the subscription //in this example the product that will be activateddeactivated 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 whichdistributed ison distributed tothe 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 processprocessed 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 //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(subscriptionServiceDeactivation); return subscriptionAction; } |