[jboss-jira] [JBoss JIRA] (DROOLS-5358) Add a way to define ResourceType inside kiebase
Gabriele Cardosi (Jira)
issues at jboss.org
Thu May 21 11:41:00 EDT 2020
[ https://issues.redhat.com/browse/DROOLS-5358?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gabriele Cardosi updated DROOLS-5358:
-------------------------------------
Description:
Step to reproduce
1) create a project with multiple pmml files, each in its own package (eg. resources/package_name/file.pmml)
2) create a kmodule xml and define one kiebase for each package
3) compile the kjar
4) in the kjar the files/classes are all in the proper place (i.e. in the expected package)
5) add the kjar in a new project
6) in the new project invoke
KieServices.get().newKieClasspathContainer().getKieBase(kbaseName);
The jar packages are inside the kieBase.getPackages(), but they are not marked as "PMMLType" packages - so it is necessary to invoke the (PMML)AssemblerService to wrap the content of the (jar) packages inside correct PMMLType packages and put them in the knowledge base
The following snippet is a temporary workaround (inside CanonicalKieModule.createKieBase(KieBaseModelImpl, KieProject, ResultsImpl, KieBaseConfiguration))
{code:java}
for (KiePackage pk : pkgs) {
// Workaround to "mark" already compiled packages (as found inside the kjar and retrieved by createKiePackages(kieProject, kBaseModel, messages, kBaseConf))
// as "PMML" packages
boolean isInternalKnowldgePackage = pk instanceof InternalKnowledgePackage;
final InternalKnowledgePackage originalPackage = kieBase.getPackage(pk.getName());
if (originalPackage != null && isInternalKnowldgePackage && ((InternalKnowledgePackage) pk).getResourceTypePackages().get(ResourceType.PMML) != null) {
originalPackage.getResourceTypePackages().put(ResourceType.PMML, ((InternalKnowledgePackage) pk).getResourceTypePackages().get(ResourceType.PMML));
} else if (originalPackage == null) {
kieBase.addPackages(pkgs);
}
}
{code}
The idea is to get the "type" information from newly compiled package and put it in the existing one (that also contains al the other compiled classes).
Ideally, we should be able to completely skip the (PMML)AssemblerService invocation (that recreate new packages)
was:
Step to reproduce
1) create a project with multiple pmml files, each in its own package (eg. resources/package_name/file.pmml)
2) create a kmodule xml and define one kiebase for each package
3) compile the kjar
4) in the kjar the files/classes are all in the proper place (i.e. in the expected package)
5) add the kjar in a new project
6) in the new project invoke
KieServices.get().newKieClasspathContainer().getKieBase(kbaseName);
The jar packages are inside the kieBase.getPackages(), but they are not marked as "PMMLType" packages - so it is necessary to invoke the (PMML)AssemblerService to wrap the content of the (jar) packages inside correct PMMLType packages and put them in the knowledge base
> Add a way to define ResourceType inside kiebase
> -----------------------------------------------
>
> Key: DROOLS-5358
> URL: https://issues.redhat.com/browse/DROOLS-5358
> Project: Drools
> Issue Type: Task
> Reporter: Gabriele Cardosi
> Assignee: Mario Fusco
> Priority: Major
>
> Step to reproduce
> 1) create a project with multiple pmml files, each in its own package (eg. resources/package_name/file.pmml)
> 2) create a kmodule xml and define one kiebase for each package
> 3) compile the kjar
> 4) in the kjar the files/classes are all in the proper place (i.e. in the expected package)
> 5) add the kjar in a new project
> 6) in the new project invoke
> KieServices.get().newKieClasspathContainer().getKieBase(kbaseName);
> The jar packages are inside the kieBase.getPackages(), but they are not marked as "PMMLType" packages - so it is necessary to invoke the (PMML)AssemblerService to wrap the content of the (jar) packages inside correct PMMLType packages and put them in the knowledge base
> The following snippet is a temporary workaround (inside CanonicalKieModule.createKieBase(KieBaseModelImpl, KieProject, ResultsImpl, KieBaseConfiguration))
> {code:java}
> for (KiePackage pk : pkgs) {
> // Workaround to "mark" already compiled packages (as found inside the kjar and retrieved by createKiePackages(kieProject, kBaseModel, messages, kBaseConf))
> // as "PMML" packages
> boolean isInternalKnowldgePackage = pk instanceof InternalKnowledgePackage;
> final InternalKnowledgePackage originalPackage = kieBase.getPackage(pk.getName());
> if (originalPackage != null && isInternalKnowldgePackage && ((InternalKnowledgePackage) pk).getResourceTypePackages().get(ResourceType.PMML) != null) {
> originalPackage.getResourceTypePackages().put(ResourceType.PMML, ((InternalKnowledgePackage) pk).getResourceTypePackages().get(ResourceType.PMML));
> } else if (originalPackage == null) {
> kieBase.addPackages(pkgs);
> }
> }
> {code}
> The idea is to get the "type" information from newly compiled package and put it in the existing one (that also contains al the other compiled classes).
> Ideally, we should be able to completely skip the (PMML)AssemblerService invocation (that recreate new packages)
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
More information about the jboss-jira
mailing list