#1051: ScriptDO.kt

projectforge-business/src/main/kotlin/org/projectforge/business/scripting/ScriptDO.kt JPA Entity (Script), projectforge-business/src/main/kotlin/org/projectforge/business/scripting/ScriptDO.kt 436 lines · 321 code · 54 comments · 61 blank
Central entity for stored scripts. Maps to T_SCRIPT table. Supports three script types (KOTLIN, GROOVY, INCLUDE), six parameter slots, execution as another user (sudo), executable-by user/group restrictions, script backup storage, file attachments, and recursive include resolution.

Entity Design

Script Types

Enum ScriptType: KOTLIN (Kotlin .kts), GROOVY, and INCLUDE (script sniplet, not executable standalone).

Execution Control

Parameter System

Six static parameter slots (parameter1-6Name, parameter1-6Type, parameter1-6Description). getParameterList() builds a List<ScriptParameter> with type safety. setParameterList() rebuilds individual fields from a list.

Script Content

Script body stored as ByteArray BLOB with @NoHistory (not tracked in history). Instead, scriptBackup stores the previous version. scriptAsString is a @Transient property with UTF-8 conversion convenience. Supports AttachmentsInfo for file attachments.

Include System

includes (transient) stores referenced ScriptDO objects. includesRecursive walks the include tree with circular reference detection (by ID), producing a flattened set of all transitively included scripts.

Git History

868d6abb7 2025 -> 2026
f84a49eba Scripting: Description for script parameters added.
63081666f Source file headers: 2024-> 2025.
0237d5eba Json serialization refactored: IdOnlySerializer and IdsOnlySerializer.
5f9bbfbd3 Fix typos in projectforge-business directory.
a72903e36 *.java, *.kt: StringBuffer -> StringBuilder.
ad9ac6b63 Migration stuff in progress...
f5c09f87f Migration stuff in progress...
c1d14ecdb Migration stuff in progress...
c04fb0d51 Migration stuff in progress...
06828f490 Migration stuff in progress...
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
12dc9eb8f Scripting: show included scripts in list view.
dcbdb9fba ScriptDO.description: markdown format is now supported.
37935341a WIP: sudo scripting and executable scripts by normal users.
9e7810a92 WIP: Scripting #INCLUDE is now supported.
97e4bd526 Scripting: pantha rein. ACE editor added.
5f7ef41b8 Copyright 2021 -> 2022
c0f2b9de0 Tenants functionality removed everywhere.
ceb63e8a1 Source code header: (C) 2001-2021.
6fd010dd6 Kotlin scripting works now with ugly work-around for Spring boot fat jar.
52d9c1d88 WIP: Kotlin scripts...
7c79f1922 Copyright of source header -> 2020.
45e1c6d2b LicenseDO, ScriptDO: NoHistory annotation fixed.
8675a1dbe Declared all Kotlin JPA entities and their properties as open.
2e254d6b0 Add ScriptRest page
859c69ede Code warnings fixed.
353dad6ae ScriptDO.java -> ScriptDO.kt