use of io.automatiko.engine.services.io.InternalResource in project automatiko-engine by automatiko-io.
the class DecisionCodegen method ofPath.
public static DecisionCodegen ofPath(List<String> dependencies, Path... paths) throws IOException {
List<DMNResource> resources = new ArrayList<>();
for (String dependency : dependencies) {
List<Resource> dmnresources = new ArrayList<>();
File file = new File(dependency);
if (file.isDirectory()) {
Path srcPath = file.toPath();
if (Files.exists(srcPath)) {
try (Stream<Path> filesStream = Files.walk(srcPath)) {
List<File> files = filesStream.filter(p -> p.toString().endsWith(".dmn")).map(Path::toFile).collect(Collectors.toList());
resources.addAll(parseFiles(srcPath, files));
}
}
} else {
try (ZipFile zipFile = new ZipFile(dependency)) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (entry.getName().endsWith(".dmn")) {
InternalResource resource = new ByteArrayResource(readBytesFromInputStream(zipFile.getInputStream(entry)));
resource.setSourcePath(entry.getName());
dmnresources.add(resource);
}
}
} catch (IOException e) {
}
resources.addAll(parseDecisions(Paths.get(dependency), dmnresources));
}
}
for (Path path : paths) {
Path srcPath = Paths.get(path.toString());
if (Files.exists(srcPath)) {
try (Stream<Path> filesStream = Files.walk(srcPath)) {
List<File> files = filesStream.filter(p -> p.toString().endsWith(".dmn")).map(Path::toFile).collect(Collectors.toList());
resources.addAll(parseFiles(srcPath, files));
}
}
}
return ofDecisions(resources);
}
use of io.automatiko.engine.services.io.InternalResource in project automatiko-engine by automatiko-io.
the class DecisionCodegen method ofJar.
public static DecisionCodegen ofJar(List<String> dependencies, Path... jarPaths) throws IOException {
List<DMNResource> dmnResources = new ArrayList<>();
for (Path jarPath : jarPaths) {
List<Resource> resources = new ArrayList<>();
try (ZipFile zipFile = new ZipFile(jarPath.toFile())) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (entry.getName().endsWith(".dmn")) {
InternalResource resource = new ByteArrayResource(readBytesFromInputStream(zipFile.getInputStream(entry)));
resource.setSourcePath(entry.getName());
resources.add(resource);
}
}
}
dmnResources.addAll(parseDecisions(jarPath, resources));
}
for (String dependency : dependencies) {
List<Resource> resources = new ArrayList<>();
try (ZipFile zipFile = new ZipFile(dependency)) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (entry.getName().endsWith(".dmn")) {
InternalResource resource = new ByteArrayResource(readBytesFromInputStream(zipFile.getInputStream(entry)));
resource.setSourcePath(entry.getName());
resources.add(resource);
}
}
} catch (IOException e) {
}
dmnResources.addAll(parseDecisions(Paths.get(dependency), resources));
}
return ofDecisions(dmnResources);
}
use of io.automatiko.engine.services.io.InternalResource in project automatiko-engine by automatiko-io.
the class ProcessCodegen method ofPath.
public static ProcessCodegen ofPath(List<String> dependencies, Path... paths) throws IOException {
List<Process> allProcesses = new ArrayList<>();
for (String dependency : dependencies) {
File file = new File(dependency);
if (file.isDirectory()) {
try (Stream<Path> filesStream = Files.walk(file.toPath())) {
List<File> files = filesStream.filter(p -> SUPPORTED_BPMN_EXTENSIONS.stream().anyMatch(p.toString()::endsWith) || SUPPORTED_SW_EXTENSIONS.keySet().stream().anyMatch(p.toString()::endsWith)).map(Path::toFile).collect(Collectors.toList());
allProcesses.addAll(parseProcesses(files, true));
}
} else {
try (ZipFile zipFile = new ZipFile(dependency)) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
ResourceType resourceType = determineResourceType(entry.getName());
if (SUPPORTED_BPMN_EXTENSIONS.stream().anyMatch(entry.getName()::endsWith)) {
InternalResource resource = new ByteArrayResource(readBytesFromInputStream(zipFile.getInputStream(entry)));
resource.setResourceType(resourceType);
resource.setSourcePath(entry.getName());
allProcesses.addAll(parseProcessFile(resource));
}
}
} catch (IOException e) {
}
}
}
for (Path path : paths) {
Path srcPath = Paths.get(path.toString());
try (Stream<Path> filesStream = Files.walk(srcPath)) {
List<File> files = filesStream.filter(p -> SUPPORTED_BPMN_EXTENSIONS.stream().anyMatch(p.toString()::endsWith) || SUPPORTED_SW_EXTENSIONS.keySet().stream().anyMatch(p.toString()::endsWith)).map(Path::toFile).collect(Collectors.toList());
allProcesses.addAll(parseProcesses(files, false));
}
}
return ofProcesses(allProcesses);
}
use of io.automatiko.engine.services.io.InternalResource in project automatiko-engine by automatiko-io.
the class ProcessCodegen method ofJar.
public static ProcessCodegen ofJar(List<String> dependencies, Path... jarPaths) {
List<Process> processes = new ArrayList<>();
for (Path jarPath : jarPaths) {
try (ZipFile zipFile = new ZipFile(jarPath.toFile())) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
ResourceType resourceType = determineResourceType(entry.getName());
if (SUPPORTED_BPMN_EXTENSIONS.stream().anyMatch(entry.getName()::endsWith)) {
InternalResource resource = new ByteArrayResource(readBytesFromInputStream(zipFile.getInputStream(entry)));
resource.setResourceType(resourceType);
resource.setSourcePath(entry.getName());
processes.addAll(parseProcessFile(resource));
}
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
for (String dependency : dependencies) {
try (ZipFile zipFile = new ZipFile(dependency)) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
ResourceType resourceType = determineResourceType(entry.getName());
if (SUPPORTED_BPMN_EXTENSIONS.stream().anyMatch(entry.getName()::endsWith)) {
InternalResource resource = new ByteArrayResource(readBytesFromInputStream(zipFile.getInputStream(entry)));
resource.setResourceType(resourceType);
resource.setSourcePath(entry.getName());
processes.addAll(parseProcessFile(resource));
}
}
} catch (IOException e) {
}
}
return ofProcesses(processes);
}
Aggregations