Skip to content

Commit

Permalink
Merge pull request apache#51 from rgdoliveira/sync_main
Browse files Browse the repository at this point in the history
Sync main branch with Apache main branch
  • Loading branch information
rgdoliveira authored Dec 2, 2024
2 parents 5b8fcc1 + 6385952 commit 78a414d
Show file tree
Hide file tree
Showing 14 changed files with 238 additions and 32 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ package-lock.json
/cypress*

.factorypath

# Apache RAT check excludes file
!.rat-excludes
100 changes: 100 additions & 0 deletions .rat-excludes
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# .rat-excludes
.rat-excludes
# DISCLAIMER-WIP
DISCLAIMER-WIP
# apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-common/src/main/resources/approval.bpmn
approval.bpmn
# apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/main/resources/META-INF/processSVG/approvals.svg
approvals.svg
# apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/resources/approval.bpmn
approval.bpmn
# apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/resources/org/acme/processes/MultipleTimerInstancesBoundaryTimerEvent.bpmn
MultipleTimerInstancesBoundaryTimerEvent.bpmn
# apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/resources/org/acme/processes/MultipleTimerInstancesTimerEvent.bpmn
MultipleTimerInstancesTimerEvent.bpmn
# apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/resources/org/acme/travels/async.bpmn
async.bpmn
# apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/resources/org/acme/travels/timer-on-task.bpmn
timer-on-task.bpmn
# apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/resources/org/acme/travels/timers.bpmn
timers.bpmn
# apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/resources/org/acme/travels/timersCycle.bpmn
timersCycle.bpmn
# apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-common/src/main/resources/TrafficViolation.dmn
TrafficViolation.dmn
# data-audit/data-audit-common/src/main/resources/META-INF/data-audit-job-query.graphqls
data-audit-job-query.graphqls
# data-audit/data-audit-common/src/main/resources/META-INF/data-audit-process-query.graphqls
data-audit-process-query.graphqls
# data-audit/data-audit-common/src/main/resources/META-INF/data-audit-types.graphqls
data-audit-types.graphqls
# data-audit/data-audit-common/src/main/resources/META-INF/data-audit-usertask-query.graphqls
data-audit-usertask-query.graphqls
# data-audit/kogito-addons-data-audit-jpa/kogito-addons-data-audit-jpa-common/src/main/resources/META-INF/data-audit-orm.xml
data-audit-orm.xml
# data-audit/kogito-addons-data-audit-jpa/kogito-addons-data-audit-jpa-common/src/main/resources/META-INF/services/org.kie.kogito.app.audit.spi.DataAuditStore
org.kie.kogito.app.audit.spi.DataAuditStore
# data-audit/kogito-addons-data-audit-jpa/kogito-addons-data-audit-jpa-common/src/main/resources/META-INF/services/org.kie.kogito.app.audit.spi.GraphQLSchemaQueryProvider
org.kie.kogito.app.audit.spi.GraphQLSchemaQueryProvider
# data-audit/kogito-addons-data-audit-springboot/src/test/resources/application.properties
application.properties
# data-index/data-index-graphql/src/main/resources/basic.schema.graphqls
basic.schema.graphqls
# data-index/data-index-service/data-index-service-common/src/main/resources/domain.schema.graphqls
domain.schema.graphqls
# data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-infinispan/integration-tests-process/src/main/resources/hello.bpmn
hello.bpmn
# data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-infinispan/integration-tests-process/src/main/resources/META-INF/processSVG/hello.svg
hello.svg
# data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-inmemory/integration-tests-process/src/main/resources/hello.bpmn
hello.bpmn
# data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-inmemory/integration-tests-process/src/main/resources/META-INF/processSVG/hello.svg
hello.svg
# data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/main/resources/hello.bpmn
hello.bpmn
# data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-jpa/integration-tests-process/src/main/resources/META-INF/processSVG/hello.svg
hello.svg
# data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-mongodb/integration-tests-process/src/main/resources/hello.bpmn
hello.bpmn
# data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-mongodb/integration-tests-process/src/main/resources/META-INF/processSVG/hello.svg
hello.svg
# data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-postgresql/integration-tests-process/src/main/resources/hello.bpmn
hello.bpmn
# data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-postgresql/integration-tests-process/src/main/resources/META-INF/processSVG/hello.svg
hello.svg
# data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-infinispan/integration-tests-process/src/main/resources/hello.bpmn
hello.bpmn
# data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/main/resources/hello.bpmn
hello.bpmn
# data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-jpa/integration-tests-process/src/main/resources/META-INF/processSVG/hello.svg
hello.svg
# data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-mongodb/integration-tests-process/src/main/resources/hello.bpmn
hello.bpmn
# data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-postgresql/integration-tests-process/src/main/resources/hello.bpmn
hello.bpmn
# explainability/explainability-service/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
org.mockito.plugins.MockMaker
# jitexecutor/jitexecutor-bpmn/src/test/resources/MultipleInvalidModel.bpmn2
MultipleInvalidModel.bpmn2
# jitexecutor/jitexecutor-bpmn/src/test/resources/MultipleProcess.bpmn2
MultipleProcess.bpmn2
# jitexecutor/jitexecutor-bpmn/src/test/resources/SingleInvalidModel.bpmn2
SingleInvalidModel.bpmn2
# jitexecutor/jitexecutor-bpmn/src/test/resources/SingleProcess.bpmn
SingleProcess.bpmn
# jitexecutor/jitexecutor-bpmn/src/test/resources/SingleProcess.bpmn2
SingleProcess.bpmn2
# jitexecutor/jitexecutor-bpmn/src/test/resources/SingleUnparsableModel.bpmn2
SingleUnparsableModel.bpmn2
# jitexecutor/jitexecutor-bpmn/src/test/resources/UnparsableModel.bpmn2
UnparsableModel.bpmn2
# jitexecutor/jitexecutor-bpmn/src/test/resources/ValidModel.bpmn
ValidModel.bpmn
# jitexecutor/jitexecutor-dmn/src/main/resources/META-INF/resources/bundle.js
bundle.js
# jobs-service/kogito-addons-jobs-service/kogito-addons-quarkus-jobs/src/test/resources/application.properties
application.properties
# jobs-service/kogito-addons-jobs-service/kogito-addons-quarkus-jobs-service-embedded/runtime/src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource
org.eclipse.microprofile.config.spi.ConfigSource
# trusty/trusty-service/trusty-service-common/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
org.mockito.plugins.MockMaker
53 changes: 53 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,56 @@
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.

