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

Feature/add action #3

Merged
merged 8 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions .github/workflows/backend-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ on:
push:
branches: [ "main" ]
paths: ['backend/**']
pull_request:
branches: [ "main" ]
paths: ['backend/**']

jobs:
build:
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/frontend-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
push:
branches: [ "main" ]
paths: ['frontend/**']
pull_request:
branches: [ "main" ]
paths: ['frontend/**']

jobs:
build:
Expand All @@ -21,10 +18,10 @@ jobs:
node-version: 18

- run: npm install --global @angular/cli
working-directory: frontend/projects/valtimo/spotler
- run: npm install
working-directory: frontend/projects/valtimo/spotler
working-directory: frontend/projects/valtimo/xential
- run: npm install --legacy-peer-deps
working-directory: frontend/projects/valtimo/xential
- run: npm run build
working-directory: frontend/projects/valtimo/spotler
working-directory: frontend/projects/valtimo/xential


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ out/**
# Package Files
######################
*.jar
!gradle-wrapper.jar
*.war
*.ear
*.db
Expand Down
2 changes: 1 addition & 1 deletion backend/app/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kotlinVersion=1.9.23
springVersion=3.2.5
springDependencyManagementVersion=1.1.4
valtimoVersion=12.2.0.RELEASE
valtimoVersion=12.0.0.RELEASE

pluginGroupId=com.ritense.valtimo
pluginArtifactId=xential
Expand Down
Binary file added backend/app/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion backend/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kotlinVersion=1.9.23
springVersion=3.2.5
springDependencyManagementVersion=1.1.4
valtimoVersion=12.2.0.RELEASE
valtimoVersion=12.0.0.RELEASE

pluginGroupId=com.ritense.valtimo
pluginArtifactId=xential
Expand Down
Binary file added backend/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion backend/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
22 changes: 13 additions & 9 deletions backend/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -83,7 +85,9 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -144,15 +148,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,11 +205,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
22 changes: 12 additions & 10 deletions backend/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
30 changes: 28 additions & 2 deletions backend/plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ plugins {
id "org.jetbrains.kotlin.plugin.spring" version "${kotlinVersion}"
id "org.jetbrains.kotlin.plugin.allopen" version "${kotlinVersion}"
id "com.avast.gradle.docker-compose" version "0.16.9"

id "org.openapi.generator" version "7.9.0"
}

repositories {
Expand All @@ -49,9 +51,17 @@ dependencies {
implementation "com.ritense.valtimo:value-resolver:${valtimoVersion}"

implementation "org.springframework.boot:spring-boot-starter-webflux:${springVersion}"
implementation "org.springframework.boot:spring-boot-starter-data-jpa:${springVersion}"

implementation "io.github.microutils:kotlin-logging:3.0.5"

implementation "jakarta.inject:jakarta.inject-api:2.0.1"
implementation "jakarta.persistence:jakarta.persistence-api:3.1.0"

implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("com.squareup.moshi:moshi:1.15.1")
implementation("com.squareup.moshi:moshi-kotlin:1.15.1")

// Testing
testImplementation "com.ritense.valtimo:document:${valtimoVersion}"
testImplementation "com.ritense.valtimo:local-resource:${valtimoVersion}"
Expand All @@ -74,6 +84,23 @@ dependencies {
testImplementation "org.jetbrains.kotlin:kotlin-test-junit5"
}

openApiGenerate {
inputSpec.set("$rootDir/plugin/src/main/resources/dcsg_xential.yaml")
generatorName.set("kotlin")
outputDir.set("${getLayout().getBuildDirectory().get()}/generated")
apiPackage.set("com.rotterdam.xential.api")
invokerPackage.set("com.rotterdam.xential.invoker")
modelPackage.set("com.rotterdam.xential.model")
}

sourceSets {
main {
java {
srcDir("${buildDir}/generated/src/main")
}
}
}

tasks.register("integrationTesting", Test) {
group = "verification"
useJUnitPlatform {
Expand All @@ -92,8 +119,7 @@ test {
useJUnitPlatform()
}

sourceCompatibility = 17
targetCompatibility = 17
java.sourceCompatibility = JavaVersion.VERSION_22

apply plugin: "com.avast.gradle.docker-compose"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,64 @@
package com.ritense.valtimo.xential.autoconfiguration

import com.ritense.plugin.service.PluginService
import com.ritense.resource.service.TemporaryResourceStorageService
import com.ritense.valtimo.contract.config.LiquibaseMasterChangeLogLocation
import com.ritense.valtimo.xential.plugin.XentialPluginFactory
import com.ritense.valtimo.xential.repository.XentialTokenRepository
import com.ritense.valtimo.xential.service.DocumentGenerationService
import com.rotterdam.xential.api.DefaultApi
import org.openapitools.client.infrastructure.ApiClient
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.AutoConfiguration
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.boot.autoconfigure.domain.EntityScan
import org.springframework.context.annotation.Bean
import org.springframework.data.jpa.repository.config.EnableJpaRepositories
import org.springframework.web.reactive.function.client.WebClient

@AutoConfiguration
@EnableJpaRepositories(basePackages = ["com.ritense.valtimo.xential.repository"])
@EntityScan("com.ritense.valtimo.xential.domain")
class XentialAutoConfiguration {

@Bean
@ConditionalOnMissingBean(XentialPluginFactory::class)
fun xentialPluginFactory(
pluginService: PluginService,
documentGenerationService: DocumentGenerationService
): XentialPluginFactory {
return XentialPluginFactory(pluginService)
return XentialPluginFactory(
pluginService,
documentGenerationService,
)
}

@Bean
@ConditionalOnMissingBean(name = ["xentialLiquibaseMasterChangeLogLocation"])
fun xentialLiquibaseMasterChangeLogLocation(): LiquibaseMasterChangeLogLocation {
return LiquibaseMasterChangeLogLocation("config/liquibase/xential-plugin-master.xml")
}

@Bean
@ConditionalOnMissingBean
fun defaultApi(): DefaultApi {
return DefaultApi()
}

@Bean
@ConditionalOnMissingBean
fun apiClient(
@Value("plugin.xential.baseurl")
baseUrl: String,
) = ApiClient(baseUrl)

@Bean
@ConditionalOnMissingBean
fun documentGenerationService(
defaultApi: DefaultApi,
xentialTokenRepository: XentialTokenRepository
) = DocumentGenerationService(
defaultApi,
xentialTokenRepository,
)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.ritense.valtimo.xential.domain

import java.util.UUID

data class GenerateDocumentProperties(
val templateId: UUID,
val fileFormat: FileFormat,
val documentId: String,
val templateData: Map<String, String>
)

enum class FileFormat {
WORD, PDF
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.ritense.valtimo.xential.domain

import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Id
import jakarta.persistence.Table
import java.net.URI
import java.util.UUID

@Entity
@Table(name = "xential_tokens")
data class XentialToken (
@Id
@Column(name = "token", nullable = false, updatable = false)
val token: UUID,
@Column(name = "process_id", nullable = false, updatable = false)
val processId: UUID,
@Column(name = "resume_url", nullable = true, updatable = false)
val resumeUrl: URI?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,46 @@
package com.ritense.valtimo.xential.plugin

import com.ritense.plugin.annotation.Plugin
import com.ritense.plugin.annotation.PluginAction
import com.ritense.plugin.annotation.PluginProperty
import com.ritense.processlink.domain.ActivityTypeWithEventName
import com.ritense.valtimo.xential.domain.GenerateDocumentProperties
import com.ritense.valtimo.xential.domain.XentialToken
import com.ritense.valtimo.xential.repository.XentialTokenRepository
import com.ritense.valtimo.xential.service.DocumentGenerationService
import com.rotterdam.xential.api.DefaultApi
import com.rotterdam.xential.model.Sjabloondata
import org.camunda.bpm.engine.delegate.DelegateExecution
import java.util.UUID

@Plugin(
key = "xential",
title = "Xential Plugin",
description = ""
)
class XentialPlugin(
val documentGenerationService: DocumentGenerationService
) {

@PluginProperty(key = "clientId", secret = false)
private lateinit var clientId: String

@PluginProperty(key = "clientPassword", secret = true)
private lateinit var clientPassword: String

@PluginAction(
key = "generate-document",
title = "Generate document",
description = "Generate a document using xential.",
activityTypes = [ActivityTypeWithEventName.SERVICE_TASK_START]
)
fun generateDocument(execution: DelegateExecution, generateDocumentProperties: GenerateDocumentProperties) {
documentGenerationService.generateDocument(
UUID.fromString(execution.processInstanceId),
generateDocumentProperties,
clientId,
clientPassword
)
}

}
Loading