Package org.rhq.enterprise.server.resource.group.definition.framework

Examples of org.rhq.enterprise.server.resource.group.definition.framework.ExpressionEvaluator


    }

    private static boolean validateCGE(CannedGroupExpression cge) {
        boolean valid = true;
        try {
            ExpressionEvaluator evaluator = new ExpressionEvaluator();
            evaluator.setTestMode(true); // to prevent actual query from happening
            for (String expr : cge.getExpression()) {
                evaluator.addExpression(expr);
            }
            evaluator.execute();
           
        } catch (Exception ex) {
            log.error("Failed to evaluate [expression], evaluator result : "+ex.getMessage());
            valid = false;
        }
View Full Code Here


        if (definition.getExpression() == null || definition.getExpression().isEmpty()) {
            throw new GroupDefinitionException("Expression is empty");
        }
       
        try {
            ExpressionEvaluator evaluator = new ExpressionEvaluator();
            for (String expression : definition.getExpressionAsList()) {
                evaluator.addExpression(expression);
            }
        } catch (InvalidExpressionException e) {
            throw new GroupDefinitionException("Cannot parse the expression: " + e.getMessage());
        }
View Full Code Here

        long startTime = System.currentTimeMillis();

        GroupDefinition groupDefinition = getById(groupDefinitionId);
        groupDefinition.setLastCalculationTime(System.currentTimeMillis()); // we're calculating now

        ExpressionEvaluator evaluator = new ExpressionEvaluator();
        for (String expression : groupDefinition.getExpressionAsList()) {
            evaluator.addExpression(expression);
        }

        Collection<Integer> doomedResourceGroupIds = new ArrayList<Integer>();
        for (Integer managedGroupId : getManagedResourceGroupIdsForGroupDefinition(groupDefinitionId)) {
            doomedResourceGroupIds.add(managedGroupId);
View Full Code Here

                String expectedGroupResult = "";
                if (successTestCases[i].length == 3) {
                    expectedGroupResult = successTestCases[i][2];
                }

                ExpressionEvaluator evaluator = new ExpressionEvaluator();
                evaluator.setTestMode(true); // to prevent actual query from happening
                for (String expression : inputExpressions.split(";")) {
                    try {
                        evaluator.addExpression(expression); // do not trim, evaluator must handle sloppy expressions
                    } catch (Exception e) {
                        e.printStackTrace(System.out);
                        assert false : "Error in TestCase[" + i + "], could not add expression[" + expression
                            + "], input[" + inputExpressions + "]";
                    }
                }

                evaluator.execute(); // execute will compute the JPQL statements

                String actualTopResult = evaluator.getComputedJPQLStatement();
                String actualGroupResult = evaluator.getComputedJPQLGroupStatement();

                expectedTopResult = cleanUp(expectedTopResult);
                actualTopResult = cleanUp(actualTopResult);
                expectedGroupResult = cleanUp(expectedGroupResult);
                actualGroupResult = cleanUp(actualGroupResult);
View Full Code Here

            { "resource", "pluginConfiguration[partition]" }, //
            { "resource", "pluginConfiguration[partition]", "contains" }, //
            { "resource", "pluginConfiguration[partition.name]", "contains" }, //
            { "memberof" } };

        ExpressionEvaluator evaluator = new ExpressionEvaluator();
        evaluator.setTestMode(true); // to prevent actual query from happening

        for (int i = 0; i < input.length; i++) {
            String nextInput = input[i];
            String[] nextExpectedOutput = expectedOutput[i];

            List<String> output = evaluator.tokenizeCondition(nextInput);
            String[] outputArray = output.toArray(new String[0]);

            if (nextExpectedOutput.length != outputArray.length) {
                System.out.println("Expected (" + Arrays.asList(nextExpectedOutput) + "), Received (" + output + ")");
                continue;
View Full Code Here

    }

    private void evaluateExpressions(ExpressionGenerator generator) throws Exception {
        try {
            getTransactionManager().begin();
            ExpressionEvaluator evaluator = new ExpressionEvaluator();
            for (String expression : generator.getExpressions()) {
                evaluator.addExpression(expression);
            }
            evaluator.execute();
            evaluator.iterator().next();
        } finally {
            getTransactionManager().rollback();
        }
    }
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.resource.group.definition.framework.ExpressionEvaluator

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.