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);
}
Aggregations