Search in sources :

Example 1 with TypeMetaData

use of org.drools.model.TypeMetaData in project drools by kiegroup.

the class KiePackagesBuilder method build.

public CanonicalKiePackages build() {
    for (Model model : models) {
        for (TypeMetaData metaType : model.getTypeMetaDatas()) {
            KnowledgePackageImpl pkg = (KnowledgePackageImpl) packages.computeIfAbsent(metaType.getPackage(), this::createKiePackage);
            pkg.addTypeDeclaration(createTypeDeclaration(pkg, metaType));
        }
        for (Global global : model.getGlobals()) {
            KnowledgePackageImpl pkg = (KnowledgePackageImpl) packages.computeIfAbsent(global.getPackage(), this::createKiePackage);
            pkg.addGlobal(global.getName(), global.getType());
        }
        for (Query query : model.getQueries()) {
            KnowledgePackageImpl pkg = (KnowledgePackageImpl) packages.computeIfAbsent(query.getPackage(), this::createKiePackage);
            pkg.addRule(compileQuery(pkg, query));
        }
        int ruleCounter = 0;
        for (Rule rule : model.getRules()) {
            KnowledgePackageImpl pkg = (KnowledgePackageImpl) packages.computeIfAbsent(rule.getPackage(), this::createKiePackage);
            RuleImpl ruleImpl = compileRule(pkg, rule);
            ruleImpl.setLoadOrder(ruleCounter++);
            pkg.addRule(ruleImpl);
        }
    }
    return new CanonicalKiePackages(packages);
}
Also used : TypeMetaData(org.drools.model.TypeMetaData) Query(org.drools.model.Query) DroolsQuery(org.drools.core.base.DroolsQuery) Model(org.drools.model.Model) RuleImpl(org.drools.core.definitions.rule.impl.RuleImpl) Rule(org.drools.model.Rule) KnowledgePackageImpl(org.drools.core.definitions.impl.KnowledgePackageImpl) Global(org.drools.model.Global) SingleConstraint(org.drools.model.SingleConstraint) QueryNameConstraint(org.drools.core.rule.constraint.QueryNameConstraint) LambdaConstraint(org.drools.modelcompiler.constraints.LambdaConstraint) FlowDSL.entryPoint(org.drools.model.FlowDSL.entryPoint) UnificationConstraint(org.drools.modelcompiler.constraints.UnificationConstraint) EntryPoint(org.drools.model.EntryPoint) Constraint(org.drools.model.Constraint)

Aggregations

DroolsQuery (org.drools.core.base.DroolsQuery)1 KnowledgePackageImpl (org.drools.core.definitions.impl.KnowledgePackageImpl)1 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)1 QueryNameConstraint (org.drools.core.rule.constraint.QueryNameConstraint)1 Constraint (org.drools.model.Constraint)1 EntryPoint (org.drools.model.EntryPoint)1 FlowDSL.entryPoint (org.drools.model.FlowDSL.entryPoint)1 Global (org.drools.model.Global)1 Model (org.drools.model.Model)1 Query (org.drools.model.Query)1 Rule (org.drools.model.Rule)1 SingleConstraint (org.drools.model.SingleConstraint)1 TypeMetaData (org.drools.model.TypeMetaData)1 LambdaConstraint (org.drools.modelcompiler.constraints.LambdaConstraint)1 UnificationConstraint (org.drools.modelcompiler.constraints.UnificationConstraint)1