Swap Subscription Service

The following example shows how to replace an effective subscription service with a new service.

 

swapService.java
@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 products that will be swapped
    //in that example we swap only one product but you can swap in one go more than one products
    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 processed 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. 

    //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;
}