Skip to content

Commit

Permalink
fix(#1065): added attribute length limit to update events
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Tim committed Oct 11, 2024
1 parent c378c48 commit 4529401
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
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 4529401

Please sign in to comment.