KnowledgeBuilder kBuilder = kieModule.getKnowledgeBuilderForKieBase( kBaseModel.getName() );
for ( KnowledgeBuilderError error : kBuilder.getErrors() ) {
results.removeMessage( error );
}
CompositeKnowledgeBuilder ckbuilder = kBuilder.batch();
PackageBuilder pkgBuilder = ((KnowledgeBuilderImpl)kBuilder).getPackageBuilder();
boolean modified = false;
for (String file : files) {
String resourceName = file.startsWith(KieBuilderImpl.RESOURCES_ROOT) ?
file.substring(KieBuilderImpl.RESOURCES_ROOT.length()) :
file;
// remove the objects generated by the old Resource
modified = pkgBuilder.removeObjectsGeneratedFromResource(new DummyResource(resourceName)) || modified;
// add the modified Resource
modified = addResource(ckbuilder, kBaseModel, kieModule, resourceName) || modified;
}
if (modified) {
ckbuilder.build();
if ( kBuilder.hasErrors() ) {
for ( KnowledgeBuilderError error : kBuilder.getErrors() ) {
results.addMessage( error );
}
kBuilder.undo();