This repository has been archived by the owner on Nov 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Integration CRD: Missing multiple route support
Fixes: #733
- Loading branch information
1 parent
8227241
commit 5f0b26f
Showing
11 changed files
with
322 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
api/src/test/resources/io/kaoto/backend/api/resource/integration-multiroute.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apiVersion: camel.apache.org/v1 | ||
kind: Integration | ||
metadata: | ||
name: multiroute-integration-example | ||
spec: | ||
flows: | ||
- route: | ||
id: timer-amq-log | ||
from: | ||
uri: timer:tick | ||
parameters: | ||
period: '5000' | ||
steps: | ||
- to: | ||
uri: activemq:queue:myQueue | ||
- to: | ||
uri: log:save | ||
- route: | ||
id: timer-amq-log2 | ||
from: | ||
uri: timer:tick2 | ||
parameters: | ||
period: '5000' | ||
steps: | ||
- to: | ||
uri: activemq:queue:myQueue2 | ||
- to: | ||
uri: log:save2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...t/src/main/java/io/kaoto/backend/api/service/step/parser/camelroute/FlowDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.kaoto.backend.api.service.step.parser.camelroute; | ||
|
||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.core.JacksonException; | ||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
|
||
import io.kaoto.backend.model.deployment.kamelet.Flow; | ||
import io.kaoto.backend.model.deployment.kamelet.step.From; | ||
import io.kaoto.backend.model.deployment.rest.Rest; | ||
|
||
public class FlowDeserializer extends StdDeserializer<Flow> { | ||
protected FlowDeserializer() { | ||
this(null); | ||
} | ||
|
||
protected FlowDeserializer(Class<?> vc) { | ||
super(vc); | ||
} | ||
|
||
@Override | ||
public Flow deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JacksonException { | ||
Flow flow = new Flow(); | ||
var root = p.getCodec().readTree(p); | ||
if (((ObjectNode)root).has("route")) { | ||
var route = ((ObjectNode)root).get("route"); | ||
if (route.has("id")) { | ||
flow.setId(route.get("id").asText()); | ||
} | ||
if (route.has("route-configuration-id")) { | ||
flow.setRouteConfigurationId(route.get("route-configuration-id").asText()); | ||
} | ||
if (route.has("description")) { | ||
flow.setDescription(route.get("description").asText()); | ||
} | ||
if (route.has("from")) { | ||
var from = ctxt.readTreeAsValue(route.get("from"), From.class); | ||
flow.setFrom(from); | ||
} | ||
} | ||
if (((ObjectNode)root).has("from")) { | ||
var from = ctxt.readTreeAsValue((JsonNode)root.get("from"), From.class); | ||
flow.setFrom(from); | ||
} | ||
if (((ObjectNode)root).has("rest")) { | ||
var rest = ctxt.readTreeAsValue((JsonNode)root.get("rest"), Rest.class); | ||
flow.setRest(rest); | ||
} | ||
return flow; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.