Package org.drools.core.definitions.rule.impl

Examples of org.drools.core.definitions.rule.impl.RuleImpl


    public PropagationContext getPropagationContext() {
        return null;
    }

    public RuleImpl getRule() {
        return new RuleImpl( ruleName );
    }
View Full Code Here


    /**
     * This will add the rule for compiling later on.
     * It will not actually call the compiler
     */
    public void addRule(final RuleBuildContext context) {
        final RuleImpl rule = context.getRule();
        final RuleDescr ruleDescr = context.getRuleDescr();

        RuleClassBuilder classBuilder = context.getDialect().getRuleClassBuilder();

        String ruleClass = classBuilder.buildRule( context );
View Full Code Here

                }
            }

            KieBase kBase = kBaseEntry.getValue();
            for ( ResourceChangeSet.RuleLoadOrder loadOrder : rcs.getLoadOrder() ) {
                RuleImpl rule = ((KnowledgePackageImpl)kBase.getKiePackage( loadOrder.getPkgName() )).getRule( loadOrder.getRuleName() );
                if ( rule != null ) {
                    // rule can be null, if it didn't exist before
                    rule.setLoadOrder( loadOrder.getLoadOrder() );
                }
            }
        }
        return fileCount;
    }
View Full Code Here

                                        (QueryImpl) context.getRule() );
            }

            if ( rce == null ) {
                // look up the query in the current package
                RuleImpl rule = context.getPkg().getRule( patternDescr.getObjectType() );
                if ( rule instanceof QueryImpl ) {
                    // it's a query so delegate to the QueryElementBuilder
                    QueryElementBuilder qeBuilder = QueryElementBuilder.getInstance();
                    rce = qeBuilder.build( context,
                                           descr,
                                           prefixPattern,
                                           (QueryImpl) rule );
                }
            }

            if ( rce == null ) {
                // the query may have been imported, so try package imports
                for ( String importName : context.getDialect().getTypeResolver().getImports() ) {
                    importName = importName.trim();
                    int pos = importName.indexOf( '*' );
                    if ( pos >= 0 ) {
                        String pkgName = importName.substring( 0,
                                                               pos - 1 );
                        PackageRegistry pkgReg = context.getKnowledgeBuilder().getPackageRegistry( pkgName );
                        if ( pkgReg != null ) {
                            RuleImpl rule = pkgReg.getPackage().getRule( patternDescr.getObjectType() );
                            if ( rule instanceof QueryImpl) {
                                // it's a query so delegate to the QueryElementBuilder
                                QueryElementBuilder qeBuilder = QueryElementBuilder.getInstance();
                                rce = qeBuilder.build( context,
                                                       descr,
View Full Code Here

        for (List<RuleDescr> rds : parents.values()) {
            for (RuleDescr ruleDescr : rds) {
                if (parents.get(ruleDescr.getParentName()) != null
                    && (sorted.containsKey(ruleDescr.getName()) || parents.containsKey(ruleDescr.getName()))) {
                    circularDep = true;
                    results.add(new RuleBuildError(new RuleImpl(ruleDescr.getName()), ruleDescr, null,
                                                   "Circular dependency in rules hierarchy"));
                    break;
                }
                manageUnresolvedExtension(ruleDescr, sorted.values());
            }
View Full Code Here

        }
        String msg = "Unresolved parent name " + ruleDescr.getParentName();
        if (candidateRules.size() > 0) {
            msg += " >> did you mean any of :" + candidateRules;
        }
        results.add(new RuleBuildError(new RuleImpl(ruleDescr.getName()), ruleDescr, msg,
                                       "Unable to resolve parent rule, please check that both rules are in the same package"));
    }
View Full Code Here

                                                 rule.getLine(),
                                                 rule.getColumn(),
                                                 packageDescr.getNamespace()));
            }
            if (pkg != null) {
                RuleImpl duplicatedRule = pkg.getRule(name);
                if (duplicatedRule != null) {
                    Resource resource = rule.getResource();
                    Resource duplicatedResource = duplicatedRule.getResource();
                    if (resource == null || duplicatedResource == null || duplicatedResource.getSourcePath() == null ||
                        duplicatedResource.getSourcePath().equals(resource.getSourcePath())) {
                        addBuilderResult(new DuplicateRule(rule,
                                                           packageDescr,
                                                           this.configuration));
View Full Code Here

    /* (non-Javadoc)
     * @see junit.framework.TestCase#setUp()
     */
    @Before
    public void setUp() throws Exception {
        this.rule = new RuleImpl("test-rule");

        InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase();
        pctxFactory = kBase.getConfiguration().getComponentFactory().getPropagationContextFactory();
        this.context = pctxFactory.createPropagationContext(0, PropagationContext.INSERTION, null, null, null);

View Full Code Here

        return i;
    }

    public void addActivation(AgendaItem item,
                              boolean notify) {
        RuleImpl rule = item.getRule();
        item.setQueued(true);

        // set the focus if rule autoFocus is true
        if ( rule.getAutoFocus() ) {
            this.setFocus( item.getPropagationContext(),
                           rule.getAgendaGroup() );
        }

        // adds item to activation group if appropriate
        addItemToActivationGroup( item );

        final Timer timer = rule.getTimer();
        if ( timer != null && item instanceof ScheduledAgendaItem ) {
            ScheduledAgendaItem sitem = (ScheduledAgendaItem) item;
            if ( sitem.isEnqueued() ) {
                // it's about to be re-added to scheduled list, so remove first
                this.scheduledActivations.remove( sitem );
View Full Code Here

            tuple.increaseActivationCountForEvents();
            fireActivation( item); // Control rules fire straight away.
            return true;
        }

        final RuleImpl rule = rtn.getRule();
        AgendaItem item;
        final Timer timer = rule.getTimer();
        InternalAgendaGroup agendaGroup = (InternalAgendaGroup) getAgendaGroup( rule.getAgendaGroup() );
        if ( timer != null ) {
            item = createScheduledAgendaItem( tuple,
                                              context,
                                              rtn,
                                              agendaGroup
                                            );
        } else {
            if ( rule.getCalendars() != null ) {
                // for normal activations check for Calendar inclusion here, scheduled activations check on each trigger point
                long timestamp = workingMemory.getSessionClock().getCurrentTime();
                for ( String cal : rule.getCalendars() ) {
                    if ( !workingMemory.getCalendars().get( cal ).isTimeIncluded( timestamp ) ) {
                        return false;
                    }
                }
            }

            if ( rule.isLockOnActive() && agendaGroup.isActive()  && agendaGroup.getAutoFocusActivator() != context ) {
                // do not add the activation if the rule is "lock-on-active" and the AgendaGroup is active
                if ( tuple.getObject() == null ) {
                    tuple.setObject( Boolean.TRUE ); // this is so we can do a check with a bit more intent than a null check on modify
                }
                return false;
            }

            item = createAgendaItem( tuple,
                                     0,
                                     context,
                                     rtn,
                                     null,
                                     agendaGroup
                                   );
            item.setSalience( rule.getSalience().getValue( new DefaultKnowledgeHelper( item, workingMemory ),
                                                           rule,
                                                           workingMemory ) );
        }

        if ( activationsFilter != null && !activationsFilter.accept( item,
View Full Code Here

TOP

Related Classes of org.drools.core.definitions.rule.impl.RuleImpl

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.