-------------------------------------------------------------------------------
for jitexecutor/jitexecutor-dmn/src/main/resources/META-INF/resources/bundle.js

It is a combination of:

Copyright (c) 2017 Jed Watson.
Licensed under the MIT License (MIT)

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

and

(c) Sindre Sorhus
Licensed under the MIT License (MIT)

and

Copyright (c) Meta Platforms, Inc. and affiliates.
Licensed under the MIT License (MIT)

and

Copyright 2011 Gary Court. All rights reserved.
License available: https://github.com/garycourt/uri-js/blob/4.4.0/LICENSE

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY GARY COURT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of Gary Court.
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).

The Initial Developer of some parts of the framework, which are copied from, derived from, or
inspired by KIE (Knowledge Is Everthing) group, is Red Hat, Inc (https://www.redhat.com/).
inspired by KIE (Knowledge Is Everything) group, is Red Hat, Inc (https://www.redhat.com/).
Copyright Red Hat, Inc. and/or its affiliates.. All Rights Reserved.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,14 @@
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-maven-plugin</artifactId>
<version>${project.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generateModel</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,14 @@
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-maven-plugin</artifactId>
<version>${project.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generateModel</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,14 @@
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-maven-plugin</artifactId>
<version>${project.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generateModel</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,27 @@ public boolean isEnabled() {
public void jobStatusChange(JobDetails job) {
if (isEnabled()) {
try {
JobDataEvent event = JobDataEvent
.builder()
.source(url + RestApiConstants.JOBS_PATH)
.data(ScheduledJobAdapter.of(job))//this should support jobs crated with V1 and V2
.build();
JobDataEvent event = buildEvent(job);
LOGGER.debug("emit jobStatusChange, hasRequests: {}, eventId: {}, jobDetails: {}", emitter.hasRequests(), event.getId(), job);
String json = objectMapper.writeValueAsString(event);
emitter.send(decorate(ContextAwareMessage.of(json)
.withAck(() -> onAck(event.getId(), job))
.withNack(reason -> onNack(reason, job))));
.withNack(reason -> onNack(reason, job)), event));
} catch (Exception e) {
String msg = String.format("An unexpected error was produced while processing a Job status change for the job: %s", job);
LOGGER.error(msg, e);
}
}
}

protected JobDataEvent buildEvent(JobDetails job) {
return JobDataEvent
.builder()
.source(url + RestApiConstants.JOBS_PATH)
.data(ScheduledJobAdapter.of(job))//this should support jobs crated with V1 and V2
.build();
}

protected CompletionStage<Void> onAck(String eventId, JobDetails job) {
LOGGER.debug("Job Status change emitted successfully, eventId: {}, jobDetails: {}", eventId, job);
return CompletableFuture.completedFuture(null);
Expand All @@ -93,7 +97,7 @@ protected CompletionStage<Void> onNack(Throwable reason, JobDetails job) {
return CompletableFuture.completedFuture(null);
}

protected Message<String> decorate(Message<String> message) {
protected Message<String> decorate(Message<String> message, JobDataEvent event) {
return message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public abstract class AbstractJobStreamsTest<T extends AbstractJobStreams> {
protected static final String URL = "http://localhost:8180";
private static final String SERIALIZED_MESSAGE = "SERIALIZED_MESSAGE";

private static final String JOB_ID = "JOB_ID";
protected static final String JOB_ID = "JOB_ID";
private static final String CORRELATION_ID = "CORRELATION_ID";
private static final JobStatus STATUS = JobStatus.SCHEDULED;
private static final ZonedDateTime LAST_UPDATE = ZonedDateTime.parse("2022-08-03T18:00:15.001+01:00");
Expand Down Expand Up @@ -170,7 +170,7 @@ private JobDetails mockJobDetails() {

}

private void assertExpectedEvent(JobDataEvent event) {
protected void assertExpectedEvent(JobDataEvent event) {
assertThat(event.getId()).isNotNull();
assertThat(event.getType()).isEqualTo(JobDataEvent.JOB_EVENT_TYPE);
assertThat(event.getSource()).hasToString(URL + "/jobs");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.microprofile.reactive.messaging.Emitter;
import org.eclipse.microprofile.reactive.messaging.Message;
import org.eclipse.microprofile.reactive.messaging.OnOverflow;
import org.kie.kogito.jobs.service.events.JobDataEvent;
import org.kie.kogito.jobs.service.model.JobDetails;
import org.kie.kogito.jobs.service.stream.AbstractJobStreams;
import org.slf4j.Logger;
Expand All @@ -45,6 +46,7 @@ public class HttpJobStreams extends AbstractJobStreams {

public static final String PUBLISH_EVENTS_CONFIG_KEY = "kogito.jobs-service.http.job-status-change-events";
public static final String JOB_STATUS_CHANGE_EVENTS_HTTP = "kogito-job-service-job-status-events-http";
public static final String PARTITION_KEY_EXTENSION = "partitionkey";

private static final Logger LOGGER = LoggerFactory.getLogger(HttpJobStreams.class);

Expand All @@ -70,7 +72,16 @@ public void jobStatusChange(JobDetails job) {
}

@Override
protected Message<String> decorate(Message<String> message) {
protected JobDataEvent buildEvent(JobDetails job) {
JobDataEvent event = super.buildEvent(job);
// use the well-known extension https://github.com/cloudevents/spec/blob/main/cloudevents/extensions/partitioning.md
// to instruct potential http driven Brokers like, Knative Eventing Kafka Broker, to process accordingly.
event.addExtensionAttribute(PARTITION_KEY_EXTENSION, event.getData().getId());
return event;
}

@Override
protected Message<String> decorate(Message<String> message, JobDataEvent event) {
return message.addMetadata(OUTGOING_HTTP_METADATA.get());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Optional;

import org.eclipse.microprofile.reactive.messaging.Message;
import org.kie.kogito.jobs.service.events.JobDataEvent;
import org.kie.kogito.jobs.service.stream.AbstractJobStreamsTest;

import io.cloudevents.jackson.JsonFormat;
Expand All @@ -29,6 +30,7 @@
import jakarta.ws.rs.core.HttpHeaders;

import static org.assertj.core.api.Assertions.assertThat;
import static org.kie.kogito.jobs.service.messaging.http.stream.HttpJobStreams.PARTITION_KEY_EXTENSION;

class HttpJobStreamsTest extends AbstractJobStreamsTest<HttpJobStreams> {

Expand All @@ -44,4 +46,12 @@ protected void assertExpectedMetadata(Message<String> message) {
assertThat(metadata.getHeaders()).hasSize(1);
assertThat(metadata.getHeaders().get(HttpHeaders.CONTENT_TYPE)).containsExactlyInAnyOrder(JsonFormat.CONTENT_TYPE);
}

@Override
protected void assertExpectedEvent(JobDataEvent event) {
super.assertExpectedEvent(event);
assertThat(event.getExtension(PARTITION_KEY_EXTENSION))
.isNotNull()
.isEqualTo(JOB_ID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.reactive.messaging.Channel;
import org.eclipse.microprofile.reactive.messaging.Emitter;
import org.eclipse.microprofile.reactive.messaging.Message;
import org.eclipse.microprofile.reactive.messaging.OnOverflow;
import org.kie.kogito.jobs.service.events.JobDataEvent;
import org.kie.kogito.jobs.service.model.JobDetails;
import org.kie.kogito.jobs.service.stream.AbstractJobStreams;
import org.kie.kogito.jobs.service.stream.AvailableStreams;
Expand All @@ -32,6 +34,8 @@

import com.fasterxml.jackson.databind.ObjectMapper;

import io.smallrye.reactive.messaging.kafka.api.OutgoingKafkaRecordMetadata;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

Expand All @@ -54,4 +58,10 @@ public void jobStatusChange(JobDetails job) {
LOGGER.debug("jobStatusChange call received, enabled: {}, job: {}", enabled, job);
super.jobStatusChange(job);
}

@Override
protected Message<String> decorate(Message<String> message, JobDataEvent event) {
// regular kafka partitioning.
return message.addMetadata(OutgoingKafkaRecordMetadata.builder().withKey(event.getData().getId()).build());
}
}
Loading

0 comments on commit 78a414d

Please sign in to comment.