if (resource.getSourcePath() != null ) { String path = resource.getSourcePath();
resource.setSourcePath(processResource.getSourcePath()); resource.setTargetPath(processResource.getTargetPath());
if (duplicateProcess != null) { Resource duplicatedResource = duplicateProcess.getResource(); if (resource == null || duplicatedResource == null || duplicatedResource.getSourcePath() == null || duplicatedResource.getSourcePath().equals(resource.getSourcePath())) { this.errors.add(new DuplicateProcess(process, this.knowledgeBuilder.getBuilderConfiguration()));
protected List<Resource> buildAndDumpBPMN2Process(String process) throws SAXException, IOException { KnowledgeBuilderConfiguration conf = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(); ((KnowledgeBuilderConfigurationImpl) conf).initSemanticModules(); ((KnowledgeBuilderConfigurationImpl) conf).addSemanticModule(new BPMNSemanticModule()); ((KnowledgeBuilderConfigurationImpl) conf).addSemanticModule(new BPMNDISemanticModule()); ((KnowledgeBuilderConfigurationImpl) conf).addSemanticModule(new BPMNExtensionsSemanticModule()); Resource classpathResource = ResourceFactory.newClassPathResource(process); // Dump and reread XmlProcessReader processReader = new XmlProcessReader(((KnowledgeBuilderConfigurationImpl) conf).getSemanticModules(), getClass().getClassLoader()); List<Process> processes = processReader.read(this.getClass().getResourceAsStream("/" + process)); List<Resource> resources = new ArrayList<Resource>(); for (Process p : processes) { RuleFlowProcess ruleFlowProcess = (RuleFlowProcess) p; String dumpedString = XmlBPMNProcessDumper.INSTANCE.dump(ruleFlowProcess); Resource resource = ResourceFactory.newReaderResource(new StringReader(dumpedString)); resource.setSourcePath(classpathResource.getSourcePath()); resource.setTargetPath(classpathResource.getTargetPath()); resources.add(resource); } return resources; }
kfs.delete(res.getSourcePath()); kfs.write(ResourceFactory.newFileResource(packageFile));
@Test public void testDummyResourceWithWrongEncodedFileName() { final Resource dummyResource = new KieBuilderSetImpl.DummyResource("Dummy 100%"); assertEquals(dummyResource.getSourcePath(), "Dummy 100%"); }
public String getSourcePath() { return delegate.getSourcePath(); }
@Override public boolean accept(Process process, Resource resource) { if (process != null && RuleFlowProcess.RULEFLOW_TYPE.equals(process.getType()) && resource.getSourcePath() != null && resource.getSourcePath().matches(".+\\.bpsim\\.bpmn[2]?$")) { return true; } return false; }
@Override public boolean accept(Process process, Resource resource) { if (process != null && RuleFlowProcess.RULEFLOW_TYPE.equals(process.getType()) && resource.getSourcePath() != null && resource.getSourcePath().matches(".+\\.bpsim\\.bpmn[2]?$")) { return true; } return false; }
assertNotNull( ikm.getResource( r1.getSourcePath() ) ); assertNotNull( ikm.getResource( r2.getSourcePath() ) ); assertNotNull( ikm.getResource( r3.getSourcePath() ) ); assertNotNull( ikm.getResource( r4.getSourcePath() ) );
public DMNModel getDMNModel(Path path, String dmnPath) { return getDMNRuntime(path).getModels().stream() .filter(model -> dmnPath.endsWith(model.getResource().getSourcePath())) .findFirst() .orElseThrow(() -> new IllegalStateException("Impossible to find DMN model")); }
private Resource buildOutputResource(Resource resource, String theory) { ByteArrayResource byteArrayResource = new ByteArrayResource(theory.getBytes(IoUtils.UTF8_CHARSET)); byteArrayResource.setResourceType(ResourceType.PMML); if (resource.getSourcePath() != null) { String originalPath = resource.getSourcePath(); int start = originalPath.lastIndexOf(File.separator); byteArrayResource.setSourcePath("generated-sources/" + originalPath.substring(start) + ".pmml"); } else { byteArrayResource.setSourcePath("generated-sources/" + helper.getContext() + ".pmml"); } return byteArrayResource; }
public void setActiveModel(String path) { dmnRuntimeFluent .addCommand(context -> { RegistryContext registryContext = (RegistryContext) context; DMNRuntime dmnRuntime = registryContext.lookup(DMNRuntime.class); if (dmnRuntime == null) { throw new IllegalStateException("There is no DMNRuntime available"); } DMNModel dmnModel = dmnRuntime.getModels().stream() .filter(model -> path.endsWith(model.getResource().getSourcePath())) .findFirst() .orElseThrow(() -> new IllegalStateException("Cannot find a DMN model with resource=" + path)); registryContext.register(DMNModel.class, dmnModel); return dmnModel; }) .out(DMN_MODEL); }
public KieHelper addResource(Resource resource, ResourceType type) { if (resource.getSourcePath() == null && resource.getTargetPath() == null) { resource.setSourcePath(generateResourceName(type)); } return addResource(resource); }
@Test public void executeWithResource() { GetDMNModelCommand getDMNModelCommand = new GetDMNModelCommand(resource.getSourcePath()); assertThatThrownBy(() -> getDMNModelCommand.execute(registryContext)) .isInstanceOf(IllegalStateException.class) .hasMessage("There is no DMNRuntime available"); registryContext.register(DMNRuntime.class, dmnRuntime); DMNModel dmnModel = getDMNModelCommand.execute(registryContext); assertEquals(resource.getSourcePath(), dmnModel.getResource().getSourcePath()); } }
@Test public void executeWithResource() { SetDMNActiveModelCommand setDMNActiveModelCommand = new SetDMNActiveModelCommand(resource.getSourcePath()); assertThatThrownBy(() -> setDMNActiveModelCommand.execute(registryContext)) .isInstanceOf(IllegalStateException.class) .hasMessage("There is no DMNRuntime available"); registryContext.register(DMNRuntime.class, dmnRuntime); DMNModel dmnModel = setDMNActiveModelCommand.execute(registryContext); assertEquals(resource.getSourcePath(), dmnModel.getResource().getSourcePath()); } }
public byte[] getImageContent(String location, String name) { org.kie.api.definition.process.Process process = kieContainer.getKieBase(kieBaseName).getProcess(name); if (process != null) { String sourcePath = process.getResource().getSourcePath(); if (sourcePath != null) { String processDirectory = ""; if (sourcePath.indexOf("/") != -1) { processDirectory = sourcePath.substring(0, sourcePath.lastIndexOf("/") + 1); } byte[] data = seek(processDirectory, name, kieModule); if (data != null) { return data; } // set process directory as location in case the main search mechanism did not find the image location = processDirectory; } } byte[] data = seek(location, name, kieModule); if (data == null && kieModule.getKieDependencies() != null) { for (InternalKieModule depKieModule : kieModule.getKieDependencies().values()) { data = seek(location, name, depKieModule); if (data != null) { break; } } } return data; }
resource.setSourcePath(processResource.getSourcePath()); resource.setTargetPath(processResource.getTargetPath());
protected List<Resource> buildAndDumpBPMN2Process(String process) throws SAXException, IOException { KnowledgeBuilderConfiguration conf = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(); ((KnowledgeBuilderConfigurationImpl) conf).initSemanticModules(); ((KnowledgeBuilderConfigurationImpl) conf).addSemanticModule(new BPMNSemanticModule()); ((KnowledgeBuilderConfigurationImpl) conf).addSemanticModule(new BPMNDISemanticModule()); ((KnowledgeBuilderConfigurationImpl) conf).addSemanticModule(new BPMNExtensionsSemanticModule()); Resource classpathResource = ResourceFactory.newClassPathResource(process); // Dump and reread XmlProcessReader processReader = new XmlProcessReader(((KnowledgeBuilderConfigurationImpl) conf).getSemanticModules(), getClass().getClassLoader()); List<Process> processes = processReader.read(this.getClass().getResourceAsStream("/" + process)); List<Resource> resources = new ArrayList<Resource>(); for (Process p : processes) { RuleFlowProcess ruleFlowProcess = (RuleFlowProcess) p; String dumpedString = XmlBPMNProcessDumper.INSTANCE.dump(ruleFlowProcess); Resource resource = ResourceFactory.newReaderResource(new StringReader(dumpedString)); resource.setSourcePath(classpathResource.getSourcePath()); resource.setTargetPath(classpathResource.getTargetPath()); resources.add(resource); } return resources; }
kfs.delete(res.getSourcePath()); kfs.write(ResourceFactory.newFileResource(packageFile));