Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-5358

Add a way to define ResourceType inside kiebase

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • None
    • None
    • None
    • 2020 Week 22-24 (from May 25)
    • NEW
    • NEW

      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))

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

      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)

              mfusco@redhat.com Mario Fusco
              gcardosi Gabriele Cardosi (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: