Package org.candlepin.policy.js

Examples of org.candlepin.policy.js.JsonJsContext


        mapper = RulesObjectMapper.instance();
        jsRules.init("pool_type_name_space");
    }

    public PoolComplianceType getPoolType(Pool p) {
        JsonJsContext args = new JsonJsContext(mapper);

        args.put("pool", p);
        args.put("log", log, false);

        String json = jsRules.runJsFunction(String.class, "get_pool_type", args);
        PoolComplianceType dto = mapper.toObject(json, PoolComplianceType.class);
        return dto;
    }
View Full Code Here


                    "due to too much content");
            }
        }

        // Provide objects for the script:
        JsonJsContext args = new JsonJsContext(mapper);
        args.put("consumer", consumer);
        args.put("owner", consumer.getOwner());
        args.put("serviceLevelOverride", serviceLevelOverride);
        args.put("pools", pools.toArray());
        args.put("products", productIds);
        args.put("log", log, false);
        args.put("compliance", compliance);
        args.put("exemptList", exemptLevels);
        args.put("considerDerived", considerDerived);

        // Convert the JSON returned into a Map object:
        Map<String, Integer> result = null;
        try {
            String json = jsRules.invokeMethod(SELECT_POOL_FUNCTION, args);
View Full Code Here

        mapper = RulesObjectMapper.instance();
        jsRules.init("activation_key_name_space");
    }

    public ValidationResult runPreActKey(ActivationKey key, Pool pool, Long quantity) {
        JsonJsContext args = new JsonJsContext(mapper);
        args.put("key", key);
        args.put("pool", pool);
        args.put("quantity", quantity);
        args.put("log", log, false);

        String json = jsRules.invokeRule("validate_pool", args);
        ValidationResult result = mapper.toObject(json, ValidationResult.class);
        return result;
    }
View Full Code Here

    }

    public ValidationResult preEntitlement(Consumer consumer, Consumer host,
        Pool entitlementPool, Integer quantity, CallerType caller) {

        JsonJsContext args = new JsonJsContext(objectMapper);
        args.put("consumer", consumer);
        args.put("hostConsumer", host);
        args.put("consumerEntitlements", consumer.getEntitlements());
        args.put("standalone", config.getBoolean(ConfigProperties.STANDALONE));
        args.put("pool", entitlementPool);
        args.put("quantity", quantity);
        args.put("caller", caller.getLabel());
        args.put("log", log, false);

        String json = jsRules.runJsFunction(String.class, "validate_pool", args);
        ValidationResult result;
        try {
            result = objectMapper.toObject(json, ValidationResult.class);
View Full Code Here

        mapper = RulesObjectMapper.instance();
        jsRules.init("quantity_name_space");
    }

    public SuggestedQuantity getSuggestedQuantity(Pool p, Consumer c, Date date) {
        JsonJsContext args = new JsonJsContext(mapper);

        Set<Entitlement> validEntitlements = new HashSet<Entitlement>();
        for (Entitlement e : c.getEntitlements()) {
            if (e.isValidOnDate(date)) {
                validEntitlements.add(e);
            }
        }

        args.put("pool", p);
        args.put("consumer", c);
        args.put("validEntitlements", validEntitlements);
        args.put("log", log, false);

        String json = jsRules.runJsFunction(String.class, "get_suggested_quantity", args);
        SuggestedQuantity dto = mapper.toObject(json, SuggestedQuantity.class);
        return dto;
    }
View Full Code Here

        mapper = RulesObjectMapper.instance();
        jsRules.init("override_name_space");
    }

    public boolean canOverrideForConsumer(String name) {
        JsonJsContext args = new JsonJsContext(mapper);

        args.put("name", name);
        args.put("log", log, false);

        return !jsRules.runJsFunction(Boolean.class, "get_allow_override", args);
    }
View Full Code Here

        boolean currentCompliance = false;
        if (date == null) {
            date = new Date();
            currentCompliance = true;
        }
        JsonJsContext args = new JsonJsContext(mapper);
        args.put("consumer", c);
        args.put("entitlements", c.getEntitlements());
        args.put("ondate", date);
        args.put("calculateCompliantUntil", calculateCompliantUntil);
        args.put("log", log, false);

        // Convert the JSON returned into a ComplianceStatus object:
        String json = jsRules.runJsFunction(String.class, "get_status", args);
        try {
            ComplianceStatus result = mapper.toObject(json, ComplianceStatus.class);
View Full Code Here

        }
    }

    public boolean isStackCompliant(Consumer consumer, String stackId,
        List<Entitlement> entsToConsider) {
        JsonJsContext args = new JsonJsContext(mapper);
        args.put("stack_id", stackId);
        args.put("consumer", consumer);
        args.put("entitlements", entsToConsider);
        args.put("log", log, false);
        return jsRules.runJsFunction(Boolean.class, "is_stack_compliant", args);
    }
View Full Code Here

    }

    public boolean isEntitlementCompliant(Consumer consumer, Entitlement ent, Date onDate) {
        List<Entitlement> ents = entCurator.listByConsumerAndDate(consumer, onDate);

        JsonJsContext args = new JsonJsContext(mapper);
        args.put("consumer", consumer);
        args.put("entitlement", ent);
        args.put("entitlements", ents);
        args.put("log", log, false);
        return jsRules.runJsFunction(Boolean.class, "is_ent_compliant", args);
    }
View Full Code Here

TOP

Related Classes of org.candlepin.policy.js.JsonJsContext

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.