Skip to content

Commit 1a46d14

Browse files
authored
feat: add save method on Dataplane (#20)
1 parent 682743f commit 1a46d14

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ build/
66
.kotlin
77

88
### IntelliJ IDEA ###
9-
.idea/modules.xml
10-
.idea/jarRepositories.xml
11-
.idea/compiler.xml
12-
.idea/libraries/
9+
.idea/
1310
*.iws
1411
*.iml
1512
*.ipr

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
}
88

99
group = "org.eclipse.dataplane-core"
10-
version = "0.0.3-SNAPSHOT"
10+
version = "0.0.4-SNAPSHOT"
1111

1212
repositories {
1313
mavenCentral()

src/main/java/org/eclipse/dataplane/Dataplane.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ public Result<DataFlow> getById(String dataFlowId) {
8080
return store.findById(dataFlowId);
8181
}
8282

83+
public Result<Void> save(DataFlow dataFlow) {
84+
return store.save(dataFlow);
85+
}
86+
8387
public Result<DataFlowStatusResponseMessage> status(String dataFlowId) {
8488
return store.findById(dataFlowId)
8589
.map(f -> new DataFlowStatusResponseMessage(f.getId(), f.getState().name()));
@@ -113,7 +117,7 @@ public Result<DataFlowResponseMessage> prepare(DataFlowPrepareMessage message) {
113117
response = new DataFlowResponseMessage(id, null, initialDataFlow.getState().name(), null);
114118
}
115119

116-
return store.save(dataFlow).map(it -> response);
120+
return save(dataFlow).map(it -> response);
117121
});
118122
}
119123

@@ -144,7 +148,7 @@ public Result<DataFlowResponseMessage> start(DataFlowStartMessage message) {
144148
} else {
145149
response = new DataFlowResponseMessage(id, null, dataFlow.getState().name(), null);
146150
}
147-
return store.save(dataFlow).map(it -> response);
151+
return save(dataFlow).map(it -> response);
148152
});
149153
}
150154

@@ -191,7 +195,7 @@ public Result<Void> notifyCompleted(String dataFlowId) {
191195
var successful = response.statusCode() >= 200 && response.statusCode() < 300;
192196
if (successful) {
193197
dataFlow.transitionToCompleted();
194-
return store.save(dataFlow);
198+
return save(dataFlow);
195199
}
196200

197201
return Result.failure(new DataFlowNotifyCompletedFailed(response));
@@ -220,7 +224,7 @@ public Result<Void> notifyErrored(String dataFlowId, Throwable throwable) {
220224
var successful = response.statusCode() >= 200 && response.statusCode() < 300;
221225
if (successful) {
222226
dataFlow.transitionToTerminated(throwable.getMessage());
223-
return store.save(dataFlow);
227+
return save(dataFlow);
224228
}
225229

226230
return Result.failure(new DataFlowNotifyErroredFailed(response));
@@ -236,7 +240,7 @@ public Result<Void> started(String flowId, DataFlowStartedNotificationMessage st
236240
.compose(onStarted::action)
237241
.compose(dataFlow -> {
238242
dataFlow.transitionToStarted();
239-
return store.save(dataFlow);
243+
return save(dataFlow);
240244
});
241245
}
242246

@@ -250,7 +254,7 @@ public Result<Void> completed(String flowId) {
250254
return store.findById(flowId).compose(onCompleted::action)
251255
.compose(dataFlow -> {
252256
dataFlow.transitionToCompleted();
253-
return store.save(dataFlow);
257+
return save(dataFlow);
254258
});
255259
}
256260

0 commit comments

Comments
 (0)