@EJB private CRMProcessSubscriptionServiceSwapBean processSubscriptionServiceSwapBean;
public CRMDOSubscriptionAction swapService(CRMDOSubscription subscription,CRMDOProduct product,CRMDOProduct newProduct){
//create the subscription service swap data object
SubscriptionServiceSwap subscriptionServiceSwap = processSubscriptionServiceSwapBean.constructSubscriptionServiceSwap(subscription);
//in that action you don't need to define classification code
//The system will decide the classification code
//The applicable classification for that action are:UPGRADE_SERVICE,DOWNGRADE_SERVICE,SWITCH_SERVICE
//the list of the productproducts that will be swapped
on the subscription //in that example we swap only one product but you can swap in one go more than one productproducts
Set<SubscriptionActionProduct> servicesToBeProcessed = new HashSet<SubscriptionActionProduct>();
//create a new subscription action product data object where you will define the from/to product that will be processprocessed by the action
SubscriptionActionProduct subscriptionActionProduct =new SubscriptionActionProduct();
//load the related subscription service
CRMDOSubscriptionService subscriptionService = subscriptionServiceBean.load(subscription, product);
subscriptionActionProduct.setIsDeleted(new Integer(0));
subscriptionActionProduct.setProduct(product);
subscriptionActionProduct.setSubService(subscriptionService);
subscriptionActionProduct.setChangeToProduct(newProduct);
subscriptionActionProduct.setIsSelected(new Integer(1));
servicesToBeProcessed.add(subscriptionActionProduct);
subscriptionServiceSwap.setServicesToBeProcessed(servicesToBeProcessed);
//submit the subscription service swap data object in order the new product replace the existing product on the 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 = processSubscriptionServiceSwapBean.submit(subscriptionServiceSwap);
return subscriptionAction;
} |