forked from camunda-community-hub/kafka-connect-zeebe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make source variables filtering more powerful camunda-community-hub#80
- Loading branch information
Farid Ben Miled
committed
Jul 30, 2022
1 parent
6e1baa1
commit c7b1e17
Showing
6 changed files
with
100 additions
and
32 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
47 changes: 47 additions & 0 deletions
47
src/main/java/io/zeebe/kafka/connect/source/ZeebeSourceJobVariablesExtractor.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,47 @@ | ||
/* | ||
* Copyright © 2019 camunda services GmbH ([email protected]) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.zeebe.kafka.connect.source; | ||
|
||
import io.camunda.zeebe.client.api.response.ActivatedJob; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class ZeebeSourceJobVariablesExtractor { | ||
private final String jobVariables; | ||
|
||
public ZeebeSourceJobVariablesExtractor(ZeebeSourceConnectorConfig config) { | ||
jobVariables = config.getString(ZeebeSourceConnectorConfig.JOB_HEADER_VARIABLES_CONFIG); | ||
} | ||
|
||
public List<String> extract(ActivatedJob job) { | ||
final List<String> variableNames; | ||
final String jobVariableString = job.getCustomHeaders().get(jobVariables); | ||
if (jobVariableString == null) { | ||
variableNames = null; | ||
} else if (jobVariableString.contains(",")) { | ||
variableNames = | ||
Arrays.stream(jobVariableString.split(",", 0)) | ||
.map(String::trim) | ||
.collect(Collectors.toList()); | ||
} else { | ||
variableNames = new ArrayList<String>(1); | ||
variableNames.add(jobVariableString); | ||
} | ||
return variableNames; | ||
} | ||
} |
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