Package org.candlepin.json.model

Examples of org.candlepin.json.model.Subscription


        return toReturn;
    }

    public Subscription createSubscription(
        Entitlement ent) {
        Subscription toReturn = new Subscription();
        Pool pool = ent.getPool();

        toReturn.setSku(pool.getProductId());
        toReturn.setName(pool.getProductName());

        String warningPeriod = pool.getProductAttributeValue(
            "warning_period");
        if (warningPeriod != null && !warningPeriod.trim().equals("")) {
            // only included if not the default value of 0
            if (!warningPeriod.equals("0")) {
                toReturn.setWarning(new Integer(warningPeriod));
            }
        }

        String socketLimit = pool.getProductAttributeValue("sockets");
        if (socketLimit != null && !socketLimit.trim().equals("")) {
            toReturn.setSockets(new Integer(socketLimit));
        }

        String ramLimit = pool.getProductAttributeValue("ram");
        if (ramLimit != null && !ramLimit.trim().equals("")) {
            toReturn.setRam(new Integer(ramLimit));
        }

        String coreLimit = pool.getProductAttributeValue("cores");
        if (coreLimit != null && !coreLimit.trim().equals("")) {
            toReturn.setCores(new Integer(coreLimit));
        }

        String management = pool.getProductAttributeValue("management_enabled");
        if (management != null && !management.trim().equals("")) {
            // only included if not the default value of false
            if (management.equalsIgnoreCase("true") ||
                    management.equalsIgnoreCase("1")) {
                toReturn.setManagement(Boolean.TRUE);
            }
        }

        String stackingId = pool.getProductAttributeValue("stacking_id");
        if (stackingId != null && !stackingId.trim().equals("")) {
            toReturn.setStackingId(stackingId);
        }

        String virtOnly = ent.getPool().getAttributeValue("virt_only");
        if (virtOnly != null && !virtOnly.trim().equals("")) {
            // only included if not the default value of false
            Boolean vo = Boolean.valueOf(virtOnly.equalsIgnoreCase("true") ||
                virtOnly.equalsIgnoreCase("1"));
            if (vo) {
                toReturn.setVirtOnly(vo);
            }
        }

        toReturn.setService(createService(pool));
        return toReturn;
    }
View Full Code Here

TOP

Related Classes of org.candlepin.json.model.Subscription

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.