EN · DE · RU · FR · ES

#813: Constants.kt

projectforge-business/src/main/kotlin/org/projectforge/Constants.kt Kotlin singleton, projectforge-business/src/main/kotlin/org/projectforge/Constants.kt 158 lines · 65 code · 46 comments · 47 blank

Central Constants Repository

The single source of truth for all project-wide constants. A Kotlin object (thread-safe singleton) at 158 lines, referenced everywhere — by JPA entities as @Column(length = Constants.LENGTH_TITLE), by validators, formatters, and UI components. Javadoc: "Defines different constants (typical length of string columns) usable by plugins and core package."

Categories of Constants

Database Column Lengths

ConstantValueUsage
LENGTH_TEXT4000Default for text/description fields
LENGTH_COMMENT4000Comment fields
COMMENT_LENGTH4000Legacy alias for comment fields
LENGTH_SUBJECT1000Subject line fields
LENGTH_TITLE1000Title fields in all entities

Standardizing column lengths in one place guarantees database schema consistency across all entity classes. Used in JPA @Column(length = ...) annotations and front-end validation.

Numeric Limits

ConstantValuePurpose
TEN_BILLION10000000000Upper bound for monetary fields (BigDecimal precision=12, scale=2)
TEN_BILLION_NEGATIVE-10000000000Lower bound for monetary fields
HUNDRED_BD100Used in percentage calculations

Data Size Constants

ConstantValueNote
KB1024Integer and BigDecimal variants available (e.g. KB_BD). Used for file size formatting and upload limit validation.
MBKB * 1024
GBMB * 1024
TBGB * 1024L (Long)

Time Constants

SECONDS_PER_MINUTE = 60MILLIS_PER_SECOND = 1_000L
SECONDS_PER_HOUR = 60 * 60MILLIS_PER_MINUTE = 60 * 1_000L
SECONDS_PER_DAY = 3600 * 24MILLIS_PER_HOUR = 3_600_000L
SECONDS_PER_WEEK = 86400 * 7MILLIS_PER_DAY = 86_400_000L
MILLIS_PER_WEEK = 604_800_000L

Each time constant has a corresponding _BD variant (BigDecimal). Used in timesheet calculations, timers, and date/time arithmetic.

Application Paths

ConstantValuePurpose
REACT_APP_PATH"react/"URL path prefix for the React SPA frontend
WICKET_APPLICATION_PATH"wa/"URL path prefix for legacy Wicket pages
BUILD_DIR"build"Gradle build output directory (was "target" with Maven)

External Links

Prefixed with WEB_, these constants form a link hierarchy: WEB_HOME_PAGE_LINKWEB_DOCS_LINKWEB_DOCS_USER_GUIDE_LINK, WEB_DOCS_ADMIN_GUIDE_LINK, etc. Used throughout the UI for help links and documentation references.

Calendar & Event Constants

TIMESHEET_CALENDAR_ID = -1LSpecial calendar ID for timesheet events
MINYEAR = 1900, MAXYEAR = 2100Valid year range for date pickers and validation
EVENT_CLASS_NAME = "timesheet"Identifier for timesheet calendar events
BREAK_EVENT_CLASS_NAME = "ts-break"Identifier for break entries in timesheets

Kotlin object — Why Not a Class?

A Kotlin object is a thread-safe singleton created on first access via JVM class loading guarantees. Constants declared with const val are compiled to JVM static fields and inlined at the call site — no runtime resolution overhead.

For Java interop:

Git History

868d6abb7 2025 -> 2026
47d42a5bb AI savings: mass update of time-sheets, editing in classic page added.
63081666f Source file headers: 2024-> 2025.
1ffa5a1ef WIP: gradle...
4c04cfd65 MAJOR-CHANGE! Migration of integer id's to Long id's.
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
dcfc7c1a9 Old calendar moved to sub menu, ScriptingTask*, JiraUtils
1ea8d4062 WIP: Jobs and Bank account records.
d7b3e8751 AG grid: Copy and paste and Excel export improved.