@Service
class TemplatedNodeService(val objectMapper: ObjectMapper, val jsonNodeMapper: JsonNodeMapper, val validator: Validator)

Service for TemplatedNodes. Provides functions to create, update and delete

Parameters

objectMapper

injected ObjectMapper, used to parse JSONFieldInput

jsonNodeMapper

used to map JsonNode to String

Constructors

Link copied to clipboard
constructor(objectMapper: ObjectMapper, jsonNodeMapper: JsonNodeMapper, validator: Validator)

Properties

Link copied to clipboard
Link copied to clipboard
val objectMapper: ObjectMapper
Link copied to clipboard

Functions

Link copied to clipboard
fun ensureTemplatedFieldExist(template: BaseTemplate<*, *>, field: String)

Ensures that field is defined by template

Link copied to clipboard
private fun ensureTemplatedFieldsExist(template: BaseTemplate<*, *>, fields: Collection<String>)

Ensures that all fields in fields are defined by template

Link copied to clipboard

Updates the TemplatedNode.templatedFields of a TemplatedNode based on field Does not check authorization permissions, and does not save the provided node afterwards. Validates the new value of the updated field.

Link copied to clipboard
suspend fun updateTemplatedFields(node: TemplatedNode, templatedFields: OptionalInput<List<JSONFieldInput>>, templateWasUpdated: Boolean)

Updates the TemplatedNode.templatedFields of a TemplatedNode based on the templatedFields Does not check authorization permissions, and does not save the provided node afterwards Validates the new value of the fields If templateWasUpdated, validates all fields. Requires that the new template is already set

suspend fun updateTemplatedFields(node: TemplatedNode, input: UpdateTemplatedNodeInput, templateWasUpdated: Boolean = false)

Updates the TemplatedNode.templatedFields of a TemplatedNode based on the input Does not check authorization permissions, and does not save the provided node afterwards Validates the new value of the fields If templateWasUpdated, validates all fields. Requires that the new template is already set

Link copied to clipboard
private fun validateField(value: JsonNode?, schema: String, name: String)

Validates a value for a templated field

Link copied to clipboard

Validates the initial input for TemplatedNode.templatedFields If no input is provided for a field, null is assigned as default value

Link copied to clipboard
suspend fun validateTemplatedField(templatedNode: TemplatedNode, field: String): Boolean

Validates a value of a templated field

private suspend fun validateTemplatedFieldsAfterTemplateUpdate(node: TemplatedNode, templatedFields: OptionalInput<List<JSONFieldInput>>)

After the template of node was updated, validate all fields and remove fields which are no longer necessary