Package org.wso2.carbon.billing.core.dataobjects

Examples of org.wso2.carbon.billing.core.dataobjects.Customer


        return dataAccessManager.addSubscription(subscription);
    }

    public Customer getCustomerWithName (String customerName) throws Exception {
        DataAccessManager dataAccessManager = Util.getDataAccessManager();
        Customer customer = null;
        List<Customer> customers = dataAccessManager.getCustomersWithName(customerName);
        if(customers.size()>0){
            customer = customers.get(0);
        }
        return customer;
View Full Code Here


    }

    private void feedSubscriptions(BillingEngineContext handlerContext) throws BillingException {
        // get the subscriptions of the customer.
        String filter = handlerContext.getTaskConfiguration().getSubscriptionFilter();
        Customer customer = handlerContext.getCustomer();
        List<Subscription> subscriptions = getSubscriptions(filter, customer);
        log.debug("Found subscriptions: " + subscriptions.size());

        //Filtering out the subscription entries of customers who has not activated their accounts
        //This will avoid an invoice being generated for such customers
View Full Code Here

            } else {
                subscriptions = dataAccessObject.getFilteredActiveSubscriptionsForCustomer(filter, customer);
            }
            if(subscriptions!=null && subscriptions.size()>0){
                for (Subscription subscription : subscriptions) {
                    Customer dummyCustomer = subscription.getCustomer();
                    int customerId = dummyCustomer.getId();
                    Customer correctCustomer = customersCash.get(customerId);
                    if (correctCustomer == null) {
                        correctCustomer = getCustomer(customerId);
                        customersCash.put(customerId, correctCustomer);
                    }
                    subscription.setCustomer(correctCustomer);
View Full Code Here

    public static void addSubscriptionInfo(SubscriptionInfoBean subscriptionInfoBean,
                                           UserRegistry userRegistry) throws Exception {
        BillingEngine billingEngine = billingManager.getBillingEngine(StratosConstants.MULTITENANCY_SCHEDULED_TASK_ID);

        Customer customer = getCurrentCustomer(userRegistry);
        // if customer doesn't exist, we are making a one
        if (customer == null) {
            int currentTenantId = userRegistry.getTenantId();
            TenantManager tenantManger = getRealmService().getTenantManager();
            Tenant currentTenant = (Tenant) tenantManger.getTenant(currentTenantId);
            if (currentTenant == null || currentTenant.getDomain() == null) {
                String msg = "Error in getting the customer information.";
                throw new Exception(msg);
            }
            customer = new Customer();
            customer.setName(currentTenant.getDomain());
            customer.setEmail(currentTenant.getEmail());
            customer.setStartedDate(new Date());

            billingEngine.addCustomer(customer);
        }

        String itemName = subscriptionInfoBean.getPackageName();
View Full Code Here

    }

    public static Subscription getCurrentSubscription(UserRegistry userRegistry) throws Exception {
        BillingEngine billingEngine = billingManager.getBillingEngine(StratosConstants.MULTITENANCY_SCHEDULED_TASK_ID);

        Customer customer = getCurrentCustomer(userRegistry);
        if (customer == null) {
            return null;
        }
        List<Subscription> subscriptions = billingEngine.getActiveSubscriptions(customer);
        if (subscriptions == null || subscriptions.size() == 0) {
View Full Code Here

        }
        String customerName = tenant.getDomain();

        BillingEngine billingEngine =
                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_SCHEDULED_TASK_ID);
        Customer customer;
        try {
            List<Customer> customers = billingEngine.getCustomersWithName(customerName);
            if (customers == null || customers.size() == 0) {
                customer = null;
            } else {
View Full Code Here

     */
    public static Subscription getCurrentSubscription(int tenantId) throws RegistryException {
        BillingEngine billingEngine =
                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_SCHEDULED_TASK_ID);

        Customer customer = getCurrentBillingCustomer(tenantId);
        if (customer == null) {
            return null;
        }
        List<Subscription> subscriptions;
        try {
View Full Code Here

        }
    }

    public static boolean addUsagePlan(TenantInfoBean tenantBean) throws Exception{

        Customer customer=new Customer();
        customer.setName(tenantBean.getTenantDomain());
        customer.setEmail(tenantBean.getEmail());
        customer.setStartedDate(tenantBean.getCreatedDate().getTime());
        customer.setFullName(tenantBean.getFirstname()+" "+tenantBean.getLastname());

        customer.setId(tenantBean.getTenantId());
        Subscription subscription=new Subscription();
        subscription.setCustomer(customer);
        subscription.setActive(false);
        subscription.setActiveSince(Calendar.getInstance().getTime());
        Item item=new Item();
View Full Code Here

        List<Customer> customers = new ArrayList<Customer>();
        try{
            int tenantId = tenantManager.getTenantId(customerName);
            Tenant tenant = tenantManager.getTenant(tenantId);
            if(tenant!=null){
                Customer customer = new Customer();
                customer.setId(tenant.getId());
                customer.setName(tenant.getDomain());
                customer.setStartedDate(tenant.getCreatedDate());
                customer.setEmail(tenant.getEmail());
                //customer.setAddress();
                customers.add(customer);
            }
        }catch(Exception e){
            String msg = "Failed to get customers for customers: " + customerName + ".";
View Full Code Here

        }
    }

    public static Customer getCustomer(int customerId) throws BillingException{
        TenantManager tenantManager = Util.getRealmService().getTenantManager();
        Customer customer = null;

        try{
            Tenant tenant = tenantManager.getTenant(customerId);
            if(tenant!=null){
                customer = new Customer();
                customer.setId(customerId);
                customer.setName(tenant.getDomain());
                customer.setStartedDate(tenant.getCreatedDate());
                customer.setEmail(tenant.getEmail());
                //customer.setAddress();
            }
        } catch (Exception e){
            String msg = "Failed to get customer for customer id: " + customerId + ".";
            log.error(msg, e);
View Full Code Here

TOP

Related Classes of org.wso2.carbon.billing.core.dataobjects.Customer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.