Skip to content

Commit

Permalink
Merge pull request #1066 from holunda-io/bugfix/1065-attribute-length…
Browse files Browse the repository at this point in the history
…-limit-does-not-work-on-updates

Added attribute length limit to update events
  • Loading branch information
MichaelVonB authored Oct 11, 2024
2 parents c378c48 + 9a705ec commit 0a80b87
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/reference-guide/components/view-jpa.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ internal fun Pair<String, Any?>.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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ fun DataEntryUpdatedEvent.toEntity(
revisionValue: RevisionValue,
oldEntry: DataEntryEntity?,
limit: Int,
filters: List<Pair<JsonPathFilterFunction, FilterType>>
filters: List<Pair<JsonPathFilterFunction, FilterType>>,
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ fun TaskCreatedEngineEvent.toEntity(
fun TaskEntity.update(event: TaskAttributeUpdatedEngineEvent,
objectMapper: ObjectMapper,
limit: Int,
filters: List<Pair<JsonPathFilterFunction, FilterType>>) {
filters: List<Pair<JsonPathFilterFunction, FilterType>>,
payLoadAttributeColumnLength: Int?) {
this.taskDefinitionKey = event.taskDefinitionKey
this.sourceReference = event.sourceReference.toSourceReferenceEmbeddable()
this.name = event.name ?: this.name
Expand All @@ -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
Expand Down

0 comments on commit 0a80b87

Please sign in to comment.