-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(QTDI-653): Add a sample connector #986
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
880cd53
feat(QTDI-653): add annotation LastGroup for AfterGroup
yyin-talend 6c1ceba
feat(QTDI-653): fix/changes proposal
d23e313
feat(TCOMP-2828): Add a sample connector to test @AfterGroup only once.
ypiel-talend 61bbc80
feat(TCOMP-2828): Fix missing resources.
ypiel-talend 8f2dd19
feat(TCOMP-2828): Fix API Test
acatoire 6c4795c
feat(QTDI-653): add junit to test
yyin-talend 2ef3df5
feat(QTDI-653): fix junit
yyin-talend bc8c79b
optimize some code
yyin-talend 25c940a
Add validation rule for aftergroup method
yyin-talend 82fb952
Revert "feat(QTDI-653): add junit to test"
yyin-talend 66a449b
Merge branch 'master' into yyin/QTDI-653_AddLastToAfterGroup
yyin-talend 3a48e70
fix merged conflicts.
yyin-talend 27f6f15
fix conflict
yyin-talend aeac195
Update ModelVisitor.java
yyin-talend 88d505a
remove empty line
yyin-talend ce55d0b
fix sonars
yyin-talend bb49901
add test coverage
yyin-talend 7082d8d
Merge branch 'master' into yyin/QTDI-653_AddLastToAfterGroup
yyin-talend 08ecec0
Add test case in ComponentBValidator
yyin-talend 401c7c2
Add junit for AutoChunkProcessor
yyin-talend 7922ac9
Add junit for auto chunk processor
yyin-talend 2c2d10d
Add info for failed junit
yyin-talend 9f67f80
fix filter action in junit
yyin-talend 5bf41df
fix filter in junit
yyin-talend bc3d4d4
Merge branch 'master' into yyin/QTDI-653_AddLastToAfterGroup
yyin-talend 42245e8
fix 3 small Sonars
yyin-talend 595a3a2
Add junit case
yyin-talend 9aac26b
Merge branch 'master' into yyin/QTDI-653_AddLastToAfterGroup
yyin-talend 1ea41fd
Merge branch 'master' into yyin/QTDI-653_AddLastToAfterGroup
ypiel-talend 2d4014f
feat(QTDI-653): Add a sample connector for @LastGRoup.
ypiel-talend dd05004
feat(QTDI-653): Fix artifact's name.
ypiel-talend 444d260
feat(QTDI-653): Fix processor.
ypiel-talend 979457e
Merge branch 'master' into ypiel/QTDI-653_AddASampleConnector
ypiel-talend 049200b
feat(QTDI-653): Add a readme on @LastGroup sample.
ypiel-talend 2903748
feat(QTDI-653): Immprove a readme of @LastGroup sample.
ypiel-talend File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
sample-parent/sample-features/aftergroup-lastgroup/README.md
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,19 @@ | ||
This is a TCK connector to validate thethe new `@LastGroup` annotation that is used in conjonctino with `@AfterGroup` within a processor. | ||
|
||
# How to build & deploy in a studio | ||
From the root of `component-runtime` workspace, run: | ||
```shell | ||
mvn clean sample -pl sample-parent/sample-features/aftergroup-lastgroup/ -am | ||
``` | ||
Then deploy it into a studio: | ||
```shell | ||
java -jar sample-parent/sample-features/aftergroup-lastgroup/target/lastGroup-<version>.car studio-deploy --location <path to a studio> -f | ||
``` | ||
|
||
# What is `@AfterGroup` / `@LastGroup` parameter for ? | ||
Now, methods with annotated with `@AfterGroup` in a `@Processor` connector, can have a boolean parameter annotated `@LastGroup`. If this parameter is defined in the `@AfterGroup` method, it will be set to `true` for the last group, and only for it. | ||
|
||
# LastGroupProcessor Sample explanation | ||
This sample is a simple `@Processor` that uses the `@AfterGroup` annotation with a `@LastGroup` parameter, [as you can see here](./src/main/java/org/talend/sdk/component/feature/lastgroup/processor/LastGroupProcessor.java#L41). | ||
|
||
This processor just buffers records, and, in the last call of `@AfterGroup` [method](./src/main/java/org/talend/sdk/component/feature/lastgroup/processor/LastGroupProcessor.java#L62), it will send all the records to the output. It also checks that the number of bufferized records is the same as the expected number set in its configuration [Config.java](./src/main/java/org/talend/sdk/component/feature/lastgroup/config/Config.java#L36). |
30 changes: 30 additions & 0 deletions
30
sample-parent/sample-features/aftergroup-lastgroup/pom.xml
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,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2006-2025 Talend Inc. - www.talend.com | ||
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. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.talend.sdk.component</groupId> | ||
<artifactId>sample-features</artifactId> | ||
<version>1.68.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<groupId>org.talend.sdk.component.sample.feature</groupId> | ||
<artifactId>lastGroup</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>Component Runtime :: Sample Feature @AfterGroup / @LastGroup</name> | ||
</project> |
38 changes: 38 additions & 0 deletions
38
...oup-lastgroup/src/main/java/org/talend/sdk/component/feature/lastgroup/config/Config.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,38 @@ | ||
/** | ||
* Copyright (C) 2006-2025 Talend Inc. - www.talend.com | ||
* | ||
* 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 org.talend.sdk.component.feature.lastgroup.config; | ||
|
||
import java.io.Serializable; | ||
|
||
import org.talend.sdk.component.api.configuration.Option; | ||
import org.talend.sdk.component.api.configuration.constraint.Min; | ||
import org.talend.sdk.component.api.configuration.constraint.Required; | ||
import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; | ||
import org.talend.sdk.component.api.meta.Documentation; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
@GridLayout(value = { @GridLayout.Row({ "expectedNumberOfInputRecords" }) }) | ||
public class Config implements Serializable { | ||
|
||
@Option | ||
@Min(0) | ||
@Required | ||
@Documentation("The expected number of records.") | ||
private int expectedNumberOfInputRecords; | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...roup-lastgroup/src/main/java/org/talend/sdk/component/feature/lastgroup/package-info.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,23 @@ | ||
/** | ||
* Copyright (C) 2006-2025 Talend Inc. - www.talend.com | ||
* | ||
* 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. | ||
*/ | ||
@Components( | ||
family = "sampleLastGroup", | ||
categories = "sample") | ||
@Icon(value = Icon.IconType.CUSTOM, custom = "icon") | ||
package org.talend.sdk.component.feature.lastgroup; | ||
|
||
import org.talend.sdk.component.api.component.Components; | ||
import org.talend.sdk.component.api.component.Icon; |
73 changes: 73 additions & 0 deletions
73
...rc/main/java/org/talend/sdk/component/feature/lastgroup/processor/LastGroupProcessor.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,73 @@ | ||
/** | ||
* Copyright (C) 2006-2025 Talend Inc. - www.talend.com | ||
* | ||
* 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 org.talend.sdk.component.feature.lastgroup.processor; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
import org.talend.sdk.component.api.component.Icon; | ||
import org.talend.sdk.component.api.component.Version; | ||
import org.talend.sdk.component.api.meta.Documentation; | ||
import org.talend.sdk.component.api.processor.AfterGroup; | ||
import org.talend.sdk.component.api.processor.ElementListener; | ||
import org.talend.sdk.component.api.processor.Input; | ||
import org.talend.sdk.component.api.processor.LastGroup; | ||
import org.talend.sdk.component.api.processor.Output; | ||
import org.talend.sdk.component.api.processor.OutputEmitter; | ||
import org.talend.sdk.component.api.processor.Processor; | ||
import org.talend.sdk.component.api.record.Record; | ||
import org.talend.sdk.component.feature.lastgroup.config.Config; | ||
|
||
@Version | ||
@Processor(name = "Processor") | ||
@Icon(value = Icon.IconType.CUSTOM, custom = "icon") | ||
@Documentation("AfterGroup / LastGroup sample processor connector.") | ||
public class LastGroupProcessor implements Serializable { | ||
|
||
private final Config config; | ||
|
||
private List<Record> buffer; | ||
Check failure on line 45 in sample-parent/sample-features/aftergroup-lastgroup/src/main/java/org/talend/sdk/component/feature/lastgroup/processor/LastGroupProcessor.java sonar-eks / Component Runtime Sonarqube Resultssample-parent/sample-features/aftergroup-lastgroup/src/main/java/org/talend/sdk/component/feature/lastgroup/processor/LastGroupProcessor.java#L45
|
||
|
||
public LastGroupProcessor(final Config config) { | ||
this.config = config; | ||
} | ||
|
||
@PostConstruct | ||
public void init() { | ||
buffer = new ArrayList<>(); | ||
} | ||
|
||
@ElementListener | ||
public void process(@Input final Record input) { | ||
buffer.add(input); | ||
} | ||
|
||
@AfterGroup | ||
public void afterGroup(@Output final OutputEmitter<Record> main, @LastGroup final boolean lastGroup) { | ||
if (lastGroup) { | ||
if (buffer.size() != config.getExpectedNumberOfInputRecords()) { | ||
throw new IllegalStateException("Expected " + | ||
config.getExpectedNumberOfInputRecords() + " records but got " + buffer.size()); | ||
} | ||
buffer.stream().forEach(main::emit); | ||
buffer.clear(); | ||
} | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
...ent/sample-features/aftergroup-lastgroup/src/main/resources/icons/dark/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
...nt/sample-features/aftergroup-lastgroup/src/main/resources/icons/light/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions
18
.../src/main/resources/org/talend/sdk/component/feature/lastgroup/config/Messages.properties
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,18 @@ | ||
# Copyright (C) 2006-2025 Talend Inc. - www.talend.com | ||
# | ||
# 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. | ||
# Here you can change all your configuration display names to use more explicit labels | ||
# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example | ||
|
||
Config.expectedNumberOfInputRecords._displayName = <expectedNumberOfInputRecords> | ||
Config.expectedNumberOfInputRecords._placeholder = |
17 changes: 17 additions & 0 deletions
17
...c/main/resources/org/talend/sdk/component/feature/lastgroup/processor/Messages.properties
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,17 @@ | ||
# Copyright (C) 2006-2025 Talend Inc. - www.talend.com | ||
# | ||
# 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. | ||
# Here you can change all your configuration display names to use more explicit labels | ||
# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example | ||
|
||
sampleLastGroup.Processor._displayName = Processor |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we set a real display name here?