Skip to content
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

[incubator-kie-issues-576] Data Audit apps for kogito #1905

Merged
merged 47 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
13437bf
[incubator-kie-issues-576] Data Audit app for kogito
elguardian Oct 25, 2023
6045e3a
[incubator-kie-issues-576] add tests for data audit
elguardian Oct 27, 2023
8dff491
added data audit context to local
elguardian Oct 27, 2023
be247eb
make proxy independent of runtime
elguardian Oct 27, 2023
d4a0923
tweak events
elguardian Oct 30, 2023
352fa6a
fix deletion of spring boot subsystem
elguardian Oct 30, 2023
414d51a
fix logic in data audit
elguardian Oct 31, 2023
b9f6933
fix tests
elguardian Nov 2, 2023
7322597
fix json objects in variable values
elguardian Nov 2, 2023
5668302
added pagination
elguardian Nov 2, 2023
d264b2f
fix roles in process state query
elguardian Nov 2, 2023
82d288e
add mechanism extension
elguardian Nov 2, 2023
10dfdde
fix for assignments
elguardian Nov 2, 2023
bc04592
fix deadlines notifications
elguardian Nov 2, 2023
1547279
fix spring boot test
elguardian Nov 3, 2023
9f38056
add queries for processes
elguardian Nov 3, 2023
6c34080
repacle anonymous classe by reusable classes
elguardian Nov 3, 2023
b505624
job log changed to match data index
elguardian Nov 6, 2023
51a0e86
add microprofile to subsystem
elguardian Nov 6, 2023
5b90d92
make context factory independent
elguardian Nov 6, 2023
6e4b0af
fix names
elguardian Nov 6, 2023
e8dcb41
readme.md
elguardian Nov 6, 2023
a4849fe
fix compilation problems
elguardian Nov 6, 2023
eee46b5
fix artifact id and added new query
elguardian Nov 7, 2023
6d1616d
fix master pom adding data audit module
elguardian Nov 8, 2023
93cecff
fix names in the projects to fit naming conventions
elguardian Nov 9, 2023
f8029fd
formatting pom.xml
elguardian Nov 10, 2023
23868d7
setting configuration
elguardian Nov 10, 2023
973029b
fix service
elguardian Nov 10, 2023
caa5281
fix jdbc driver dependencies
elguardian Nov 14, 2023
40dab61
fix jdbc driver dependencies
elguardian Nov 14, 2023
e108817
added jpa container service
elguardian Nov 14, 2023
6922fc1
Fix naming conventions for tables
elguardian Nov 15, 2023
0f0c034
fix sla
elguardian Nov 15, 2023
4fe323b
fix configuration. simplification
elguardian Nov 15, 2023
e90da08
fix service
elguardian Nov 16, 2023
cf382e9
fix for orm
elguardian Nov 16, 2023
6399101
fix classloader
elguardian Nov 16, 2023
cf7ad2e
clean unnecessary fields
elguardian Nov 17, 2023
0149ee3
fix readme.md
elguardian Nov 17, 2023
5a71e70
fix transaction error in springboot
elguardian Nov 20, 2023
0fe785a
fix try for transactions wthout transaction manager provider
elguardian Nov 20, 2023
0b177ac
fix
elguardian Dec 14, 2023
38f088a
fix query
elguardian Nov 22, 2023
d6bcde7
fix plural queries
elguardian Nov 22, 2023
24335a1
Quarkus 3 upgrade fixes:
pefernan Dec 19, 2023
d157e3a
- fix log
pefernan Dec 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions data-audit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/target/
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache


ObjectStore/
PutObjectStoreDirHere/

# Created by https://www.gitignore.io/api/git,java,maven,eclipse,windows

### Eclipse ###

.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# CDT- autotools
.autotools

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/

# Annotation Processing
.apt_generated/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet

### Eclipse Patch ###
# Eclipse Core
.project

# JDT-specific (Eclipse Java Development Tools)
.classpath

# Annotation Processing
.apt_generated

.sts4-cache/

### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig

# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar

### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk


# End of https://www.gitignore.io/api/git,java,maven,eclipse,windows
84 changes: 84 additions & 0 deletions data-audit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
### Data Audit subsystem

This is the implementation of the Kogito Audit subystem. The subsystem allows to store events from issued by
- process engine
- user task
- job service

Main features are:

- runs as colocated services with quarkus and springboot
- module to write your own subsystem
- graphql modules to query data
- extension points to develop new storage easily
- extension points to develop new queries extending graphql definitions

