From 452940176aa64c720e5bb8a13f49af41aaccd510 Mon Sep 17 00:00:00 2001 From: Tim Holzke Date: Fri, 11 Oct 2024 13:20:52 +0200 Subject: [PATCH 1/2] fix(#1065): added attribute length limit to update events --- .../src/main/kotlin/VariableSerializer.kt | 1 - .../polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt | 3 ++- .../holunda/polyflow/view/jpa/JpaPolyflowViewTaskService.kt | 2 +- .../kotlin/io/holunda/polyflow/view/jpa/data/ConverterExt.kt | 5 +++-- .../kotlin/io/holunda/polyflow/view/jpa/task/ConverterExt.kt | 5 +++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/integration/common/variable-serializer/src/main/kotlin/VariableSerializer.kt b/integration/common/variable-serializer/src/main/kotlin/VariableSerializer.kt index edbaf5619..a1b4bdc25 100644 --- a/integration/common/variable-serializer/src/main/kotlin/VariableSerializer.kt +++ b/integration/common/variable-serializer/src/main/kotlin/VariableSerializer.kt @@ -78,7 +78,6 @@ internal fun Pair.toJsonPathWithValue( // trim strings to the value length limit if provided if(valueLengthLimit != null && value is String && value.length > valueLengthLimit) { - // TODO: logging value = value.substring(0 until valueLengthLimit) } diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt index 83b4955e2..2b8db49af 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewDataEntryService.kt @@ -145,7 +145,8 @@ class JpaPolyflowViewDataEntryService( revisionValue = RevisionValue.fromMetaData(metaData), oldEntry = savedEntity, limit = polyflowJpaViewProperties.payloadAttributeLevelLimit, - filters = polyflowJpaViewProperties.dataEntryJsonPathFilters() + filters = polyflowJpaViewProperties.dataEntryJsonPathFilters(), + payLoadAttributeColumnLength = polyflowJpaViewProperties.payloadAttributeColumnLength ) ).apply { logger.debug { "JPA-VIEW-42: Business data entry updated $event" } diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewTaskService.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewTaskService.kt index 116bd50e1..7a2e61179 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewTaskService.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/JpaPolyflowViewTaskService.kt @@ -418,7 +418,7 @@ class JpaPolyflowViewTaskService( logger.warn { "Cannot update task '${event.id}' because it does not exist in the database" } } .ifPresent { entity -> - entity.update(event, objectMapper, polyflowJpaViewProperties.payloadAttributeLevelLimit, polyflowJpaViewProperties.taskJsonPathFilters()) + entity.update(event, objectMapper, polyflowJpaViewProperties.payloadAttributeLevelLimit, polyflowJpaViewProperties.taskJsonPathFilters(), polyflowJpaViewProperties.payloadAttributeColumnLength) val updated = taskRepository.save(entity) emitTaskUpdate(updated) } diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExt.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExt.kt index 14c072942..228f6d1a1 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExt.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/ConverterExt.kt @@ -111,12 +111,13 @@ fun DataEntryUpdatedEvent.toEntity( revisionValue: RevisionValue, oldEntry: DataEntryEntity?, limit: Int, - filters: List> + filters: List>, + payLoadAttributeColumnLength: Int? = null ) = if (oldEntry == null) { DataEntryEntity( dataEntryId = DataEntryId(entryType = this.entryType, entryId = this.entryId), payload = this.payload.toPayloadJson(objectMapper), - payloadAttributes = this.payload.toJsonPathsWithValues(limit, filters).map { attr -> PayloadAttribute(attr) }.toMutableSet(), + payloadAttributes = this.payload.toJsonPathsWithValues(limit, filters, payLoadAttributeColumnLength).map { attr -> PayloadAttribute(attr) }.toMutableSet(), name = this.name, applicationName = this.applicationName, type = this.type, diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/task/ConverterExt.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/task/ConverterExt.kt index f121fabdd..7d1dce74d 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/task/ConverterExt.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/task/ConverterExt.kt @@ -53,7 +53,8 @@ fun TaskCreatedEngineEvent.toEntity( fun TaskEntity.update(event: TaskAttributeUpdatedEngineEvent, objectMapper: ObjectMapper, limit: Int, - filters: List>) { + filters: List>, + payLoadAttributeColumnLength: Int?) { this.taskDefinitionKey = event.taskDefinitionKey this.sourceReference = event.sourceReference.toSourceReferenceEmbeddable() this.name = event.name ?: this.name @@ -65,7 +66,7 @@ fun TaskEntity.update(event: TaskAttributeUpdatedEngineEvent, if (event.payload.isNotEmpty()) { this.payload = event.payload.toPayloadJson(objectMapper) this.payloadAttributes.clear() - this.payloadAttributes.addAll(event.payload.toJsonPathsWithValues(limit, filters).map { attr -> PayloadAttribute(attr) }.toMutableSet()) + this.payloadAttributes.addAll(event.payload.toJsonPathsWithValues(limit, filters, payLoadAttributeColumnLength).map { attr -> PayloadAttribute(attr) }.toMutableSet()) } businessKey = event.businessKey ?: this.businessKey description = event.description ?: this.description From 9a705ecb54be2f6662b2d9095094396c5a592b4c Mon Sep 17 00:00:00 2001 From: Tim Holzke Date: Fri, 11 Oct 2024 13:36:10 +0200 Subject: [PATCH 2/2] chore(#1065): added property to example configuration to make it more visible in the documentation --- docs/reference-guide/components/view-jpa.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/reference-guide/components/view-jpa.md b/docs/reference-guide/components/view-jpa.md index 13a8035f3..6c8442081 100644 --- a/docs/reference-guide/components/view-jpa.md +++ b/docs/reference-guide/components/view-jpa.md @@ -61,6 +61,7 @@ configuration of this indexing process by the following configuration options: polyflow.view.jpa: stored-items: task, data-entry, process-instance, process-definition payload-attribute-level-limit: 2 + payload-attribute-column-length: 255 include-correlated-data-entries-in-data-entry-queries: false process-outdated-events: false data-entry-filters: