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

Added attribute length limit to update events #1066

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
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
Loading