## Design of the Data Audit

The system contains several modules and common modules to redistribute responsabilities.

![Data Audit Architecture](img/design.png "Data Audit Architecture")

Data Audit Common: Provides the common framework to create implementations.
Data Audit «Quarkus»: Provides the wiring to use Data Audit with Quarkus as colocated service (deployment)
Data Audit «SpringBoot»: Provides the wiring to use Data Audit with SpringBoot as colocated service (deployment)

Now we have and implementation examples

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sentence appears truncated


Data Audit JPA Common: Provides the common exension not depending on the runtime
Data Audit JPA «Quarkus»: Provides the wiring between the specific implementation and Quarkus System
Data Audit JPA «SpringBoot»: Provides the wiring between the specific implementation and Springboot colocated system


## Queries

The way to retrieve information from the data audit is using GraphQL. This way we can abstract how the information is retrieved and allow different needs depending on the user.

## JPA implementation

The jpa implementation allows you to store those events to be stored in a database.

## Extension Points

There are two different extensions. Those who belong to the runtime to wire things and those which does not depends on the runtime

Extension points depending on the runtime is:
org.kie.kogito.app.audit.spi.DataAuditContextFactory: this allows creating the context needed by a particular implementation.

Extension points not depending on the runtime:
org.kie.kogito.app.audit.spi.DataAuditStore: This is responsible to store the data in certain way
org.kie.kogito.app.audit.spi.GraphQLSchemaQuery<T>: This is responsible to execute a GraphQL query
org.kie.kogito.app.audit.spi.GraphQLSchemaQueryProvider: this allow the subsystem to identify additional queries provided by the end user
pefernan marked this conversation as resolved.
Show resolved Hide resolved


## How to use in with Quarkus/Springboot

You need to add two different dependencies to your project.

<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-data-audit-<runtime></artifactId>
<version>${version}</version>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-data-audit-jpa-<runtime></artifactId>
<version>${version}</version>
</dependency>




The first dependency is related how to you want to deploy it. In this case as collocated/embedded service
The second dependency is which implementation you want to use.

Each implementation might require additional dependencies. In our case for using JPA implementation we might require driver

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```xml

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-h2</artifactId>
</dependency>

No additional configuration is requires besides the default datasource use by the application already.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
No additional configuration is requires besides the default datasource use by the application already.
No additional configuration is required besides the default datasource use by the application already.


40 changes: 40 additions & 0 deletions data-audit/data-audit-common-service/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<artifactId>data-audit</artifactId>
<groupId>org.kie.kogito</groupId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>data-audit-common-service</artifactId>

<name>Kogito Apps :: Data Audit :: Service Common</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-events-core</artifactId>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>jobs-service-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</dependency>
</dependencies>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.kie.kogito.app.audit.json;

import java.io.IOException;
import java.time.OffsetDateTime;

import org.kie.kogito.event.job.JobInstanceDataEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;

public class JsonJobDataEventDeserializer extends StdDeserializer<JobInstanceDataEvent> {

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

private static final long serialVersionUID = 6152014726577574241L;

public JsonJobDataEventDeserializer() {
this(null);
}

public JsonJobDataEventDeserializer(Class<?> vc) {
super(vc);
}

@Override
public JobInstanceDataEvent deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
JsonNode node = jp.getCodec().readTree(jp);
LOGGER.debug("Deserialize process instance data event: {}", node);

JobInstanceDataEvent event = new JobInstanceDataEvent(
node.has("type") ? node.get("type").asText() : null,
node.has("source") ? node.get("source").asText() : null,
node.has("data") ? node.get("data").binaryValue() : null,
node.has("kogitoprocinstanceid") ? node.get("kogitoprocinstanceid").asText() : null,
node.has("kogitorootprociid") ? node.get("kogitorootprociid").asText() : null,
node.has("kogitoprocid") ? node.get("kogitoprocid").asText() : null,
node.has("kogitorootprocid") ? node.get("kogitorootprocid").asText() : null,
node.has("kogitoidentity") ? node.get("kogitoidentity").asText() : null);

event.setId(node.has("id") ? node.get("id").asText() : null);
event.setKogitoIdentity(node.has("kogitoidentity") ? node.get("kogitoidentity").asText() : null);
event.setTime(node.has("time") ? jp.getCodec().treeToValue(node.get("time"), OffsetDateTime.class) : null);

return event;
}
}
Loading
Loading