Search in sources :

Example 1 with SmartRuleStringParser

use of org.smartdata.rule.parser.SmartRuleStringParser in project SSM by Intel-bigdata.

the class TestSmartRuleStringParser method parseRule.

private void parseRule(String rule) throws Exception {
    TranslationContext tc = new TranslationContext(1, System.currentTimeMillis());
    SmartRuleStringParser parser = new SmartRuleStringParser(rule, tc, new SmartConf());
    TranslateResult tr = parser.translate();
    int index = 1;
    System.out.println("\n" + rule);
    for (String sql : tr.getSqlStatements()) {
        System.out.println("\t" + index + ". " + sql);
        index++;
    }
}
Also used : SmartRuleStringParser(org.smartdata.rule.parser.SmartRuleStringParser) TranslateResult(org.smartdata.model.rule.TranslateResult) SmartConf(org.smartdata.conf.SmartConf) TranslationContext(org.smartdata.rule.parser.TranslationContext)

Example 2 with SmartRuleStringParser

use of org.smartdata.rule.parser.SmartRuleStringParser in project SSM by Intel-bigdata.

the class RuleInfoRepo method doLaunchExecutor.

private RuleExecutor doLaunchExecutor(RuleManager ruleManager) throws IOException {
    RuleState state = ruleInfo.getState();
    if (state == RuleState.ACTIVE || state == RuleState.DRYRUN) {
        if (executor != null && !executor.isExited()) {
            return null;
        }
        ExecutionContext ctx = new ExecutionContext();
        ctx.setRuleId(ruleInfo.getId());
        TranslationContext transCtx = new TranslationContext(ruleInfo.getId(), ruleInfo.getSubmitTime());
        TranslateResult tr = executor != null ? executor.getTranslateResult() : new SmartRuleStringParser(ruleInfo.getRuleText(), transCtx, conf).translate();
        List<RuleExecutorPlugin> plugins = RuleExecutorPluginManager.getPlugins();
        for (RuleExecutorPlugin plugin : plugins) {
            plugin.onNewRuleExecutor(ruleInfo, tr);
        }
        executor = new RuleExecutor(ruleManager, ctx, tr, ruleManager.getMetaStore());
        return executor;
    }
    return null;
}
Also used : SmartRuleStringParser(org.smartdata.rule.parser.SmartRuleStringParser) RuleState(org.smartdata.model.RuleState) ExecutionContext(org.smartdata.server.engine.data.ExecutionContext) TranslateResult(org.smartdata.model.rule.TranslateResult) TranslationContext(org.smartdata.rule.parser.TranslationContext) RuleExecutorPlugin(org.smartdata.model.rule.RuleExecutorPlugin)

Aggregations

TranslateResult (org.smartdata.model.rule.TranslateResult)2 SmartRuleStringParser (org.smartdata.rule.parser.SmartRuleStringParser)2 TranslationContext (org.smartdata.rule.parser.TranslationContext)2 SmartConf (org.smartdata.conf.SmartConf)1 RuleState (org.smartdata.model.RuleState)1 RuleExecutorPlugin (org.smartdata.model.rule.RuleExecutorPlugin)1 ExecutionContext (org.smartdata.server.engine.data.ExecutionContext)1