16. Flow-Dienst
Der Zugriff erfolgt über client.flow(). Sie rufen die visuelle Automatisierungsansicht von PlantPulse auf, den Flow und die darin enthaltenen Knoten (Flow-Node). Dies ist ein neuer Dienst in V5.
Hinweis: Der Flow-Dienst in V5 ist schreibgeschützt. Die Erstellung, Änderung und Ausführung von Flows erfolgt über die UI oder die dedizierte API der Flow-Engine. Detaillierte Informationen zur Funktionsweise der Flow-Engine finden Sie in der Dokumentation zur Flow-Engine.
16.1 Methodenübersicht
| Methode | Rückgabetyp | HTTP | Endpunkt |
|---|---|---|---|
get(flow_id) | FlowResponseV5 oder null | GET | /api/v5/flow/{id} |
list() | List<FlowResponseV5> (inkl. Statistik) | GET | /api/v5/flow |
listNodes(flow_id) | List<FlowNodeResponseV5> | GET | /api/v5/flow/{id}/node |
16.2 FlowResponseV5 DTO
| Feld | Typ | Beschreibung |
|---|---|---|
flow_id | String | Flow-ID (PK) |
flow_name | String | Flow-Name |
description | String | Beschreibung |
enabled | boolean | Aktiviert |
is_root | boolean | Root-Flow |
debug_mode | boolean | Debug-Modus |
insert_user / insert_date | String | Ersteller/Zeitpunkt |
update_user / update_date | String | Bearbeiter/Zeitpunkt |
node_count | int | Anzahl der Knoten (Statistik) |
trigger_count | int | Anzahl der Trigger (Statistik) |
error_count | long | Kumulierte Fehleranzahl (Statistik) |
16.3 FlowNodeResponseV5 DTO
| Feld | Typ | Beschreibung |
|---|---|---|
flow_node_id | String | Knoten-ID (PK) |
flow_id | String | Zugehöriger Flow |
type | String | Knotentyp (trigger, function, action usw.) |
name | String | Knotenname |
configuration_json | String | Knotenkonfiguration als JSON-String |
position_x / position_y | int | Canvas-Position |
debug_mode | boolean | Knotenspezifischer Debug |
16.4 Verwendungsbeispiel
Flow-Liste (inkl. Statistik)
import java.util.List;
import plantpulse.api.v5.dto.response.FlowResponseV5;
List<FlowResponseV5> flows = client.flow().list();
for (FlowResponseV5 f : flows) {
System.out.printf("[%s] %s — 노드 %d개, 트리거 %d개, 에러 %d건%n",
f.isEnabled() ? "ON" : "OFF",
f.getFlow_name(),
f.getNode_count(),
f.getTrigger_count(),
f.getError_count());
}
Beispielausgabe:
[ON] 생산 카운트 집계 — 노드 8개, 트리거 1개, 에러 0건
[ON] 알람 알림 라우팅 — 노드 12개, 트리거 3개, 에러 2건
[OFF] (실험) ML 예측 — 노드 5개, 트리거 0개, 에러 0건
Einzelnen Flow abrufen
FlowResponseV5 flow = client.flow().get("flow_001");
if (flow != null && !flow.isEnabled()) {
System.err.println("Flow가 비활성 상태: " + flow.getFlow_name());
}
Knotenliste eines Flows
import plantpulse.api.v5.dto.response.FlowNodeResponseV5;
String flowId = "flow_001";
List<FlowNodeResponseV5> nodes = client.flow().listNodes(flowId);
for (FlowNodeResponseV5 n : nodes) {
System.out.printf(" [%s] %s (%s)%n",
n.getType(), n.getName(), n.getFlow_node_id());
}
Fehlerhafte Flows identifizieren
import java.util.stream.Collectors;
List<FlowResponseV5> errored = client.flow().list().stream()
.filter(f -> f.getError_count() > 0)
.collect(Collectors.toList());
System.out.println("에러 발생 Flow: " + errored.size() + "개");
for (FlowResponseV5 f : errored) {
System.out.printf(" %s: %d건%n", f.getFlow_name(), f.getError_count());
}
16.5 Nutzungsszenarien
Szenario — Flow-Health-Dashboard
while (running) {
List<FlowResponseV5> all = client.flow().list();
long total = all.size();
long enabled = all.stream().filter(FlowResponseV5::isEnabled).count();
long errored = all.stream().filter(f -> f.getError_count() > 0).count();
long triggers = all.stream().mapToInt(FlowResponseV5::getTrigger_count).sum();
updateUI(total, enabled, errored, triggers);
Thread.sleep(5_000);
}
Nächste Schritte
- Leitfaden zur Flow-Engine — Funktionsweise von Flows (separates Dokument)
- Integriertes Beispiel — Beispiel zur Integration von Flow und API