Compare commits

...
Author SHA1 Message Date
James MaesandClaude Fable 5.2 e51605e0a4 feat: ship the qbit's own help, and a changelog a host can include
build / maven (push) Successful in 2m43s
maven / build (push) Successful in 2m37s
A host should take the CMS whole from this qbit: its tables, its help and
its schema. Two things forced a host to write CMS material of its own; both
are fixed here.

- Help: help/qbit-cms.yaml (643 entries) covers every app, home, table,
  section, field, child list and value list. The producer registers it when
  the host uses the default names. CmsHelpTest holds it to the core's
  coverage gate (HelpBundleAssertions) and to every section.
- Schema: the first guard changeset (1.0.0-guard-existing-tables) no longer
  has runAlways. It rewrote its DATABASECHANGELOG row on every migration,
  so a second migration was never a no-op and a rollback by count began with
  it; a host whose migrations must be repeatable had to copy the tables. It
  runs once now, with validCheckSum: ANY so an install that already ran it
  migrates on unchanged. This changes a released changeset on purpose;
  CmsInstallTest.testRerunIsNoop covers a second run and an install the
  earlier version recorded.
- Homes: text sizes in rem (labels 0.875rem instead of 13px), so they follow
  the reader's text size.

Tests: 40, Checkstyle 0, guardrails and coverage checks pass.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-18 15:33:54 -06:00
James MaesandClaude Fable 5.2 c95bc588c5 fix: "Media" is its own plural
The table label and the home counts read "Medias" and "0 medias". Seen in
the admin of a host application.

Tests: 37, Checkstyle 0, guardrails and coverage checks pass.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-18 12:37:32 -06:00
James MaesandClaude Fable 5.2 9c17458fec fix: keep value-list fields to the values of their lists
QQQ offers a fixed list (a possible-value source of an enum) in a form but
accepts any value in a write: through the API a project could be saved with
a status that is not on the list. Found by a live check in a host
application.

- CmsValueListCheck: a pre-insert and pre-update customizer on every table
  with a value-list field; a record with another value gets an error and is
  not written, and an update is checked only for the fields it names.
- Changelog: check constraints on the same columns (as kof22 has for
  media_type and blog_post_version; the project status check is new), and
  kof22's checks on media_type.max_file_size_mb and the focal point of a
  project's image. They are part of the not yet released
  1.0.0-constraints-<feature> changesets.
- Reference DDL regenerated.

Tests: 37, Checkstyle 0, guardrails and coverage checks pass.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-18 12:26:33 -06:00
James MaesandClaude Fable 5.2 e952950d6a feat: add the MEDIA, BLOG, PROJECTS and PHOTOS features as tables with admin screens
Eighteen content tables from the kof22 website's models, as standard QQQ
tables in the qbit's own style: media and media types; blogs, blog types,
authors, blog tags, blog posts with their tags, media and related versions;
project categories, projects and project updates; album folders, photo
albums, photos, photo tags and their links.

- Entities under media/model, blog/model, projects/model and photos/model,
  with six value-list enums registered in CmsTables.VALUE_LISTS and produced
  as possible-value sources named with the table prefix.
- CmsTableDefinition gains imagePreview, filePreview and help; the table
  builder turns them into QQQ file-preview adornments and field help.
- Four more areas (Media, Blogs, Projects, Photos), each with its own home.
- Changelog: 1.0.0-create-<table> for each table, constraints per feature,
  two changesets for the links between two features, generic media and blog
  type seeds, and a run-once guard against name collisions. Every content
  changeset is gated on the features it needs, so a feature can be installed
  by a later run and a feature whose needs are missing installs nothing.
- A feature that is off produces nothing; a lookup, a child list or a
  foreign key that links two features exists only when both are on.
- Reference DDL regenerated from the changelog on PostgreSQL 17 (the eleven
  CORE tables come out unchanged).

Not in this change: file upload, storage and renditions (a media record
points at a file by its address), the publishing processes, the content
stream and the Site API.

Tests: 37 (6 new in CmsContentFeaturesTest), Checkstyle 0, guardrails and
coverage checks pass.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-18 12:05:28 -06:00
james.maes 191b165593 Merge pull request 'build(deps): align with Gitea registry (parent 2.2.1, QQQ 4.1.0-RC.26)' (#28) from deps/align-gitea into develop
build / maven (push) Successful in 3m10s
maven / build (push) Successful in 3m10s
2026-11-07 18:03:41 +00:00
james.maesandClaude Opus 5.5 9d7214912a build(deps): align with Gitea registry (parent 2.2.1, QQQ 4.1.0-RC.26)
build / maven (push) Successful in 3m5s
maven / build (push) Successful in 3m6s
pom.xml: parent -> 2.2.1
pom.xml: qqq.snapshot.version: 4.1.0-RC.21 -> 4.1.0-RC.26
pom.xml: qqq-frontend-next: 1.0.0-RC.14 -> 1.0.0-RC.38
pom.xml: added qqq.version=4.1.0-RC.26 (parent BOM import)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 17:58:48 +00:00
james.maes 716cccc30d Merge pull request 'ci: pin shared workflow to v1' (#27) from ci/pin-v1-develop into develop
QRun-IO/ci-policy: native / dotnet-0 (push) Skipped
QRun-IO/ci-policy: native / native-result (push) Successful in 13s
QRun-IO/ci-policy: ci / head-profile (push) Skipped
QRun-IO/ci-policy: ci / repository-policy (push) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (push) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (push) Skipped
QRun-IO/ci-policy: ci / node-8 (push) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (push) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (push) Skipped
QRun-IO/ci-policy: ci / source-config-13 (push) Skipped
QRun-IO/ci-policy: ci / source-config-14 (push) Skipped
QRun-IO/ci-policy: ci / original-voyage (push) Skipped
QRun-IO/ci-policy: ci / original-cli (push) Skipped
QRun-IO/ci-policy: ci / ci-result (push) Successful in 12s
build / maven (push) Successful in 3m55s
QRun-IO/ci-policy: ci / fork-guard (push) Skipped
QRun-IO/ci-policy: native / fork-deny (push) Skipped
QRun-IO/ci-policy: ci / Scoped workflow [workflow 1e25bb5a243dfdcd95d4b9a4f780200ff8c8778a] (push) Successful in 15s
QRun-IO/ci-policy: ci / application-template-0 (push) Skipped
QRun-IO/ci-policy: ci / gradle-1 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (push) Skipped
QRun-IO/ci-policy: ci / node-9 (push) Skipped
QRun-IO/ci-policy: ci / node-10 (push) Skipped
QRun-IO/ci-policy: ci / android-0 (push) Skipped
QRun-IO/ci-policy: ci / original-business (push) Skipped
QRun-IO/ci-policy: ci / original-mcp (push) Skipped
QRun-IO/ci-policy: ci / not-enrolled (push) Skipped
QRun-IO/ci-policy: ci / shared-pipeline (push) Skipped
maven / build (push) Successful in 3m55s
2026-11-06 16:04:41 +00:00
james.maesandClaude Opus 5.5 c42195cd61 ci: pin shared workflow to v1
QRun-IO/ci-policy: ci / fork-guard (pull_request) Skipped
QRun-IO/ci-policy: native / fork-deny (pull_request) Skipped
QRun-IO/ci-policy: ci / head-profile (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy (pull_request) Skipped
QRun-IO/ci-policy: ci / application-template-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (pull_request) Skipped
QRun-IO/ci-policy: ci / node-8 (pull_request) Skipped
QRun-IO/ci-policy: ci / original-business (pull_request) Skipped
QRun-IO/ci-policy: ci / original-voyage (pull_request) Skipped
QRun-IO/ci-policy: ci / original-cli (pull_request) Skipped
QRun-IO/ci-policy: ci / ci-result (pull_request) Waiting to run
build / maven (push) Successful in 3m21s
QRun-IO/ci-policy: native / dotnet-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / Scoped workflow [workflow 1e25bb5a243dfdcd95d4b9a4f780200ff8c8778a] (pull_request) Successful in 7s
QRun-IO/ci-policy: native / native-result (pull_request) Successful in 5s
QRun-IO/ci-policy: ci / gradle-1 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-9 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-10 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-13 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-14 (pull_request) Skipped
QRun-IO/ci-policy: ci / android-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / original-mcp (pull_request) Skipped
QRun-IO/ci-policy: ci / not-enrolled (pull_request) Skipped
QRun-IO/ci-policy: ci / shared-pipeline (pull_request) Skipped
maven / build (push) Successful in 3m21s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 14:06:12 +00:00
james.maes 6a1edfae3c Merge pull request 'ci: use shared ci-workflows Maven workflow' (#26) from ci/ci-workflows into develop
build / maven (push) Successful in 3m4s
QRun-IO/ci-policy: native / dotnet-0 (push) Skipped
QRun-IO/ci-policy: native / native-result (push) Successful in 6s
QRun-IO/ci-policy: ci / head-profile (push) Skipped
QRun-IO/ci-policy: ci / repository-policy (push) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (push) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (push) Skipped
QRun-IO/ci-policy: ci / node-8 (push) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (push) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (push) Skipped
QRun-IO/ci-policy: ci / source-config-13 (push) Skipped
QRun-IO/ci-policy: ci / source-config-14 (push) Skipped
QRun-IO/ci-policy: ci / original-voyage (push) Skipped
QRun-IO/ci-policy: ci / original-cli (push) Skipped
QRun-IO/ci-policy: ci / ci-result (push) Successful in 5s
maven / build (push) Successful in 3m5s
QRun-IO/ci-policy: ci / fork-guard (push) Skipped
QRun-IO/ci-policy: native / fork-deny (push) Skipped
QRun-IO/ci-policy: ci / Scoped workflow [workflow d20a578c7d818bc7ca32a2ac2c675da4e4f27385] (push) Successful in 9s
QRun-IO/ci-policy: ci / application-template-0 (push) Skipped
QRun-IO/ci-policy: ci / gradle-1 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (push) Skipped
QRun-IO/ci-policy: ci / node-9 (push) Skipped
QRun-IO/ci-policy: ci / node-10 (push) Skipped
QRun-IO/ci-policy: ci / android-0 (push) Skipped
QRun-IO/ci-policy: ci / original-business (push) Skipped
QRun-IO/ci-policy: ci / original-mcp (push) Skipped
QRun-IO/ci-policy: ci / not-enrolled (push) Skipped
QRun-IO/ci-policy: ci / shared-pipeline (push) Skipped
2026-11-05 23:15:16 +00:00
james.maesandClaude Opus 5.5 ad2edb6769 ci: use shared ci-workflows Maven workflow
QRun-IO/ci-policy: ci / fork-guard (pull_request) Skipped
QRun-IO/ci-policy: native / fork-deny (pull_request) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (pull_request) Skipped
QRun-IO/ci-policy: ci / Scoped workflow [workflow 1b3648d9421543350067e95e54959dfb471b26d5] (pull_request) Successful in 4s
QRun-IO/ci-policy: ci / head-profile (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy (pull_request) Skipped
QRun-IO/ci-policy: ci / application-template-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (pull_request) Skipped
QRun-IO/ci-policy: ci / node-8 (pull_request) Skipped
QRun-IO/ci-policy: ci / original-business (pull_request) Skipped
QRun-IO/ci-policy: ci / original-voyage (pull_request) Skipped
QRun-IO/ci-policy: ci / original-cli (pull_request) Skipped
build / maven (push) Successful in 1m58s
QRun-IO/ci-policy: Shared Java Maven CI / verify (pull_request) Successful in 2m4s
QRun-IO/ci-policy: Shared Java Maven CI / secrets (pull_request) Failing after 1s
QRun-IO/ci-policy: Shared Java Maven CI / gate (pull_request) Failing after 1s
QRun-IO/ci-policy: ci / java-maven-6 (pull_request) Failing after 17m12s
QRun-IO/ci-policy: ci / ci-result (pull_request) Failing after 2s
QRun-IO/ci-policy: native / dotnet-0 (pull_request) Skipped
QRun-IO/ci-policy: native / native-result (pull_request) Successful in 5s
QRun-IO/ci-policy: ci / gradle-1 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-9 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-10 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-13 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-14 (pull_request) Skipped
QRun-IO/ci-policy: ci / android-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / original-mcp (pull_request) Skipped
QRun-IO/ci-policy: ci / not-enrolled (pull_request) Skipped
QRun-IO/ci-policy: ci / shared-pipeline (pull_request) Skipped
maven / build (push) Successful in 1m58s
Replace the platform-ci release callers with one caller of
KofTwentyTwo/ci-workflows maven.yaml (qqq-orb port).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 22:03:09 +00:00
james.maes 629cfb287f Merge canonical CMS CORE and PostgreSQL runtime integration (#25)
QRun-IO/ci-policy: native / dotnet-0 (push) Skipped
QRun-IO/ci-policy: ci / head-profile (push) Skipped
QRun-IO/ci-policy: ci / repository-policy (push) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (push) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (push) Skipped
QRun-IO/ci-policy: ci / node-8 (push) Skipped
QRun-IO/ci-policy: native / native-result (push) Successful in 10s
QRun-IO/ci-policy: ci / node-playwright-11 (push) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (push) Skipped
QRun-IO/ci-policy: ci / source-config-13 (push) Skipped
QRun-IO/ci-policy: ci / source-config-14 (push) Skipped
QRun-IO/ci-policy: ci / original-cli (push) Skipped
QRun-IO/ci-policy: ci / original-voyage (push) Skipped
Shared Java Maven CI / secrets (push) Successful in 47s
Shared Java Maven CI / verify (push) Successful in 2m42s
QRun-IO/ci-policy: Shared Java Maven CI / verify (push) Successful in 1m28s
QRun-IO/ci-policy: ci / ci-result (push) Successful in 14s
qrun-release / postpublish (push) Successful in 7m26s
QRun-IO/ci-policy: ci / fork-guard (push) Skipped
QRun-IO/ci-policy: native / fork-deny (push) Skipped
QRun-IO/ci-policy: ci / Scoped workflow [workflow 60e5a80ed7a5a67877bfb3e129b1929c83464b6e] (push) Successful in 10s
QRun-IO/ci-policy: ci / application-template-0 (push) Skipped
QRun-IO/ci-policy: ci / gradle-1 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (push) Skipped
QRun-IO/ci-policy: ci / node-9 (push) Skipped
QRun-IO/ci-policy: ci / node-10 (push) Skipped
QRun-IO/ci-policy: ci / android-0 (push) Skipped
QRun-IO/ci-policy: ci / original-business (push) Skipped
QRun-IO/ci-policy: ci / original-mcp (push) Skipped
QRun-IO/ci-policy: ci / not-enrolled (push) Skipped
QRun-IO/ci-policy: ci / shared-pipeline (push) Skipped
QRun-IO/ci-policy: Shared Java Maven CI / secrets (push) Successful in 43s
Shared Java Maven CI / gate (push) Successful in 23s
qrun-release / release (push) Successful in 51m53s
QRun-IO/ci-policy: Shared Java Maven CI / gate (push) Successful in 27s
QRun-IO/ci-policy: ci / java-maven-6 (push) Successful in 53m0s
Shared QRun source version / version (push) Successful in 7m26s
2026-11-05 12:47:10 +00:00
James MaesandClaude Sonnet 5.5 3fb67aac99 feat(cms): implement the CMS CORE feature on QQQ 4.1
QRun-IO/ci-policy: ci / fork-guard (pull_request) Skipped
Shared Java Maven CI / secrets (push) Successful in 33s
QRun-IO/ci-policy: native / fork-deny (pull_request) Skipped
QRun-IO/ci-policy: ci / head-profile (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy (pull_request) Skipped
QRun-IO/ci-policy: ci / application-template-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (pull_request) Skipped
QRun-IO/ci-policy: ci / node-8 (pull_request) Skipped
QRun-IO/ci-policy: ci / original-business (pull_request) Skipped
QRun-IO/ci-policy: ci / original-voyage (pull_request) Skipped
QRun-IO/ci-policy: ci / original-cli (pull_request) Skipped
QRun-IO/ci-policy: Shared Java Maven CI / secrets (pull_request) Successful in 30s
Shared Java Maven CI / verify (push) Successful in 1m31s
qrun-release / postpublish (push) Skipped
QRun-IO/ci-policy: Shared Java Maven CI / verify (pull_request) Successful in 1m33s
QRun-IO/ci-policy: Shared Java Maven CI / gate (pull_request) Successful in 26s
QRun-IO/ci-policy: ci / java-maven-6 (pull_request) Successful in 58m32s
QRun-IO/ci-policy: ci / ci-result (pull_request) Successful in 10s
Release candidate / release-rc (pull_request) Skipped
QRun-IO/ci-policy: native / dotnet-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / Scoped workflow [workflow f1d46718955078331817c6206b822a94bc7d769f] (pull_request) Successful in 12s
QRun-IO/ci-policy: native / native-result (pull_request) Successful in 9s
QRun-IO/ci-policy: ci / gradle-1 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-9 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-10 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-13 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-14 (pull_request) Skipped
QRun-IO/ci-policy: ci / android-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / original-mcp (pull_request) Skipped
QRun-IO/ci-policy: ci / not-enrolled (pull_request) Skipped
QRun-IO/ci-policy: ci / shared-pipeline (pull_request) Skipped
Shared Java Maven CI / gate (push) Successful in 20s
qrun-release / release (push) Successful in 56m59s
Implement the CORE feature area as standard QQQ tables: site, domain,
redirect, redirect type, page, page type, page section, page section type,
snippet, menu and menu item. Add the CMS app with Sites, Pages and
Navigation homes, CmsFeature flags with dependency validation, per-table
permissions with CmsRole bundles and openReads, a startup schema check
(FAIL_FAST, DEGRADED, SKIP), a prefix-parameterized Liquibase changelog and
the Postgres DDL.

Add unit tests, Postgres-backed Testcontainers install and runtime-identity
tests, and a local demo server used to produce the docs screenshots.

Build against the published QQQ 4.1 BOM (4.1.0-RC.21), add the test-scope
Postgres, Javalin, frontend-next and Testcontainers dependencies, and
enforce checkstyle at validate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 05:28:20 -06:00
forge-recovery e0bb637277 ci: enroll shared Gitea lifecycle
QRun-IO/ci-policy: ci / head-profile (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (push) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (push) Skipped
QRun-IO/ci-policy: ci / node-8 (push) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (push) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (push) Skipped
QRun-IO/ci-policy: ci / source-config-13 (push) Skipped
QRun-IO/ci-policy: ci / source-config-14 (push) Skipped
QRun-IO/ci-policy: native / dotnet-0 (push) Skipped
Shared Java Maven CI / secrets (push) Successful in 33s
QRun-IO/ci-policy: ci / repository-policy (push) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (push) Skipped
QRun-IO/ci-policy: native / native-result (push) Successful in 11s
QRun-IO/ci-policy: Shared Java Maven CI / verify (push) Successful in 1m1s
Shared Java Maven CI / verify (push) Successful in 1m36s
QRun-IO/ci-policy: ci / ci-result (push) Successful in 9s
qrun-release / postpublish (push) Failing after 10m53s
QRun-IO/ci-policy: ci / fork-guard (push) Skipped
QRun-IO/ci-policy: ci / application-template-0 (push) Skipped
QRun-IO/ci-policy: ci / gradle-1 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (push) Skipped
QRun-IO/ci-policy: ci / node-9 (push) Skipped
QRun-IO/ci-policy: ci / node-10 (push) Skipped
QRun-IO/ci-policy: ci / android-0 (push) Skipped
QRun-IO/ci-policy: ci / original-mcp (push) Skipped
QRun-IO/ci-policy: ci / not-enrolled (push) Skipped
QRun-IO/ci-policy: native / fork-deny (push) Skipped
QRun-IO/ci-policy: Shared Java Maven CI / secrets (push) Successful in 36s
QRun-IO/ci-policy: ci / java-docker-3-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (push) Skipped
QRun-IO/ci-policy: Shared Java Maven CI / gate (push) Successful in 20s
QRun-IO/ci-policy: ci / java-maven-6 (push) Successful in 8m7s
Shared Java Maven CI / gate (push) Successful in 22s
qrun-release / release (push) Successful in 9m28s
Shared QRun source version / version (push) Failing after 10m53s
2026-11-02 21:30:55 +00:00
forge-recoveryandCodex d2af100c99 ci: enroll shared Gitea release-candidate lifecycle
QRun-IO/ci-policy: ci / fork-guard (pull_request) Skipped
QRun-IO/ci-policy: ci / head-profile (pull_request) Skipped
QRun-IO/ci-policy: ci / application-template-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-8 (pull_request) Skipped
QRun-IO/ci-policy: native / fork-deny (pull_request) Skipped
Shared Java Maven CI / secrets (push) Successful in 16s
QRun-IO/ci-policy: Shared Java Maven CI / secrets (pull_request) Successful in 15s
QRun-IO/ci-policy: ci / repository-policy (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (pull_request) Skipped
Shared Java Maven CI / verify (push) Successful in 19s
qrun-release / postpublish (push) Skipped
QRun-IO/ci-policy: Shared Java Maven CI / verify (pull_request) Successful in 1m3s
QRun-IO/ci-policy: Shared Java Maven CI / gate (pull_request) Successful in 14s
QRun-IO/ci-policy: ci / java-maven-6 (pull_request) Successful in 55m56s
QRun-IO/ci-policy: ci / ci-result (pull_request) Successful in 6s
Release candidate / release-rc (pull_request) Skipped
QRun-IO/ci-policy: ci / gradle-1 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-9 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-10 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-13 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-14 (pull_request) Skipped
QRun-IO/ci-policy: ci / android-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / not-enrolled (pull_request) Skipped
QRun-IO/ci-policy: native / dotnet-0 (pull_request) Skipped
QRun-IO/ci-policy: native / native-result (pull_request) Successful in 5s
QRun-IO/ci-policy: ci / java-core-2-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (pull_request) Skipped
Shared Java Maven CI / gate (push) Successful in 12s
qrun-release / release (push) Successful in 55m12s
Co-Authored-By: Codex <noreply@openai.com>
2026-11-02 20:14:14 +00:00
forge-recovery cfe41b4807 ci: enroll shared Gitea lifecycle
QRun-IO/ci-policy: ci / head-profile (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (push) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (push) Skipped
QRun-IO/ci-policy: ci / node-8 (push) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (push) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (push) Skipped
QRun-IO/ci-policy: ci / source-config-13 (push) Skipped
QRun-IO/ci-policy: ci / source-config-14 (push) Skipped
QRun-IO/ci-policy: native / dotnet-0 (push) Skipped
QRun-IO/ci-policy: native / native-result (push) Successful in 6s
QRun-IO/ci-policy: ci / repository-policy (push) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (push) Skipped
QRun-IO/ci-policy: Shared Java Maven CI / verify (push) Successful in 52s
QRun-IO/ci-policy: ci / ci-result (push) Successful in 4s
Shared Java Maven CI / verify (push) Successful in 19s
Shared Java Maven CI / secrets (push) Successful in 15s
qrun-release / postpublish (push) Skipped
QRun-IO/ci-policy: ci / fork-guard (push) Skipped
QRun-IO/ci-policy: ci / application-template-0 (push) Skipped
QRun-IO/ci-policy: ci / gradle-1 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (push) Skipped
QRun-IO/ci-policy: ci / node-9 (push) Skipped
QRun-IO/ci-policy: ci / node-10 (push) Skipped
QRun-IO/ci-policy: ci / android-0 (push) Skipped
QRun-IO/ci-policy: ci / not-enrolled (push) Skipped
QRun-IO/ci-policy: native / fork-deny (push) Skipped
QRun-IO/ci-policy: Shared Java Maven CI / secrets (push) Successful in 19s
QRun-IO/ci-policy: ci / java-docker-3-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (push) Skipped
QRun-IO/ci-policy: Shared Java Maven CI / gate (push) Successful in 15s
QRun-IO/ci-policy: ci / java-maven-6 (push) Successful in 1h44m43s
Shared QRun source version / version (push) Successful in 2m31s
Shared Java Maven CI / gate (push) Successful in 14s
qrun-release / release (push) Successful in 54m57s
2026-11-02 19:15:40 +00:00
d3e39fd6cb ci: add the isolated postpublish job to the QRun release caller
QRun-IO/ci-policy: ci / fork-guard (pull_request) Skipped
QRun-IO/ci-policy: ci / head-profile (pull_request) Skipped
QRun-IO/ci-policy: ci / application-template-0 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-8 (pull_request) Skipped
QRun-IO/ci-policy: native / fork-deny (pull_request) Skipped
Shared Java Maven CI / secrets (push) Successful in 14s
QRun-IO/ci-policy: Shared Java Maven CI / secrets (pull_request) Successful in 13s
QRun-IO/ci-policy: ci / repository-policy (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (pull_request) Skipped
Shared Java Maven CI / verify (push) Successful in 49s
QRun-IO/ci-policy: Shared Java Maven CI / verify (pull_request) Successful in 54s
qrun-release / postpublish (push) Skipped
QRun-IO/ci-policy: Shared Java Maven CI / gate (pull_request) Successful in 9s
QRun-IO/ci-policy: ci / java-maven-6 (pull_request) Successful in 2h38m19s
QRun-IO/ci-policy: ci / ci-result (pull_request) Successful in 4s
QRun-IO/ci-policy: ci / gradle-1 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (pull_request) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-9 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-10 (pull_request) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (pull_request) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-13 (pull_request) Skipped
QRun-IO/ci-policy: ci / source-config-14 (pull_request) Skipped
QRun-IO/ci-policy: ci / not-enrolled (pull_request) Skipped
QRun-IO/ci-policy: native / dotnet-0 (pull_request) Skipped
QRun-IO/ci-policy: native / native-result (pull_request) Successful in 4s
QRun-IO/ci-policy: ci / java-core-2-head (pull_request) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (pull_request) Skipped
Shared Java Maven CI / gate (push) Successful in 12s
qrun-release / release (push) Successful in 2h38m13s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex <noreply@openai.com>
2026-11-02 15:47:28 +00:00
forge-recovery dd43ebbaae ci: add the QRun release caller (#19)
QRun-IO/ci-policy: ci / ci-result (push) Failing after 0s
QRun-IO/ci-policy: ci / java-docker-2 (push) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-3 (push) Skipped
QRun-IO/ci-policy: ci / node-playwright-7 (push) Skipped
QRun-IO/ci-policy: ci / source-config-8 (push) Skipped
Shared Java Maven CI / verify (push) Failing after 1s
Shared Java Maven CI / secrets (push) Failing after 0s
QRun-IO/ci-policy: Shared Java Maven CI / verify (push) Failing after 0s
QRun-IO/ci-policy: ci / java-maven-4 (push) Failing after 1m4s
QRun-IO/ci-policy: ci / fork-guard (push) Skipped
QRun-IO/ci-policy: ci / application-template-0 (push) Skipped
QRun-IO/ci-policy: ci / gradle-1 (push) Skipped
QRun-IO/ci-policy: ci / node-5 (push) Skipped
QRun-IO/ci-policy: ci / node-6 (push) Skipped
QRun-IO/ci-policy: ci / not-enrolled (push) Skipped
QRun-IO/ci-policy: Shared Java Maven CI / secrets (push) Failing after 0s
Shared Java Maven CI / gate (push) Failing after 0s
qrun-release / release (push) Failing after 1m5s
QRun-IO/ci-policy: Shared Java Maven CI / gate (push) Failing after 0s
2026-11-02 04:17:48 +00:00
james.maesandCodex 6c9bf5bbea ci: adopt managed orb 0.8 patch track (#16)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 15:29:32 -05:00
james.maesandCodex debbbeb571 ci: adopt shared orb 0.7.18 (#15)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 14:47:23 -05:00
james.maesandCodex 900915ee0e ci: adopt shared orb 0.7.17 (#14)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 14:17:15 -05:00
99 changed files with 27753 additions and 57 deletions

No files matched your search

+2 -2
View File
@@ -1,12 +1,12 @@
version: 2.1
setup: true
orbs:
qqq-orb: kingsrook/qqq-orb@0.7.12
qqq-orb: kingsrook/qqq-orb@0.8
workflows:
setup:
jobs:
- qqq-orb/generate_pipeline:
orb_version: 0.7.12
orb_version: '0.8'
filters:
branches:
ignore: automation/qbit-rc-pending
+7
View File
@@ -0,0 +1,7 @@
name: build
on:
push:
jobs:
maven:
uses: self:KofTwentyTwo/ci-workflows/.gitea/workflows/maven.yaml@v1
secrets: inherit
+1 -1
View File
@@ -1,5 +1,5 @@
profile: qbit
orb_version: 0.7.12
orb_version: '0.8'
default_branch: develop
java_version: '21'
browsers: true
+10
View File
@@ -18,6 +18,16 @@ This file provides guidance to Codex when working with code in this repository.
**Entry point:** `CmsQBitProducer implements QBitMetaDataProducer<CmsQBitConfig>` in `com.kingsrook.qbits.cms`. The producer builds every table, possible-value source, app and widget itself (no package scanning); `CmsFeature` flags switch feature areas on and off. The schema is a prefix-parameterized Liquibase changelog the host includes and runs (`src/main/resources/qbit-cms/db/changelog/`); the qbit never runs DDL.
Packages:
- `CmsQBitConfig`, `CmsFeature`, `CmsTables` (logical names and table definitions), `CmsRuntime`, `CmsSchemaCheck` (startup check), `CmsStartupMode`.
- `core/model`: CORE entities. Their `TABLE_NAME` and possible-value source names are logical; the builder adds the prefix.
- `media/model`, `blog/model`, `projects/model`, `photos/model`: the content features' entities and their value-list enums (same rule). A value list is registered in `CmsTables.VALUE_LISTS` and named on the field by its logical name.
- `metadata`: `CmsTableBuilder` (tables, possible values, joins, child lists, associations, permission rules), `CmsAppBuilder` and `CmsAreas` (apps and homes).
- `home`: `CmsHomeRenderer` and `CmsHtml` (one renderer for every home; reads run with `PermissionEnforcement.ENFORCE`).
- `security`: `CmsRole`, `CmsSecurity`, `CmsOpenReadsPermissionChecker`.
- Schema: `src/main/resources/qbit-cms/db/changelog/qbit-cms.changelog.yaml`. Its changesets are append-only once released, and `docs/ddl/postgres.sql` is generated from it.
## Naming (owner rule)
- Tables are lowercase snake_case prefixed with the full qbit name: `cms_<name>`. The QQQ table name and the backend (SQL) name are identical; possible-value sources take the table name.
+21 -1
View File
@@ -5,4 +5,24 @@ All notable changes to this project are documented here. The format follows Keep
## [Unreleased]
### Added
- Repository scaffold: `CmsQBitConfig` and `CmsQBitProducer` (table prefix `cms_`, permissions `cms.*`), build, CI and repository standard files.
- Repository scaffold: build, CI and repository standard files.
- `CmsQBitProducer` and `CmsQBitConfig`: table prefix `cms_`, name prefix `cms`, permission base `cms`, namespaces for a second install, validation, and a collision check against names already on the instance.
- `CmsFeature` flags with dependencies. `CORE` is implemented; the other features are rejected until they ship.
- CORE tables as standard QQQ tables: site, domain, redirect, redirect type, page, page type, page section, page section type, snippet, menu and menu item. Each comes with a possible-value source, child lists on parent records, associations (`page.sections`, `menu.items`) and field audit when the host has QQQ audit tables.
- The CMS app with one home per area (Sites, Pages, Navigation). The homes show only real data read as the user and are readable at any width.
- Permissions: per-table rules, `CmsRole` bundles, `CmsSecurity.applySessionPermissions`, and `openReads`.
- Startup schema check (`startupMode` `FAIL_FAST`, `DEGRADED`, `SKIP`).
- The content features `MEDIA`, `BLOG`, `PROJECTS` and `PHOTOS`, as standard QQQ tables with the kof22 fields: media and media types; blogs, blog types, authors, blog tags, blog posts, their tags, their media and related versions; project categories, projects and project updates; album folders, photo albums, photos, photo tags and their links. Each table has a possible-value source, child lists on its parents' records, associations (`blog.tags`, `blog_post.tags`, `blog_post.media`, `project.updates`, `photo_album.photos`, `photo.tags`), per-table permission rules and field audit when the host has QQQ audit tables.
- Four more areas in the CMS app, each with its own home: Media, Blogs, Projects and Photos.
- Value lists as possible-value sources named with the table prefix: `media_rendition_format`, `media_cache_class`, `content_channel`, `content_format`, `content_version_status` and `project_status`.
- File previews on the fields that hold an image's or a file's address, and help text on the media type settings (`CmsTableDefinition` `imagePreview`, `filePreview`, `help`).
- A field whose possible-value source is one of these value lists takes only the values of its list: `CmsValueListCheck` puts an error on a record that an insert or an edit gives another value (QQQ offers such a list in a form but accepts any value in a write), and the changelog guards the same columns with check constraints.
- The qbit ships its own help (`help/qbit-cms.yaml`, 643 entries): every app, home, table, section, field, child list and value list, written for the default names and registered by the producer when the host uses them (`HelpBundles.register`; a host with other prefixes writes its own). A host no longer writes help for CMS tables. `CmsHelpTest` holds it to the core's coverage gate and to every section.
- The homes set their text in `rem` (labels 0.875rem, never 13px), so it follows the reader's text size and a host's minimum.
- Features depend on each other without being welded together: a feature that is off produces nothing, and a field, a child list or a foreign key that links two features exists only when both are on.
- Not in this version: file upload, storage and renditions (a media record points at a file by its address, and the image address fields of content are plain fields), the publishing processes, the content stream, the Site API, and the lookup filter that limits a project's category to its own site.
### Schema changes
- `1.0.0` baseline: a prefix-parameterized Liquibase changelog (`qbit-cms/db/changelog/qbit-cms.changelog.yaml`, logical path `qbit-cms/changelog`). It creates the CORE tables with the kof22 column types, adds their foreign keys and indexes, and seeds generic reference data. Feature sections are gated by `cms.features`, and a name collision halts the install. Reference DDL is in `docs/ddl/postgres.sql`.
- `1.0.0` content tables, appended to the same changelog: `1.0.0-create-<table>` for the eighteen tables of `MEDIA`, `BLOG`, `PROJECTS` and `PHOTOS`, `1.0.0-constraints-<feature>` for each feature's foreign keys and indexes, `1.0.0-constraints-blog-projects` and `1.0.0-constraints-photos-projects` for the links between two features, and `1.0.0-seed-media_type` and `1.0.0-seed-blog_type` for generic reference data. Each is gated by `cms.features` and by the features it needs. `1.0.0-guard-existing-content-tables` halts the install when a table with one of these names already exists; it runs once, not on every run.
- **Changed, on purpose, in a released changeset:** `1.0.0-guard-existing-tables` no longer has `runAlways`. It rewrote its `DATABASECHANGELOG` row on every migration, so a second migration was never a no-op and a rollback by count began with it; a host whose migrations must be repeatable could not include this changelog and had to copy the tables instead. It now runs once, before the tables are created, and carries `validCheckSum: ANY` so an install that already ran it migrates on unchanged (`CmsInstallTest.testRerunIsNoop` covers both). A table that appears later under a qbit name still stops the install, at its `createTable`. Check constraints as in kof22: the value-list columns of `media_type`, `blog_post_version` and `project` (the project status check is new), `media_type.max_file_size_mb` above zero and the focal point of a project's image between 0 and 100. `project_category.section` is optional (kof22 requires it); latitude and longitude columns are `DOUBLE PRECISION` as in kof22. A host that already runs `CORE` gets the content tables at its next migration run unless its `cms.features` leaves them out.
+10
View File
@@ -18,6 +18,16 @@ This file provides guidance to Claude Code when working with code in this reposi
**Entry point:** `CmsQBitProducer implements QBitMetaDataProducer<CmsQBitConfig>` in `com.kingsrook.qbits.cms`. The producer builds every table, possible-value source, app and widget itself (no package scanning); `CmsFeature` flags switch feature areas on and off. The schema is a prefix-parameterized Liquibase changelog the host includes and runs (`src/main/resources/qbit-cms/db/changelog/`); the qbit never runs DDL.
Packages:
- `CmsQBitConfig`, `CmsFeature`, `CmsTables` (logical names and table definitions), `CmsRuntime`, `CmsSchemaCheck` (startup check), `CmsStartupMode`.
- `core/model`: CORE entities. Their `TABLE_NAME` and possible-value source names are logical; the builder adds the prefix.
- `media/model`, `blog/model`, `projects/model`, `photos/model`: the content features' entities and their value-list enums (same rule). A value list is registered in `CmsTables.VALUE_LISTS` and named on the field by its logical name.
- `metadata`: `CmsTableBuilder` (tables, possible values, joins, child lists, associations, permission rules), `CmsAppBuilder` and `CmsAreas` (apps and homes).
- `home`: `CmsHomeRenderer` and `CmsHtml` (one renderer for every home; reads run with `PermissionEnforcement.ENFORCE`).
- `security`: `CmsRole`, `CmsSecurity`, `CmsOpenReadsPermissionChecker`.
- Schema: `src/main/resources/qbit-cms/db/changelog/qbit-cms.changelog.yaml`. Its changesets are append-only once released, and `docs/ddl/postgres.sql` is generated from it.
## Naming (owner rule)
- Tables are lowercase snake_case prefixed with the full qbit name: `cms_<name>`. The QQQ table name and the backend (SQL) name are identical; possible-value sources take the table name.
+101 -11
View File
@@ -5,27 +5,117 @@
> QQQ QBit: a headless CMS (sites, pages, menus, blog, media, projects, photos and publishing) as standard QQQ tables.
**Status:** design approved: [QRun-IO/qqq#1083](https://github.com/QRun-IO/qqq/pull/1083) (see [docs/DESIGN.md](docs/DESIGN.md)); implementation in progress. Nothing is published yet.
**Status:** design approved in [QRun-IO/qqq#1083](https://github.com/QRun-IO/qqq/pull/1083) (see [docs/DESIGN.md](docs/DESIGN.md)). CORE, MEDIA, BLOG, PROJECTS and PHOTOS are implemented as tables with their admin screens. File upload, storage and renditions, the publishing processes, the content stream and the Site API are not built yet; PUBLISHING and STREAM are next.
The CMS is extracted from the kof22 website, which runs it in production. Its data lives in ordinary QQQ tables in your own database, secured by QQQ permissions. It brings an admin app with one home per area, and a schema you run with your own Liquibase.
## Requirements
- Java 21.
- QQQ 4.1 (built against `4.1.0-RC.4`) with an RDBMS backend (PostgreSQL in production, H2 for tests).
- QQQ 4.1 (built against `4.1.0-RC.4`) with an RDBMS backend: PostgreSQL 14+ in production, H2 for tests.
- QQQ Next UI 1.0 (`1.0.0-RC.14` or later). Material is not supported.
- Liquibase in your migration pipeline (or the reference DDL in `docs/ddl/postgres.sql`).
## Install
Not yet published. Once released, add `com.kingsrook.qbits:qbit-cms` and produce the qbit into your `QInstance`:
1. **Add the dependency** `com.kingsrook.qbits:qbit-cms` (once released).
2. **Run the schema.** Put the qbit jar on your Liquibase classpath and include its changelog. Set its properties *before* the include (the first definition wins):
```java
new CmsQBitProducer()
.withQBitConfig(new CmsQBitConfig().withBackendName("rdbms"))
.produce(qInstance);
```
```yaml
databaseChangeLog:
- property: { name: cms.tablePrefix, value: cms_ } # must equal CmsQBitConfig.tableNamePrefix
- property: { name: cms.features, value: "CORE,MEDIA,BLOG" } # the features you install (default: all)
- include: { file: qbit-cms/db/changelog/qbit-cms.changelog.yaml }
```
## Naming
The changelog is safe to include in a migration that must be repeatable: a second run changes nothing, the migration history included. The changelog never touches a table it did not create. If a table with one of its names already exists, it halts with a message telling you to choose another prefix. It seeds only generic reference data (redirect, page, section, media and blog types); set `cms.seedReferenceData` to `false` to skip that.
3. **Produce the qbit** after your backends (and the parent app, if any) are on the instance:
Tables are `cms_<name>` (lowercase snake_case, backend name equal to the table name). Permissions are `cms.<table>.<action>` and `cms.<action>`.
```java
new CmsQBitProducer()
.withQBitConfig(new CmsQBitConfig()
.withBackendName("rdbms")
.withRole("cms-admins", CmsRole.ADMIN)
.withRole("cms-editors", CmsRole.EDITOR))
.produce(qInstance);
```
4. **Grant permissions** from your authentication customizer: `CmsSecurity.applySessionPermissions(session, userGroups, config)`.
At startup the producer checks that the changelog ran for every enabled feature and that the tables exist. `startupMode` `FAIL_FAST` (the default) refuses to start and lists what is missing. `DEGRADED` starts and shows the problem on the CMS home. `SKIP` does not check (unit tests without a database).
## Configuration reference (`CmsQBitConfig`)
| Setting | Default | Meaning |
|---|---|---|
| `backendName` | required | The RDBMS backend for every CMS table |
| `tableNamePrefix` | `cms_` | Table name prefix (QQQ and SQL names are equal); must equal the changelog's `cms.tablePrefix` |
| `namePrefix` | `cms` | Prefix of app and widget names (`cmsPages`, `cmsPagesHome`) |
| `permissionBaseName` | `cms` | Base of qbit-wide permissions (`cms.admin`, `cms.publish`) |
| `features` | every available feature | `CmsFeature` set; `CORE` is required, and a feature this version does not implement yet is rejected |
| `appName`, `appLabel`, `parentAppName` | `cms`, `CMS`, none | The top app and where it nests in your app tree |
| `openReads` | `false` | When true, reading CMS tables needs no permission (writes always do) |
| `startupMode` | `FAIL_FAST` | `FAIL_FAST`, `DEGRADED` or `SKIP` (see above) |
| `roleMapping` | empty | Identity-provider group name to `CmsRole` |
A namespace (`withNamespace("siteTwo")`) fills in all three prefixes for a second install in the same instance (`site_two_page`, `siteTwoPages`, `site_two.admin`).
## Features
| Feature | Tables | Status |
|---|---|---|
| `CORE` | site, domain, redirect, redirect type, page, page type, page section, page section type, snippet, menu, menu item | available |
| `MEDIA` | media, media type | available: a media record points at a file by its address; upload, storage and renditions are not built yet |
| `BLOG` (needs `MEDIA`) | blog, blog type, author, blog tag, blog post, blog post tag, blog post media, related version | available |
| `PROJECTS` (needs `MEDIA`) | project category, project, project update | available |
| `PHOTOS` (needs `MEDIA`) | album folder, photo album, photo, photo tag, photo tag link | available |
| `PUBLISHING`, `STREAM`, `DATA_HEALTH_RULES` | see the design | planned |
A feature that is off produces no tables, and its changesets are skipped until a later migration run names it in `cms.features`. Every content feature needs `CORE`, and blogs, projects and photos need `MEDIA`; a feature whose needs are not named installs nothing. What links two features (a related version of a project, a photo album of a project) keeps its column either way and gets its lookup, its list on the parent record and its foreign key only when both features are on.
Fixed lists (rendition format, cache class, content channel, content format, version status, project status) are possible-value sources named with the table prefix, for example `cms_project_status`. A write with a value that is not on the list is refused with an error on the record, and the database has a check constraint on the same column.
## The admin
The qbit adds one app (`CMS`) with a home, and one sub-app per area, each with its own home:
- **Sites:** sites (domains are a list on each site) and redirects; Settings has redirect types.
- **Pages:** pages (sections and child pages are lists on each page) and snippets; Settings has page types and page section types.
- **Navigation:** menus (items are a list on each menu).
- **Media:** the media library; Settings has media types (upload rules, renditions, required text, cache and storage settings).
- **Blogs:** blog posts (tags, media and related versions are lists on each post), blogs (their tags are a list on each blog) and authors; Settings has blog types.
- **Projects:** projects (updates, photo albums and related versions are lists on each project) and project categories.
- **Photos:** photo albums (photos are a list on each album), album folders and photo tags.
Fields that hold an image's or a file's address show it as a preview (QQQ's file preview).
The nav shows only main tables and reference data; child tables are edited on their parents' records. Each home shows only real data read as the current user: counts, drafts, inactive rows and recently changed records, readable at any width in light and dark mode. The qbit never sets the instance's home app.
## Help
The qbit ships its own help for every app, home, table, section, field, child list and value list (`help/qbit-cms.yaml`). The producer registers it when you use the default names (`cms_`, `cms`); a host that has the QQQ help tables then shows it with nothing to write. With your own prefixes, write your own bundle from it. Bulk screens that QQQ generates per table are the host's, as for any table.
## Permissions
Every CMS table has QQQ permission rules. The table permissions are `<table>.read`, `.insert`, `.edit` and `.delete` (for example `cms_page.edit`). The qbit-wide permissions are `cms.admin` and `cms.publish`.
| Role | Grants |
|---|---|
| `ADMIN` | everything, including reference data, `cms.admin` and `cms.publish` |
| `EDITOR` | read everything; write content tables |
| `PUBLISHER` | `EDITOR` plus `cms.publish` |
| `DRAFTER` | read everything; insert and edit content (no deletes, no publishing) |
| `VIEWER` | read everything |
The qbit is built for QQQ core permission enforcement (`qInstance.setEnforcePermissionsInCoreActions(true)`, the default from QQQ 4.2).
## Operational tables
All CMS data is in normal, visible QQQ tables. Nothing is hidden and there is no side store. The schema is in `docs/ddl/postgres.sql` (generated from the changelog).
## Upgrading
Read the CHANGELOG's "Schema changes" before deploying. Run your migrations before the new app version. Released changesets never change; new versions only append changesets.
## Adopting in another app
@@ -37,7 +127,7 @@ Follow the QQQ [adoption checklist](https://github.com/QRun-IO/qqq/blob/develop/
./mvnw verify
```
Always use the Maven wrapper (Maven 3.9.11); Maven 3.10 cannot read the parent POM.
Always use the Maven wrapper (Maven 3.9.11); Maven 3.10 cannot read the parent POM. The PostgreSQL tests use Testcontainers and are skipped when Docker is not available.
## License
+2 -6
View File
@@ -1,15 +1,11 @@
/*
* QQQ - Low-code Application Framework for Engineers.
* Copyright (C) 2021-2025. Kingsrook, LLC
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
* contact@kingsrook.com
* https://github.com/Kingsrook/
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
File diff suppressed because it is too large. Load diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

+66 -3
View File
@@ -18,17 +18,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
<qqq.version>4.1.0-RC.26</qqq.version> <!-- feeds qbit-build-parent's qqq-bom-pom import -->
<revision>0.1.0-SNAPSHOT</revision>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<jacoco.version>0.8.15</jacoco.version>
<liquibase.version>4.33.0</liquibase.version>
<testcontainers.version>1.21.4</testcontainers.version>
</properties>
<parent>
<groupId>com.kingsrook</groupId>
<artifactId>qbit-build-parent</artifactId>
<version>2.0.0</version>
<version>2.2.1</version>
</parent>
<groupId>com.kingsrook.qbits</groupId>
@@ -94,6 +96,35 @@
<version>2.2.220</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.kingsrook.qqq</groupId>
<artifactId>qqq-backend-module-postgres</artifactId>
<scope>test</scope>
</dependency>
<!-- Demo server for local screenshots only (src/test/.../demo). -->
<dependency>
<groupId>com.kingsrook.qqq</groupId>
<artifactId>qqq-middleware-javalin</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.kingsrook.qqq</groupId>
<artifactId>qqq-frontend-next</artifactId>
<version>1.0.0-RC.38</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
@@ -104,6 +135,37 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.3.1</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.12.6</version>
</dependency>
</dependencies>
<configuration>
<configLocation>checkstyle/config.xml</configLocation>
<headerLocation>checkstyle/license.txt</headerLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>false</failsOnError>
<failOnViolation>true</failOnViolation>
<violationSeverity>warning</violationSeverity>
<includeTestSourceDirectory>false</includeTestSourceDirectory>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
@@ -155,14 +217,15 @@
<profiles>
<!-- Built against qqq 4.1 (QBitMetaDataProducer). Until qbit-build-parent -->
<!-- imports the released 4.1 BOM, this profile is active by default and -->
<!-- imports qqq-bom-pom 4.1.0-RC.4 ahead of the parent's 4.0.0 BOM. -->
<!-- imports qqq-bom-pom 4.1.0-RC.21 ahead of the parent's 4.0.0 BOM. -->
<profile>
<id>qqq-snapshot</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<qqq.snapshot.version>4.1.0-RC.4</qqq.snapshot.version>
<!-- The published QQQ 4.1 core (Central JAR/POM), the one BOM version shared by the four app-QBit patches. -->
<qqq.snapshot.version>4.1.0-RC.26</qqq.snapshot.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -0,0 +1,154 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
/*******************************************************************************
** The feature areas of the CMS (spec section 2.3). A host turns features on
** and off in CmsQBitConfig.features; a feature that is off produces no meta
** data, and its changesets are skipped by the cms.features changelog
** property.
**
** CORE is always on. A feature that is not built yet (available = false) is
** rejected by validation, so a host never believes it installed something
** that is not there.
*******************************************************************************/
public enum CmsFeature
{
/** Sites, domains, redirects, pages, page sections, snippets, menus. */
CORE(true),
/** The media library and media types: a media record points at a file by its address (no upload yet). */
MEDIA(true),
/** Blogs, posts, tags, authors, post media and related versions. */
BLOG(true, MEDIA),
/** Projects, project categories and project updates. */
PROJECTS(true, MEDIA),
/** Photo albums, folders, photos and photo tags. */
PHOTOS(true, MEDIA),
/** Publishing processes, publications and receipts. */
PUBLISHING(false),
/** The public content stream across content kinds. */
STREAM(false, BLOG),
/** CMS Data Health rules, for hosts with a Data Health framework (D10). */
DATA_HEALTH_RULES(false);
private final boolean available;
private final List<CmsFeature> requires;
/*******************************************************************************
** Constructor.
**
** @param available whether this version of the qbit implements the feature
** @param requires features this one needs
*******************************************************************************/
CmsFeature(boolean available, CmsFeature... requires)
{
this.available = available;
this.requires = List.of(requires);
}
/*******************************************************************************
** Whether this version of the qbit implements the feature.
*******************************************************************************/
public boolean isAvailable()
{
return (available);
}
/*******************************************************************************
** The features this one needs (beyond CORE, which is always on).
*******************************************************************************/
public List<CmsFeature> getRequires()
{
return (requires);
}
/*******************************************************************************
** Every feature this version implements: the default feature set.
*******************************************************************************/
public static Set<CmsFeature> allAvailable()
{
EnumSet<CmsFeature> rs = EnumSet.noneOf(CmsFeature.class);
for(CmsFeature feature : values())
{
if(feature.available)
{
rs.add(feature);
}
}
return (rs);
}
/*******************************************************************************
** Validation messages for a feature set: unknown-in-this-version features,
** missing dependencies, and PUBLISHING without BLOG or PROJECTS.
**
** @param features the requested features
** @return the problems (empty when valid)
*******************************************************************************/
public static List<String> validate(Set<CmsFeature> features)
{
List<String> errors = new ArrayList<>();
if(features == null || !features.contains(CORE))
{
errors.add("features must include CORE");
return (errors);
}
for(CmsFeature feature : features)
{
if(!feature.available)
{
errors.add("feature " + feature + " is not available in this version of qbit-cms");
}
for(CmsFeature required : feature.requires)
{
if(!features.contains(required))
{
errors.add("feature " + feature + " requires " + required);
}
}
}
if(features.contains(PUBLISHING) && !features.contains(BLOG) && !features.contains(PROJECTS))
{
errors.add("feature PUBLISHING requires BLOG or PROJECTS");
}
return (errors);
}
}
@@ -17,34 +17,89 @@
package com.kingsrook.qbits.cms;
import java.util.EnumSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.kingsrook.qbits.cms.security.CmsRole;
import com.kingsrook.qqq.backend.core.model.metadata.QBackendMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.qbits.QBitConfig;
import com.kingsrook.qqq.backend.core.utils.StringUtils;
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSBackendMetaData;
/*******************************************************************************
** Host-facing configuration for the CMS QBit.
** Host-facing configuration for the CMS QBit (spec section 2.4).
**
** Tables are named cms_<name> (lowercase snake_case, backend name equal
** to the table name); permissions are cms.<action>.
** Tables are named tableNamePrefix + lowercase snake_case (cms_page by
** default); the QQQ table name equals the backend (SQL) table name, and the
** prefix must equal the cms.tablePrefix property the host gives the
** changelog. Apps and widgets are named namePrefix + CamelCase (cmsPages).
** Table permissions are the table name plus .read, .insert, .edit or .delete
** (cms_page.edit); qbit-wide permissions are permissionBaseName + .action
** (cms.admin).
*******************************************************************************/
public class CmsQBitConfig implements QBitConfig
{
public static final String TABLE_NAME_PREFIX = "cms_";
public static final String PERMISSION_BASE_NAME = "cms";
public static final String DEFAULT_TABLE_NAME_PREFIX = "cms_";
public static final String DEFAULT_NAME_PREFIX = "cms";
public static final String DEFAULT_PERMISSION_BASE = "cms";
public static final String DEFAULT_APP_LABEL = "CMS";
public static final String CHANGELOG = "qbit-cms/db/changelog/qbit-cms.changelog.yaml";
public static final String CHANGELOG_LOGICAL_FILE_PATH = "qbit-cms/changelog";
private String backendName;
private static final Pattern TABLE_PREFIX = Pattern.compile("^[a-z][a-z0-9_]{0,20}_$");
private static final Pattern NAME_PREFIX = Pattern.compile("^[a-z][a-zA-Z0-9]{0,20}$");
private String backendName;
private String tableNamePrefix = DEFAULT_TABLE_NAME_PREFIX;
private String namePrefix = DEFAULT_NAME_PREFIX;
private String permissionBaseName = DEFAULT_PERMISSION_BASE;
private Set<CmsFeature> features = CmsFeature.allAvailable();
private String appName;
private String appLabel = DEFAULT_APP_LABEL;
private String parentAppName;
private Boolean openReads = false;
private CmsStartupMode startupMode = CmsStartupMode.FAIL_FAST;
private CmsSchemaVerification schemaVerification = CmsSchemaVerification.CHANGELOG_HISTORY;
private Map<String, CmsRole> roleMapping = new LinkedHashMap<>();
private CmsRuntime runtime;
/*******************************************************************************
** The backend must be named.
** Validate against the instance: an RDBMS backend, well-formed prefixes,
** a consistent feature set, and a parent app that exists.
*******************************************************************************/
@Override
public void validate(QInstance qInstance, List<String> errors)
{
assertCondition(StringUtils.hasContent(backendName), "backendName is required for the CMS QBit", errors);
if(assertCondition(StringUtils.hasContent(backendName), "backendName is required for the CMS QBit", errors))
{
QBackendMetaData backend = qInstance.getBackend(backendName);
if(assertCondition(backend != null, "backendName " + backendName + " is not a backend on this instance", errors))
{
assertCondition(backend instanceof RDBMSBackendMetaData, "backend " + backendName + " must be an RDBMS backend (the CMS uses SQL joins and views)", errors);
}
}
assertCondition(tableNamePrefix != null && TABLE_PREFIX.matcher(tableNamePrefix).matches(),
"tableNamePrefix must be lowercase letters, digits and underscores, ending in _ (for example cms_): " + tableNamePrefix, errors);
assertCondition(namePrefix != null && NAME_PREFIX.matcher(namePrefix).matches(),
"namePrefix must start with a lowercase letter and be letters and digits (for example cms): " + namePrefix, errors);
assertCondition(StringUtils.hasContent(permissionBaseName), "permissionBaseName is required", errors);
errors.addAll(CmsFeature.validate(features));
if(StringUtils.hasContent(parentAppName))
{
assertCondition(qInstance.getApp(parentAppName) != null, "parentAppName " + parentAppName + " is not an app on this instance (define it before producing the CMS)", errors);
}
assertCondition(roleMapping != null, "roleMapping may be empty but not null", errors);
assertCondition(startupMode != null, "startupMode is required", errors);
assertCondition(schemaVerification != null, "schemaVerification is required", errors);
}
@@ -60,6 +115,78 @@ public class CmsQBitConfig implements QBitConfig
/*******************************************************************************
** The physical (and QQQ) table name of a logical table name.
**
** @param logicalTableName e.g. "page"
** @return e.g. "cms_page"
*******************************************************************************/
public String applyPrefix(String logicalTableName)
{
return (tableNamePrefix + logicalTableName);
}
/*******************************************************************************
** A prefixed app, widget or process name.
**
** @param suffix e.g. "Pages" or "PagesHome"
** @return e.g. "cmsPages"
*******************************************************************************/
public String name(String suffix)
{
return (namePrefix + suffix);
}
/*******************************************************************************
** The name of the CMS top app (appName, else the name prefix).
*******************************************************************************/
public String getEffectiveAppName()
{
return (StringUtils.hasContent(appName) ? appName : namePrefix);
}
/*******************************************************************************
** A qbit-wide permission name.
**
** @param action e.g. "admin"
** @return e.g. "cms.admin"
*******************************************************************************/
public String permission(String action)
{
return (permissionBaseName + "." + action);
}
/*******************************************************************************
** Whether a feature is on.
*******************************************************************************/
public boolean hasFeature(CmsFeature feature)
{
return (features != null && features.contains(feature));
}
/*******************************************************************************
** Description for logs (the config holds no secrets yet).
*******************************************************************************/
@Override
public String toString()
{
return ("CmsQBitConfig{backendName=" + backendName + ", tableNamePrefix=" + tableNamePrefix + ", namePrefix=" + namePrefix
+ ", features=" + features + ", app=" + getEffectiveAppName() + ", parentAppName=" + parentAppName + ", openReads=" + openReads
+ ", startupMode=" + startupMode + ", roleMapping=" + roleMapping + "}");
}
/*******************************************************************************
** Getter for backendName
*******************************************************************************/
@@ -89,4 +216,382 @@ public class CmsQBitConfig implements QBitConfig
return (this);
}
/*******************************************************************************
** Getter for tableNamePrefix
*******************************************************************************/
public String getTableNamePrefix()
{
return (this.tableNamePrefix);
}
/*******************************************************************************
** Setter for tableNamePrefix
*******************************************************************************/
public void setTableNamePrefix(String tableNamePrefix)
{
this.tableNamePrefix = tableNamePrefix;
}
/*******************************************************************************
** Fluent setter for tableNamePrefix
*******************************************************************************/
public CmsQBitConfig withTableNamePrefix(String tableNamePrefix)
{
this.tableNamePrefix = tableNamePrefix;
return (this);
}
/*******************************************************************************
** Getter for namePrefix
*******************************************************************************/
public String getNamePrefix()
{
return (this.namePrefix);
}
/*******************************************************************************
** Setter for namePrefix
*******************************************************************************/
public void setNamePrefix(String namePrefix)
{
this.namePrefix = namePrefix;
}
/*******************************************************************************
** Fluent setter for namePrefix
*******************************************************************************/
public CmsQBitConfig withNamePrefix(String namePrefix)
{
this.namePrefix = namePrefix;
return (this);
}
/*******************************************************************************
** Getter for permissionBaseName
*******************************************************************************/
public String getPermissionBaseName()
{
return (this.permissionBaseName);
}
/*******************************************************************************
** Setter for permissionBaseName
*******************************************************************************/
public void setPermissionBaseName(String permissionBaseName)
{
this.permissionBaseName = permissionBaseName;
}
/*******************************************************************************
** Fluent setter for permissionBaseName
*******************************************************************************/
public CmsQBitConfig withPermissionBaseName(String permissionBaseName)
{
this.permissionBaseName = permissionBaseName;
return (this);
}
/*******************************************************************************
** Getter for features
*******************************************************************************/
public Set<CmsFeature> getFeatures()
{
return (this.features);
}
/*******************************************************************************
** Setter for features
*******************************************************************************/
public void setFeatures(Set<CmsFeature> features)
{
this.features = features == null || features.isEmpty() ? EnumSet.noneOf(CmsFeature.class) : EnumSet.copyOf(features);
}
/*******************************************************************************
** Fluent setter for features
*******************************************************************************/
public CmsQBitConfig withFeatures(Set<CmsFeature> features)
{
setFeatures(features);
return (this);
}
/*******************************************************************************
** Getter for appName
*******************************************************************************/
public String getAppName()
{
return (this.appName);
}
/*******************************************************************************
** Setter for appName
*******************************************************************************/
public void setAppName(String appName)
{
this.appName = appName;
}
/*******************************************************************************
** Fluent setter for appName
*******************************************************************************/
public CmsQBitConfig withAppName(String appName)
{
this.appName = appName;
return (this);
}
/*******************************************************************************
** Getter for appLabel
*******************************************************************************/
public String getAppLabel()
{
return (this.appLabel);
}
/*******************************************************************************
** Setter for appLabel
*******************************************************************************/
public void setAppLabel(String appLabel)
{
this.appLabel = appLabel;
}
/*******************************************************************************
** Fluent setter for appLabel
*******************************************************************************/
public CmsQBitConfig withAppLabel(String appLabel)
{
this.appLabel = appLabel;
return (this);
}
/*******************************************************************************
** Getter for parentAppName
*******************************************************************************/
public String getParentAppName()
{
return (this.parentAppName);
}
/*******************************************************************************
** Setter for parentAppName
*******************************************************************************/
public void setParentAppName(String parentAppName)
{
this.parentAppName = parentAppName;
}
/*******************************************************************************
** Fluent setter for parentAppName
*******************************************************************************/
public CmsQBitConfig withParentAppName(String parentAppName)
{
this.parentAppName = parentAppName;
return (this);
}
/*******************************************************************************
** Getter for openReads
*******************************************************************************/
public Boolean getOpenReads()
{
return (this.openReads);
}
/*******************************************************************************
** Setter for openReads
*******************************************************************************/
public void setOpenReads(Boolean openReads)
{
this.openReads = openReads;
}
/*******************************************************************************
** Fluent setter for openReads: when true, reading CMS tables needs no
** permission (writes always do).
*******************************************************************************/
public CmsQBitConfig withOpenReads(Boolean openReads)
{
this.openReads = openReads;
return (this);
}
/*******************************************************************************
** Getter for schemaVerification
*******************************************************************************/
public CmsSchemaVerification getSchemaVerification()
{
return (this.schemaVerification);
}
/*******************************************************************************
** Setter for schemaVerification
*******************************************************************************/
public void setSchemaVerification(CmsSchemaVerification schemaVerification)
{
this.schemaVerification = schemaVerification;
}
/*******************************************************************************
** Fluent setter for schemaVerification
*******************************************************************************/
public CmsQBitConfig withSchemaVerification(CmsSchemaVerification schemaVerification)
{
this.schemaVerification = schemaVerification;
return (this);
}
/*******************************************************************************
** Getter for startupMode
*******************************************************************************/
public CmsStartupMode getStartupMode()
{
return (this.startupMode);
}
/*******************************************************************************
** Setter for startupMode
*******************************************************************************/
public void setStartupMode(CmsStartupMode startupMode)
{
this.startupMode = startupMode;
}
/*******************************************************************************
** Fluent setter for startupMode
*******************************************************************************/
public CmsQBitConfig withStartupMode(CmsStartupMode startupMode)
{
this.startupMode = startupMode;
return (this);
}
/*******************************************************************************
** Getter for roleMapping
*******************************************************************************/
public Map<String, CmsRole> getRoleMapping()
{
return (this.roleMapping);
}
/*******************************************************************************
** Setter for roleMapping
*******************************************************************************/
public void setRoleMapping(Map<String, CmsRole> roleMapping)
{
this.roleMapping = roleMapping;
}
/*******************************************************************************
** Fluent setter for roleMapping: identity-provider group name to CMS role.
*******************************************************************************/
public CmsQBitConfig withRoleMapping(Map<String, CmsRole> roleMapping)
{
this.roleMapping = roleMapping;
return (this);
}
/*******************************************************************************
** The install's runtime state, set when the qbit is produced (not part of
** the config's JSON: tables carry their source qbit config to the frontend).
*******************************************************************************/
@JsonIgnore
public CmsRuntime getRuntime()
{
return (this.runtime);
}
/*******************************************************************************
** Setter for runtime (the producer sets it).
*******************************************************************************/
public void setRuntime(CmsRuntime runtime)
{
this.runtime = runtime;
}
/*******************************************************************************
** Fluent adder for one roleMapping entry.
*******************************************************************************/
public CmsQBitConfig withRole(String groupName, CmsRole role)
{
if(this.roleMapping == null)
{
this.roleMapping = new LinkedHashMap<>();
}
this.roleMapping.put(groupName, role);
return (this);
}
}
@@ -17,22 +17,61 @@
package com.kingsrook.qbits.cms;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import com.kingsrook.qbits.cms.metadata.CmsAppBuilder;
import com.kingsrook.qbits.cms.metadata.CmsTableBuilder;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.logging.QLogger;
import com.kingsrook.qqq.backend.core.model.metadata.MetaDataProducerMultiOutput;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.dashboard.QWidgetMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.help.bundles.HelpBundles;
import com.kingsrook.qqq.backend.core.model.metadata.joins.QJoinMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.QPossibleValueSource;
import com.kingsrook.qqq.backend.core.model.metadata.qbits.QBitMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.qbits.QBitMetaDataProducer;
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
import com.kingsrook.qqq.backend.core.utils.StringUtils;
import static com.kingsrook.qqq.backend.core.logging.LogUtils.logPair;
/*******************************************************************************
** Produces the CMS QBit. Component producers in this package are found by
** package scanning.
** Produces the CMS QBit: standard QQQ tables for the enabled features, their
** possible-value sources, joins and child lists, the CMS app with one home
** per area, and permission rules on everything (spec QRun-IO/qqq#1083).
**
** <pre>
** new CmsQBitProducer()
** .withQBitConfig(new CmsQBitConfig()
** .withBackendName("rdbms")
** .withRole("cms-admins", CmsRole.ADMIN))
** .produce(qInstance);
** </pre>
**
** The database comes from the qbit's Liquibase changelog
** (CmsQBitConfig.CHANGELOG), which the host includes and runs; its
** cms.tablePrefix property must equal the config's tableNamePrefix. At
** startup the producer checks that the changelog ran (startupMode).
**
** The producer builds everything itself instead of scanning for component
** producers, so the output depends only on the config.
*******************************************************************************/
public class CmsQBitProducer implements QBitMetaDataProducer<CmsQBitConfig>
{
private static final QLogger LOG = QLogger.getLogger(CmsQBitProducer.class);
public static final String GROUP_ID = "com.kingsrook.qbits";
public static final String ARTIFACT_ID = "qbit-cms";
public static final String VERSION = "0.1.0";
/** The qbit's own help: every app, home, table, section, field, child list and value list, under the default names. */
public static final String HELP_BUNDLE = "help/qbit-cms.yaml";
private CmsQBitConfig qBitConfig;
private String namespace;
private String namespace;
@@ -59,7 +98,9 @@ public class CmsQBitProducer implements QBitMetaDataProducer<CmsQBitConfig>
/*******************************************************************************
** Fluent setter for the namespace.
** Fluent setter for the namespace. A second install in one instance needs
** its own namespace; the namespace becomes the table prefix, name prefix
** and permission base unless the config sets them.
*******************************************************************************/
public CmsQBitProducer withNamespace(String namespace)
{
@@ -100,4 +141,148 @@ public class CmsQBitProducer implements QBitMetaDataProducer<CmsQBitConfig>
return (qBitConfig != null);
}
/*******************************************************************************
** Validate, build and add everything to the instance, then check the
** schema. Returns an empty output, so a host that also adds the output to
** the instance adds nothing twice.
*******************************************************************************/
@Override
public MetaDataProducerMultiOutput produce(QInstance qInstance) throws QException
{
if(qBitConfig == null)
{
throw (new QException("CMS QBit configuration validation failed: no config was supplied (call withQBitConfig)"));
}
applyNamespace();
List<String> errors = new ArrayList<>();
qBitConfig.validate(qInstance, errors);
if(!errors.isEmpty())
{
throw (new QException("CMS QBit configuration validation failed: " + String.join("; ", errors)));
}
CmsTableBuilder.Built tables = new CmsTableBuilder(qBitConfig).build(qInstance);
CmsAppBuilder.Built apps = new CmsAppBuilder(qBitConfig).build();
MetaDataProducerMultiOutput output = new MetaDataProducerMultiOutput();
tables.tables().values().forEach(output::add);
tables.possibleValueSources().forEach(output::add);
tables.joins().forEach(output::add);
tables.widgets().forEach(output::add);
apps.widgets().forEach(output::add);
apps.apps().forEach(output::add);
List<String> collisions = collisions(qInstance, output);
if(!collisions.isEmpty())
{
throw (new QException("CMS QBit names collide with names already on the instance (set a different tableNamePrefix and namePrefix, or a namespace): "
+ String.join(", ", collisions)));
}
QBitMetaData qBitMetaData = getQBitMetaData();
qInstance.addQBit(qBitMetaData);
for(QTableMetaData table : output.getEach(QTableMetaData.class))
{
if(qBitConfig.getTableMetaDataCustomizer() != null)
{
qBitConfig.getTableMetaDataCustomizer().customizeMetaData(qInstance, table);
}
table.setSourceQBitName(qBitMetaData.getName());
}
output.addSelfToInstance(qInstance);
/////////////////////////////////////////////////////////////////////////
// the help is written for the default names; with them it is registered //
// (metadata only: a host without help tables is not affected, and a //
// host with its own prefixes writes its own) //
/////////////////////////////////////////////////////////////////////////
if(CmsQBitConfig.DEFAULT_TABLE_NAME_PREFIX.equals(qBitConfig.getTableNamePrefix()) && CmsQBitConfig.DEFAULT_NAME_PREFIX.equals(qBitConfig.getNamePrefix()))
{
HelpBundles.register(qInstance, HELP_BUNDLE);
}
if(StringUtils.hasContent(qBitConfig.getParentAppName()))
{
qInstance.getApp(qBitConfig.getParentAppName()).withChild(qInstance.getApp(qBitConfig.getEffectiveAppName()));
}
postProduceActions(output, qInstance);
return (new MetaDataProducerMultiOutput());
}
/*******************************************************************************
** Check the schema per the startup mode and set the runtime.
*******************************************************************************/
@Override
public void postProduceActions(MetaDataProducerMultiOutput output, QInstance qInstance) throws QException
{
List<String> problems = qBitConfig.getStartupMode() == CmsStartupMode.SKIP ? List.of() : CmsSchemaCheck.check(qInstance, qBitConfig);
if(!problems.isEmpty() && qBitConfig.getStartupMode() == CmsStartupMode.FAIL_FAST)
{
throw (new QException("The CMS database is not up to date (startupMode FAIL_FAST): " + String.join(" ", problems)));
}
if(!problems.isEmpty())
{
LOG.warn("The CMS database is not up to date; starting degraded", logPair("problems", problems));
}
qBitConfig.setRuntime(new CmsRuntime(problems));
LOG.info("CMS QBit produced", logPair("version", VERSION), logPair("backendName", qBitConfig.getBackendName()),
logPair("tablePrefix", qBitConfig.getTableNamePrefix()), logPair("features", qBitConfig.getFeatures()),
logPair("app", qBitConfig.getEffectiveAppName()), logPair("startupMode", qBitConfig.getStartupMode()));
}
/*******************************************************************************
** A namespace fills in prefixes the config leaves at their defaults.
*******************************************************************************/
private void applyNamespace()
{
if(!StringUtils.hasContent(namespace))
{
return;
}
String snake = namespace.replaceAll("([a-z0-9])([A-Z])", "$1_$2").toLowerCase(Locale.ROOT).replaceAll("[^a-z0-9_]", "_");
if(CmsQBitConfig.DEFAULT_TABLE_NAME_PREFIX.equals(qBitConfig.getTableNamePrefix()))
{
qBitConfig.setTableNamePrefix(snake.endsWith("_") ? snake : snake + "_");
}
if(CmsQBitConfig.DEFAULT_NAME_PREFIX.equals(qBitConfig.getNamePrefix()))
{
StringBuilder camel = new StringBuilder();
for(String part : snake.split("_"))
{
if(!part.isEmpty())
{
camel.append(camel.isEmpty() ? part : Character.toUpperCase(part.charAt(0)) + part.substring(1));
}
}
qBitConfig.setNamePrefix(camel.toString());
}
if(CmsQBitConfig.DEFAULT_PERMISSION_BASE.equals(qBitConfig.getPermissionBaseName()))
{
qBitConfig.setPermissionBaseName(snake.replaceAll("_+$", ""));
}
}
/*******************************************************************************
** Names the qbit would add that the instance already has.
*******************************************************************************/
static List<String> collisions(QInstance qInstance, MetaDataProducerMultiOutput output)
{
List<String> rs = new ArrayList<>();
output.getEach(QTableMetaData.class).stream().filter(t -> qInstance.getTable(t.getName()) != null).forEach(t -> rs.add("table " + t.getName()));
output.getEach(QPossibleValueSource.class).stream().filter(p -> qInstance.getPossibleValueSource(p.getName()) != null).forEach(p -> rs.add("possible-value source " + p.getName()));
output.getEach(QJoinMetaData.class).stream().filter(j -> qInstance.getJoin(j.getName()) != null).forEach(j -> rs.add("join " + j.getName()));
output.getEach(QWidgetMetaData.class).stream().filter(w -> qInstance.getWidget(w.getName()) != null).forEach(w -> rs.add("widget " + w.getName()));
output.getEach(QAppMetaData.class).stream().filter(a -> qInstance.getApp(a.getName()) != null).forEach(a -> rs.add("app " + a.getName()));
return (rs);
}
}
@@ -0,0 +1,83 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
import java.util.List;
import java.util.Optional;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.qbits.QBitMetaData;
/*******************************************************************************
** Runtime state of one CMS install, held by its config: the result of the
** startup schema check. Code that runs per request (widget renderers, processes)
** finds it by the install's name prefix, so two installs in one instance
** (two namespaces) stay apart.
*******************************************************************************/
public class CmsRuntime
{
private final List<String> schemaProblems;
/*******************************************************************************
** Constructor.
**
** @param schemaProblems what the startup schema check found (empty when fine
** or not checked)
*******************************************************************************/
public CmsRuntime(List<String> schemaProblems)
{
this.schemaProblems = List.copyOf(schemaProblems);
}
/*******************************************************************************
** The config of the CMS install with a name prefix on an instance.
**
** @param qInstance the instance
** @param namePrefix the install's name prefix (CmsQBitConfig.namePrefix)
** @return the config, if installed
*******************************************************************************/
public static Optional<CmsQBitConfig> findConfig(QInstance qInstance, String namePrefix)
{
if(qInstance == null || qInstance.getQBits() == null)
{
return (Optional.empty());
}
for(QBitMetaData qBit : qInstance.getQBits().values())
{
if(qBit.getConfig() instanceof CmsQBitConfig config && config.getNamePrefix().equals(namePrefix))
{
return (Optional.of(config));
}
}
return (Optional.empty());
}
/*******************************************************************************
** Getter for schemaProblems
*******************************************************************************/
public List<String> getSchemaProblems()
{
return (schemaProblems);
}
}
@@ -0,0 +1,211 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import com.kingsrook.qbits.cms.metadata.CmsTableDefinition;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
import com.kingsrook.qqq.backend.module.rdbms.jdbc.ConnectionManager;
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSBackendMetaData;
/*******************************************************************************
** The startup schema check, the "install doctor" (spec section 3.4): the
** qbit's changelog has run for every enabled feature (its create changesets
** are recorded in DATABASECHANGELOG under the qbit's logical file path) and
** every enabled table exists. The qbit never creates or alters anything; it
** only reports, and the startup mode decides whether that stops the app.
*******************************************************************************/
public final class CmsSchemaCheck
{
/** The baseline version of the changesets that create the tables. */
static final String BASELINE = "1.0.0";
/*******************************************************************************
** Not instantiable.
*******************************************************************************/
private CmsSchemaCheck()
{
}
/*******************************************************************************
** The problems with the database behind a config (empty when it is fine).
**
** @param qInstance the instance (for the backend)
** @param config the CMS config
** @return one message per problem
*******************************************************************************/
public static List<String> check(QInstance qInstance, CmsQBitConfig config)
{
List<String> problems = new ArrayList<>();
try(Connection connection = ConnectionManager.getConnection((RDBMSBackendMetaData) qInstance.getBackend(config.getBackendName())))
{
if(config.getSchemaVerification() == CmsSchemaVerification.CATALOG)
{
return (checkCatalog(qInstance, config, connection));
}
Set<String> recorded = recordedChangesets(connection);
if(recorded == null)
{
problems.add("The qbit-cms changelog has not been run: there is no DATABASECHANGELOG table. Include "
+ CmsQBitConfig.CHANGELOG + " in your Liquibase changelog and run your migrations.");
return (problems);
}
for(CmsTableDefinition definition : CmsTables.definitions(config))
{
String table = config.applyPrefix(definition.logicalName());
if(!recorded.contains(BASELINE + "-create-" + definition.logicalName()))
{
problems.add("Changeset " + BASELINE + "-create-" + definition.logicalName() + " (" + table + ") has not run: run your migrations with "
+ "cms.tablePrefix=" + config.getTableNamePrefix() + " and the " + definition.feature() + " feature in cms.features.");
}
else if(!tableExists(connection, table))
{
problems.add("Table " + table + " is missing although its changeset is recorded.");
}
}
}
catch(SQLException e)
{
problems.add("Could not check the CMS schema: " + e.getMessage());
}
return (problems);
}
/*******************************************************************************
** Verify from the database catalog alone: each table of the installed features
** exists and has every column the qbit maps. Never reads Liquibase tables, so it
** works for an identity that has only table privileges.
*******************************************************************************/
static List<String> checkCatalog(QInstance qInstance, CmsQBitConfig config, Connection connection) throws SQLException
{
List<String> problems = new ArrayList<>();
for(CmsTableDefinition definition : CmsTables.definitions(config))
{
String table = config.applyPrefix(definition.logicalName());
if(!tableExists(connection, table))
{
problems.add("Table " + table + " is missing: run the qbit-cms changelog with cms.tablePrefix=" + config.getTableNamePrefix()
+ " and the " + definition.feature() + " feature in cms.features.");
continue;
}
QTableMetaData metaData = qInstance.getTable(table);
if(metaData == null)
{
continue;
}
Set<String> columns = columnsOf(connection, table);
for(QFieldMetaData field : metaData.getFields().values())
{
String column = field.getBackendName() != null ? field.getBackendName() : field.getName();
if(!columns.contains(column.toLowerCase(Locale.ROOT)))
{
problems.add("Column " + table + "." + column + " is missing: the database is behind this version of qbit-cms.");
}
}
}
return (problems);
}
/*******************************************************************************
** The lower-cased column names of a table, from the catalog.
*******************************************************************************/
static Set<String> columnsOf(Connection connection, String table) throws SQLException
{
Set<String> columns = new HashSet<>();
DatabaseMetaData metaData = connection.getMetaData();
for(String candidate : List.of(table, table.toUpperCase(Locale.ROOT), table.toLowerCase(Locale.ROOT)))
{
try(ResultSet resultSet = metaData.getColumns(connection.getCatalog(), null, candidate, null))
{
while(resultSet.next())
{
columns.add(resultSet.getString("COLUMN_NAME").toLowerCase(Locale.ROOT));
}
}
}
return (columns);
}
/*******************************************************************************
** The qbit's recorded changeset ids, or null when Liquibase has never run.
*******************************************************************************/
static Set<String> recordedChangesets(Connection connection) throws SQLException
{
if(!tableExists(connection, "databasechangelog"))
{
return (null);
}
Set<String> ids = new HashSet<>();
try(PreparedStatement statement = connection.prepareStatement("SELECT ID FROM DATABASECHANGELOG WHERE FILENAME = ?"))
{
statement.setString(1, CmsQBitConfig.CHANGELOG_LOGICAL_FILE_PATH);
try(ResultSet resultSet = statement.executeQuery())
{
while(resultSet.next())
{
ids.add(resultSet.getString(1));
}
}
}
return (ids);
}
/*******************************************************************************
** Whether a table (or view) exists, in any case the database folds names to.
*******************************************************************************/
static boolean tableExists(Connection connection, String name) throws SQLException
{
DatabaseMetaData metaData = connection.getMetaData();
for(String candidate : List.of(name, name.toUpperCase(Locale.ROOT), name.toLowerCase(Locale.ROOT)))
{
try(ResultSet resultSet = metaData.getTables(connection.getCatalog(), null, candidate, new String[] { "TABLE", "VIEW" }))
{
if(resultSet.next())
{
return (true);
}
}
}
return (false);
}
}
@@ -0,0 +1,39 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
/*******************************************************************************
** What the startup schema check reads to decide the database is up to date.
*******************************************************************************/
public enum CmsSchemaVerification
{
/**
* The Liquibase history (DATABASECHANGELOG) records every changeset and the tables exist
* (the original check). Needs read access to the history table, which a DML-only
* runtime identity does not have.
*/
CHANGELOG_HISTORY,
/**
* Only the database catalog: every table of the installed features exists and has every
* column the qbit's metadata maps. Needs no Liquibase tables and no privilege beyond
* connecting, so it is the check for a runtime identity that owns nothing and may not
* read migration history.
*/
CATALOG
}
@@ -0,0 +1,34 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
/*******************************************************************************
** What the qbit does when its startup schema check finds the database
** behind the code (spec section 3.4, the "install doctor").
*******************************************************************************/
public enum CmsStartupMode
{
/** Refuse to start, listing what is missing (the production default). */
FAIL_FAST,
/** Start, log the problems and show them on the CMS home. */
DEGRADED,
/** Do not check (unit tests that build meta data without a database). */
SKIP
}
@@ -0,0 +1,397 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import com.kingsrook.qbits.cms.blog.model.CmsAuthor;
import com.kingsrook.qbits.cms.blog.model.CmsBlog;
import com.kingsrook.qbits.cms.blog.model.CmsBlogPost;
import com.kingsrook.qbits.cms.blog.model.CmsBlogPostMedia;
import com.kingsrook.qbits.cms.blog.model.CmsBlogPostTag;
import com.kingsrook.qbits.cms.blog.model.CmsBlogPostVersion;
import com.kingsrook.qbits.cms.blog.model.CmsBlogTag;
import com.kingsrook.qbits.cms.blog.model.CmsBlogType;
import com.kingsrook.qbits.cms.blog.model.CmsContentChannel;
import com.kingsrook.qbits.cms.blog.model.CmsContentFormat;
import com.kingsrook.qbits.cms.blog.model.CmsContentVersionStatus;
import com.kingsrook.qbits.cms.core.model.CmsDomain;
import com.kingsrook.qbits.cms.core.model.CmsMenu;
import com.kingsrook.qbits.cms.core.model.CmsMenuItem;
import com.kingsrook.qbits.cms.core.model.CmsPage;
import com.kingsrook.qbits.cms.core.model.CmsPageSection;
import com.kingsrook.qbits.cms.core.model.CmsPageSectionType;
import com.kingsrook.qbits.cms.core.model.CmsPageType;
import com.kingsrook.qbits.cms.core.model.CmsRedirect;
import com.kingsrook.qbits.cms.core.model.CmsRedirectType;
import com.kingsrook.qbits.cms.core.model.CmsSite;
import com.kingsrook.qbits.cms.core.model.CmsSnippet;
import com.kingsrook.qbits.cms.media.model.CmsMedia;
import com.kingsrook.qbits.cms.media.model.CmsMediaCacheClass;
import com.kingsrook.qbits.cms.media.model.CmsMediaRenditionFormat;
import com.kingsrook.qbits.cms.media.model.CmsMediaType;
import com.kingsrook.qbits.cms.metadata.CmsTableDefinition;
import com.kingsrook.qbits.cms.metadata.CmsTableDefinition.Kind;
import com.kingsrook.qbits.cms.photos.model.CmsPhoto;
import com.kingsrook.qbits.cms.photos.model.CmsPhotoAlbum;
import com.kingsrook.qbits.cms.photos.model.CmsPhotoAlbumFolder;
import com.kingsrook.qbits.cms.photos.model.CmsPhotoTag;
import com.kingsrook.qbits.cms.photos.model.CmsPhotoTagLink;
import com.kingsrook.qbits.cms.projects.model.CmsProject;
import com.kingsrook.qbits.cms.projects.model.CmsProjectCategory;
import com.kingsrook.qbits.cms.projects.model.CmsProjectStatus;
import com.kingsrook.qbits.cms.projects.model.CmsProjectUpdate;
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.PossibleValueEnum;
import com.kingsrook.qqq.backend.core.model.metadata.tables.Tier;
/*******************************************************************************
** The CMS tables: logical names (the physical name is the configured prefix
** plus the logical name, CmsQBitConfig.applyPrefix) and their definitions.
** Java code names CMS tables only through these constants and the config, so
** a host can choose any prefix (spec section 2.4).
*******************************************************************************/
public final class CmsTables
{
public static final String SITE = CmsSite.TABLE_NAME;
public static final String DOMAIN = CmsDomain.TABLE_NAME;
public static final String REDIRECT = CmsRedirect.TABLE_NAME;
public static final String REDIRECT_TYPE = CmsRedirectType.TABLE_NAME;
public static final String PAGE = CmsPage.TABLE_NAME;
public static final String PAGE_TYPE = CmsPageType.TABLE_NAME;
public static final String PAGE_SECTION = CmsPageSection.TABLE_NAME;
public static final String PAGE_SECTION_TYPE = CmsPageSectionType.TABLE_NAME;
public static final String SNIPPET = CmsSnippet.TABLE_NAME;
public static final String MENU = CmsMenu.TABLE_NAME;
public static final String MENU_ITEM = CmsMenuItem.TABLE_NAME;
public static final String MEDIA_TYPE = CmsMediaType.TABLE_NAME;
public static final String MEDIA = CmsMedia.TABLE_NAME;
public static final String BLOG_TYPE = CmsBlogType.TABLE_NAME;
public static final String BLOG = CmsBlog.TABLE_NAME;
public static final String AUTHOR = CmsAuthor.TABLE_NAME;
public static final String BLOG_TAG = CmsBlogTag.TABLE_NAME;
public static final String BLOG_POST = CmsBlogPost.TABLE_NAME;
public static final String BLOG_POST_TAG_INT = CmsBlogPostTag.TABLE_NAME;
public static final String BLOG_POST_MEDIA = CmsBlogPostMedia.TABLE_NAME;
public static final String BLOG_POST_VERSION = CmsBlogPostVersion.TABLE_NAME;
public static final String PROJECT_CATEGORY = CmsProjectCategory.TABLE_NAME;
public static final String PROJECT = CmsProject.TABLE_NAME;
public static final String PROJECT_UPDATE = CmsProjectUpdate.TABLE_NAME;
public static final String PHOTO_ALBUM_FOLDER = CmsPhotoAlbumFolder.TABLE_NAME;
public static final String PHOTO_ALBUM = CmsPhotoAlbum.TABLE_NAME;
public static final String PHOTO = CmsPhoto.TABLE_NAME;
public static final String PHOTO_TAG = CmsPhotoTag.TABLE_NAME;
public static final String PHOTO_TAG_INT = CmsPhotoTagLink.TABLE_NAME;
private static final List<CmsTableDefinition> DEFINITIONS = List.of(
CmsTableDefinition.builder(SITE, CmsSite.class, CmsFeature.CORE, "Site", "language", Kind.MAIN)
.recordLabel("name")
.section("site", "Site", "language", Tier.T1, "id", "name", "shortName", "description")
.child(DOMAIN, "siteId", "Domains", null, "name")
.unique("name")
.build(),
CmsTableDefinition.builder(DOMAIN, CmsDomain.class, CmsFeature.CORE, "Domain", "dns", Kind.CHILD)
.recordLabel("fqdn")
.section("domain", "Domain", "dns", Tier.T1, "id", "fqdn", "siteId", "isPrimary", "name", "shortName", "description")
.unique("shortName").unique("name").unique("fqdn")
.build(),
CmsTableDefinition.builder(REDIRECT, CmsRedirect.class, CmsFeature.CORE, "Redirect", "open_in_new", Kind.MAIN)
.section("redirect", "Redirect", "open_in_new", Tier.T1, "id", "name", "sourcePath", "targetPath", "redirectTypeId", "siteId", "description")
.section("matching", "Matching", "tune", Tier.T2, "matchType", "priority", "preserveQueryParams", "isActive", "expiryDate")
.section("usage", "Usage", "query_stats", Tier.T2, "hitCount", "lastHitDate")
.build(),
CmsTableDefinition.builder(REDIRECT_TYPE, CmsRedirectType.class, CmsFeature.CORE, "Redirect Type", "alt_route", Kind.REFERENCE)
.section("redirectType", "Redirect Type", "alt_route", Tier.T1, "id", "name", "code", "httpStatusCode", "isActive", "sortOrder", "description")
.unique("code")
.build(),
CmsTableDefinition.builder(PAGE, CmsPage.class, CmsFeature.CORE, "Page", "description", Kind.MAIN)
.recordLabel("title")
.section("page", "Page", "description", Tier.T1, "id", "title", "name", "slug", "siteId", "pageTypeId", "template", "isPublished", "publishDate")
.section("content", "Content", "notes", Tier.T2, "content")
.section("structure", "Structure", "account_tree", Tier.T2, "parentPageId", "sortOrder")
.section("seo", "SEO", "travel_explore", Tier.T2, "metaDescription", "metaKeywords", "ogImage")
.child(PAGE_SECTION, "pageId", "Sections", "sections", "sortOrder")
.child(PAGE, "parentPageId", "Child Pages", null, "sortOrder")
.unique("slug", "siteId").unique("slug", "parentPageId")
.text("content")
.build(),
CmsTableDefinition.builder(PAGE_TYPE, CmsPageType.class, CmsFeature.CORE, "Page Type", "layers", Kind.REFERENCE)
.section("pageType", "Page Type", "layers", Tier.T1, "id", "name", "code", "isActive", "sortOrder", "description")
.unique("name").unique("code")
.build(),
CmsTableDefinition.builder(PAGE_SECTION, CmsPageSection.class, CmsFeature.CORE, "Page Section", "view_agenda", Kind.CHILD)
.section("pageSection", "Page Section", "view_agenda", Tier.T1, "id", "name", "pageId", "sectionTypeId", "sortOrder", "cssClassName")
.section("content", "Content", "notes", Tier.T2, "content")
.text("content")
.build(),
CmsTableDefinition.builder(PAGE_SECTION_TYPE, CmsPageSectionType.class, CmsFeature.CORE, "Page Section Type", "category", Kind.REFERENCE)
.section("pageSectionType", "Page Section Type", "category", Tier.T1, "id", "name", "code", "isActive", "sortOrder", "description")
.unique("code").unique("name")
.build(),
CmsTableDefinition.builder(SNIPPET, CmsSnippet.class, CmsFeature.CORE, "Snippet", "code", Kind.MAIN)
.section("snippet", "Snippet", "code", Tier.T1, "id", "name", "shortName", "siteId", "isActive", "sortOrder", "cssClassName")
.section("content", "Content", "notes", Tier.T2, "content")
.unique("shortName", "siteId")
.text("content")
.build(),
CmsTableDefinition.builder(MENU, CmsMenu.class, CmsFeature.CORE, "Menu", "menu", Kind.MAIN)
.section("menu", "Menu", "menu", Tier.T1, "id", "name", "slug", "menuType", "siteId", "isActive", "description")
.child(MENU_ITEM, "menuId", "Items", "items", "displayOrder")
.unique("slug", "siteId")
.build(),
CmsTableDefinition.builder(MENU_ITEM, CmsMenuItem.class, CmsFeature.CORE, "Menu Item", "link", Kind.CHILD)
.section("menuItem", "Menu Item", "link", Tier.T1, "id", "name", "slug", "menuId", "parentId", "itemType", "displayOrder", "isActive")
.section("target", "Link", "open_in_new", Tier.T2, "linkUrl", "routePath", "target")
.section("display", "Display", "palette", Tier.T2, "icon", "cssClasses", "description")
.child(MENU_ITEM, "parentId", "Child Items", null, "displayOrder")
.build(),
CmsTableDefinition.builder(MEDIA_TYPE, CmsMediaType.class, CmsFeature.MEDIA, "Media Type", "perm_media", Kind.REFERENCE)
.section("mediaType", "Media Type", "perm_media", Tier.T1, "id", "name", "code", "description", "isActive", "sortOrder")
.section("uploadRules", "Upload Rules", "rule", Tier.T2, "allowedMimeTypes", "allowedExtensions", "maxFileSizeMb")
.section("renditions", "Renditions", "photo_size_select_large", Tier.T2, "thumbnailEnabled", "thumbnailWidth", "thumbnailFormat", "thumbnailQuality", "galleryEnabled", "galleryWidth", "galleryFormat", "galleryQuality", "slideshowEnabled", "slideshowWidth", "slideshowFormat", "slideshowQuality")
.section("privacy", "Privacy and Required Fields", "privacy_tip", Tier.T2, "stripMetadata", "requireAltText", "requireCaption", "defaultCredit", "defaultLicense")
.section("cacheStorage", "Cache and Storage", "cached", Tier.T2, "cacheClass", "storagePrefix")
.child(MEDIA, "mediaTypeId", "Media", null, "name")
.unique("code")
.help("allowedMimeTypes", "Comma-separated, e.g. image/jpeg, image/png or image/*. Blank allows any type.")
.help("allowedExtensions", "Comma-separated, without dots, e.g. jpg, png. Blank allows any extension.")
.help("maxFileSizeMb", "Largest accepted upload, in megabytes. Blank sets no limit of its own.")
.help("thumbnailWidth", "Maximum width in pixels. Blank keeps the built-in width.")
.help("galleryWidth", "Maximum width in pixels. Blank keeps the built-in width.")
.help("slideshowWidth", "Maximum width in pixels. Blank keeps the built-in width.")
.help("thumbnailQuality", "JPEG or WebP quality from 1 to 100. Blank means 85.")
.help("galleryQuality", "JPEG or WebP quality from 1 to 100. Blank means 85.")
.help("slideshowQuality", "JPEG or WebP quality from 1 to 100. Blank means 85.")
.help("stripMetadata", "Removes EXIF, GPS, XMP and IPTC data from uploaded images; orientation is applied to the pixels first.")
.help("cacheClass", "How long browsers and CDNs may keep files of this type.")
.help("storagePrefix", "The storage folder for new uploads, e.g. media.")
.build(),
CmsTableDefinition.builder(MEDIA, CmsMedia.class, CmsFeature.MEDIA, "Media", "perm_media", Kind.MAIN)
.section("media", "Media", "perm_media", Tier.T1, "id", "name", "publicUrl", "slug", "description", "mediaTypeId", "siteId", "isActive")
.section("textAndCredit", "Text and Credit", "subtitles", Tier.T2, "altText", "caption", "credit", "license")
.section("renditions", "Renditions", "photo_size_select_large", Tier.T2, "thumbnailUrl", "galleryUrl", "slideshowUrl")
.section("file", "File", "insert_drive_file", Tier.T2, "fileName", "fileExtension", "mimeType", "fileSize", "width", "height", "duration", "checksum", "storageKey")
.filePreview("publicUrl", "thumbnailUrl", "fileName", "altText", "caption")
.build(),
CmsTableDefinition.builder(BLOG_TYPE, CmsBlogType.class, CmsFeature.BLOG, "Blog Type", "rss_feed", Kind.REFERENCE)
.section("blogType", "Blog Type", "rss_feed", Tier.T1, "id", "name", "code", "isActive", "sortOrder", "description")
.unique("name").unique("code")
.build(),
CmsTableDefinition.builder(BLOG, CmsBlog.class, CmsFeature.BLOG, "Blog", "article_person", Kind.MAIN)
.recordLabel("name")
.section("blog", "Blog", "article_person", Tier.T1, "id", "name", "shortName", "slug", "blogTypeId", "siteId", "description")
.section("seo", "SEO", "travel_explore", Tier.T2, "metaTitle", "metaDescription", "metaKeywords")
.child(BLOG_POST, "blogId", "Posts", null, "title")
.child(BLOG_TAG, "blogId", "Tags", "tags", "name")
.unique("name").unique("slug", "siteId").unique("shortName")
.build(),
CmsTableDefinition.builder(AUTHOR, CmsAuthor.class, CmsFeature.BLOG, "Author", "person", Kind.MAIN)
.section("author", "Author", "person", Tier.T1, "id", "name", "shortName", "slug", "isActive", "description")
.section("links", "Links", "link", Tier.T2, "website", "email", "socialLinks")
.section("profile", "Profile", "account_circle", Tier.T2, "displayOrder", "profileMediaId", "profileImageUrl")
.child(BLOG_POST, "authorId", "Posts", null, "title")
.unique("name").unique("slug")
.text("socialLinks")
.imagePreview("profileImageUrl", "name", null)
.build(),
CmsTableDefinition.builder(BLOG_TAG, CmsBlogTag.class, CmsFeature.BLOG, "Blog Tag", "local_offer", Kind.CHILD)
.section("tag", "Tag", "local_offer", Tier.T1, "id", "name", "slug", "blogId", "description")
.child(BLOG_POST_TAG_INT, "blogTagId", "Posts", null, "id")
.unique("name", "blogId").unique("slug", "blogId")
.build(),
CmsTableDefinition.builder(BLOG_POST, CmsBlogPost.class, CmsFeature.BLOG, "Blog Post", "article", Kind.MAIN)
.recordLabel("title")
.section("blogPost", "Blog Post", "article", Tier.T1, "id", "title", "name", "shortName", "slug", "blogId", "authorId", "isPublished", "publishDate")
.section("content", "Content", "notes", Tier.T2, "content", "excerpt", "description", "readTime")
.section("featured", "Featured Image", "image", Tier.T2, "featuredMediaId", "featuredImage", "isFeatured")
.section("seo", "SEO", "travel_explore", Tier.T2, "metaTitle", "metaDescription", "metaKeywords")
.section("usage", "Usage", "query_stats", Tier.T2, "viewCount")
.child(BLOG_POST_TAG_INT, "blogPostId", "Tags", "tags", "id")
.child(BLOG_POST_MEDIA, "blogPostId", "Media", "media", "sortOrder")
.child(BLOG_POST_VERSION, "blogPostId", "Related Versions", null, "name")
.unique("name", "blogId").unique("shortName", "blogId").unique("slug", "blogId")
.text("content", "excerpt")
.imagePreview("featuredImage", "title", null)
.build(),
CmsTableDefinition.builder(BLOG_POST_TAG_INT, CmsBlogPostTag.class, CmsFeature.BLOG, "Blog Post Tag", "label", Kind.CHILD)
.recordLabel("id")
.section("blogPostTag", "Blog Post Tag", "label", Tier.T1, "id", "blogPostId", "blogTagId")
.unique("blogPostId", "blogTagId")
.build(),
CmsTableDefinition.builder(BLOG_POST_MEDIA, CmsBlogPostMedia.class, CmsFeature.BLOG, "Blog Post Media", "photo_library", Kind.CHILD)
.recordLabel("url")
.section("blogPostMedia", "Blog Post Media", "photo_library", Tier.T1, "id", "blogPostId", "mediaId", "sortOrder", "url", "thumbnailUrl")
.section("text", "Text", "subtitles", Tier.T2, "altText", "caption")
.section("size", "Size", "aspect_ratio", Tier.T2, "width", "height")
.unique("blogPostId", "mediaId")
.imagePreview("url", "altText", "caption")
.build(),
CmsTableDefinition.builder(BLOG_POST_VERSION, CmsBlogPostVersion.class, CmsFeature.BLOG, "Related Version", "content_copy", Kind.CHILD)
.section("version", "Version", "content_copy", Tier.T1, "id", "name", "variantKey", "channel", "status", "blogPostId", "projectId", "projectUpdateId")
.section("content", "Content", "notes", Tier.T2, "title", "contentFormat", "content")
.section("publication", "External Publication", "public", Tier.T2, "publishedUrl", "publishedDate")
.section("source", "Source", "history", Tier.T2, "sourceDigest", "sourceCommit")
.unique("blogPostId", "variantKey").unique("projectId", "variantKey").unique("projectUpdateId", "variantKey")
.text("content")
.build(),
CmsTableDefinition.builder(PROJECT_CATEGORY, CmsProjectCategory.class, CmsFeature.PROJECTS, "Project Category", "category", Kind.MAIN)
.recordLabel("title")
.section("projectCategory", "Project Category", "category", Tier.T1, "id", "title", "name", "slug", "siteId", "section", "sortOrder", "isPublished", "description")
.section("featured", "Featured Image", "image", Tier.T2, "featuredMediaId", "featuredImage")
.child(PROJECT, "categoryId", "Projects", null, "sortOrder")
.unique("slug", "siteId")
.imagePreview("featuredImage", "title", null)
.help("section", "A grouping code the site chooses for its categories, for example a site area. Optional.")
.build(),
CmsTableDefinition.builder(PROJECT, CmsProject.class, CmsFeature.PROJECTS, "Project", "code", Kind.MAIN)
.recordLabel("title")
.section("project", "Project", "code", Tier.T1, "id", "title", "name", "shortName", "slug", "siteId", "categoryId", "projectStatus", "isPublished", "publishDate", "isFeatured", "sortOrder")
.section("content", "Content", "notes", Tier.T2, "description", "content")
.section("links", "Links", "link", Tier.T2, "githubUrl", "liveUrl")
.section("featured", "Featured Image", "image", Tier.T2, "featuredMediaId", "featuredImage", "imageAlt", "imageCaption", "imageFocalX", "imageFocalY")
.section("projectDates", "Project Dates", "schedule", Tier.T2, "startDate", "endDate")
.child(PROJECT_UPDATE, "projectId", "Updates", "updates", "updateDate")
.child(PHOTO_ALBUM, "projectId", "Photo Albums", null, "sortOrder")
.child(BLOG_POST_VERSION, "projectId", "Related Versions", null, "name")
.unique("slug", "siteId")
.text("description", "content")
.imagePreview("featuredImage", "imageAlt", "imageCaption")
.build(),
CmsTableDefinition.builder(PROJECT_UPDATE, CmsProjectUpdate.class, CmsFeature.PROJECTS, "Project Update", "history", Kind.CHILD)
.recordLabel("title")
.section("projectUpdate", "Project Update", "history", Tier.T1, "id", "title", "slug", "projectId", "updateDate", "isPublished", "publishDate", "sortOrder")
.section("content", "Content", "notes", Tier.T2, "excerpt", "content")
.section("featured", "Featured Image", "image", Tier.T2, "featuredMediaId", "featuredImage")
.child(PHOTO_ALBUM, "projectUpdateId", "Photo Albums", null, "sortOrder")
.child(BLOG_POST_VERSION, "projectUpdateId", "Related Versions", null, "name")
.unique("slug", "projectId")
.text("content")
.imagePreview("featuredImage", "title", null)
.build(),
CmsTableDefinition.builder(PHOTO_ALBUM_FOLDER, CmsPhotoAlbumFolder.class, CmsFeature.PHOTOS, "Album Folder", "folder", Kind.MAIN)
.section("folder", "Album Folder", "folder", Tier.T1, "id", "name", "slug", "siteId", "parentId", "isPublished", "sortOrder")
.section("content", "Content", "notes", Tier.T2, "description", "folderImageUrl")
.section("seo", "SEO", "travel_explore", Tier.T2, "metaTitle", "metaDescription")
.child(PHOTO_ALBUM_FOLDER, "parentId", "Sub-Folders", null, "sortOrder")
.child(PHOTO_ALBUM, "photoAlbumFolderId", "Albums", null, "sortOrder")
.unique("slug", "siteId")
.imagePreview("folderImageUrl", "name", null)
.build(),
CmsTableDefinition.builder(PHOTO_ALBUM, CmsPhotoAlbum.class, CmsFeature.PHOTOS, "Photo Album", "photo_library", Kind.MAIN)
.section("album", "Photo Album", "photo_library", Tier.T1, "id", "name", "shortName", "slug", "siteId", "photoAlbumFolderId", "projectId", "projectUpdateId", "isPublished", "publishDate", "sortOrder")
.section("content", "Content", "notes", Tier.T2, "title", "description", "coverPhotoId", "coverImageUrl")
.section("location", "Location", "place", Tier.T2, "location", "locationLatitude", "locationLongitude")
.section("shoot", "Shoot Details", "camera", Tier.T2, "albumDate", "albumEndDate", "primaryCamera", "primaryLens", "weather")
.section("seo", "SEO", "travel_explore", Tier.T2, "metaTitle", "metaDescription")
.child(PHOTO, "photoAlbumId", "Photos", "photos", "sortOrder")
.unique("slug", "siteId").unique("shortName", "siteId")
.imagePreview("coverImageUrl", "title", null)
.build(),
CmsTableDefinition.builder(PHOTO, CmsPhoto.class, CmsFeature.PHOTOS, "Photo", "photo_camera", Kind.CHILD)
.recordLabel("title")
.section("photo", "Photo", "photo_camera", Tier.T1, "id", "title", "slug", "photoAlbumId", "mediaId", "caption", "isPublished", "publishDate", "sortOrder")
.section("content", "Content", "notes", Tier.T2, "description", "score", "isFavorite", "isAlbumCover")
.section("renditions", "Renditions", "photo_size_select_large", Tier.T2, "originalUrl", "galleryUrl", "slideshowUrl", "thumbnailUrl")
.section("file", "File", "insert_drive_file", Tier.T2, "originalFilename", "storageKey", "mimeType", "fileSize", "width", "height")
.section("exif", "Camera Data", "camera", Tier.T2, "exifDateTaken", "exifCameraMake", "exifCameraModel", "exifLensModel", "exifFocalLength", "exifAperture", "exifShutterSpeed", "exifIso", "exifWhiteBalance", "exifFlash", "exifGpsLatitude", "exifGpsLongitude")
.child(PHOTO_TAG_INT, "photoId", "Tags", "tags", "id")
.unique("slug", "photoAlbumId")
.filePreview("originalUrl", "thumbnailUrl", "originalFilename", "title", "caption")
.build(),
CmsTableDefinition.builder(PHOTO_TAG, CmsPhotoTag.class, CmsFeature.PHOTOS, "Photo Tag", "label", Kind.MAIN)
.section("tag", "Tag", "label", Tier.T1, "id", "name", "slug", "description")
.child(PHOTO_TAG_INT, "photoTagId", "Photos", null, "id")
.unique("slug").unique("name")
.build(),
CmsTableDefinition.builder(PHOTO_TAG_INT, CmsPhotoTagLink.class, CmsFeature.PHOTOS, "Photo Tag Link", "label", Kind.CHILD)
.recordLabel("id")
.section("photoTag", "Photo Tag", "label", Tier.T1, "id", "photoId", "photoTagId")
.unique("photoId", "photoTagId")
.build());
/** Value lists by logical possible-value source name (each gets the table prefix when built). */
private static final Map<String, PossibleValueEnum<String>[]> VALUE_LISTS = Map.of(
CmsMediaRenditionFormat.NAME, CmsMediaRenditionFormat.values(),
CmsMediaCacheClass.NAME, CmsMediaCacheClass.values(),
CmsContentChannel.NAME, CmsContentChannel.values(),
CmsContentFormat.NAME, CmsContentFormat.values(),
CmsContentVersionStatus.NAME, CmsContentVersionStatus.values(),
CmsProjectStatus.NAME, CmsProjectStatus.values());
/*******************************************************************************
** Not instantiable.
*******************************************************************************/
private CmsTables()
{
}
/*******************************************************************************
** Every table definition, in a stable order.
*******************************************************************************/
public static List<CmsTableDefinition> definitions()
{
return (DEFINITIONS);
}
/*******************************************************************************
** The definitions of the features a config turns on.
*******************************************************************************/
public static List<CmsTableDefinition> definitions(CmsQBitConfig config)
{
return (DEFINITIONS.stream().filter(d -> config.hasFeature(d.feature())).toList());
}
/*******************************************************************************
** One definition by logical name.
*******************************************************************************/
public static Optional<CmsTableDefinition> definition(String logicalName)
{
return (DEFINITIONS.stream().filter(d -> d.logicalName().equals(logicalName)).findFirst());
}
/*******************************************************************************
** The values of a value list (a possible-value source that is a fixed list,
** such as the status of a project) by its logical name.
*******************************************************************************/
public static Optional<PossibleValueEnum<String>[]> valueList(String logicalName)
{
return (Optional.ofNullable(VALUE_LISTS.get(logicalName)));
}
/*******************************************************************************
** The logical names of the value lists, in a stable order.
*******************************************************************************/
public static List<String> valueListNames()
{
return (VALUE_LISTS.keySet().stream().sorted().toList());
}
}
@@ -0,0 +1,535 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.blog.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A person who writes posts.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_author); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsAuthor extends QRecordEntity
{
public static final String TABLE_NAME = "author";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 40, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 20, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String shortName;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String description;
@QField(isRequired = true, maxLength = 40, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String slug;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String email;
@QField(possibleValueSourceName = "media", label = "Profile Media")
private Long profileMediaId;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "Profile Image URL")
private String profileImageUrl;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String website;
@QField(gridColumns = 12)
private String socialLinks;
@QField(defaultValue = "true")
private Boolean isActive;
@QField
private Integer displayOrder;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsAuthor()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsAuthor(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsAuthor withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsAuthor withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for shortName
*******************************************************************************/
public String getShortName()
{
return (this.shortName);
}
/*******************************************************************************
** Setter for shortName
*******************************************************************************/
public void setShortName(String shortName)
{
this.shortName = shortName;
}
/*******************************************************************************
** Fluent setter for shortName
*******************************************************************************/
public CmsAuthor withShortName(String shortName)
{
this.shortName = shortName;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsAuthor withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for slug
*******************************************************************************/
public String getSlug()
{
return (this.slug);
}
/*******************************************************************************
** Setter for slug
*******************************************************************************/
public void setSlug(String slug)
{
this.slug = slug;
}
/*******************************************************************************
** Fluent setter for slug
*******************************************************************************/
public CmsAuthor withSlug(String slug)
{
this.slug = slug;
return (this);
}
/*******************************************************************************
** Getter for email
*******************************************************************************/
public String getEmail()
{
return (this.email);
}
/*******************************************************************************
** Setter for email
*******************************************************************************/
public void setEmail(String email)
{
this.email = email;
}
/*******************************************************************************
** Fluent setter for email
*******************************************************************************/
public CmsAuthor withEmail(String email)
{
this.email = email;
return (this);
}
/*******************************************************************************
** Getter for profileMediaId
*******************************************************************************/
public Long getProfileMediaId()
{
return (this.profileMediaId);
}
/*******************************************************************************
** Setter for profileMediaId
*******************************************************************************/
public void setProfileMediaId(Long profileMediaId)
{
this.profileMediaId = profileMediaId;
}
/*******************************************************************************
** Fluent setter for profileMediaId
*******************************************************************************/
public CmsAuthor withProfileMediaId(Long profileMediaId)
{
this.profileMediaId = profileMediaId;
return (this);
}
/*******************************************************************************
** Getter for profileImageUrl
*******************************************************************************/
public String getProfileImageUrl()
{
return (this.profileImageUrl);
}
/*******************************************************************************
** Setter for profileImageUrl
*******************************************************************************/
public void setProfileImageUrl(String profileImageUrl)
{
this.profileImageUrl = profileImageUrl;
}
/*******************************************************************************
** Fluent setter for profileImageUrl
*******************************************************************************/
public CmsAuthor withProfileImageUrl(String profileImageUrl)
{
this.profileImageUrl = profileImageUrl;
return (this);
}
/*******************************************************************************
** Getter for website
*******************************************************************************/
public String getWebsite()
{
return (this.website);
}
/*******************************************************************************
** Setter for website
*******************************************************************************/
public void setWebsite(String website)
{
this.website = website;
}
/*******************************************************************************
** Fluent setter for website
*******************************************************************************/
public CmsAuthor withWebsite(String website)
{
this.website = website;
return (this);
}
/*******************************************************************************
** Getter for socialLinks
*******************************************************************************/
public String getSocialLinks()
{
return (this.socialLinks);
}
/*******************************************************************************
** Setter for socialLinks
*******************************************************************************/
public void setSocialLinks(String socialLinks)
{
this.socialLinks = socialLinks;
}
/*******************************************************************************
** Fluent setter for socialLinks
*******************************************************************************/
public CmsAuthor withSocialLinks(String socialLinks)
{
this.socialLinks = socialLinks;
return (this);
}
/*******************************************************************************
** Getter for isActive
*******************************************************************************/
public Boolean getIsActive()
{
return (this.isActive);
}
/*******************************************************************************
** Setter for isActive
*******************************************************************************/
public void setIsActive(Boolean isActive)
{
this.isActive = isActive;
}
/*******************************************************************************
** Fluent setter for isActive
*******************************************************************************/
public CmsAuthor withIsActive(Boolean isActive)
{
this.isActive = isActive;
return (this);
}
/*******************************************************************************
** Getter for displayOrder
*******************************************************************************/
public Integer getDisplayOrder()
{
return (this.displayOrder);
}
/*******************************************************************************
** Setter for displayOrder
*******************************************************************************/
public void setDisplayOrder(Integer displayOrder)
{
this.displayOrder = displayOrder;
}
/*******************************************************************************
** Fluent setter for displayOrder
*******************************************************************************/
public CmsAuthor withDisplayOrder(Integer displayOrder)
{
this.displayOrder = displayOrder;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsAuthor withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsAuthor withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,467 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.blog.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A blog of a site: a named stream of posts with its own tags.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_blog); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsBlog extends QRecordEntity
{
public static final String TABLE_NAME = "blog";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 20, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String shortName;
@QField(isRequired = true, maxLength = 40, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String description;
@QField(isRequired = true, maxLength = 40, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String slug;
@QField(isRequired = true, possibleValueSourceName = "blog_type", label = "Blog Type")
private Long blogTypeId;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String metaTitle;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String metaDescription;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String metaKeywords;
@QField(isRequired = true, possibleValueSourceName = "site", label = "Site")
private Long siteId;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsBlog()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsBlog(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsBlog withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for shortName
*******************************************************************************/
public String getShortName()
{
return (this.shortName);
}
/*******************************************************************************
** Setter for shortName
*******************************************************************************/
public void setShortName(String shortName)
{
this.shortName = shortName;
}
/*******************************************************************************
** Fluent setter for shortName
*******************************************************************************/
public CmsBlog withShortName(String shortName)
{
this.shortName = shortName;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsBlog withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsBlog withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for slug
*******************************************************************************/
public String getSlug()
{
return (this.slug);
}
/*******************************************************************************
** Setter for slug
*******************************************************************************/
public void setSlug(String slug)
{
this.slug = slug;
}
/*******************************************************************************
** Fluent setter for slug
*******************************************************************************/
public CmsBlog withSlug(String slug)
{
this.slug = slug;
return (this);
}
/*******************************************************************************
** Getter for blogTypeId
*******************************************************************************/
public Long getBlogTypeId()
{
return (this.blogTypeId);
}
/*******************************************************************************
** Setter for blogTypeId
*******************************************************************************/
public void setBlogTypeId(Long blogTypeId)
{
this.blogTypeId = blogTypeId;
}
/*******************************************************************************
** Fluent setter for blogTypeId
*******************************************************************************/
public CmsBlog withBlogTypeId(Long blogTypeId)
{
this.blogTypeId = blogTypeId;
return (this);
}
/*******************************************************************************
** Getter for metaTitle
*******************************************************************************/
public String getMetaTitle()
{
return (this.metaTitle);
}
/*******************************************************************************
** Setter for metaTitle
*******************************************************************************/
public void setMetaTitle(String metaTitle)
{
this.metaTitle = metaTitle;
}
/*******************************************************************************
** Fluent setter for metaTitle
*******************************************************************************/
public CmsBlog withMetaTitle(String metaTitle)
{
this.metaTitle = metaTitle;
return (this);
}
/*******************************************************************************
** Getter for metaDescription
*******************************************************************************/
public String getMetaDescription()
{
return (this.metaDescription);
}
/*******************************************************************************
** Setter for metaDescription
*******************************************************************************/
public void setMetaDescription(String metaDescription)
{
this.metaDescription = metaDescription;
}
/*******************************************************************************
** Fluent setter for metaDescription
*******************************************************************************/
public CmsBlog withMetaDescription(String metaDescription)
{
this.metaDescription = metaDescription;
return (this);
}
/*******************************************************************************
** Getter for metaKeywords
*******************************************************************************/
public String getMetaKeywords()
{
return (this.metaKeywords);
}
/*******************************************************************************
** Setter for metaKeywords
*******************************************************************************/
public void setMetaKeywords(String metaKeywords)
{
this.metaKeywords = metaKeywords;
}
/*******************************************************************************
** Fluent setter for metaKeywords
*******************************************************************************/
public CmsBlog withMetaKeywords(String metaKeywords)
{
this.metaKeywords = metaKeywords;
return (this);
}
/*******************************************************************************
** Getter for siteId
*******************************************************************************/
public Long getSiteId()
{
return (this.siteId);
}
/*******************************************************************************
** Setter for siteId
*******************************************************************************/
public void setSiteId(Long siteId)
{
this.siteId = siteId;
}
/*******************************************************************************
** Fluent setter for siteId
*******************************************************************************/
public CmsBlog withSiteId(Long siteId)
{
this.siteId = siteId;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsBlog withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsBlog withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,809 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.blog.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DisplayFormat;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A post of a blog: its content, author, publication state and search
** engine text.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_blog_post); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsBlogPost extends QRecordEntity
{
public static final String TABLE_NAME = "blog_post";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 40, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 20, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String shortName;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String description;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String title;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String slug;
@QField(isRequired = true, gridColumns = 12)
private String content;
@QField(isRequired = true, possibleValueSourceName = "author", label = "Author")
private Long authorId;
@QField(isRequired = true, possibleValueSourceName = "blog", label = "Blog")
private Long blogId;
@QField(isRequired = true, defaultValue = "false")
private Boolean isPublished;
@QField
private Instant publishDate;
@QField(possibleValueSourceName = "media", label = "Featured Media")
private Long featuredMediaId;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "Featured Image URL")
private String featuredImage;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String metaTitle;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String metaDescription;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String metaKeywords;
@QField(isRequired = true, defaultValue = "4", label = "Read time (minutes)")
private Integer readTime;
@QField(isEditable = false, defaultValue = "0", displayFormat = DisplayFormat.COMMAS)
private Long viewCount;
@QField(isRequired = true, defaultValue = "false")
private Boolean isFeatured;
@QField(gridColumns = 12)
private String excerpt;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsBlogPost()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsBlogPost(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsBlogPost withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsBlogPost withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for shortName
*******************************************************************************/
public String getShortName()
{
return (this.shortName);
}
/*******************************************************************************
** Setter for shortName
*******************************************************************************/
public void setShortName(String shortName)
{
this.shortName = shortName;
}
/*******************************************************************************
** Fluent setter for shortName
*******************************************************************************/
public CmsBlogPost withShortName(String shortName)
{
this.shortName = shortName;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsBlogPost withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for title
*******************************************************************************/
public String getTitle()
{
return (this.title);
}
/*******************************************************************************
** Setter for title
*******************************************************************************/
public void setTitle(String title)
{
this.title = title;
}
/*******************************************************************************
** Fluent setter for title
*******************************************************************************/
public CmsBlogPost withTitle(String title)
{
this.title = title;
return (this);
}
/*******************************************************************************
** Getter for slug
*******************************************************************************/
public String getSlug()
{
return (this.slug);
}
/*******************************************************************************
** Setter for slug
*******************************************************************************/
public void setSlug(String slug)
{
this.slug = slug;
}
/*******************************************************************************
** Fluent setter for slug
*******************************************************************************/
public CmsBlogPost withSlug(String slug)
{
this.slug = slug;
return (this);
}
/*******************************************************************************
** Getter for content
*******************************************************************************/
public String getContent()
{
return (this.content);
}
/*******************************************************************************
** Setter for content
*******************************************************************************/
public void setContent(String content)
{
this.content = content;
}
/*******************************************************************************
** Fluent setter for content
*******************************************************************************/
public CmsBlogPost withContent(String content)
{
this.content = content;
return (this);
}
/*******************************************************************************
** Getter for authorId
*******************************************************************************/
public Long getAuthorId()
{
return (this.authorId);
}
/*******************************************************************************
** Setter for authorId
*******************************************************************************/
public void setAuthorId(Long authorId)
{
this.authorId = authorId;
}
/*******************************************************************************
** Fluent setter for authorId
*******************************************************************************/
public CmsBlogPost withAuthorId(Long authorId)
{
this.authorId = authorId;
return (this);
}
/*******************************************************************************
** Getter for blogId
*******************************************************************************/
public Long getBlogId()
{
return (this.blogId);
}
/*******************************************************************************
** Setter for blogId
*******************************************************************************/
public void setBlogId(Long blogId)
{
this.blogId = blogId;
}
/*******************************************************************************
** Fluent setter for blogId
*******************************************************************************/
public CmsBlogPost withBlogId(Long blogId)
{
this.blogId = blogId;
return (this);
}
/*******************************************************************************
** Getter for isPublished
*******************************************************************************/
public Boolean getIsPublished()
{
return (this.isPublished);
}
/*******************************************************************************
** Setter for isPublished
*******************************************************************************/
public void setIsPublished(Boolean isPublished)
{
this.isPublished = isPublished;
}
/*******************************************************************************
** Fluent setter for isPublished
*******************************************************************************/
public CmsBlogPost withIsPublished(Boolean isPublished)
{
this.isPublished = isPublished;
return (this);
}
/*******************************************************************************
** Getter for publishDate
*******************************************************************************/
public Instant getPublishDate()
{
return (this.publishDate);
}
/*******************************************************************************
** Setter for publishDate
*******************************************************************************/
public void setPublishDate(Instant publishDate)
{
this.publishDate = publishDate;
}
/*******************************************************************************
** Fluent setter for publishDate
*******************************************************************************/
public CmsBlogPost withPublishDate(Instant publishDate)
{
this.publishDate = publishDate;
return (this);
}
/*******************************************************************************
** Getter for featuredMediaId
*******************************************************************************/
public Long getFeaturedMediaId()
{
return (this.featuredMediaId);
}
/*******************************************************************************
** Setter for featuredMediaId
*******************************************************************************/
public void setFeaturedMediaId(Long featuredMediaId)
{
this.featuredMediaId = featuredMediaId;
}
/*******************************************************************************
** Fluent setter for featuredMediaId
*******************************************************************************/
public CmsBlogPost withFeaturedMediaId(Long featuredMediaId)
{
this.featuredMediaId = featuredMediaId;
return (this);
}
/*******************************************************************************
** Getter for featuredImage
*******************************************************************************/
public String getFeaturedImage()
{
return (this.featuredImage);
}
/*******************************************************************************
** Setter for featuredImage
*******************************************************************************/
public void setFeaturedImage(String featuredImage)
{
this.featuredImage = featuredImage;
}
/*******************************************************************************
** Fluent setter for featuredImage
*******************************************************************************/
public CmsBlogPost withFeaturedImage(String featuredImage)
{
this.featuredImage = featuredImage;
return (this);
}
/*******************************************************************************
** Getter for metaTitle
*******************************************************************************/
public String getMetaTitle()
{
return (this.metaTitle);
}
/*******************************************************************************
** Setter for metaTitle
*******************************************************************************/
public void setMetaTitle(String metaTitle)
{
this.metaTitle = metaTitle;
}
/*******************************************************************************
** Fluent setter for metaTitle
*******************************************************************************/
public CmsBlogPost withMetaTitle(String metaTitle)
{
this.metaTitle = metaTitle;
return (this);
}
/*******************************************************************************
** Getter for metaDescription
*******************************************************************************/
public String getMetaDescription()
{
return (this.metaDescription);
}
/*******************************************************************************
** Setter for metaDescription
*******************************************************************************/
public void setMetaDescription(String metaDescription)
{
this.metaDescription = metaDescription;
}
/*******************************************************************************
** Fluent setter for metaDescription
*******************************************************************************/
public CmsBlogPost withMetaDescription(String metaDescription)
{
this.metaDescription = metaDescription;
return (this);
}
/*******************************************************************************
** Getter for metaKeywords
*******************************************************************************/
public String getMetaKeywords()
{
return (this.metaKeywords);
}
/*******************************************************************************
** Setter for metaKeywords
*******************************************************************************/
public void setMetaKeywords(String metaKeywords)
{
this.metaKeywords = metaKeywords;
}
/*******************************************************************************
** Fluent setter for metaKeywords
*******************************************************************************/
public CmsBlogPost withMetaKeywords(String metaKeywords)
{
this.metaKeywords = metaKeywords;
return (this);
}
/*******************************************************************************
** Getter for readTime
*******************************************************************************/
public Integer getReadTime()
{
return (this.readTime);
}
/*******************************************************************************
** Setter for readTime
*******************************************************************************/
public void setReadTime(Integer readTime)
{
this.readTime = readTime;
}
/*******************************************************************************
** Fluent setter for readTime
*******************************************************************************/
public CmsBlogPost withReadTime(Integer readTime)
{
this.readTime = readTime;
return (this);
}
/*******************************************************************************
** Getter for viewCount
*******************************************************************************/
public Long getViewCount()
{
return (this.viewCount);
}
/*******************************************************************************
** Setter for viewCount
*******************************************************************************/
public void setViewCount(Long viewCount)
{
this.viewCount = viewCount;
}
/*******************************************************************************
** Fluent setter for viewCount
*******************************************************************************/
public CmsBlogPost withViewCount(Long viewCount)
{
this.viewCount = viewCount;
return (this);
}
/*******************************************************************************
** Getter for isFeatured
*******************************************************************************/
public Boolean getIsFeatured()
{
return (this.isFeatured);
}
/*******************************************************************************
** Setter for isFeatured
*******************************************************************************/
public void setIsFeatured(Boolean isFeatured)
{
this.isFeatured = isFeatured;
}
/*******************************************************************************
** Fluent setter for isFeatured
*******************************************************************************/
public CmsBlogPost withIsFeatured(Boolean isFeatured)
{
this.isFeatured = isFeatured;
return (this);
}
/*******************************************************************************
** Getter for excerpt
*******************************************************************************/
public String getExcerpt()
{
return (this.excerpt);
}
/*******************************************************************************
** Setter for excerpt
*******************************************************************************/
public void setExcerpt(String excerpt)
{
this.excerpt = excerpt;
}
/*******************************************************************************
** Fluent setter for excerpt
*******************************************************************************/
public CmsBlogPost withExcerpt(String excerpt)
{
this.excerpt = excerpt;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsBlogPost withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsBlogPost withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,468 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.blog.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DisplayFormat;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A media file attached to a post, in order, with the text shown with it.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_blog_post_media); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsBlogPostMedia extends QRecordEntity
{
public static final String TABLE_NAME = "blog_post_media";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, possibleValueSourceName = "blog_post", label = "Blog Post")
private Long blogPostId;
@QField(isRequired = true, possibleValueSourceName = "media", label = "Media")
private Long mediaId;
@QField(isRequired = true, defaultValue = "0")
private Integer sortOrder;
@QField(maxLength = 1000, valueTooLongBehavior = ValueTooLongBehavior.ERROR, label = "Alt text")
private String altText;
@QField(maxLength = 2000, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String caption;
@QField(isRequired = true, maxLength = 1000, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "URL")
private String url;
@QField(maxLength = 1000, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "Thumbnail URL")
private String thumbnailUrl;
@QField(displayFormat = DisplayFormat.COMMAS)
private Integer width;
@QField(displayFormat = DisplayFormat.COMMAS)
private Integer height;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsBlogPostMedia()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsBlogPostMedia(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsBlogPostMedia withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for blogPostId
*******************************************************************************/
public Long getBlogPostId()
{
return (this.blogPostId);
}
/*******************************************************************************
** Setter for blogPostId
*******************************************************************************/
public void setBlogPostId(Long blogPostId)
{
this.blogPostId = blogPostId;
}
/*******************************************************************************
** Fluent setter for blogPostId
*******************************************************************************/
public CmsBlogPostMedia withBlogPostId(Long blogPostId)
{
this.blogPostId = blogPostId;
return (this);
}
/*******************************************************************************
** Getter for mediaId
*******************************************************************************/
public Long getMediaId()
{
return (this.mediaId);
}
/*******************************************************************************
** Setter for mediaId
*******************************************************************************/
public void setMediaId(Long mediaId)
{
this.mediaId = mediaId;
}
/*******************************************************************************
** Fluent setter for mediaId
*******************************************************************************/
public CmsBlogPostMedia withMediaId(Long mediaId)
{
this.mediaId = mediaId;
return (this);
}
/*******************************************************************************
** Getter for sortOrder
*******************************************************************************/
public Integer getSortOrder()
{
return (this.sortOrder);
}
/*******************************************************************************
** Setter for sortOrder
*******************************************************************************/
public void setSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
}
/*******************************************************************************
** Fluent setter for sortOrder
*******************************************************************************/
public CmsBlogPostMedia withSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
return (this);
}
/*******************************************************************************
** Getter for altText
*******************************************************************************/
public String getAltText()
{
return (this.altText);
}
/*******************************************************************************
** Setter for altText
*******************************************************************************/
public void setAltText(String altText)
{
this.altText = altText;
}
/*******************************************************************************
** Fluent setter for altText
*******************************************************************************/
public CmsBlogPostMedia withAltText(String altText)
{
this.altText = altText;
return (this);
}
/*******************************************************************************
** Getter for caption
*******************************************************************************/
public String getCaption()
{
return (this.caption);
}
/*******************************************************************************
** Setter for caption
*******************************************************************************/
public void setCaption(String caption)
{
this.caption = caption;
}
/*******************************************************************************
** Fluent setter for caption
*******************************************************************************/
public CmsBlogPostMedia withCaption(String caption)
{
this.caption = caption;
return (this);
}
/*******************************************************************************
** Getter for url
*******************************************************************************/
public String getUrl()
{
return (this.url);
}
/*******************************************************************************
** Setter for url
*******************************************************************************/
public void setUrl(String url)
{
this.url = url;
}
/*******************************************************************************
** Fluent setter for url
*******************************************************************************/
public CmsBlogPostMedia withUrl(String url)
{
this.url = url;
return (this);
}
/*******************************************************************************
** Getter for thumbnailUrl
*******************************************************************************/
public String getThumbnailUrl()
{
return (this.thumbnailUrl);
}
/*******************************************************************************
** Setter for thumbnailUrl
*******************************************************************************/
public void setThumbnailUrl(String thumbnailUrl)
{
this.thumbnailUrl = thumbnailUrl;
}
/*******************************************************************************
** Fluent setter for thumbnailUrl
*******************************************************************************/
public CmsBlogPostMedia withThumbnailUrl(String thumbnailUrl)
{
this.thumbnailUrl = thumbnailUrl;
return (this);
}
/*******************************************************************************
** Getter for width
*******************************************************************************/
public Integer getWidth()
{
return (this.width);
}
/*******************************************************************************
** Setter for width
*******************************************************************************/
public void setWidth(Integer width)
{
this.width = width;
}
/*******************************************************************************
** Fluent setter for width
*******************************************************************************/
public CmsBlogPostMedia withWidth(Integer width)
{
this.width = width;
return (this);
}
/*******************************************************************************
** Getter for height
*******************************************************************************/
public Integer getHeight()
{
return (this.height);
}
/*******************************************************************************
** Setter for height
*******************************************************************************/
public void setHeight(Integer height)
{
this.height = height;
}
/*******************************************************************************
** Fluent setter for height
*******************************************************************************/
public CmsBlogPostMedia withHeight(Integer height)
{
this.height = height;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsBlogPostMedia withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsBlogPostMedia withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,228 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.blog.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
/*******************************************************************************
** One tag on one post.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_blog_post_tag_int); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsBlogPostTag extends QRecordEntity
{
public static final String TABLE_NAME = "blog_post_tag_int";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, possibleValueSourceName = "blog_post", label = "Blog Post")
private Long blogPostId;
@QField(isRequired = true, possibleValueSourceName = "blog_tag", label = "Blog Tag")
private Long blogTagId;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsBlogPostTag()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsBlogPostTag(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsBlogPostTag withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for blogPostId
*******************************************************************************/
public Long getBlogPostId()
{
return (this.blogPostId);
}
/*******************************************************************************
** Setter for blogPostId
*******************************************************************************/
public void setBlogPostId(Long blogPostId)
{
this.blogPostId = blogPostId;
}
/*******************************************************************************
** Fluent setter for blogPostId
*******************************************************************************/
public CmsBlogPostTag withBlogPostId(Long blogPostId)
{
this.blogPostId = blogPostId;
return (this);
}
/*******************************************************************************
** Getter for blogTagId
*******************************************************************************/
public Long getBlogTagId()
{
return (this.blogTagId);
}
/*******************************************************************************
** Setter for blogTagId
*******************************************************************************/
public void setBlogTagId(Long blogTagId)
{
this.blogTagId = blogTagId;
}
/*******************************************************************************
** Fluent setter for blogTagId
*******************************************************************************/
public CmsBlogPostTag withBlogTagId(Long blogTagId)
{
this.blogTagId = blogTagId;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsBlogPostTag withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsBlogPostTag withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,639 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.blog.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A version of a piece of content written for another channel (LinkedIn,
** Medium and so on). It belongs to one post, one project or one project
** update.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_blog_post_version); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsBlogPostVersion extends QRecordEntity
{
public static final String TABLE_NAME = "blog_post_version";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(possibleValueSourceName = "blog_post", label = "Blog Post")
private Long blogPostId;
@QField(possibleValueSourceName = "project", label = "Project")
private Long projectId;
@QField(possibleValueSourceName = "project_update", label = "Project Update")
private Long projectUpdateId;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String variantKey;
@QField(isRequired = true, maxLength = 40, valueTooLongBehavior = ValueTooLongBehavior.ERROR, possibleValueSourceName = "content_channel")
private String channel;
@QField(maxLength = 200, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String title;
@QField(isRequired = true, gridColumns = 12)
private String content;
@QField(isRequired = true, maxLength = 20, defaultValue = "MARKDOWN", possibleValueSourceName = "content_format")
private String contentFormat;
@QField(isRequired = true, maxLength = 20, defaultValue = "DRAFT", possibleValueSourceName = "content_version_status")
private String status;
@QField(maxLength = 64, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String sourceDigest;
@QField(maxLength = 64, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String sourceCommit;
@QField(maxLength = 2000, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "Published URL")
private String publishedUrl;
@QField
private Instant publishedDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsBlogPostVersion()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsBlogPostVersion(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsBlogPostVersion withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for blogPostId
*******************************************************************************/
public Long getBlogPostId()
{
return (this.blogPostId);
}
/*******************************************************************************
** Setter for blogPostId
*******************************************************************************/
public void setBlogPostId(Long blogPostId)
{
this.blogPostId = blogPostId;
}
/*******************************************************************************
** Fluent setter for blogPostId
*******************************************************************************/
public CmsBlogPostVersion withBlogPostId(Long blogPostId)
{
this.blogPostId = blogPostId;
return (this);
}
/*******************************************************************************
** Getter for projectId
*******************************************************************************/
public Long getProjectId()
{
return (this.projectId);
}
/*******************************************************************************
** Setter for projectId
*******************************************************************************/
public void setProjectId(Long projectId)
{
this.projectId = projectId;
}
/*******************************************************************************
** Fluent setter for projectId
*******************************************************************************/
public CmsBlogPostVersion withProjectId(Long projectId)
{
this.projectId = projectId;
return (this);
}
/*******************************************************************************
** Getter for projectUpdateId
*******************************************************************************/
public Long getProjectUpdateId()
{
return (this.projectUpdateId);
}
/*******************************************************************************
** Setter for projectUpdateId
*******************************************************************************/
public void setProjectUpdateId(Long projectUpdateId)
{
this.projectUpdateId = projectUpdateId;
}
/*******************************************************************************
** Fluent setter for projectUpdateId
*******************************************************************************/
public CmsBlogPostVersion withProjectUpdateId(Long projectUpdateId)
{
this.projectUpdateId = projectUpdateId;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsBlogPostVersion withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for variantKey
*******************************************************************************/
public String getVariantKey()
{
return (this.variantKey);
}
/*******************************************************************************
** Setter for variantKey
*******************************************************************************/
public void setVariantKey(String variantKey)
{
this.variantKey = variantKey;
}
/*******************************************************************************
** Fluent setter for variantKey
*******************************************************************************/
public CmsBlogPostVersion withVariantKey(String variantKey)
{
this.variantKey = variantKey;
return (this);
}
/*******************************************************************************
** Getter for channel
*******************************************************************************/
public String getChannel()
{
return (this.channel);
}
/*******************************************************************************
** Setter for channel
*******************************************************************************/
public void setChannel(String channel)
{
this.channel = channel;
}
/*******************************************************************************
** Fluent setter for channel
*******************************************************************************/
public CmsBlogPostVersion withChannel(String channel)
{
this.channel = channel;
return (this);
}
/*******************************************************************************
** Getter for title
*******************************************************************************/
public String getTitle()
{
return (this.title);
}
/*******************************************************************************
** Setter for title
*******************************************************************************/
public void setTitle(String title)
{
this.title = title;
}
/*******************************************************************************
** Fluent setter for title
*******************************************************************************/
public CmsBlogPostVersion withTitle(String title)
{
this.title = title;
return (this);
}
/*******************************************************************************
** Getter for content
*******************************************************************************/
public String getContent()
{
return (this.content);
}
/*******************************************************************************
** Setter for content
*******************************************************************************/
public void setContent(String content)
{
this.content = content;
}
/*******************************************************************************
** Fluent setter for content
*******************************************************************************/
public CmsBlogPostVersion withContent(String content)
{
this.content = content;
return (this);
}
/*******************************************************************************
** Getter for contentFormat
*******************************************************************************/
public String getContentFormat()
{
return (this.contentFormat);
}
/*******************************************************************************
** Setter for contentFormat
*******************************************************************************/
public void setContentFormat(String contentFormat)
{
this.contentFormat = contentFormat;
}
/*******************************************************************************
** Fluent setter for contentFormat
*******************************************************************************/
public CmsBlogPostVersion withContentFormat(String contentFormat)
{
this.contentFormat = contentFormat;
return (this);
}
/*******************************************************************************
** Getter for status
*******************************************************************************/
public String getStatus()
{
return (this.status);
}
/*******************************************************************************
** Setter for status
*******************************************************************************/
public void setStatus(String status)
{
this.status = status;
}
/*******************************************************************************
** Fluent setter for status
*******************************************************************************/
public CmsBlogPostVersion withStatus(String status)
{
this.status = status;
return (this);
}
/*******************************************************************************
** Getter for sourceDigest
*******************************************************************************/
public String getSourceDigest()
{
return (this.sourceDigest);
}
/*******************************************************************************
** Setter for sourceDigest
*******************************************************************************/
public void setSourceDigest(String sourceDigest)
{
this.sourceDigest = sourceDigest;
}
/*******************************************************************************
** Fluent setter for sourceDigest
*******************************************************************************/
public CmsBlogPostVersion withSourceDigest(String sourceDigest)
{
this.sourceDigest = sourceDigest;
return (this);
}
/*******************************************************************************
** Getter for sourceCommit
*******************************************************************************/
public String getSourceCommit()
{
return (this.sourceCommit);
}
/*******************************************************************************
** Setter for sourceCommit
*******************************************************************************/
public void setSourceCommit(String sourceCommit)
{
this.sourceCommit = sourceCommit;
}
/*******************************************************************************
** Fluent setter for sourceCommit
*******************************************************************************/
public CmsBlogPostVersion withSourceCommit(String sourceCommit)
{
this.sourceCommit = sourceCommit;
return (this);
}
/*******************************************************************************
** Getter for publishedUrl
*******************************************************************************/
public String getPublishedUrl()
{
return (this.publishedUrl);
}
/*******************************************************************************
** Setter for publishedUrl
*******************************************************************************/
public void setPublishedUrl(String publishedUrl)
{
this.publishedUrl = publishedUrl;
}
/*******************************************************************************
** Fluent setter for publishedUrl
*******************************************************************************/
public CmsBlogPostVersion withPublishedUrl(String publishedUrl)
{
this.publishedUrl = publishedUrl;
return (this);
}
/*******************************************************************************
** Getter for publishedDate
*******************************************************************************/
public Instant getPublishedDate()
{
return (this.publishedDate);
}
/*******************************************************************************
** Setter for publishedDate
*******************************************************************************/
public void setPublishedDate(Instant publishedDate)
{
this.publishedDate = publishedDate;
}
/*******************************************************************************
** Fluent setter for publishedDate
*******************************************************************************/
public CmsBlogPostVersion withPublishedDate(Instant publishedDate)
{
this.publishedDate = publishedDate;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsBlogPostVersion withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsBlogPostVersion withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,297 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.blog.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A tag of one blog; posts of that blog carry it.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_blog_tag); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsBlogTag extends QRecordEntity
{
public static final String TABLE_NAME = "blog_tag";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 40, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 40, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String slug;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String description;
@QField(isRequired = true, possibleValueSourceName = "blog", label = "Blog")
private Long blogId;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsBlogTag()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsBlogTag(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsBlogTag withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsBlogTag withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for slug
*******************************************************************************/
public String getSlug()
{
return (this.slug);
}
/*******************************************************************************
** Setter for slug
*******************************************************************************/
public void setSlug(String slug)
{
this.slug = slug;
}
/*******************************************************************************
** Fluent setter for slug
*******************************************************************************/
public CmsBlogTag withSlug(String slug)
{
this.slug = slug;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsBlogTag withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for blogId
*******************************************************************************/
public Long getBlogId()
{
return (this.blogId);
}
/*******************************************************************************
** Setter for blogId
*******************************************************************************/
public void setBlogId(Long blogId)
{
this.blogId = blogId;
}
/*******************************************************************************
** Fluent setter for blogId
*******************************************************************************/
public CmsBlogTag withBlogId(Long blogId)
{
this.blogId = blogId;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsBlogTag withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsBlogTag withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,331 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.blog.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A kind of blog.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_blog_type); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsBlogType extends QRecordEntity
{
public static final String TABLE_NAME = "blog_type";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 50, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String code;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String description;
@QField(isRequired = true, defaultValue = "true")
private Boolean isActive;
@QField(isRequired = true, defaultValue = "0")
private Integer sortOrder;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsBlogType()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsBlogType(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsBlogType withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsBlogType withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for code
*******************************************************************************/
public String getCode()
{
return (this.code);
}
/*******************************************************************************
** Setter for code
*******************************************************************************/
public void setCode(String code)
{
this.code = code;
}
/*******************************************************************************
** Fluent setter for code
*******************************************************************************/
public CmsBlogType withCode(String code)
{
this.code = code;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsBlogType withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for isActive
*******************************************************************************/
public Boolean getIsActive()
{
return (this.isActive);
}
/*******************************************************************************
** Setter for isActive
*******************************************************************************/
public void setIsActive(Boolean isActive)
{
this.isActive = isActive;
}
/*******************************************************************************
** Fluent setter for isActive
*******************************************************************************/
public CmsBlogType withIsActive(Boolean isActive)
{
this.isActive = isActive;
return (this);
}
/*******************************************************************************
** Getter for sortOrder
*******************************************************************************/
public Integer getSortOrder()
{
return (this.sortOrder);
}
/*******************************************************************************
** Setter for sortOrder
*******************************************************************************/
public void setSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
}
/*******************************************************************************
** Fluent setter for sortOrder
*******************************************************************************/
public CmsBlogType withSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsBlogType withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsBlogType withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,71 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.blog.model;
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.PossibleValueEnum;
/*******************************************************************************
** Where a related version of a piece of content is meant to be published.
** Its possible-value source gets the table prefix (cms_content_channel).
*******************************************************************************/
public enum CmsContentChannel implements PossibleValueEnum<String>
{
WEBSITE("Website"),
LINKEDIN("LinkedIn"),
MEDIUM("Medium"),
FACEBOOK("Facebook"),
OTHER("Other");
/** The logical possible-value source name (the prefix is added). */
public static final String NAME = "content_channel";
private final String label;
/*******************************************************************************
** Constructor.
*******************************************************************************/
CmsContentChannel(String label)
{
this.label = label;
}
/*******************************************************************************
** The stored value.
*******************************************************************************/
@Override
public String getPossibleValueId()
{
return (name());
}
/*******************************************************************************
** The label.
*******************************************************************************/
@Override
public String getPossibleValueLabel()
{
return (label);
}
}
@@ -0,0 +1,68 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.blog.model;
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.PossibleValueEnum;
/*******************************************************************************
** The format of a related version's content. Its possible-value source gets
** the table prefix (cms_content_format).
*******************************************************************************/
public enum CmsContentFormat implements PossibleValueEnum<String>
{
MARKDOWN("Markdown"),
PLAIN_TEXT("Plain text");
/** The logical possible-value source name (the prefix is added). */
public static final String NAME = "content_format";
private final String label;
/*******************************************************************************
** Constructor.
*******************************************************************************/
CmsContentFormat(String label)
{
this.label = label;
}
/*******************************************************************************
** The stored value.
*******************************************************************************/
@Override
public String getPossibleValueId()
{
return (name());
}
/*******************************************************************************
** The label.
*******************************************************************************/
@Override
public String getPossibleValueLabel()
{
return (label);
}
}
@@ -0,0 +1,70 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.blog.model;
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.PossibleValueEnum;
/*******************************************************************************
** The state of a related version. Its possible-value source gets the table
** prefix (cms_content_version_status).
*******************************************************************************/
public enum CmsContentVersionStatus implements PossibleValueEnum<String>
{
DRAFT("Draft"),
READY("Ready"),
PUBLISHED("Published externally"),
ARCHIVED("Archived");
/** The logical possible-value source name (the prefix is added). */
public static final String NAME = "content_version_status";
private final String label;
/*******************************************************************************
** Constructor.
*******************************************************************************/
CmsContentVersionStatus(String label)
{
this.label = label;
}
/*******************************************************************************
** The stored value.
*******************************************************************************/
@Override
public String getPossibleValueId()
{
return (name());
}
/*******************************************************************************
** The label.
*******************************************************************************/
@Override
public String getPossibleValueLabel()
{
return (label);
}
}
@@ -0,0 +1,366 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.core.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A host name (fully qualified domain name) of a site; one per site is
** primary.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_domain); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsDomain extends QRecordEntity
{
public static final String TABLE_NAME = "domain";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 40, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 20, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String shortName;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.TRUNCATE, gridColumns = 12)
private String description;
@QField(isRequired = true, maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, label = "FQDN")
private String fqdn;
@QField(isRequired = true, defaultValue = "false")
private Boolean isPrimary;
@QField(isRequired = true, possibleValueSourceName = "site", label = "Site")
private Long siteId;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsDomain()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsDomain(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsDomain withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsDomain withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for shortName
*******************************************************************************/
public String getShortName()
{
return (this.shortName);
}
/*******************************************************************************
** Setter for shortName
*******************************************************************************/
public void setShortName(String shortName)
{
this.shortName = shortName;
}
/*******************************************************************************
** Fluent setter for shortName
*******************************************************************************/
public CmsDomain withShortName(String shortName)
{
this.shortName = shortName;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsDomain withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for fqdn
*******************************************************************************/
public String getFqdn()
{
return (this.fqdn);
}
/*******************************************************************************
** Setter for fqdn
*******************************************************************************/
public void setFqdn(String fqdn)
{
this.fqdn = fqdn;
}
/*******************************************************************************
** Fluent setter for fqdn
*******************************************************************************/
public CmsDomain withFqdn(String fqdn)
{
this.fqdn = fqdn;
return (this);
}
/*******************************************************************************
** Getter for isPrimary
*******************************************************************************/
public Boolean getIsPrimary()
{
return (this.isPrimary);
}
/*******************************************************************************
** Setter for isPrimary
*******************************************************************************/
public void setIsPrimary(Boolean isPrimary)
{
this.isPrimary = isPrimary;
}
/*******************************************************************************
** Fluent setter for isPrimary
*******************************************************************************/
public CmsDomain withIsPrimary(Boolean isPrimary)
{
this.isPrimary = isPrimary;
return (this);
}
/*******************************************************************************
** Getter for siteId
*******************************************************************************/
public Long getSiteId()
{
return (this.siteId);
}
/*******************************************************************************
** Setter for siteId
*******************************************************************************/
public void setSiteId(Long siteId)
{
this.siteId = siteId;
}
/*******************************************************************************
** Fluent setter for siteId
*******************************************************************************/
public CmsDomain withSiteId(Long siteId)
{
this.siteId = siteId;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsDomain withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsDomain withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,365 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.core.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A navigation menu of a site (for example the header or footer menu).
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_menu); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsMenu extends QRecordEntity
{
public static final String TABLE_NAME = "menu";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String slug;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String description;
@QField(isRequired = true, possibleValueSourceName = "site", label = "Site")
private Long siteId;
@QField(isRequired = true, maxLength = 50, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String menuType;
@QField(isRequired = true, defaultValue = "true")
private Boolean isActive;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsMenu()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsMenu(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsMenu withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsMenu withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for slug
*******************************************************************************/
public String getSlug()
{
return (this.slug);
}
/*******************************************************************************
** Setter for slug
*******************************************************************************/
public void setSlug(String slug)
{
this.slug = slug;
}
/*******************************************************************************
** Fluent setter for slug
*******************************************************************************/
public CmsMenu withSlug(String slug)
{
this.slug = slug;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsMenu withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for siteId
*******************************************************************************/
public Long getSiteId()
{
return (this.siteId);
}
/*******************************************************************************
** Setter for siteId
*******************************************************************************/
public void setSiteId(Long siteId)
{
this.siteId = siteId;
}
/*******************************************************************************
** Fluent setter for siteId
*******************************************************************************/
public CmsMenu withSiteId(Long siteId)
{
this.siteId = siteId;
return (this);
}
/*******************************************************************************
** Getter for menuType
*******************************************************************************/
public String getMenuType()
{
return (this.menuType);
}
/*******************************************************************************
** Setter for menuType
*******************************************************************************/
public void setMenuType(String menuType)
{
this.menuType = menuType;
}
/*******************************************************************************
** Fluent setter for menuType
*******************************************************************************/
public CmsMenu withMenuType(String menuType)
{
this.menuType = menuType;
return (this);
}
/*******************************************************************************
** Getter for isActive
*******************************************************************************/
public Boolean getIsActive()
{
return (this.isActive);
}
/*******************************************************************************
** Setter for isActive
*******************************************************************************/
public void setIsActive(Boolean isActive)
{
this.isActive = isActive;
}
/*******************************************************************************
** Fluent setter for isActive
*******************************************************************************/
public CmsMenu withIsActive(Boolean isActive)
{
this.isActive = isActive;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsMenu withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsMenu withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,604 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.core.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** One entry of a menu: a link or route, ordered, optionally nested under a
** parent item.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_menu_item); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsMenuItem extends QRecordEntity
{
public static final String TABLE_NAME = "menu_item";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, possibleValueSourceName = "menu", label = "Menu")
private Long menuId;
@QField(possibleValueSourceName = "menu_item", label = "Parent Item")
private Long parentId;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String slug;
@QField(isRequired = true, maxLength = 50, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String itemType;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR, label = "Link URL", gridColumns = 12)
private String linkUrl;
@QField(maxLength = 200, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String routePath;
@QField(maxLength = 20, valueTooLongBehavior = ValueTooLongBehavior.ERROR, defaultValue = "_self")
private String target;
@QField(maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String icon;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String description;
@QField(isRequired = true, defaultValue = "0")
private Integer displayOrder;
@QField(isRequired = true, defaultValue = "true")
private Boolean isActive;
@QField(maxLength = 200, valueTooLongBehavior = ValueTooLongBehavior.ERROR, label = "CSS Classes")
private String cssClasses;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsMenuItem()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsMenuItem(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsMenuItem withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for menuId
*******************************************************************************/
public Long getMenuId()
{
return (this.menuId);
}
/*******************************************************************************
** Setter for menuId
*******************************************************************************/
public void setMenuId(Long menuId)
{
this.menuId = menuId;
}
/*******************************************************************************
** Fluent setter for menuId
*******************************************************************************/
public CmsMenuItem withMenuId(Long menuId)
{
this.menuId = menuId;
return (this);
}
/*******************************************************************************
** Getter for parentId
*******************************************************************************/
public Long getParentId()
{
return (this.parentId);
}
/*******************************************************************************
** Setter for parentId
*******************************************************************************/
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
/*******************************************************************************
** Fluent setter for parentId
*******************************************************************************/
public CmsMenuItem withParentId(Long parentId)
{
this.parentId = parentId;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsMenuItem withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for slug
*******************************************************************************/
public String getSlug()
{
return (this.slug);
}
/*******************************************************************************
** Setter for slug
*******************************************************************************/
public void setSlug(String slug)
{
this.slug = slug;
}
/*******************************************************************************
** Fluent setter for slug
*******************************************************************************/
public CmsMenuItem withSlug(String slug)
{
this.slug = slug;
return (this);
}
/*******************************************************************************
** Getter for itemType
*******************************************************************************/
public String getItemType()
{
return (this.itemType);
}
/*******************************************************************************
** Setter for itemType
*******************************************************************************/
public void setItemType(String itemType)
{
this.itemType = itemType;
}
/*******************************************************************************
** Fluent setter for itemType
*******************************************************************************/
public CmsMenuItem withItemType(String itemType)
{
this.itemType = itemType;
return (this);
}
/*******************************************************************************
** Getter for linkUrl
*******************************************************************************/
public String getLinkUrl()
{
return (this.linkUrl);
}
/*******************************************************************************
** Setter for linkUrl
*******************************************************************************/
public void setLinkUrl(String linkUrl)
{
this.linkUrl = linkUrl;
}
/*******************************************************************************
** Fluent setter for linkUrl
*******************************************************************************/
public CmsMenuItem withLinkUrl(String linkUrl)
{
this.linkUrl = linkUrl;
return (this);
}
/*******************************************************************************
** Getter for routePath
*******************************************************************************/
public String getRoutePath()
{
return (this.routePath);
}
/*******************************************************************************
** Setter for routePath
*******************************************************************************/
public void setRoutePath(String routePath)
{
this.routePath = routePath;
}
/*******************************************************************************
** Fluent setter for routePath
*******************************************************************************/
public CmsMenuItem withRoutePath(String routePath)
{
this.routePath = routePath;
return (this);
}
/*******************************************************************************
** Getter for target
*******************************************************************************/
public String getTarget()
{
return (this.target);
}
/*******************************************************************************
** Setter for target
*******************************************************************************/
public void setTarget(String target)
{
this.target = target;
}
/*******************************************************************************
** Fluent setter for target
*******************************************************************************/
public CmsMenuItem withTarget(String target)
{
this.target = target;
return (this);
}
/*******************************************************************************
** Getter for icon
*******************************************************************************/
public String getIcon()
{
return (this.icon);
}
/*******************************************************************************
** Setter for icon
*******************************************************************************/
public void setIcon(String icon)
{
this.icon = icon;
}
/*******************************************************************************
** Fluent setter for icon
*******************************************************************************/
public CmsMenuItem withIcon(String icon)
{
this.icon = icon;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsMenuItem withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for displayOrder
*******************************************************************************/
public Integer getDisplayOrder()
{
return (this.displayOrder);
}
/*******************************************************************************
** Setter for displayOrder
*******************************************************************************/
public void setDisplayOrder(Integer displayOrder)
{
this.displayOrder = displayOrder;
}
/*******************************************************************************
** Fluent setter for displayOrder
*******************************************************************************/
public CmsMenuItem withDisplayOrder(Integer displayOrder)
{
this.displayOrder = displayOrder;
return (this);
}
/*******************************************************************************
** Getter for isActive
*******************************************************************************/
public Boolean getIsActive()
{
return (this.isActive);
}
/*******************************************************************************
** Setter for isActive
*******************************************************************************/
public void setIsActive(Boolean isActive)
{
this.isActive = isActive;
}
/*******************************************************************************
** Fluent setter for isActive
*******************************************************************************/
public CmsMenuItem withIsActive(Boolean isActive)
{
this.isActive = isActive;
return (this);
}
/*******************************************************************************
** Getter for cssClasses
*******************************************************************************/
public String getCssClasses()
{
return (this.cssClasses);
}
/*******************************************************************************
** Setter for cssClasses
*******************************************************************************/
public void setCssClasses(String cssClasses)
{
this.cssClasses = cssClasses;
}
/*******************************************************************************
** Fluent setter for cssClasses
*******************************************************************************/
public CmsMenuItem withCssClasses(String cssClasses)
{
this.cssClasses = cssClasses;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsMenuItem withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsMenuItem withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,638 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.core.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A page of a site, made of ordered page sections; pages nest under a parent
** page.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_page); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsPage extends QRecordEntity
{
public static final String TABLE_NAME = "page";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String slug;
@QField(isRequired = true, maxLength = 200, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String title;
@QField(gridColumns = 12)
private String content;
@QField(isRequired = true, possibleValueSourceName = "page_type", label = "Page Type")
private Long pageTypeId;
@QField(maxLength = 50, valueTooLongBehavior = ValueTooLongBehavior.ERROR, defaultValue = "default")
private String template;
@QField(isRequired = true, defaultValue = "false")
private Boolean isPublished;
@QField()
private Instant publishDate;
@QField(isRequired = true, defaultValue = "0")
private Integer sortOrder;
@QField(possibleValueSourceName = "page", label = "Parent Page")
private Long parentPageId;
@QField(isRequired = true, possibleValueSourceName = "site", label = "Site")
private Long siteId;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.TRUNCATE, gridColumns = 12)
private String metaDescription;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.TRUNCATE, gridColumns = 12)
private String metaKeywords;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.TRUNCATE, label = "Open Graph Image", gridColumns = 12)
private String ogImage;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsPage()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsPage(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsPage withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsPage withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for slug
*******************************************************************************/
public String getSlug()
{
return (this.slug);
}
/*******************************************************************************
** Setter for slug
*******************************************************************************/
public void setSlug(String slug)
{
this.slug = slug;
}
/*******************************************************************************
** Fluent setter for slug
*******************************************************************************/
public CmsPage withSlug(String slug)
{
this.slug = slug;
return (this);
}
/*******************************************************************************
** Getter for title
*******************************************************************************/
public String getTitle()
{
return (this.title);
}
/*******************************************************************************
** Setter for title
*******************************************************************************/
public void setTitle(String title)
{
this.title = title;
}
/*******************************************************************************
** Fluent setter for title
*******************************************************************************/
public CmsPage withTitle(String title)
{
this.title = title;
return (this);
}
/*******************************************************************************
** Getter for content
*******************************************************************************/
public String getContent()
{
return (this.content);
}
/*******************************************************************************
** Setter for content
*******************************************************************************/
public void setContent(String content)
{
this.content = content;
}
/*******************************************************************************
** Fluent setter for content
*******************************************************************************/
public CmsPage withContent(String content)
{
this.content = content;
return (this);
}
/*******************************************************************************
** Getter for pageTypeId
*******************************************************************************/
public Long getPageTypeId()
{
return (this.pageTypeId);
}
/*******************************************************************************
** Setter for pageTypeId
*******************************************************************************/
public void setPageTypeId(Long pageTypeId)
{
this.pageTypeId = pageTypeId;
}
/*******************************************************************************
** Fluent setter for pageTypeId
*******************************************************************************/
public CmsPage withPageTypeId(Long pageTypeId)
{
this.pageTypeId = pageTypeId;
return (this);
}
/*******************************************************************************
** Getter for template
*******************************************************************************/
public String getTemplate()
{
return (this.template);
}
/*******************************************************************************
** Setter for template
*******************************************************************************/
public void setTemplate(String template)
{
this.template = template;
}
/*******************************************************************************
** Fluent setter for template
*******************************************************************************/
public CmsPage withTemplate(String template)
{
this.template = template;
return (this);
}
/*******************************************************************************
** Getter for isPublished
*******************************************************************************/
public Boolean getIsPublished()
{
return (this.isPublished);
}
/*******************************************************************************
** Setter for isPublished
*******************************************************************************/
public void setIsPublished(Boolean isPublished)
{
this.isPublished = isPublished;
}
/*******************************************************************************
** Fluent setter for isPublished
*******************************************************************************/
public CmsPage withIsPublished(Boolean isPublished)
{
this.isPublished = isPublished;
return (this);
}
/*******************************************************************************
** Getter for publishDate
*******************************************************************************/
public Instant getPublishDate()
{
return (this.publishDate);
}
/*******************************************************************************
** Setter for publishDate
*******************************************************************************/
public void setPublishDate(Instant publishDate)
{
this.publishDate = publishDate;
}
/*******************************************************************************
** Fluent setter for publishDate
*******************************************************************************/
public CmsPage withPublishDate(Instant publishDate)
{
this.publishDate = publishDate;
return (this);
}
/*******************************************************************************
** Getter for sortOrder
*******************************************************************************/
public Integer getSortOrder()
{
return (this.sortOrder);
}
/*******************************************************************************
** Setter for sortOrder
*******************************************************************************/
public void setSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
}
/*******************************************************************************
** Fluent setter for sortOrder
*******************************************************************************/
public CmsPage withSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
return (this);
}
/*******************************************************************************
** Getter for parentPageId
*******************************************************************************/
public Long getParentPageId()
{
return (this.parentPageId);
}
/*******************************************************************************
** Setter for parentPageId
*******************************************************************************/
public void setParentPageId(Long parentPageId)
{
this.parentPageId = parentPageId;
}
/*******************************************************************************
** Fluent setter for parentPageId
*******************************************************************************/
public CmsPage withParentPageId(Long parentPageId)
{
this.parentPageId = parentPageId;
return (this);
}
/*******************************************************************************
** Getter for siteId
*******************************************************************************/
public Long getSiteId()
{
return (this.siteId);
}
/*******************************************************************************
** Setter for siteId
*******************************************************************************/
public void setSiteId(Long siteId)
{
this.siteId = siteId;
}
/*******************************************************************************
** Fluent setter for siteId
*******************************************************************************/
public CmsPage withSiteId(Long siteId)
{
this.siteId = siteId;
return (this);
}
/*******************************************************************************
** Getter for metaDescription
*******************************************************************************/
public String getMetaDescription()
{
return (this.metaDescription);
}
/*******************************************************************************
** Setter for metaDescription
*******************************************************************************/
public void setMetaDescription(String metaDescription)
{
this.metaDescription = metaDescription;
}
/*******************************************************************************
** Fluent setter for metaDescription
*******************************************************************************/
public CmsPage withMetaDescription(String metaDescription)
{
this.metaDescription = metaDescription;
return (this);
}
/*******************************************************************************
** Getter for metaKeywords
*******************************************************************************/
public String getMetaKeywords()
{
return (this.metaKeywords);
}
/*******************************************************************************
** Setter for metaKeywords
*******************************************************************************/
public void setMetaKeywords(String metaKeywords)
{
this.metaKeywords = metaKeywords;
}
/*******************************************************************************
** Fluent setter for metaKeywords
*******************************************************************************/
public CmsPage withMetaKeywords(String metaKeywords)
{
this.metaKeywords = metaKeywords;
return (this);
}
/*******************************************************************************
** Getter for ogImage
*******************************************************************************/
public String getOgImage()
{
return (this.ogImage);
}
/*******************************************************************************
** Setter for ogImage
*******************************************************************************/
public void setOgImage(String ogImage)
{
this.ogImage = ogImage;
}
/*******************************************************************************
** Fluent setter for ogImage
*******************************************************************************/
public CmsPage withOgImage(String ogImage)
{
this.ogImage = ogImage;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsPage withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsPage withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,366 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.core.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** One ordered section of a page; its content is interpreted by its section
** type.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_page_section); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsPageSection extends QRecordEntity
{
public static final String TABLE_NAME = "page_section";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, label = "CSS Class Name")
private String cssClassName;
@QField(isRequired = true, possibleValueSourceName = "page_section_type", label = "Section Type")
private Long sectionTypeId;
@QField(gridColumns = 12)
private String content;
@QField(isRequired = true, defaultValue = "0")
private Integer sortOrder;
@QField(isRequired = true, possibleValueSourceName = "page", label = "Page")
private Long pageId;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsPageSection()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsPageSection(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsPageSection withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsPageSection withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for cssClassName
*******************************************************************************/
public String getCssClassName()
{
return (this.cssClassName);
}
/*******************************************************************************
** Setter for cssClassName
*******************************************************************************/
public void setCssClassName(String cssClassName)
{
this.cssClassName = cssClassName;
}
/*******************************************************************************
** Fluent setter for cssClassName
*******************************************************************************/
public CmsPageSection withCssClassName(String cssClassName)
{
this.cssClassName = cssClassName;
return (this);
}
/*******************************************************************************
** Getter for sectionTypeId
*******************************************************************************/
public Long getSectionTypeId()
{
return (this.sectionTypeId);
}
/*******************************************************************************
** Setter for sectionTypeId
*******************************************************************************/
public void setSectionTypeId(Long sectionTypeId)
{
this.sectionTypeId = sectionTypeId;
}
/*******************************************************************************
** Fluent setter for sectionTypeId
*******************************************************************************/
public CmsPageSection withSectionTypeId(Long sectionTypeId)
{
this.sectionTypeId = sectionTypeId;
return (this);
}
/*******************************************************************************
** Getter for content
*******************************************************************************/
public String getContent()
{
return (this.content);
}
/*******************************************************************************
** Setter for content
*******************************************************************************/
public void setContent(String content)
{
this.content = content;
}
/*******************************************************************************
** Fluent setter for content
*******************************************************************************/
public CmsPageSection withContent(String content)
{
this.content = content;
return (this);
}
/*******************************************************************************
** Getter for sortOrder
*******************************************************************************/
public Integer getSortOrder()
{
return (this.sortOrder);
}
/*******************************************************************************
** Setter for sortOrder
*******************************************************************************/
public void setSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
}
/*******************************************************************************
** Fluent setter for sortOrder
*******************************************************************************/
public CmsPageSection withSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
return (this);
}
/*******************************************************************************
** Getter for pageId
*******************************************************************************/
public Long getPageId()
{
return (this.pageId);
}
/*******************************************************************************
** Setter for pageId
*******************************************************************************/
public void setPageId(Long pageId)
{
this.pageId = pageId;
}
/*******************************************************************************
** Fluent setter for pageId
*******************************************************************************/
public CmsPageSection withPageId(Long pageId)
{
this.pageId = pageId;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsPageSection withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsPageSection withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,332 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.core.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A kind of page section (reference data); the frontend renders a section by
** its type code.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_page_section_type); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsPageSectionType extends QRecordEntity
{
public static final String TABLE_NAME = "page_section_type";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 50, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String code;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String description;
@QField(isRequired = true, defaultValue = "true")
private Boolean isActive;
@QField(isRequired = true, defaultValue = "0")
private Integer sortOrder;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsPageSectionType()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsPageSectionType(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsPageSectionType withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsPageSectionType withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for code
*******************************************************************************/
public String getCode()
{
return (this.code);
}
/*******************************************************************************
** Setter for code
*******************************************************************************/
public void setCode(String code)
{
this.code = code;
}
/*******************************************************************************
** Fluent setter for code
*******************************************************************************/
public CmsPageSectionType withCode(String code)
{
this.code = code;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsPageSectionType withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for isActive
*******************************************************************************/
public Boolean getIsActive()
{
return (this.isActive);
}
/*******************************************************************************
** Setter for isActive
*******************************************************************************/
public void setIsActive(Boolean isActive)
{
this.isActive = isActive;
}
/*******************************************************************************
** Fluent setter for isActive
*******************************************************************************/
public CmsPageSectionType withIsActive(Boolean isActive)
{
this.isActive = isActive;
return (this);
}
/*******************************************************************************
** Getter for sortOrder
*******************************************************************************/
public Integer getSortOrder()
{
return (this.sortOrder);
}
/*******************************************************************************
** Setter for sortOrder
*******************************************************************************/
public void setSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
}
/*******************************************************************************
** Fluent setter for sortOrder
*******************************************************************************/
public CmsPageSectionType withSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsPageSectionType withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsPageSectionType withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,331 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.core.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A kind of page (reference data).
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_page_type); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsPageType extends QRecordEntity
{
public static final String TABLE_NAME = "page_type";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 50, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String code;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String description;
@QField(isRequired = true, defaultValue = "true")
private Boolean isActive;
@QField(isRequired = true, defaultValue = "0")
private Integer sortOrder;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsPageType()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsPageType(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsPageType withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsPageType withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for code
*******************************************************************************/
public String getCode()
{
return (this.code);
}
/*******************************************************************************
** Setter for code
*******************************************************************************/
public void setCode(String code)
{
this.code = code;
}
/*******************************************************************************
** Fluent setter for code
*******************************************************************************/
public CmsPageType withCode(String code)
{
this.code = code;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsPageType withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for isActive
*******************************************************************************/
public Boolean getIsActive()
{
return (this.isActive);
}
/*******************************************************************************
** Setter for isActive
*******************************************************************************/
public void setIsActive(Boolean isActive)
{
this.isActive = isActive;
}
/*******************************************************************************
** Fluent setter for isActive
*******************************************************************************/
public CmsPageType withIsActive(Boolean isActive)
{
this.isActive = isActive;
return (this);
}
/*******************************************************************************
** Getter for sortOrder
*******************************************************************************/
public Integer getSortOrder()
{
return (this.sortOrder);
}
/*******************************************************************************
** Setter for sortOrder
*******************************************************************************/
public void setSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
}
/*******************************************************************************
** Fluent setter for sortOrder
*******************************************************************************/
public CmsPageType withSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsPageType withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsPageType withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,604 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.core.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A public URL redirect: requests matching the source path go to the target
** path.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_redirect); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsRedirect extends QRecordEntity
{
public static final String TABLE_NAME = "redirect";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.TRUNCATE)
private String description;
@QField(isRequired = true, maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String sourcePath;
@QField(isRequired = true, maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String targetPath;
@QField(isRequired = true, possibleValueSourceName = "redirect_type", label = "Redirect Type")
private Long redirectTypeId;
@QField(isRequired = true, maxLength = 20, valueTooLongBehavior = ValueTooLongBehavior.ERROR, defaultValue = "EXACT")
private String matchType;
@QField(isRequired = true, defaultValue = "true")
private Boolean isActive;
@QField(isRequired = true, defaultValue = "0")
private Integer priority;
@QField(isRequired = true, defaultValue = "true")
private Boolean preserveQueryParams;
@QField(isEditable = false, defaultValue = "0")
private Long hitCount;
@QField(isEditable = false)
private Instant lastHitDate;
@QField()
private Instant expiryDate;
@QField(isRequired = true, possibleValueSourceName = "site", label = "Site")
private Long siteId;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsRedirect()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsRedirect(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsRedirect withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsRedirect withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsRedirect withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for sourcePath
*******************************************************************************/
public String getSourcePath()
{
return (this.sourcePath);
}
/*******************************************************************************
** Setter for sourcePath
*******************************************************************************/
public void setSourcePath(String sourcePath)
{
this.sourcePath = sourcePath;
}
/*******************************************************************************
** Fluent setter for sourcePath
*******************************************************************************/
public CmsRedirect withSourcePath(String sourcePath)
{
this.sourcePath = sourcePath;
return (this);
}
/*******************************************************************************
** Getter for targetPath
*******************************************************************************/
public String getTargetPath()
{
return (this.targetPath);
}
/*******************************************************************************
** Setter for targetPath
*******************************************************************************/
public void setTargetPath(String targetPath)
{
this.targetPath = targetPath;
}
/*******************************************************************************
** Fluent setter for targetPath
*******************************************************************************/
public CmsRedirect withTargetPath(String targetPath)
{
this.targetPath = targetPath;
return (this);
}
/*******************************************************************************
** Getter for redirectTypeId
*******************************************************************************/
public Long getRedirectTypeId()
{
return (this.redirectTypeId);
}
/*******************************************************************************
** Setter for redirectTypeId
*******************************************************************************/
public void setRedirectTypeId(Long redirectTypeId)
{
this.redirectTypeId = redirectTypeId;
}
/*******************************************************************************
** Fluent setter for redirectTypeId
*******************************************************************************/
public CmsRedirect withRedirectTypeId(Long redirectTypeId)
{
this.redirectTypeId = redirectTypeId;
return (this);
}
/*******************************************************************************
** Getter for matchType
*******************************************************************************/
public String getMatchType()
{
return (this.matchType);
}
/*******************************************************************************
** Setter for matchType
*******************************************************************************/
public void setMatchType(String matchType)
{
this.matchType = matchType;
}
/*******************************************************************************
** Fluent setter for matchType
*******************************************************************************/
public CmsRedirect withMatchType(String matchType)
{
this.matchType = matchType;
return (this);
}
/*******************************************************************************
** Getter for isActive
*******************************************************************************/
public Boolean getIsActive()
{
return (this.isActive);
}
/*******************************************************************************
** Setter for isActive
*******************************************************************************/
public void setIsActive(Boolean isActive)
{
this.isActive = isActive;
}
/*******************************************************************************
** Fluent setter for isActive
*******************************************************************************/
public CmsRedirect withIsActive(Boolean isActive)
{
this.isActive = isActive;
return (this);
}
/*******************************************************************************
** Getter for priority
*******************************************************************************/
public Integer getPriority()
{
return (this.priority);
}
/*******************************************************************************
** Setter for priority
*******************************************************************************/
public void setPriority(Integer priority)
{
this.priority = priority;
}
/*******************************************************************************
** Fluent setter for priority
*******************************************************************************/
public CmsRedirect withPriority(Integer priority)
{
this.priority = priority;
return (this);
}
/*******************************************************************************
** Getter for preserveQueryParams
*******************************************************************************/
public Boolean getPreserveQueryParams()
{
return (this.preserveQueryParams);
}
/*******************************************************************************
** Setter for preserveQueryParams
*******************************************************************************/
public void setPreserveQueryParams(Boolean preserveQueryParams)
{
this.preserveQueryParams = preserveQueryParams;
}
/*******************************************************************************
** Fluent setter for preserveQueryParams
*******************************************************************************/
public CmsRedirect withPreserveQueryParams(Boolean preserveQueryParams)
{
this.preserveQueryParams = preserveQueryParams;
return (this);
}
/*******************************************************************************
** Getter for hitCount
*******************************************************************************/
public Long getHitCount()
{
return (this.hitCount);
}
/*******************************************************************************
** Setter for hitCount
*******************************************************************************/
public void setHitCount(Long hitCount)
{
this.hitCount = hitCount;
}
/*******************************************************************************
** Fluent setter for hitCount
*******************************************************************************/
public CmsRedirect withHitCount(Long hitCount)
{
this.hitCount = hitCount;
return (this);
}
/*******************************************************************************
** Getter for lastHitDate
*******************************************************************************/
public Instant getLastHitDate()
{
return (this.lastHitDate);
}
/*******************************************************************************
** Setter for lastHitDate
*******************************************************************************/
public void setLastHitDate(Instant lastHitDate)
{
this.lastHitDate = lastHitDate;
}
/*******************************************************************************
** Fluent setter for lastHitDate
*******************************************************************************/
public CmsRedirect withLastHitDate(Instant lastHitDate)
{
this.lastHitDate = lastHitDate;
return (this);
}
/*******************************************************************************
** Getter for expiryDate
*******************************************************************************/
public Instant getExpiryDate()
{
return (this.expiryDate);
}
/*******************************************************************************
** Setter for expiryDate
*******************************************************************************/
public void setExpiryDate(Instant expiryDate)
{
this.expiryDate = expiryDate;
}
/*******************************************************************************
** Fluent setter for expiryDate
*******************************************************************************/
public CmsRedirect withExpiryDate(Instant expiryDate)
{
this.expiryDate = expiryDate;
return (this);
}
/*******************************************************************************
** Getter for siteId
*******************************************************************************/
public Long getSiteId()
{
return (this.siteId);
}
/*******************************************************************************
** Setter for siteId
*******************************************************************************/
public void setSiteId(Long siteId)
{
this.siteId = siteId;
}
/*******************************************************************************
** Fluent setter for siteId
*******************************************************************************/
public CmsRedirect withSiteId(Long siteId)
{
this.siteId = siteId;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsRedirect withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsRedirect withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,69 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.core.model;
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.PossibleValueEnum;
/*******************************************************************************
** How a redirect's source path matches a request path. Its possible-value
** source is named after the redirect table (cms_redirect_match_type).
*******************************************************************************/
public enum CmsRedirectMatchType implements PossibleValueEnum<String>
{
EXACT("Exact path"),
PREFIX("Path prefix"),
REGEX("Regular expression");
/** The logical possible-value source name (the prefix is added). */
public static final String NAME = "redirect_match_type";
private final String label;
/*******************************************************************************
** Constructor.
*******************************************************************************/
CmsRedirectMatchType(String label)
{
this.label = label;
}
/*******************************************************************************
** The stored value.
*******************************************************************************/
@Override
public String getPossibleValueId()
{
return (name());
}
/*******************************************************************************
** The label.
*******************************************************************************/
@Override
public String getPossibleValueLabel()
{
return (label);
}
}
@@ -0,0 +1,366 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.core.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A kind of redirect and its HTTP status (reference data, for example 301 and
** 302).
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_redirect_type); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsRedirectType extends QRecordEntity
{
public static final String TABLE_NAME = "redirect_type";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 50, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String code;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.TRUNCATE)
private String description;
@QField(isRequired = true, label = "HTTP Status Code")
private Integer httpStatusCode;
@QField(isRequired = true, defaultValue = "true")
private Boolean isActive;
@QField(isRequired = true, defaultValue = "0")
private Integer sortOrder;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsRedirectType()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsRedirectType(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsRedirectType withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsRedirectType withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for code
*******************************************************************************/
public String getCode()
{
return (this.code);
}
/*******************************************************************************
** Setter for code
*******************************************************************************/
public void setCode(String code)
{
this.code = code;
}
/*******************************************************************************
** Fluent setter for code
*******************************************************************************/
public CmsRedirectType withCode(String code)
{
this.code = code;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsRedirectType withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for httpStatusCode
*******************************************************************************/
public Integer getHttpStatusCode()
{
return (this.httpStatusCode);
}
/*******************************************************************************
** Setter for httpStatusCode
*******************************************************************************/
public void setHttpStatusCode(Integer httpStatusCode)
{
this.httpStatusCode = httpStatusCode;
}
/*******************************************************************************
** Fluent setter for httpStatusCode
*******************************************************************************/
public CmsRedirectType withHttpStatusCode(Integer httpStatusCode)
{
this.httpStatusCode = httpStatusCode;
return (this);
}
/*******************************************************************************
** Getter for isActive
*******************************************************************************/
public Boolean getIsActive()
{
return (this.isActive);
}
/*******************************************************************************
** Setter for isActive
*******************************************************************************/
public void setIsActive(Boolean isActive)
{
this.isActive = isActive;
}
/*******************************************************************************
** Fluent setter for isActive
*******************************************************************************/
public CmsRedirectType withIsActive(Boolean isActive)
{
this.isActive = isActive;
return (this);
}
/*******************************************************************************
** Getter for sortOrder
*******************************************************************************/
public Integer getSortOrder()
{
return (this.sortOrder);
}
/*******************************************************************************
** Setter for sortOrder
*******************************************************************************/
public void setSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
}
/*******************************************************************************
** Fluent setter for sortOrder
*******************************************************************************/
public CmsRedirectType withSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsRedirectType withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsRedirectType withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,264 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.core.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A website served by the CMS. Every page, menu, redirect and snippet belongs
** to one site.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_site); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsSite extends QRecordEntity
{
public static final String TABLE_NAME = "site";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 40, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 20, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String shortName;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.TRUNCATE, gridColumns = 12)
private String description;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsSite()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsSite(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsSite withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsSite withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for shortName
*******************************************************************************/
public String getShortName()
{
return (this.shortName);
}
/*******************************************************************************
** Setter for shortName
*******************************************************************************/
public void setShortName(String shortName)
{
this.shortName = shortName;
}
/*******************************************************************************
** Fluent setter for shortName
*******************************************************************************/
public CmsSite withShortName(String shortName)
{
this.shortName = shortName;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsSite withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsSite withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsSite withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,399 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.core.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A reusable block of content of a site, referenced by its short name.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_snippet); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsSnippet extends QRecordEntity
{
public static final String TABLE_NAME = "snippet";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 50, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String shortName;
@QField(gridColumns = 12)
private String content;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, label = "CSS Class Name")
private String cssClassName;
@QField(isRequired = true, defaultValue = "true")
private Boolean isActive;
@QField(isRequired = true, defaultValue = "0")
private Integer sortOrder;
@QField(isRequired = true, possibleValueSourceName = "site", label = "Site")
private Long siteId;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsSnippet()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsSnippet(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsSnippet withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsSnippet withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for shortName
*******************************************************************************/
public String getShortName()
{
return (this.shortName);
}
/*******************************************************************************
** Setter for shortName
*******************************************************************************/
public void setShortName(String shortName)
{
this.shortName = shortName;
}
/*******************************************************************************
** Fluent setter for shortName
*******************************************************************************/
public CmsSnippet withShortName(String shortName)
{
this.shortName = shortName;
return (this);
}
/*******************************************************************************
** Getter for content
*******************************************************************************/
public String getContent()
{
return (this.content);
}
/*******************************************************************************
** Setter for content
*******************************************************************************/
public void setContent(String content)
{
this.content = content;
}
/*******************************************************************************
** Fluent setter for content
*******************************************************************************/
public CmsSnippet withContent(String content)
{
this.content = content;
return (this);
}
/*******************************************************************************
** Getter for cssClassName
*******************************************************************************/
public String getCssClassName()
{
return (this.cssClassName);
}
/*******************************************************************************
** Setter for cssClassName
*******************************************************************************/
public void setCssClassName(String cssClassName)
{
this.cssClassName = cssClassName;
}
/*******************************************************************************
** Fluent setter for cssClassName
*******************************************************************************/
public CmsSnippet withCssClassName(String cssClassName)
{
this.cssClassName = cssClassName;
return (this);
}
/*******************************************************************************
** Getter for isActive
*******************************************************************************/
public Boolean getIsActive()
{
return (this.isActive);
}
/*******************************************************************************
** Setter for isActive
*******************************************************************************/
public void setIsActive(Boolean isActive)
{
this.isActive = isActive;
}
/*******************************************************************************
** Fluent setter for isActive
*******************************************************************************/
public CmsSnippet withIsActive(Boolean isActive)
{
this.isActive = isActive;
return (this);
}
/*******************************************************************************
** Getter for sortOrder
*******************************************************************************/
public Integer getSortOrder()
{
return (this.sortOrder);
}
/*******************************************************************************
** Setter for sortOrder
*******************************************************************************/
public void setSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
}
/*******************************************************************************
** Fluent setter for sortOrder
*******************************************************************************/
public CmsSnippet withSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
return (this);
}
/*******************************************************************************
** Getter for siteId
*******************************************************************************/
public Long getSiteId()
{
return (this.siteId);
}
/*******************************************************************************
** Setter for siteId
*******************************************************************************/
public void setSiteId(Long siteId)
{
this.siteId = siteId;
}
/*******************************************************************************
** Fluent setter for siteId
*******************************************************************************/
public CmsSnippet withSiteId(Long siteId)
{
this.siteId = siteId;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsSnippet withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsSnippet withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,343 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.home;
import java.io.Serializable;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import com.kingsrook.qbits.cms.CmsQBitConfig;
import com.kingsrook.qbits.cms.CmsRuntime;
import com.kingsrook.qbits.cms.CmsTables;
import com.kingsrook.qbits.cms.metadata.CmsAreas;
import com.kingsrook.qbits.cms.metadata.CmsTableDefinition;
import com.kingsrook.qqq.backend.core.actions.dashboard.widgets.AbstractWidgetRenderer;
import com.kingsrook.qqq.backend.core.actions.permissions.PermissionEnforcement;
import com.kingsrook.qqq.backend.core.actions.permissions.PermissionsHelper;
import com.kingsrook.qqq.backend.core.actions.permissions.TablePermissionSubType;
import com.kingsrook.qqq.backend.core.actions.tables.CountAction;
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.exceptions.QPermissionDeniedException;
import com.kingsrook.qqq.backend.core.model.actions.tables.count.CountInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QCriteriaOperator;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QFilterCriteria;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QFilterOrderBy;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
import com.kingsrook.qqq.backend.core.model.actions.widgets.RenderWidgetInput;
import com.kingsrook.qqq.backend.core.model.actions.widgets.RenderWidgetOutput;
import com.kingsrook.qqq.backend.core.model.dashboard.widgets.RawHTML;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.dashboard.QWidgetMetaDataInterface;
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
/*******************************************************************************
** The CMS homes. One renderer serves the top app's home and every area's
** home; the widget's default values say which (namePrefix and area). Each
** home owns its data and shows only real data read as the current user, so
** a table the user may not read is left out instead of shown as zero:
**
** - the top home: one card per area with its main tables' counts (and
** unpublished pages), linking to the area; no per-record lists, so nothing
** duplicates an area home;
** - an area home: what needs attention (unpublished or inactive rows), the
** create actions the user may run, and the area's recently changed
** records. Next's app page lists the tables and counts below it.
**
** Reads always run with PermissionEnforcement.ENFORCE: a widget renders
** inside a trusted scope, and these counts must still be the user's own.
*******************************************************************************/
public class CmsHomeRenderer extends AbstractWidgetRenderer
{
public static final String KEY_NAME_PREFIX = "namePrefix";
public static final String KEY_AREA = "area";
static final int RECENT_ROWS = 8;
private static final DateTimeFormatter DATE = DateTimeFormatter.ofPattern("MMM d, yyyy", Locale.US).withZone(ZoneOffset.UTC);
/*******************************************************************************
** Render the home named by the widget's default values.
*******************************************************************************/
@Override
public RenderWidgetOutput render(RenderWidgetInput input) throws QException
{
QWidgetMetaDataInterface widget = input.getWidgetMetaData();
Map<String, Serializable> defaults = widget.getDefaultValues();
String prefix = defaults == null ? null : (String) defaults.get(KEY_NAME_PREFIX);
String areaKey = defaults == null ? null : (String) defaults.get(KEY_AREA);
Optional<CmsQBitConfig> config = CmsRuntime.findConfig(QContext.getQInstance(), prefix);
if(config.isEmpty())
{
throw (new QException("No CMS install with name prefix " + prefix));
}
StringBuilder html = new StringBuilder();
CmsRuntime runtime = config.get().getRuntime();
if(runtime != null && !runtime.getSchemaProblems().isEmpty())
{
html.append(CmsHtml.warning("The CMS database is not up to date, so some screens may fail: "
+ CmsHtml.escape(String.join(" ", runtime.getSchemaProblems()))));
}
Optional<CmsAreas.Area> area = areaKey == null ? Optional.empty() : CmsAreas.area(areaKey);
html.append(area.isPresent() ? renderArea(config.get(), area.get()) : renderTop(config.get()));
return (new RenderWidgetOutput(new RawHTML(widget.getLabel(), html.toString())));
}
/*******************************************************************************
** The top home: a card per area.
*******************************************************************************/
String renderTop(CmsQBitConfig config) throws QException
{
List<CmsHtml.Tile> tiles = new ArrayList<>();
for(CmsAreas.Area area : CmsAreas.areas(config))
{
List<String> notes = new ArrayList<>();
long total = 0;
boolean any = false;
for(String logical : area.mainTables())
{
Long count = count(config.applyPrefix(logical), null);
if(count != null)
{
any = true;
total += count;
notes.add(CmsHtml.link(tablePath(config, logical), plural(count, label(logical))) + draftNote(config, logical));
}
}
if(any)
{
tiles.add(new CmsHtml.Tile(area.label(), String.valueOf(total), "/app/" + area.appName(config), notes));
}
}
if(tiles.isEmpty())
{
return (CmsHtml.empty("You do not have access to any CMS area."));
}
return (CmsHtml.tiles(tiles));
}
/*******************************************************************************
** An area home. Next's app page already lists the area's tables with their
** record counts, so this home shows only what that list cannot: what needs
** attention, the create actions the user may run, and recent changes.
*******************************************************************************/
String renderArea(CmsQBitConfig config, CmsAreas.Area area) throws QException
{
StringBuilder html = new StringBuilder();
List<CmsHtml.Tile> attention = new ArrayList<>();
List<String> actions = new ArrayList<>();
List<QRecord> recent = new ArrayList<>();
boolean readable = false;
for(String logical : area.mainTables())
{
String table = config.applyPrefix(logical);
if(count(table, null) == null)
{
continue;
}
readable = true;
if(hasField(table, "isPublished"))
{
addAttention(attention, config, logical, "isPublished", "Unpublished ");
}
if(hasField(table, "isActive"))
{
addAttention(attention, config, logical, "isActive", "Inactive ");
}
if(PermissionsHelper.hasTablePermission(new InsertInput(table), table, TablePermissionSubType.INSERT))
{
actions.add(CmsHtml.link(tablePath(config, logical) + "/create", "New " + label(logical).toLowerCase(Locale.ROOT)));
}
recent.addAll(recent(table));
}
if(!readable)
{
return (CmsHtml.empty("You do not have access to " + CmsHtml.escape(area.label()) + "."));
}
html.append(CmsHtml.heading("Needs attention"));
html.append(attention.isEmpty() ? CmsHtml.empty("Nothing: everything here is published and active.") : CmsHtml.tiles(attention));
if(!actions.isEmpty())
{
html.append("<div style=\"display:flex;flex-wrap:wrap;gap:6px 18px;margin-top:12px\">");
actions.forEach(a -> html.append("<span>").append(a).append("</span>"));
html.append("</div>");
}
html.append(CmsHtml.heading("Recently changed"));
recent.sort(Comparator.comparing((QRecord r) -> r.getValueInstant("modifyDate"), Comparator.nullsLast(Comparator.reverseOrder())));
if(recent.isEmpty())
{
html.append(CmsHtml.empty("Nothing yet. Records you create appear here."));
}
else
{
List<CmsHtml.Row> rows = new ArrayList<>();
for(QRecord record : recent.subList(0, Math.min(RECENT_ROWS, recent.size())))
{
String logical = record.getTableName().substring(config.getTableNamePrefix().length());
String title = record.getRecordLabel() != null ? record.getRecordLabel() : label(logical) + " " + record.getValue("id");
Instant when = record.getValueInstant("modifyDate");
rows.add(new CmsHtml.Row(title, tablePath(config, logical) + "/" + record.getValue("id"), label(logical) + (when == null ? "" : " · " + DATE.format(when))));
}
html.append(CmsHtml.rows(rows));
}
return (html.toString());
}
/*******************************************************************************
** A "needs attention" tile when some rows of a table have a flag off.
*******************************************************************************/
private void addAttention(List<CmsHtml.Tile> tiles, CmsQBitConfig config, String logical, String flagField, String labelPrefix) throws QException
{
Long count = count(config.applyPrefix(logical), new QQueryFilter(new QFilterCriteria(flagField, QCriteriaOperator.EQUALS, false)));
if(count != null && count > 0)
{
tiles.add(new CmsHtml.Tile(labelPrefix + pluralLabel(logical).toLowerCase(Locale.ROOT), String.valueOf(count), tablePath(config, logical), List.of()));
}
}
/*******************************************************************************
** ", N drafts" for a table with an isPublished field (empty otherwise).
*******************************************************************************/
private String draftNote(CmsQBitConfig config, String logical) throws QException
{
String table = config.applyPrefix(logical);
if(!hasField(table, "isPublished"))
{
return ("");
}
Long drafts = count(table, new QQueryFilter(new QFilterCriteria("isPublished", QCriteriaOperator.EQUALS, false)));
return (drafts == null || drafts == 0 ? "" : ", " + CmsHtml.muted(drafts + " unpublished"));
}
/*******************************************************************************
** The most recently changed records of a table, read as the current user.
*******************************************************************************/
private List<QRecord> recent(String table) throws QException
{
try
{
QueryInput queryInput = new QueryInput(table)
.withFilter(new QQueryFilter().withOrderBy(new QFilterOrderBy("modifyDate", false)).withLimit(RECENT_ROWS))
.withShouldGenerateDisplayValues(true);
queryInput.setPermissionEnforcement(PermissionEnforcement.ENFORCE);
return (new QueryAction().execute(queryInput).getRecords());
}
catch(QPermissionDeniedException e)
{
return (List.of());
}
}
/*******************************************************************************
** A count read as the current user, or null when the user may not read it.
*******************************************************************************/
private Long count(String table, QQueryFilter filter) throws QException
{
try
{
CountInput countInput = new CountInput(table).withFilter(filter);
countInput.setPermissionEnforcement(PermissionEnforcement.ENFORCE);
Integer count = new CountAction().execute(countInput).getCount();
return (count == null ? 0L : count.longValue());
}
catch(QPermissionDeniedException e)
{
return (null);
}
}
/*******************************************************************************
**
*******************************************************************************/
private static boolean hasField(String table, String field)
{
QTableMetaData tableMetaData = QContext.getQInstance().getTable(table);
return (tableMetaData != null && tableMetaData.getFields().containsKey(field));
}
/*******************************************************************************
** The admin path of a table (Next routes tables at /app/name).
*******************************************************************************/
static String tablePath(CmsQBitConfig config, String logical)
{
return ("/app/" + config.applyPrefix(logical));
}
/*******************************************************************************
**
*******************************************************************************/
private static String label(String logical)
{
return (CmsTables.definition(logical).map(CmsTableDefinition::label).orElse(logical));
}
/*******************************************************************************
**
*******************************************************************************/
private static String pluralLabel(String logical)
{
return (CmsTableDefinition.pluralize(label(logical)));
}
/*******************************************************************************
** "1 page" / "3 pages".
*******************************************************************************/
static String plural(long count, String label)
{
String lower = label.toLowerCase(Locale.ROOT);
return (count + " " + (count == 1 ? lower : CmsTableDefinition.pluralize(lower)));
}
}
@@ -0,0 +1,188 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.home;
import java.util.List;
/*******************************************************************************
** Small HTML building blocks for the CMS homes, readable at every width and
** in light and dark mode: text inherits the surrounding color, borders and
** fills are translucent, grids wrap to one column on a phone, long words
** break instead of scrolling sideways.
*******************************************************************************/
public final class CmsHtml
{
static final String MUTED = "opacity:.72";
static final String WRAP = "overflow-wrap:anywhere;min-width:0";
static final String CARD = "box-sizing:border-box;min-width:0;padding:14px 16px;border-radius:10px;border:1px solid rgba(127,127,127,.28);background:rgba(127,127,127,.06)";
/*******************************************************************************
** A tile: label, big number, optional notes; the number links to href.
**
** @param label the label
** @param value the value text
** @param href the link (may be null)
** @param notes secondary lines (already HTML)
*******************************************************************************/
public record Tile(String label, String value, String href, List<String> notes)
{
}
/*******************************************************************************
** A list row: a linked title and a muted detail.
**
** @param title the title
** @param href the link (may be null)
** @param detail the detail
*******************************************************************************/
public record Row(String title, String href, String detail)
{
}
/*******************************************************************************
** Not instantiable.
*******************************************************************************/
private CmsHtml()
{
}
/*******************************************************************************
** HTML-escape text.
*******************************************************************************/
public static String escape(String text)
{
if(text == null)
{
return ("");
}
StringBuilder rs = new StringBuilder(text.length());
for(char c : text.toCharArray())
{
switch(c)
{
case '<' -> rs.append("&lt;");
case '>' -> rs.append("&gt;");
case '&' -> rs.append("&amp;");
case '"' -> rs.append("&quot;");
case '\'' -> rs.append("&#39;");
default -> rs.append(c);
}
}
return (rs.toString());
}
/*******************************************************************************
** A link that inherits the text color.
*******************************************************************************/
public static String link(String href, String text)
{
return ("<a href=\"" + escape(href) + "\" style=\"color:inherit;text-decoration:underline;text-underline-offset:2px\">" + escape(text) + "</a>");
}
/*******************************************************************************
** Muted text (already HTML).
*******************************************************************************/
public static String muted(String html)
{
return ("<span style=\"" + MUTED + ";font-size:.875rem\">" + html + "</span>");
}
/*******************************************************************************
** A heading inside a widget.
*******************************************************************************/
public static String heading(String text)
{
return ("<div style=\"margin:18px 0 8px;font-size:.875rem;font-weight:600;text-transform:uppercase;letter-spacing:.04em;" + MUTED + "\">" + escape(text) + "</div>");
}
/*******************************************************************************
** A responsive grid of tiles (one column on a phone).
*******************************************************************************/
public static String tiles(List<Tile> tiles)
{
StringBuilder html = new StringBuilder("<div style=\"display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,13rem),1fr));gap:12px\">");
for(Tile tile : tiles)
{
html.append("<div style=\"").append(CARD).append("\">");
html.append("<div style=\"font-size:.875rem;").append(MUTED).append(';').append(WRAP).append("\">").append(escape(tile.label())).append("</div>");
String value = tile.href() == null ? escape(tile.value())
: "<a href=\"" + escape(tile.href()) + "\" style=\"color:inherit;text-decoration:none\">" + escape(tile.value()) + "</a>";
html.append("<div style=\"font-size:1.625rem;font-weight:600;line-height:1.3;").append(WRAP).append("\">").append(value).append("</div>");
for(String note : tile.notes())
{
html.append("<div style=\"font-size:.875rem;").append(WRAP).append("\">").append(note).append("</div>");
}
html.append("</div>");
}
return (html.append("</div>").toString());
}
/*******************************************************************************
** A plain list of rows, each wrapping as needed.
*******************************************************************************/
public static String rows(List<Row> rows)
{
StringBuilder html = new StringBuilder("<ul style=\"list-style:none;margin:0;padding:0\">");
for(Row row : rows)
{
html.append("<li style=\"display:flex;flex-wrap:wrap;align-items:baseline;column-gap:10px;row-gap:2px;padding:7px 0;border-bottom:1px solid rgba(127,127,127,.18)\">");
html.append("<span style=\"flex:1 1 14rem;").append(WRAP).append("\">").append(row.href() == null ? escape(row.title()) : link(row.href(), row.title())).append("</span>");
html.append("<span style=\"flex:0 1 auto;font-size:.875rem;").append(MUTED).append(';').append(WRAP).append("\">").append(escape(row.detail())).append("</span>");
html.append("</li>");
}
return (html.append("</ul>").toString());
}
/*******************************************************************************
** An honest empty state.
*******************************************************************************/
public static String empty(String messageHtml)
{
return ("<div style=\"padding:14px 2px;font-size:.875rem;" + MUTED + ';' + WRAP + "\">" + messageHtml + "</div>");
}
/*******************************************************************************
** A warning banner (amber left border, readable in both modes).
*******************************************************************************/
public static String warning(String messageHtml)
{
return ("<div style=\"margin:0 0 12px;padding:8px 12px;border-left:3px solid #d97706;border-radius:4px;background:rgba(217,119,6,.10);font-size:.875rem;"
+ WRAP + "\">" + messageHtml + "</div>");
}
}
@@ -0,0 +1,945 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.media.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DisplayFormat;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A file in a site's media library: where it is, what it is, and the text
** that goes with it (alternative text, caption, credit and license).
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_media); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsMedia extends QRecordEntity
{
public static final String TABLE_NAME = "media";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 200, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String slug;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.TRUNCATE)
private String description;
@QField(maxLength = 1000, valueTooLongBehavior = ValueTooLongBehavior.ERROR, label = "Alt text")
private String altText;
@QField(maxLength = 2000, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String caption;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String credit;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String license;
@QField(isRequired = true, possibleValueSourceName = "media_type", label = "Media Type")
private Long mediaTypeId;
@QField(isEditable = false, maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String fileName;
@QField(isEditable = false, maxLength = 20, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String fileExtension;
@QField(maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR, label = "MIME type")
private String mimeType;
@QField(isEditable = false, displayFormat = DisplayFormat.COMMAS)
private Long fileSize;
@QField(isEditable = false, displayFormat = DisplayFormat.COMMAS)
private Integer width;
@QField(isEditable = false, displayFormat = DisplayFormat.COMMAS)
private Integer height;
@QField(isEditable = false, displayFormat = DisplayFormat.COMMAS)
private Integer duration;
@QField(isEditable = false, maxLength = 64, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String checksum;
@QField(isRequired = true, defaultValue = "true")
private Boolean isActive;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "Public URL")
private String publicUrl;
@QField(isEditable = false, maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.TRUNCATE)
private String storageKey;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "Thumbnail URL")
private String thumbnailUrl;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "Gallery URL")
private String galleryUrl;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "Slideshow URL")
private String slideshowUrl;
@QField(isRequired = true, possibleValueSourceName = "site", label = "Site")
private Long siteId;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsMedia()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsMedia(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsMedia withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsMedia withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for slug
*******************************************************************************/
public String getSlug()
{
return (this.slug);
}
/*******************************************************************************
** Setter for slug
*******************************************************************************/
public void setSlug(String slug)
{
this.slug = slug;
}
/*******************************************************************************
** Fluent setter for slug
*******************************************************************************/
public CmsMedia withSlug(String slug)
{
this.slug = slug;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsMedia withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for altText
*******************************************************************************/
public String getAltText()
{
return (this.altText);
}
/*******************************************************************************
** Setter for altText
*******************************************************************************/
public void setAltText(String altText)
{
this.altText = altText;
}
/*******************************************************************************
** Fluent setter for altText
*******************************************************************************/
public CmsMedia withAltText(String altText)
{
this.altText = altText;
return (this);
}
/*******************************************************************************
** Getter for caption
*******************************************************************************/
public String getCaption()
{
return (this.caption);
}
/*******************************************************************************
** Setter for caption
*******************************************************************************/
public void setCaption(String caption)
{
this.caption = caption;
}
/*******************************************************************************
** Fluent setter for caption
*******************************************************************************/
public CmsMedia withCaption(String caption)
{
this.caption = caption;
return (this);
}
/*******************************************************************************
** Getter for credit
*******************************************************************************/
public String getCredit()
{
return (this.credit);
}
/*******************************************************************************
** Setter for credit
*******************************************************************************/
public void setCredit(String credit)
{
this.credit = credit;
}
/*******************************************************************************
** Fluent setter for credit
*******************************************************************************/
public CmsMedia withCredit(String credit)
{
this.credit = credit;
return (this);
}
/*******************************************************************************
** Getter for license
*******************************************************************************/
public String getLicense()
{
return (this.license);
}
/*******************************************************************************
** Setter for license
*******************************************************************************/
public void setLicense(String license)
{
this.license = license;
}
/*******************************************************************************
** Fluent setter for license
*******************************************************************************/
public CmsMedia withLicense(String license)
{
this.license = license;
return (this);
}
/*******************************************************************************
** Getter for mediaTypeId
*******************************************************************************/
public Long getMediaTypeId()
{
return (this.mediaTypeId);
}
/*******************************************************************************
** Setter for mediaTypeId
*******************************************************************************/
public void setMediaTypeId(Long mediaTypeId)
{
this.mediaTypeId = mediaTypeId;
}
/*******************************************************************************
** Fluent setter for mediaTypeId
*******************************************************************************/
public CmsMedia withMediaTypeId(Long mediaTypeId)
{
this.mediaTypeId = mediaTypeId;
return (this);
}
/*******************************************************************************
** Getter for fileName
*******************************************************************************/
public String getFileName()
{
return (this.fileName);
}
/*******************************************************************************
** Setter for fileName
*******************************************************************************/
public void setFileName(String fileName)
{
this.fileName = fileName;
}
/*******************************************************************************
** Fluent setter for fileName
*******************************************************************************/
public CmsMedia withFileName(String fileName)
{
this.fileName = fileName;
return (this);
}
/*******************************************************************************
** Getter for fileExtension
*******************************************************************************/
public String getFileExtension()
{
return (this.fileExtension);
}
/*******************************************************************************
** Setter for fileExtension
*******************************************************************************/
public void setFileExtension(String fileExtension)
{
this.fileExtension = fileExtension;
}
/*******************************************************************************
** Fluent setter for fileExtension
*******************************************************************************/
public CmsMedia withFileExtension(String fileExtension)
{
this.fileExtension = fileExtension;
return (this);
}
/*******************************************************************************
** Getter for mimeType
*******************************************************************************/
public String getMimeType()
{
return (this.mimeType);
}
/*******************************************************************************
** Setter for mimeType
*******************************************************************************/
public void setMimeType(String mimeType)
{
this.mimeType = mimeType;
}
/*******************************************************************************
** Fluent setter for mimeType
*******************************************************************************/
public CmsMedia withMimeType(String mimeType)
{
this.mimeType = mimeType;
return (this);
}
/*******************************************************************************
** Getter for fileSize
*******************************************************************************/
public Long getFileSize()
{
return (this.fileSize);
}
/*******************************************************************************
** Setter for fileSize
*******************************************************************************/
public void setFileSize(Long fileSize)
{
this.fileSize = fileSize;
}
/*******************************************************************************
** Fluent setter for fileSize
*******************************************************************************/
public CmsMedia withFileSize(Long fileSize)
{
this.fileSize = fileSize;
return (this);
}
/*******************************************************************************
** Getter for width
*******************************************************************************/
public Integer getWidth()
{
return (this.width);
}
/*******************************************************************************
** Setter for width
*******************************************************************************/
public void setWidth(Integer width)
{
this.width = width;
}
/*******************************************************************************
** Fluent setter for width
*******************************************************************************/
public CmsMedia withWidth(Integer width)
{
this.width = width;
return (this);
}
/*******************************************************************************
** Getter for height
*******************************************************************************/
public Integer getHeight()
{
return (this.height);
}
/*******************************************************************************
** Setter for height
*******************************************************************************/
public void setHeight(Integer height)
{
this.height = height;
}
/*******************************************************************************
** Fluent setter for height
*******************************************************************************/
public CmsMedia withHeight(Integer height)
{
this.height = height;
return (this);
}
/*******************************************************************************
** Getter for duration
*******************************************************************************/
public Integer getDuration()
{
return (this.duration);
}
/*******************************************************************************
** Setter for duration
*******************************************************************************/
public void setDuration(Integer duration)
{
this.duration = duration;
}
/*******************************************************************************
** Fluent setter for duration
*******************************************************************************/
public CmsMedia withDuration(Integer duration)
{
this.duration = duration;
return (this);
}
/*******************************************************************************
** Getter for checksum
*******************************************************************************/
public String getChecksum()
{
return (this.checksum);
}
/*******************************************************************************
** Setter for checksum
*******************************************************************************/
public void setChecksum(String checksum)
{
this.checksum = checksum;
}
/*******************************************************************************
** Fluent setter for checksum
*******************************************************************************/
public CmsMedia withChecksum(String checksum)
{
this.checksum = checksum;
return (this);
}
/*******************************************************************************
** Getter for isActive
*******************************************************************************/
public Boolean getIsActive()
{
return (this.isActive);
}
/*******************************************************************************
** Setter for isActive
*******************************************************************************/
public void setIsActive(Boolean isActive)
{
this.isActive = isActive;
}
/*******************************************************************************
** Fluent setter for isActive
*******************************************************************************/
public CmsMedia withIsActive(Boolean isActive)
{
this.isActive = isActive;
return (this);
}
/*******************************************************************************
** Getter for publicUrl
*******************************************************************************/
public String getPublicUrl()
{
return (this.publicUrl);
}
/*******************************************************************************
** Setter for publicUrl
*******************************************************************************/
public void setPublicUrl(String publicUrl)
{
this.publicUrl = publicUrl;
}
/*******************************************************************************
** Fluent setter for publicUrl
*******************************************************************************/
public CmsMedia withPublicUrl(String publicUrl)
{
this.publicUrl = publicUrl;
return (this);
}
/*******************************************************************************
** Getter for storageKey
*******************************************************************************/
public String getStorageKey()
{
return (this.storageKey);
}
/*******************************************************************************
** Setter for storageKey
*******************************************************************************/
public void setStorageKey(String storageKey)
{
this.storageKey = storageKey;
}
/*******************************************************************************
** Fluent setter for storageKey
*******************************************************************************/
public CmsMedia withStorageKey(String storageKey)
{
this.storageKey = storageKey;
return (this);
}
/*******************************************************************************
** Getter for thumbnailUrl
*******************************************************************************/
public String getThumbnailUrl()
{
return (this.thumbnailUrl);
}
/*******************************************************************************
** Setter for thumbnailUrl
*******************************************************************************/
public void setThumbnailUrl(String thumbnailUrl)
{
this.thumbnailUrl = thumbnailUrl;
}
/*******************************************************************************
** Fluent setter for thumbnailUrl
*******************************************************************************/
public CmsMedia withThumbnailUrl(String thumbnailUrl)
{
this.thumbnailUrl = thumbnailUrl;
return (this);
}
/*******************************************************************************
** Getter for galleryUrl
*******************************************************************************/
public String getGalleryUrl()
{
return (this.galleryUrl);
}
/*******************************************************************************
** Setter for galleryUrl
*******************************************************************************/
public void setGalleryUrl(String galleryUrl)
{
this.galleryUrl = galleryUrl;
}
/*******************************************************************************
** Fluent setter for galleryUrl
*******************************************************************************/
public CmsMedia withGalleryUrl(String galleryUrl)
{
this.galleryUrl = galleryUrl;
return (this);
}
/*******************************************************************************
** Getter for slideshowUrl
*******************************************************************************/
public String getSlideshowUrl()
{
return (this.slideshowUrl);
}
/*******************************************************************************
** Setter for slideshowUrl
*******************************************************************************/
public void setSlideshowUrl(String slideshowUrl)
{
this.slideshowUrl = slideshowUrl;
}
/*******************************************************************************
** Fluent setter for slideshowUrl
*******************************************************************************/
public CmsMedia withSlideshowUrl(String slideshowUrl)
{
this.slideshowUrl = slideshowUrl;
return (this);
}
/*******************************************************************************
** Getter for siteId
*******************************************************************************/
public Long getSiteId()
{
return (this.siteId);
}
/*******************************************************************************
** Setter for siteId
*******************************************************************************/
public void setSiteId(Long siteId)
{
this.siteId = siteId;
}
/*******************************************************************************
** Fluent setter for siteId
*******************************************************************************/
public CmsMedia withSiteId(Long siteId)
{
this.siteId = siteId;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsMedia withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsMedia withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,69 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.media.model;
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.PossibleValueEnum;
/*******************************************************************************
** How long browsers and CDNs may keep a media type's files. Its
** possible-value source is named after the media tables
** (cms_media_cache_class).
*******************************************************************************/
public enum CmsMediaCacheClass implements PossibleValueEnum<String>
{
IMMUTABLE("Immutable (1 year)"),
MUTABLE("Mutable (1 day)");
/** The logical possible-value source name (the prefix is added). */
public static final String NAME = "media_cache_class";
private final String label;
/*******************************************************************************
** Constructor.
*******************************************************************************/
CmsMediaCacheClass(String label)
{
this.label = label;
}
/*******************************************************************************
** The stored value.
*******************************************************************************/
@Override
public String getPossibleValueId()
{
return (name());
}
/*******************************************************************************
** The label.
*******************************************************************************/
@Override
public String getPossibleValueLabel()
{
return (label);
}
}
@@ -0,0 +1,69 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.media.model;
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.PossibleValueEnum;
/*******************************************************************************
** The image format of a generated rendition. Its possible-value source is
** named after the media tables (cms_media_rendition_format).
*******************************************************************************/
public enum CmsMediaRenditionFormat implements PossibleValueEnum<String>
{
JPEG("JPEG"),
PNG("PNG"),
WEBP("WebP");
/** The logical possible-value source name (the prefix is added). */
public static final String NAME = "media_rendition_format";
private final String label;
/*******************************************************************************
** Constructor.
*******************************************************************************/
CmsMediaRenditionFormat(String label)
{
this.label = label;
}
/*******************************************************************************
** The stored value.
*******************************************************************************/
@Override
public String getPossibleValueId()
{
return (name());
}
/*******************************************************************************
** The label.
*******************************************************************************/
@Override
public String getPossibleValueLabel()
{
return (label);
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,123 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.metadata;
import java.util.ArrayList;
import java.util.List;
import com.kingsrook.qbits.cms.CmsQBitConfig;
import com.kingsrook.qbits.cms.home.CmsHomeRenderer;
import com.kingsrook.qqq.backend.core.model.dashboard.widgets.WidgetType;
import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
import com.kingsrook.qqq.backend.core.model.metadata.dashboard.QWidgetMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppSection;
import com.kingsrook.qqq.backend.core.model.metadata.layout.QIcon;
/*******************************************************************************
** Builds the CMS app tree: one top app with its home, and one sub-app per
** area with its own home. The nav of an area lists its main tables and a
** Settings section of reference tables; processes are never in the nav.
** The qbit never sets the instance's home app (the host owns its landing
** page).
*******************************************************************************/
public class CmsAppBuilder
{
private final CmsQBitConfig config;
/*******************************************************************************
** Constructor.
*******************************************************************************/
public CmsAppBuilder(CmsQBitConfig config)
{
this.config = config;
}
/*******************************************************************************
** The result: the apps (top first) and their home widgets.
*******************************************************************************/
public record Built(List<QAppMetaData> apps, List<QWidgetMetaData> widgets)
{
}
/*******************************************************************************
** Build the apps and homes.
*******************************************************************************/
public Built build()
{
List<QAppMetaData> apps = new ArrayList<>();
List<QWidgetMetaData> widgets = new ArrayList<>();
String topHome = CmsAreas.topHomeWidgetName(config);
QAppMetaData top = new QAppMetaData()
.withName(config.getEffectiveAppName())
.withLabel(config.getAppLabel())
.withIcon(new QIcon("web"))
.withWidgets(List.of(topHome));
apps.add(top);
widgets.add(homeWidget(topHome, config.getAppLabel(), null));
for(CmsAreas.Area area : CmsAreas.areas(config))
{
QAppMetaData sub = new QAppMetaData()
.withName(area.appName(config))
.withLabel(area.label())
.withIcon(new QIcon(area.icon()))
.withWidgets(List.of(area.homeWidgetName(config)))
.withSection(new QAppSection().withName(area.appName(config)).withLabel(area.label()).withIcon(new QIcon(area.icon()))
.withTables(area.mainTables().stream().map(config::applyPrefix).toList()));
if(!area.settingsTables().isEmpty())
{
sub.withSection(new QAppSection().withName(area.appName(config) + "Settings").withLabel("Settings").withIcon(new QIcon("settings"))
.withTables(area.settingsTables().stream().map(config::applyPrefix).toList()));
}
top.withChild(sub);
apps.add(sub);
widgets.add(homeWidget(area.homeWidgetName(config), area.label(), area.key()));
}
return (new Built(apps, widgets));
}
/*******************************************************************************
** A home widget (full width; one renderer, told which home by its defaults).
*******************************************************************************/
private QWidgetMetaData homeWidget(String name, String label, String areaKey)
{
QWidgetMetaData widget = new QWidgetMetaData()
.withName(name)
.withLabel(label)
.withType(WidgetType.HTML.getType())
.withCodeReference(new QCodeReference(CmsHomeRenderer.class))
.withGridColumns(12)
.withIsCard(true)
.withDefaultValue(CmsHomeRenderer.KEY_NAME_PREFIX, config.getNamePrefix());
if(areaKey != null)
{
widget.withDefaultValue(CmsHomeRenderer.KEY_AREA, areaKey);
}
return (widget);
}
}
@@ -0,0 +1,114 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.metadata;
import java.util.List;
import java.util.Optional;
import com.kingsrook.qbits.cms.CmsFeature;
import com.kingsrook.qbits.cms.CmsQBitConfig;
import com.kingsrook.qbits.cms.CmsTables;
/*******************************************************************************
** The CMS areas: one sub-app each, with its own home. An area lists only its
** main tables in the nav, plus a Settings section for reference data; child
** tables are edited on their parents' records (owner rule).
*******************************************************************************/
public final class CmsAreas
{
/*******************************************************************************
** One area.
**
** @param key the name suffix (sub-app cmsSites, home cmsSitesHome)
** @param label the label
** @param icon a Material icon name
** @param feature the feature that owns the area
** @param mainTables logical names of the tables in the nav
** @param settingsTables logical names of the reference tables
*******************************************************************************/
public record Area(String key, String label, String icon, CmsFeature feature, List<String> mainTables, List<String> settingsTables)
{
/*******************************************************************************
** The sub-app name.
*******************************************************************************/
public String appName(CmsQBitConfig config)
{
return (config.name(key));
}
/*******************************************************************************
** The home widget name.
*******************************************************************************/
public String homeWidgetName(CmsQBitConfig config)
{
return (config.name(key + "Home"));
}
}
private static final List<Area> AREAS = List.of(
new Area("Sites", "Sites", "language", CmsFeature.CORE, List.of(CmsTables.SITE, CmsTables.REDIRECT), List.of(CmsTables.REDIRECT_TYPE)),
new Area("Pages", "Pages", "description", CmsFeature.CORE, List.of(CmsTables.PAGE, CmsTables.SNIPPET), List.of(CmsTables.PAGE_TYPE, CmsTables.PAGE_SECTION_TYPE)),
new Area("Navigation", "Navigation", "menu", CmsFeature.CORE, List.of(CmsTables.MENU), List.of()),
new Area("Media", "Media", "perm_media", CmsFeature.MEDIA, List.of(CmsTables.MEDIA), List.of(CmsTables.MEDIA_TYPE)),
new Area("Blogs", "Blogs", "article", CmsFeature.BLOG, List.of(CmsTables.BLOG_POST, CmsTables.BLOG, CmsTables.AUTHOR), List.of(CmsTables.BLOG_TYPE)),
new Area("Projects", "Projects", "code", CmsFeature.PROJECTS, List.of(CmsTables.PROJECT, CmsTables.PROJECT_CATEGORY), List.of()),
new Area("Photos", "Photos", "photo_camera", CmsFeature.PHOTOS, List.of(CmsTables.PHOTO_ALBUM, CmsTables.PHOTO_ALBUM_FOLDER, CmsTables.PHOTO_TAG), List.of()));
/*******************************************************************************
** Not instantiable.
*******************************************************************************/
private CmsAreas()
{
}
/*******************************************************************************
** The areas of the config's features.
*******************************************************************************/
public static List<Area> areas(CmsQBitConfig config)
{
return (AREAS.stream().filter(a -> config.hasFeature(a.feature())).toList());
}
/*******************************************************************************
** One area by key.
*******************************************************************************/
public static Optional<Area> area(String key)
{
return (AREAS.stream().filter(a -> a.key().equals(key)).findFirst());
}
/*******************************************************************************
** The top app's home widget name.
*******************************************************************************/
public static String topHomeWidgetName(CmsQBitConfig config)
{
return (config.name("Home"));
}
}
@@ -0,0 +1,319 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.metadata;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.kingsrook.qbits.cms.CmsQBitConfig;
import com.kingsrook.qbits.cms.CmsTables;
import com.kingsrook.qbits.cms.core.model.CmsRedirectMatchType;
import com.kingsrook.qbits.cms.security.CmsOpenReadsPermissionChecker;
import com.kingsrook.qqq.backend.core.actions.customizers.TableCustomizers;
import com.kingsrook.qqq.backend.core.actions.dashboard.widgets.ChildRecordListRenderer;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.instances.QInstanceEnricher;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QFilterOrderBy;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.audits.AuditLevel;
import com.kingsrook.qqq.backend.core.model.metadata.audits.QAuditRules;
import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
import com.kingsrook.qqq.backend.core.model.metadata.dashboard.QWidgetMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.fields.AdornmentType;
import com.kingsrook.qqq.backend.core.model.metadata.fields.FieldAdornment;
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldType;
import com.kingsrook.qqq.backend.core.model.metadata.help.QHelpContent;
import com.kingsrook.qqq.backend.core.model.metadata.joins.JoinOn;
import com.kingsrook.qqq.backend.core.model.metadata.joins.JoinType;
import com.kingsrook.qqq.backend.core.model.metadata.joins.QJoinMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.layout.QIcon;
import com.kingsrook.qqq.backend.core.model.metadata.permissions.PermissionLevel;
import com.kingsrook.qqq.backend.core.model.metadata.permissions.QPermissionRules;
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.QPossibleValueSource;
import com.kingsrook.qqq.backend.core.model.metadata.tables.Association;
import com.kingsrook.qqq.backend.core.model.metadata.tables.ExposedJoin;
import com.kingsrook.qqq.backend.core.model.metadata.tables.QFieldSection;
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.tables.Tier;
import com.kingsrook.qqq.backend.core.model.metadata.tables.UniqueKey;
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSTableBackendDetails;
/*******************************************************************************
** Builds the CMS tables of a config: one standard QQQ table per definition
** (fields from the entity, prefixed names, snake_case columns), a
** possible-value source per table and per value list, joins and child-record lists for child
** tables, associations, permission rules and field audit.
**
** Every table is a normal, visible QQQ table (owner rule): reference tables
** and child tables are left out of the nav, not hidden.
*******************************************************************************/
public class CmsTableBuilder
{
/** The QQQ audit table; field audit is applied only when the host has it. */
static final String AUDIT_TABLE = "audit";
private final CmsQBitConfig config;
/*******************************************************************************
** Constructor.
*******************************************************************************/
public CmsTableBuilder(CmsQBitConfig config)
{
this.config = config;
}
/*******************************************************************************
** The result of a build.
**
** @param tables the tables, by physical name
** @param possibleValueSources the possible-value sources
** @param joins the joins
** @param widgets the child-record list widgets
*******************************************************************************/
public record Built(Map<String, QTableMetaData> tables, List<QPossibleValueSource> possibleValueSources, List<QJoinMetaData> joins,
List<QWidgetMetaData> widgets)
{
}
/*******************************************************************************
** Build every table of the config's features.
*******************************************************************************/
public Built build(QInstance qInstance) throws QException
{
List<CmsTableDefinition> definitions = CmsTables.definitions(config);
Set<String> logicals = definitions.stream().map(CmsTableDefinition::logicalName).collect(Collectors.toSet());
Map<String, QTableMetaData> tables = new LinkedHashMap<>();
List<QPossibleValueSource> pvs = new ArrayList<>();
List<QJoinMetaData> joins = new ArrayList<>();
List<QWidgetMetaData> widgets = new ArrayList<>();
boolean audit = qInstance.getTable(AUDIT_TABLE) != null;
for(CmsTableDefinition definition : definitions)
{
tables.put(config.applyPrefix(definition.logicalName()), buildTable(definition, logicals, audit));
pvs.add(QPossibleValueSource.newForTable(config.applyPrefix(definition.logicalName())));
}
for(String valueList : CmsTables.valueListNames())
{
String name = config.applyPrefix(valueList);
if(tables.values().stream().anyMatch(t -> t.getFields().values().stream().anyMatch(f -> name.equals(f.getPossibleValueSourceName()))))
{
pvs.add(QPossibleValueSource.newForEnum(name, CmsTables.valueList(valueList).orElseThrow()));
}
}
if(logicals.contains(CmsTables.REDIRECT))
{
pvs.add(QPossibleValueSource.newForEnum(config.applyPrefix(CmsRedirectMatchType.NAME), CmsRedirectMatchType.values()));
}
for(CmsTableDefinition definition : definitions)
{
QTableMetaData parent = tables.get(config.applyPrefix(definition.logicalName()));
for(CmsTableDefinition.Child child : definition.children())
{
if(logicals.contains(child.childLogicalName()))
{
addChild(parent, definition, child, joins, widgets);
}
}
}
return (new Built(tables, pvs, joins, widgets));
}
/*******************************************************************************
** One table.
*******************************************************************************/
QTableMetaData buildTable(CmsTableDefinition definition, Set<String> logicals, boolean audit) throws QException
{
String name = config.applyPrefix(definition.logicalName());
QTableMetaData table = new QTableMetaData()
.withName(name)
.withLabel(definition.pluralLabel())
.withIcon(new QIcon(definition.icon()))
.withBackendName(config.getBackendName())
.withBackendDetails(new RDBMSTableBackendDetails().withTableName(name))
.withPrimaryKeyField("id")
.withFieldsFromEntity(definition.entityClass())
.withRecordLabelFormat(String.join(" ", definition.recordLabelFields().stream().map(f -> "%s").toList()))
.withRecordLabelFields(definition.recordLabelFields())
.withPermissionRules(permissionRules());
boolean valueLists = false;
for(QFieldMetaData field : table.getFields().values())
{
String pvsName = field.getPossibleValueSourceName();
valueLists |= pvsName != null && CmsTables.valueList(pvsName).isPresent();
if(pvsName != null && (logicals.contains(pvsName) || CmsTables.valueList(pvsName).isPresent()))
{
field.setPossibleValueSourceName(config.applyPrefix(pvsName));
}
else if(pvsName != null)
{
//////////////////////////////////////////////////////////////////
// a reference to a table of a feature that is off: no lookup //
//////////////////////////////////////////////////////////////////
field.setPossibleValueSourceName(null);
}
if(definition.textFields().contains(field.getName()))
{
field.setType(QFieldType.TEXT);
}
}
if(CmsTables.REDIRECT.equals(definition.logicalName()))
{
table.getField("matchType").setPossibleValueSourceName(config.applyPrefix(CmsRedirectMatchType.NAME));
}
if(valueLists)
{
table.withCustomizer(TableCustomizers.PRE_INSERT_RECORD.getRole(), new QCodeReference(CmsValueListCheck.class));
table.withCustomizer(TableCustomizers.PRE_UPDATE_RECORD.getRole(), new QCodeReference(CmsValueListCheck.class));
}
for(CmsTableDefinition.Preview preview : definition.previews())
{
table.getField(preview.field()).withFieldAdornment(previewAdornment(preview));
}
for(Map.Entry<String, String> help : definition.helpTexts().entrySet())
{
table.getField(help.getKey()).withHelpContent(new QHelpContent().withContentAsText(help.getValue()));
}
QInstanceEnricher.setInferredFieldBackendNames(table);
for(List<String> uniqueKey : definition.uniqueKeys())
{
table.withUniqueKey(new UniqueKey(uniqueKey));
}
for(CmsTableDefinition.Section section : definition.sections())
{
table.addSection(new QFieldSection(section.name(), section.label(), new QIcon(section.icon()), section.tier(), section.fields()));
}
table.addSection(new QFieldSection("dates", "Dates", new QIcon("calendar_month"), Tier.T3, List.of("createDate", "modifyDate")));
if(audit)
{
table.withAuditRules(new QAuditRules().withAuditLevel(AuditLevel.FIELD));
}
return (table);
}
/*******************************************************************************
** The file preview of a field: one image by its address, or a stored file
** with a thumbnail and its file facts.
*******************************************************************************/
static FieldAdornment previewAdornment(CmsTableDefinition.Preview preview)
{
FieldAdornment adornment = AdornmentType.FilePreviewValues.newFieldAdornment();
if(preview.thumbnailUrlField() == null)
{
adornment.withValue(AdornmentType.FilePreviewValues.DEFAULT_MIME_TYPE, "image/*");
}
else
{
adornment.withValue(AdornmentType.FilePreviewValues.THUMBNAIL_URL_FIELD, preview.thumbnailUrlField())
.withValue(AdornmentType.FilePreviewValues.MIME_TYPE_FIELD, "mimeType")
.withValue(AdornmentType.FilePreviewValues.WIDTH_FIELD, "width")
.withValue(AdornmentType.FilePreviewValues.HEIGHT_FIELD, "height")
.withValue(AdornmentType.FilePreviewValues.SIZE_BYTES_FIELD, "fileSize");
}
if(preview.fileNameField() != null)
{
adornment.withValue(AdornmentType.FilePreviewValues.FILE_NAME_FIELD, preview.fileNameField());
}
if(preview.altTextField() != null)
{
adornment.withValue(AdornmentType.FilePreviewValues.ALT_TEXT_FIELD, preview.altTextField());
}
if(preview.captionField() != null)
{
adornment.withValue(AdornmentType.FilePreviewValues.CAPTION_FIELD, preview.captionField());
}
return (adornment);
}
/*******************************************************************************
** Permission rules for every CMS table: the table name plus .read, .insert,
** .edit and .delete; with openReads, reads need nothing.
*******************************************************************************/
QPermissionRules permissionRules()
{
QPermissionRules rules = new QPermissionRules().withLevel(PermissionLevel.READ_INSERT_EDIT_DELETE_PERMISSIONS);
if(Boolean.TRUE.equals(config.getOpenReads()))
{
rules.withCustomPermissionChecker(new QCodeReference(CmsOpenReadsPermissionChecker.class));
}
return (rules);
}
/*******************************************************************************
** A child table: a join, a child-record list on the parent's screen, an
** exposed join (reports and filters) and, when named, an association.
*******************************************************************************/
private void addChild(QTableMetaData parent, CmsTableDefinition parentDefinition, CmsTableDefinition.Child child, List<QJoinMetaData> joins,
List<QWidgetMetaData> widgets)
{
String childTable = config.applyPrefix(child.childLogicalName());
String joinName = parent.getName() + "_" + childTable + "_" + child.joinField();
QJoinMetaData join = new QJoinMetaData()
.withName(joinName)
.withLeftTable(parent.getName())
.withRightTable(childTable)
.withType(JoinType.ONE_TO_MANY)
.withJoinOn(new JoinOn("id", child.joinField()))
.withOrderBy(new QFilterOrderBy(child.orderBy()));
joins.add(join);
QWidgetMetaData widget = ChildRecordListRenderer.widgetMetaDataBuilder(join)
.withName(joinName)
.withLabel(child.label())
.withMaxRows(50)
.withCanAddChildRecord(true)
.withDefaultValuesForNewChildRecordsFromParentFields(Map.of(child.joinField(), "id"))
.getWidgetMetaData();
widgets.add(widget);
String icon = CmsTables.definition(child.childLogicalName()).map(CmsTableDefinition::icon).orElse(parentDefinition.icon());
parent.addSection(new QFieldSection(joinName, child.label(), new QIcon(icon), Tier.T2, List.of()).withWidgetName(joinName));
if(!childTable.equals(parent.getName()))
{
parent.withExposedJoin(new ExposedJoin().withLabel(child.label()).withJoinPath(List.of(joinName)).withJoinTable(childTable));
}
if(child.associationName() != null)
{
parent.withAssociation(new Association().withName(child.associationName()).withAssociatedTableName(childTable).withJoinName(joinName));
}
}
}
@@ -0,0 +1,288 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.metadata;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import com.kingsrook.qbits.cms.CmsFeature;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.tables.Tier;
/*******************************************************************************
** Everything the builder needs to know about one CMS table beyond its
** entity: label, icon, record label, screen sections, child tables, unique
** keys, which fields hold long text, which show a file preview and the
** help text of fields.
**
** @param logicalName the unprefixed table name, e.g. "page"
** @param entityClass the entity whose fields the table has
** @param feature the feature that owns the table
** @param label the singular label ("Page"); the table label is the plural
** @param icon a Material icon name
** @param kind main table, child table or reference data
** @param recordLabelFields fields of the record label (joined by spaces)
** @param sections screen sections (the system dates section is added)
** @param children child tables shown as lists on this table's records
** @param uniqueKeys unique keys (field names)
** @param textFields fields stored as TEXT (long, unbounded content)
** @param previews fields that hold a file's address and show it as a preview
** @param helpTexts help text by field name
*******************************************************************************/
public record CmsTableDefinition(String logicalName, Class<? extends QRecordEntity> entityClass, CmsFeature feature, String label, String icon,
Kind kind, List<String> recordLabelFields, List<Section> sections, List<Child> children,
List<List<String>> uniqueKeys, Set<String> textFields, List<Preview> previews, Map<String, String> helpTexts)
{
/*******************************************************************************
** How a table appears in the admin.
*******************************************************************************/
public enum Kind
{
/** In the nav of its area; has its own home counts. */
MAIN,
/** Not in the nav: edited as a child list on its parent's record. */
CHILD,
/** Reference data in the area's Settings section; admin-editable only. */
REFERENCE
}
/*******************************************************************************
** A screen section.
**
** @param name the section name
** @param label the section label
** @param icon a Material icon name
** @param tier T1 (primary) or T2
** @param fields the fields, in order
*******************************************************************************/
public record Section(String name, String label, String icon, Tier tier, List<String> fields)
{
}
/*******************************************************************************
** A child table shown as a list on this table's records.
**
** @param childLogicalName the child's logical table name
** @param joinField the child's field holding this table's id
** @param label the list label
** @param associationName the association name (API and nested writes), or null
** @param orderBy the child field to order by
*******************************************************************************/
public record Child(String childLogicalName, String joinField, String label, String associationName, String orderBy)
{
}
/*******************************************************************************
** A field that holds a file's address and shows the file as a preview.
**
** @param field the field holding the address
** @param thumbnailUrlField the field holding a thumbnail's address, or null when the
** address itself is the image
** @param fileNameField the field holding the file name, or null
** @param altTextField the field holding the alternative text, or null
** @param captionField the field holding a caption, or null
*******************************************************************************/
public record Preview(String field, String thumbnailUrlField, String fileNameField, String altTextField, String captionField)
{
}
/*******************************************************************************
** The plural label (the QQQ table label, as in the nav): "Pages".
*******************************************************************************/
public String pluralLabel()
{
return (pluralize(label));
}
/*******************************************************************************
** English plural of a label's last word ("Page Type" to "Page Types",
** "Category" to "Categories"). "Media" is its own plural.
*******************************************************************************/
public static String pluralize(String word)
{
String lower = word.toLowerCase(Locale.ROOT);
if(lower.endsWith("media"))
{
return (word);
}
return (lower.endsWith("y") && !lower.endsWith("ay") && !lower.endsWith("ey") ? word.substring(0, word.length() - 1) + "ies" : word + "s");
}
/*******************************************************************************
** Start a definition.
*******************************************************************************/
public static Builder builder(String logicalName, Class<? extends QRecordEntity> entityClass, CmsFeature feature, String label, String icon, Kind kind)
{
return (new Builder(logicalName, entityClass, feature, label, icon, kind));
}
/*******************************************************************************
** Fluent builder for a definition.
*******************************************************************************/
public static final class Builder
{
private final String logicalName;
private final Class<? extends QRecordEntity> entityClass;
private final CmsFeature feature;
private final String label;
private final String icon;
private final Kind kind;
private List<String> recordLabelFields = List.of("name");
private final List<Section> sections = new ArrayList<>();
private final List<Child> children = new ArrayList<>();
private final List<List<String>> uniqueKeys = new ArrayList<>();
private Set<String> textFields = Set.of();
private final List<Preview> previews = new ArrayList<>();
private final Map<String, String> helpTexts = new LinkedHashMap<>();
/*******************************************************************************
** Constructor.
*******************************************************************************/
private Builder(String logicalName, Class<? extends QRecordEntity> entityClass, CmsFeature feature, String label, String icon, Kind kind)
{
this.logicalName = logicalName;
this.entityClass = entityClass;
this.feature = feature;
this.label = label;
this.icon = icon;
this.kind = kind;
}
/*******************************************************************************
** The record label fields.
*******************************************************************************/
public Builder recordLabel(String... fields)
{
this.recordLabelFields = List.of(fields);
return (this);
}
/*******************************************************************************
** A screen section.
*******************************************************************************/
public Builder section(String name, String label, String icon, Tier tier, String... fields)
{
this.sections.add(new Section(name, label, icon, tier, List.of(fields)));
return (this);
}
/*******************************************************************************
** A child list.
*******************************************************************************/
public Builder child(String childLogicalName, String joinField, String label, String associationName, String orderBy)
{
this.children.add(new Child(childLogicalName, joinField, label, associationName, orderBy));
return (this);
}
/*******************************************************************************
** A unique key.
*******************************************************************************/
public Builder unique(String... fields)
{
this.uniqueKeys.add(List.of(fields));
return (this);
}
/*******************************************************************************
** Fields stored as TEXT.
*******************************************************************************/
public Builder text(String... fields)
{
this.textFields = Set.of(fields);
return (this);
}
/*******************************************************************************
** A field holding one image's address, shown as that image.
*******************************************************************************/
public Builder imagePreview(String field, String altTextField, String captionField)
{
this.previews.add(new Preview(field, null, null, altTextField, captionField));
return (this);
}
/*******************************************************************************
** A field holding a stored file's address, shown with its thumbnail, file
** name, type and size (the fields mimeType, width, height and fileSize).
*******************************************************************************/
public Builder filePreview(String field, String thumbnailUrlField, String fileNameField, String altTextField, String captionField)
{
this.previews.add(new Preview(field, thumbnailUrlField, fileNameField, altTextField, captionField));
return (this);
}
/*******************************************************************************
** Help text of a field.
*******************************************************************************/
public Builder help(String field, String text)
{
this.helpTexts.put(field, text);
return (this);
}
/*******************************************************************************
** The definition.
*******************************************************************************/
public CmsTableDefinition build()
{
return (new CmsTableDefinition(logicalName, entityClass, feature, label, icon, kind, recordLabelFields, List.copyOf(sections), List.copyOf(children),
List.copyOf(uniqueKeys), textFields, List.copyOf(previews), Map.copyOf(helpTexts)));
}
}
}
@@ -0,0 +1,84 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.metadata;
import java.io.Serializable;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import com.kingsrook.qqq.backend.core.actions.customizers.TableCustomizerInterface;
import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.actions.AbstractActionInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.update.UpdateInput;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.QPossibleValueSource;
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.QPossibleValueSourceType;
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
import com.kingsrook.qqq.backend.core.model.statusmessages.BadInputStatusMessage;
/*******************************************************************************
** Keeps a field whose possible-value source is a fixed list (a project's
** status, a rendition's format) to the values of that list: QQQ offers the
** list in a form but accepts any value in a write. A record with a value that
** is not on the list gets an error and is not written. On an update only the
** fields the update names are checked.
**
** The table builder puts it on every table that has such a field; the
** changelog guards the same columns with check constraints.
*******************************************************************************/
public class CmsValueListCheck implements TableCustomizerInterface
{
/*******************************************************************************
** Mark each record whose value is not on its field's list.
*******************************************************************************/
@Override
public List<QRecord> preInsertOrUpdate(AbstractActionInput input, List<QRecord> records, boolean isPreview, Optional<List<QRecord>> oldRecordList) throws QException
{
String tableName = input instanceof InsertInput insert ? insert.getTableName() : input instanceof UpdateInput update ? update.getTableName() : null;
if(tableName == null || records == null)
{
return (records);
}
QTableMetaData table = QContext.getQInstance().getTable(tableName);
for(QFieldMetaData field : table.getFields().values())
{
QPossibleValueSource source = field.getPossibleValueSourceName() == null ? null : QContext.getQInstance().getPossibleValueSource(field.getPossibleValueSourceName());
if(source == null || source.getType() != QPossibleValueSourceType.ENUM)
{
continue;
}
Set<String> allowed = source.getEnumValues().stream().map(value -> String.valueOf(value.getId())).collect(Collectors.toSet());
for(QRecord record : records)
{
Serializable value = record.getValue(field.getName());
if(value != null && !"".equals(value) && !allowed.contains(String.valueOf(value)))
{
String label = field.getLabel() == null ? field.getName() : field.getLabel();
record.addError(new BadInputStatusMessage(label + " must be one of: " + allowed.stream().sorted().collect(Collectors.joining(", "))));
}
}
}
return (records);
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,979 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.photos.model;
import java.math.BigDecimal;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** An album of photos of a site, optionally in a folder and optionally
** belonging to a project or a project update.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_photo_album); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsPhotoAlbum extends QRecordEntity
{
public static final String TABLE_NAME = "photo_album";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, possibleValueSourceName = "site", label = "Site")
private Long siteId;
@QField(possibleValueSourceName = "photo_album_folder", label = "Folder")
private Long photoAlbumFolderId;
@QField(possibleValueSourceName = "project", label = "Project")
private Long projectId;
@QField(possibleValueSourceName = "project_update", label = "Project Update")
private Long projectUpdateId;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 40, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String shortName;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String slug;
@QField(maxLength = 200, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String title;
@QField(maxLength = 1000, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String description;
@QField(possibleValueSourceName = "photo", label = "Cover Photo")
private Long coverPhotoId;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "Cover Image URL")
private String coverImageUrl;
@QField(isRequired = true, defaultValue = "false")
private Boolean isPublished;
@QField
private Instant publishDate;
@QField(isRequired = true, defaultValue = "0")
private Integer sortOrder;
@QField(maxLength = 200, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String location;
@QField(label = "Latitude")
private BigDecimal locationLatitude;
@QField(label = "Longitude")
private BigDecimal locationLongitude;
@QField
private Instant albumDate;
@QField
private Instant albumEndDate;
@QField(maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String primaryCamera;
@QField(maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String primaryLens;
@QField(maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String weather;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String metaTitle;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String metaDescription;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsPhotoAlbum()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsPhotoAlbum(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsPhotoAlbum withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for siteId
*******************************************************************************/
public Long getSiteId()
{
return (this.siteId);
}
/*******************************************************************************
** Setter for siteId
*******************************************************************************/
public void setSiteId(Long siteId)
{
this.siteId = siteId;
}
/*******************************************************************************
** Fluent setter for siteId
*******************************************************************************/
public CmsPhotoAlbum withSiteId(Long siteId)
{
this.siteId = siteId;
return (this);
}
/*******************************************************************************
** Getter for photoAlbumFolderId
*******************************************************************************/
public Long getPhotoAlbumFolderId()
{
return (this.photoAlbumFolderId);
}
/*******************************************************************************
** Setter for photoAlbumFolderId
*******************************************************************************/
public void setPhotoAlbumFolderId(Long photoAlbumFolderId)
{
this.photoAlbumFolderId = photoAlbumFolderId;
}
/*******************************************************************************
** Fluent setter for photoAlbumFolderId
*******************************************************************************/
public CmsPhotoAlbum withPhotoAlbumFolderId(Long photoAlbumFolderId)
{
this.photoAlbumFolderId = photoAlbumFolderId;
return (this);
}
/*******************************************************************************
** Getter for projectId
*******************************************************************************/
public Long getProjectId()
{
return (this.projectId);
}
/*******************************************************************************
** Setter for projectId
*******************************************************************************/
public void setProjectId(Long projectId)
{
this.projectId = projectId;
}
/*******************************************************************************
** Fluent setter for projectId
*******************************************************************************/
public CmsPhotoAlbum withProjectId(Long projectId)
{
this.projectId = projectId;
return (this);
}
/*******************************************************************************
** Getter for projectUpdateId
*******************************************************************************/
public Long getProjectUpdateId()
{
return (this.projectUpdateId);
}
/*******************************************************************************
** Setter for projectUpdateId
*******************************************************************************/
public void setProjectUpdateId(Long projectUpdateId)
{
this.projectUpdateId = projectUpdateId;
}
/*******************************************************************************
** Fluent setter for projectUpdateId
*******************************************************************************/
public CmsPhotoAlbum withProjectUpdateId(Long projectUpdateId)
{
this.projectUpdateId = projectUpdateId;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsPhotoAlbum withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for shortName
*******************************************************************************/
public String getShortName()
{
return (this.shortName);
}
/*******************************************************************************
** Setter for shortName
*******************************************************************************/
public void setShortName(String shortName)
{
this.shortName = shortName;
}
/*******************************************************************************
** Fluent setter for shortName
*******************************************************************************/
public CmsPhotoAlbum withShortName(String shortName)
{
this.shortName = shortName;
return (this);
}
/*******************************************************************************
** Getter for slug
*******************************************************************************/
public String getSlug()
{
return (this.slug);
}
/*******************************************************************************
** Setter for slug
*******************************************************************************/
public void setSlug(String slug)
{
this.slug = slug;
}
/*******************************************************************************
** Fluent setter for slug
*******************************************************************************/
public CmsPhotoAlbum withSlug(String slug)
{
this.slug = slug;
return (this);
}
/*******************************************************************************
** Getter for title
*******************************************************************************/
public String getTitle()
{
return (this.title);
}
/*******************************************************************************
** Setter for title
*******************************************************************************/
public void setTitle(String title)
{
this.title = title;
}
/*******************************************************************************
** Fluent setter for title
*******************************************************************************/
public CmsPhotoAlbum withTitle(String title)
{
this.title = title;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsPhotoAlbum withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for coverPhotoId
*******************************************************************************/
public Long getCoverPhotoId()
{
return (this.coverPhotoId);
}
/*******************************************************************************
** Setter for coverPhotoId
*******************************************************************************/
public void setCoverPhotoId(Long coverPhotoId)
{
this.coverPhotoId = coverPhotoId;
}
/*******************************************************************************
** Fluent setter for coverPhotoId
*******************************************************************************/
public CmsPhotoAlbum withCoverPhotoId(Long coverPhotoId)
{
this.coverPhotoId = coverPhotoId;
return (this);
}
/*******************************************************************************
** Getter for coverImageUrl
*******************************************************************************/
public String getCoverImageUrl()
{
return (this.coverImageUrl);
}
/*******************************************************************************
** Setter for coverImageUrl
*******************************************************************************/
public void setCoverImageUrl(String coverImageUrl)
{
this.coverImageUrl = coverImageUrl;
}
/*******************************************************************************
** Fluent setter for coverImageUrl
*******************************************************************************/
public CmsPhotoAlbum withCoverImageUrl(String coverImageUrl)
{
this.coverImageUrl = coverImageUrl;
return (this);
}
/*******************************************************************************
** Getter for isPublished
*******************************************************************************/
public Boolean getIsPublished()
{
return (this.isPublished);
}
/*******************************************************************************
** Setter for isPublished
*******************************************************************************/
public void setIsPublished(Boolean isPublished)
{
this.isPublished = isPublished;
}
/*******************************************************************************
** Fluent setter for isPublished
*******************************************************************************/
public CmsPhotoAlbum withIsPublished(Boolean isPublished)
{
this.isPublished = isPublished;
return (this);
}
/*******************************************************************************
** Getter for publishDate
*******************************************************************************/
public Instant getPublishDate()
{
return (this.publishDate);
}
/*******************************************************************************
** Setter for publishDate
*******************************************************************************/
public void setPublishDate(Instant publishDate)
{
this.publishDate = publishDate;
}
/*******************************************************************************
** Fluent setter for publishDate
*******************************************************************************/
public CmsPhotoAlbum withPublishDate(Instant publishDate)
{
this.publishDate = publishDate;
return (this);
}
/*******************************************************************************
** Getter for sortOrder
*******************************************************************************/
public Integer getSortOrder()
{
return (this.sortOrder);
}
/*******************************************************************************
** Setter for sortOrder
*******************************************************************************/
public void setSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
}
/*******************************************************************************
** Fluent setter for sortOrder
*******************************************************************************/
public CmsPhotoAlbum withSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
return (this);
}
/*******************************************************************************
** Getter for location
*******************************************************************************/
public String getLocation()
{
return (this.location);
}
/*******************************************************************************
** Setter for location
*******************************************************************************/
public void setLocation(String location)
{
this.location = location;
}
/*******************************************************************************
** Fluent setter for location
*******************************************************************************/
public CmsPhotoAlbum withLocation(String location)
{
this.location = location;
return (this);
}
/*******************************************************************************
** Getter for locationLatitude
*******************************************************************************/
public BigDecimal getLocationLatitude()
{
return (this.locationLatitude);
}
/*******************************************************************************
** Setter for locationLatitude
*******************************************************************************/
public void setLocationLatitude(BigDecimal locationLatitude)
{
this.locationLatitude = locationLatitude;
}
/*******************************************************************************
** Fluent setter for locationLatitude
*******************************************************************************/
public CmsPhotoAlbum withLocationLatitude(BigDecimal locationLatitude)
{
this.locationLatitude = locationLatitude;
return (this);
}
/*******************************************************************************
** Getter for locationLongitude
*******************************************************************************/
public BigDecimal getLocationLongitude()
{
return (this.locationLongitude);
}
/*******************************************************************************
** Setter for locationLongitude
*******************************************************************************/
public void setLocationLongitude(BigDecimal locationLongitude)
{
this.locationLongitude = locationLongitude;
}
/*******************************************************************************
** Fluent setter for locationLongitude
*******************************************************************************/
public CmsPhotoAlbum withLocationLongitude(BigDecimal locationLongitude)
{
this.locationLongitude = locationLongitude;
return (this);
}
/*******************************************************************************
** Getter for albumDate
*******************************************************************************/
public Instant getAlbumDate()
{
return (this.albumDate);
}
/*******************************************************************************
** Setter for albumDate
*******************************************************************************/
public void setAlbumDate(Instant albumDate)
{
this.albumDate = albumDate;
}
/*******************************************************************************
** Fluent setter for albumDate
*******************************************************************************/
public CmsPhotoAlbum withAlbumDate(Instant albumDate)
{
this.albumDate = albumDate;
return (this);
}
/*******************************************************************************
** Getter for albumEndDate
*******************************************************************************/
public Instant getAlbumEndDate()
{
return (this.albumEndDate);
}
/*******************************************************************************
** Setter for albumEndDate
*******************************************************************************/
public void setAlbumEndDate(Instant albumEndDate)
{
this.albumEndDate = albumEndDate;
}
/*******************************************************************************
** Fluent setter for albumEndDate
*******************************************************************************/
public CmsPhotoAlbum withAlbumEndDate(Instant albumEndDate)
{
this.albumEndDate = albumEndDate;
return (this);
}
/*******************************************************************************
** Getter for primaryCamera
*******************************************************************************/
public String getPrimaryCamera()
{
return (this.primaryCamera);
}
/*******************************************************************************
** Setter for primaryCamera
*******************************************************************************/
public void setPrimaryCamera(String primaryCamera)
{
this.primaryCamera = primaryCamera;
}
/*******************************************************************************
** Fluent setter for primaryCamera
*******************************************************************************/
public CmsPhotoAlbum withPrimaryCamera(String primaryCamera)
{
this.primaryCamera = primaryCamera;
return (this);
}
/*******************************************************************************
** Getter for primaryLens
*******************************************************************************/
public String getPrimaryLens()
{
return (this.primaryLens);
}
/*******************************************************************************
** Setter for primaryLens
*******************************************************************************/
public void setPrimaryLens(String primaryLens)
{
this.primaryLens = primaryLens;
}
/*******************************************************************************
** Fluent setter for primaryLens
*******************************************************************************/
public CmsPhotoAlbum withPrimaryLens(String primaryLens)
{
this.primaryLens = primaryLens;
return (this);
}
/*******************************************************************************
** Getter for weather
*******************************************************************************/
public String getWeather()
{
return (this.weather);
}
/*******************************************************************************
** Setter for weather
*******************************************************************************/
public void setWeather(String weather)
{
this.weather = weather;
}
/*******************************************************************************
** Fluent setter for weather
*******************************************************************************/
public CmsPhotoAlbum withWeather(String weather)
{
this.weather = weather;
return (this);
}
/*******************************************************************************
** Getter for metaTitle
*******************************************************************************/
public String getMetaTitle()
{
return (this.metaTitle);
}
/*******************************************************************************
** Setter for metaTitle
*******************************************************************************/
public void setMetaTitle(String metaTitle)
{
this.metaTitle = metaTitle;
}
/*******************************************************************************
** Fluent setter for metaTitle
*******************************************************************************/
public CmsPhotoAlbum withMetaTitle(String metaTitle)
{
this.metaTitle = metaTitle;
return (this);
}
/*******************************************************************************
** Getter for metaDescription
*******************************************************************************/
public String getMetaDescription()
{
return (this.metaDescription);
}
/*******************************************************************************
** Setter for metaDescription
*******************************************************************************/
public void setMetaDescription(String metaDescription)
{
this.metaDescription = metaDescription;
}
/*******************************************************************************
** Fluent setter for metaDescription
*******************************************************************************/
public CmsPhotoAlbum withMetaDescription(String metaDescription)
{
this.metaDescription = metaDescription;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsPhotoAlbum withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsPhotoAlbum withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,501 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.photos.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A folder of photo albums of a site; folders nest.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_photo_album_folder); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsPhotoAlbumFolder extends QRecordEntity
{
public static final String TABLE_NAME = "photo_album_folder";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, possibleValueSourceName = "site", label = "Site")
private Long siteId;
@QField(possibleValueSourceName = "photo_album_folder", label = "Parent Folder")
private Long parentId;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String slug;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String description;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "Folder Image URL")
private String folderImageUrl;
@QField(isRequired = true, defaultValue = "false")
private Boolean isPublished;
@QField(isRequired = true, defaultValue = "0")
private Integer sortOrder;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String metaTitle;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String metaDescription;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsPhotoAlbumFolder()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsPhotoAlbumFolder(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsPhotoAlbumFolder withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for siteId
*******************************************************************************/
public Long getSiteId()
{
return (this.siteId);
}
/*******************************************************************************
** Setter for siteId
*******************************************************************************/
public void setSiteId(Long siteId)
{
this.siteId = siteId;
}
/*******************************************************************************
** Fluent setter for siteId
*******************************************************************************/
public CmsPhotoAlbumFolder withSiteId(Long siteId)
{
this.siteId = siteId;
return (this);
}
/*******************************************************************************
** Getter for parentId
*******************************************************************************/
public Long getParentId()
{
return (this.parentId);
}
/*******************************************************************************
** Setter for parentId
*******************************************************************************/
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
/*******************************************************************************
** Fluent setter for parentId
*******************************************************************************/
public CmsPhotoAlbumFolder withParentId(Long parentId)
{
this.parentId = parentId;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsPhotoAlbumFolder withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for slug
*******************************************************************************/
public String getSlug()
{
return (this.slug);
}
/*******************************************************************************
** Setter for slug
*******************************************************************************/
public void setSlug(String slug)
{
this.slug = slug;
}
/*******************************************************************************
** Fluent setter for slug
*******************************************************************************/
public CmsPhotoAlbumFolder withSlug(String slug)
{
this.slug = slug;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsPhotoAlbumFolder withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for folderImageUrl
*******************************************************************************/
public String getFolderImageUrl()
{
return (this.folderImageUrl);
}
/*******************************************************************************
** Setter for folderImageUrl
*******************************************************************************/
public void setFolderImageUrl(String folderImageUrl)
{
this.folderImageUrl = folderImageUrl;
}
/*******************************************************************************
** Fluent setter for folderImageUrl
*******************************************************************************/
public CmsPhotoAlbumFolder withFolderImageUrl(String folderImageUrl)
{
this.folderImageUrl = folderImageUrl;
return (this);
}
/*******************************************************************************
** Getter for isPublished
*******************************************************************************/
public Boolean getIsPublished()
{
return (this.isPublished);
}
/*******************************************************************************
** Setter for isPublished
*******************************************************************************/
public void setIsPublished(Boolean isPublished)
{
this.isPublished = isPublished;
}
/*******************************************************************************
** Fluent setter for isPublished
*******************************************************************************/
public CmsPhotoAlbumFolder withIsPublished(Boolean isPublished)
{
this.isPublished = isPublished;
return (this);
}
/*******************************************************************************
** Getter for sortOrder
*******************************************************************************/
public Integer getSortOrder()
{
return (this.sortOrder);
}
/*******************************************************************************
** Setter for sortOrder
*******************************************************************************/
public void setSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
}
/*******************************************************************************
** Fluent setter for sortOrder
*******************************************************************************/
public CmsPhotoAlbumFolder withSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
return (this);
}
/*******************************************************************************
** Getter for metaTitle
*******************************************************************************/
public String getMetaTitle()
{
return (this.metaTitle);
}
/*******************************************************************************
** Setter for metaTitle
*******************************************************************************/
public void setMetaTitle(String metaTitle)
{
this.metaTitle = metaTitle;
}
/*******************************************************************************
** Fluent setter for metaTitle
*******************************************************************************/
public CmsPhotoAlbumFolder withMetaTitle(String metaTitle)
{
this.metaTitle = metaTitle;
return (this);
}
/*******************************************************************************
** Getter for metaDescription
*******************************************************************************/
public String getMetaDescription()
{
return (this.metaDescription);
}
/*******************************************************************************
** Setter for metaDescription
*******************************************************************************/
public void setMetaDescription(String metaDescription)
{
this.metaDescription = metaDescription;
}
/*******************************************************************************
** Fluent setter for metaDescription
*******************************************************************************/
public CmsPhotoAlbumFolder withMetaDescription(String metaDescription)
{
this.metaDescription = metaDescription;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsPhotoAlbumFolder withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsPhotoAlbumFolder withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,263 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.photos.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A tag for photos.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_photo_tag); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsPhotoTag extends QRecordEntity
{
public static final String TABLE_NAME = "photo_tag";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String slug;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String description;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsPhotoTag()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsPhotoTag(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsPhotoTag withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsPhotoTag withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for slug
*******************************************************************************/
public String getSlug()
{
return (this.slug);
}
/*******************************************************************************
** Setter for slug
*******************************************************************************/
public void setSlug(String slug)
{
this.slug = slug;
}
/*******************************************************************************
** Fluent setter for slug
*******************************************************************************/
public CmsPhotoTag withSlug(String slug)
{
this.slug = slug;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsPhotoTag withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsPhotoTag withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsPhotoTag withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,228 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.photos.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
/*******************************************************************************
** One tag on one photo.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_photo_tag_int); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsPhotoTagLink extends QRecordEntity
{
public static final String TABLE_NAME = "photo_tag_int";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, possibleValueSourceName = "photo", label = "Photo")
private Long photoId;
@QField(isRequired = true, possibleValueSourceName = "photo_tag", label = "Photo Tag")
private Long photoTagId;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsPhotoTagLink()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsPhotoTagLink(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsPhotoTagLink withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for photoId
*******************************************************************************/
public Long getPhotoId()
{
return (this.photoId);
}
/*******************************************************************************
** Setter for photoId
*******************************************************************************/
public void setPhotoId(Long photoId)
{
this.photoId = photoId;
}
/*******************************************************************************
** Fluent setter for photoId
*******************************************************************************/
public CmsPhotoTagLink withPhotoId(Long photoId)
{
this.photoId = photoId;
return (this);
}
/*******************************************************************************
** Getter for photoTagId
*******************************************************************************/
public Long getPhotoTagId()
{
return (this.photoTagId);
}
/*******************************************************************************
** Setter for photoTagId
*******************************************************************************/
public void setPhotoTagId(Long photoTagId)
{
this.photoTagId = photoTagId;
}
/*******************************************************************************
** Fluent setter for photoTagId
*******************************************************************************/
public CmsPhotoTagLink withPhotoTagId(Long photoTagId)
{
this.photoTagId = photoTagId;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsPhotoTagLink withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsPhotoTagLink withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,943 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.projects.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A project of a site: its page content, state, links, image and dates.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_project); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsProject extends QRecordEntity
{
public static final String TABLE_NAME = "project";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 20, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String shortName;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String slug;
@QField(isRequired = true, maxLength = 200, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String title;
@QField(gridColumns = 12)
private String description;
@QField(gridColumns = 12)
private String content;
@QField(isRequired = true, maxLength = 20, defaultValue = "ACTIVE", possibleValueSourceName = "project_status", label = "Status")
private String projectStatus;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "GitHub URL")
private String githubUrl;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "Live URL")
private String liveUrl;
@QField(possibleValueSourceName = "media", label = "Featured Media")
private Long featuredMediaId;
@QField(maxLength = 255, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "Featured Image URL")
private String featuredImage;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR, label = "Image description")
private String imageAlt;
@QField(maxLength = 1000, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String imageCaption;
@QField(defaultValue = "50", label = "Horizontal focal point (%)")
private Integer imageFocalX;
@QField(defaultValue = "50", label = "Vertical focal point (%)")
private Integer imageFocalY;
@QField
private Instant startDate;
@QField
private Instant endDate;
@QField(isRequired = true, defaultValue = "false")
private Boolean isFeatured;
@QField(isRequired = true, defaultValue = "0")
private Integer sortOrder;
@QField(isRequired = true, possibleValueSourceName = "site", label = "Site")
private Long siteId;
@QField(isRequired = true, possibleValueSourceName = "project_category", label = "Category")
private Long categoryId;
@QField(isRequired = true, defaultValue = "false")
private Boolean isPublished;
@QField
private Instant publishDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsProject()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsProject(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsProject withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsProject withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for shortName
*******************************************************************************/
public String getShortName()
{
return (this.shortName);
}
/*******************************************************************************
** Setter for shortName
*******************************************************************************/
public void setShortName(String shortName)
{
this.shortName = shortName;
}
/*******************************************************************************
** Fluent setter for shortName
*******************************************************************************/
public CmsProject withShortName(String shortName)
{
this.shortName = shortName;
return (this);
}
/*******************************************************************************
** Getter for slug
*******************************************************************************/
public String getSlug()
{
return (this.slug);
}
/*******************************************************************************
** Setter for slug
*******************************************************************************/
public void setSlug(String slug)
{
this.slug = slug;
}
/*******************************************************************************
** Fluent setter for slug
*******************************************************************************/
public CmsProject withSlug(String slug)
{
this.slug = slug;
return (this);
}
/*******************************************************************************
** Getter for title
*******************************************************************************/
public String getTitle()
{
return (this.title);
}
/*******************************************************************************
** Setter for title
*******************************************************************************/
public void setTitle(String title)
{
this.title = title;
}
/*******************************************************************************
** Fluent setter for title
*******************************************************************************/
public CmsProject withTitle(String title)
{
this.title = title;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsProject withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for content
*******************************************************************************/
public String getContent()
{
return (this.content);
}
/*******************************************************************************
** Setter for content
*******************************************************************************/
public void setContent(String content)
{
this.content = content;
}
/*******************************************************************************
** Fluent setter for content
*******************************************************************************/
public CmsProject withContent(String content)
{
this.content = content;
return (this);
}
/*******************************************************************************
** Getter for projectStatus
*******************************************************************************/
public String getProjectStatus()
{
return (this.projectStatus);
}
/*******************************************************************************
** Setter for projectStatus
*******************************************************************************/
public void setProjectStatus(String projectStatus)
{
this.projectStatus = projectStatus;
}
/*******************************************************************************
** Fluent setter for projectStatus
*******************************************************************************/
public CmsProject withProjectStatus(String projectStatus)
{
this.projectStatus = projectStatus;
return (this);
}
/*******************************************************************************
** Getter for githubUrl
*******************************************************************************/
public String getGithubUrl()
{
return (this.githubUrl);
}
/*******************************************************************************
** Setter for githubUrl
*******************************************************************************/
public void setGithubUrl(String githubUrl)
{
this.githubUrl = githubUrl;
}
/*******************************************************************************
** Fluent setter for githubUrl
*******************************************************************************/
public CmsProject withGithubUrl(String githubUrl)
{
this.githubUrl = githubUrl;
return (this);
}
/*******************************************************************************
** Getter for liveUrl
*******************************************************************************/
public String getLiveUrl()
{
return (this.liveUrl);
}
/*******************************************************************************
** Setter for liveUrl
*******************************************************************************/
public void setLiveUrl(String liveUrl)
{
this.liveUrl = liveUrl;
}
/*******************************************************************************
** Fluent setter for liveUrl
*******************************************************************************/
public CmsProject withLiveUrl(String liveUrl)
{
this.liveUrl = liveUrl;
return (this);
}
/*******************************************************************************
** Getter for featuredMediaId
*******************************************************************************/
public Long getFeaturedMediaId()
{
return (this.featuredMediaId);
}
/*******************************************************************************
** Setter for featuredMediaId
*******************************************************************************/
public void setFeaturedMediaId(Long featuredMediaId)
{
this.featuredMediaId = featuredMediaId;
}
/*******************************************************************************
** Fluent setter for featuredMediaId
*******************************************************************************/
public CmsProject withFeaturedMediaId(Long featuredMediaId)
{
this.featuredMediaId = featuredMediaId;
return (this);
}
/*******************************************************************************
** Getter for featuredImage
*******************************************************************************/
public String getFeaturedImage()
{
return (this.featuredImage);
}
/*******************************************************************************
** Setter for featuredImage
*******************************************************************************/
public void setFeaturedImage(String featuredImage)
{
this.featuredImage = featuredImage;
}
/*******************************************************************************
** Fluent setter for featuredImage
*******************************************************************************/
public CmsProject withFeaturedImage(String featuredImage)
{
this.featuredImage = featuredImage;
return (this);
}
/*******************************************************************************
** Getter for imageAlt
*******************************************************************************/
public String getImageAlt()
{
return (this.imageAlt);
}
/*******************************************************************************
** Setter for imageAlt
*******************************************************************************/
public void setImageAlt(String imageAlt)
{
this.imageAlt = imageAlt;
}
/*******************************************************************************
** Fluent setter for imageAlt
*******************************************************************************/
public CmsProject withImageAlt(String imageAlt)
{
this.imageAlt = imageAlt;
return (this);
}
/*******************************************************************************
** Getter for imageCaption
*******************************************************************************/
public String getImageCaption()
{
return (this.imageCaption);
}
/*******************************************************************************
** Setter for imageCaption
*******************************************************************************/
public void setImageCaption(String imageCaption)
{
this.imageCaption = imageCaption;
}
/*******************************************************************************
** Fluent setter for imageCaption
*******************************************************************************/
public CmsProject withImageCaption(String imageCaption)
{
this.imageCaption = imageCaption;
return (this);
}
/*******************************************************************************
** Getter for imageFocalX
*******************************************************************************/
public Integer getImageFocalX()
{
return (this.imageFocalX);
}
/*******************************************************************************
** Setter for imageFocalX
*******************************************************************************/
public void setImageFocalX(Integer imageFocalX)
{
this.imageFocalX = imageFocalX;
}
/*******************************************************************************
** Fluent setter for imageFocalX
*******************************************************************************/
public CmsProject withImageFocalX(Integer imageFocalX)
{
this.imageFocalX = imageFocalX;
return (this);
}
/*******************************************************************************
** Getter for imageFocalY
*******************************************************************************/
public Integer getImageFocalY()
{
return (this.imageFocalY);
}
/*******************************************************************************
** Setter for imageFocalY
*******************************************************************************/
public void setImageFocalY(Integer imageFocalY)
{
this.imageFocalY = imageFocalY;
}
/*******************************************************************************
** Fluent setter for imageFocalY
*******************************************************************************/
public CmsProject withImageFocalY(Integer imageFocalY)
{
this.imageFocalY = imageFocalY;
return (this);
}
/*******************************************************************************
** Getter for startDate
*******************************************************************************/
public Instant getStartDate()
{
return (this.startDate);
}
/*******************************************************************************
** Setter for startDate
*******************************************************************************/
public void setStartDate(Instant startDate)
{
this.startDate = startDate;
}
/*******************************************************************************
** Fluent setter for startDate
*******************************************************************************/
public CmsProject withStartDate(Instant startDate)
{
this.startDate = startDate;
return (this);
}
/*******************************************************************************
** Getter for endDate
*******************************************************************************/
public Instant getEndDate()
{
return (this.endDate);
}
/*******************************************************************************
** Setter for endDate
*******************************************************************************/
public void setEndDate(Instant endDate)
{
this.endDate = endDate;
}
/*******************************************************************************
** Fluent setter for endDate
*******************************************************************************/
public CmsProject withEndDate(Instant endDate)
{
this.endDate = endDate;
return (this);
}
/*******************************************************************************
** Getter for isFeatured
*******************************************************************************/
public Boolean getIsFeatured()
{
return (this.isFeatured);
}
/*******************************************************************************
** Setter for isFeatured
*******************************************************************************/
public void setIsFeatured(Boolean isFeatured)
{
this.isFeatured = isFeatured;
}
/*******************************************************************************
** Fluent setter for isFeatured
*******************************************************************************/
public CmsProject withIsFeatured(Boolean isFeatured)
{
this.isFeatured = isFeatured;
return (this);
}
/*******************************************************************************
** Getter for sortOrder
*******************************************************************************/
public Integer getSortOrder()
{
return (this.sortOrder);
}
/*******************************************************************************
** Setter for sortOrder
*******************************************************************************/
public void setSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
}
/*******************************************************************************
** Fluent setter for sortOrder
*******************************************************************************/
public CmsProject withSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
return (this);
}
/*******************************************************************************
** Getter for siteId
*******************************************************************************/
public Long getSiteId()
{
return (this.siteId);
}
/*******************************************************************************
** Setter for siteId
*******************************************************************************/
public void setSiteId(Long siteId)
{
this.siteId = siteId;
}
/*******************************************************************************
** Fluent setter for siteId
*******************************************************************************/
public CmsProject withSiteId(Long siteId)
{
this.siteId = siteId;
return (this);
}
/*******************************************************************************
** Getter for categoryId
*******************************************************************************/
public Long getCategoryId()
{
return (this.categoryId);
}
/*******************************************************************************
** Setter for categoryId
*******************************************************************************/
public void setCategoryId(Long categoryId)
{
this.categoryId = categoryId;
}
/*******************************************************************************
** Fluent setter for categoryId
*******************************************************************************/
public CmsProject withCategoryId(Long categoryId)
{
this.categoryId = categoryId;
return (this);
}
/*******************************************************************************
** Getter for isPublished
*******************************************************************************/
public Boolean getIsPublished()
{
return (this.isPublished);
}
/*******************************************************************************
** Setter for isPublished
*******************************************************************************/
public void setIsPublished(Boolean isPublished)
{
this.isPublished = isPublished;
}
/*******************************************************************************
** Fluent setter for isPublished
*******************************************************************************/
public CmsProject withIsPublished(Boolean isPublished)
{
this.isPublished = isPublished;
return (this);
}
/*******************************************************************************
** Getter for publishDate
*******************************************************************************/
public Instant getPublishDate()
{
return (this.publishDate);
}
/*******************************************************************************
** Setter for publishDate
*******************************************************************************/
public void setPublishDate(Instant publishDate)
{
this.publishDate = publishDate;
}
/*******************************************************************************
** Fluent setter for publishDate
*******************************************************************************/
public CmsProject withPublishDate(Instant publishDate)
{
this.publishDate = publishDate;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsProject withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsProject withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,501 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.projects.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A group of projects of a site, with its own page text and image.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_project_category); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsProjectCategory extends QRecordEntity
{
public static final String TABLE_NAME = "project_category";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, possibleValueSourceName = "site", label = "Site")
private Long siteId;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String name;
@QField(isRequired = true, maxLength = 200, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String title;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String slug;
@QField(maxLength = 20, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String section;
@QField(maxLength = 1000, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String description;
@QField(possibleValueSourceName = "media", label = "Featured Media")
private Long featuredMediaId;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "Featured Image URL")
private String featuredImage;
@QField(isRequired = true, defaultValue = "0")
private Integer sortOrder;
@QField(isRequired = true, defaultValue = "false")
private Boolean isPublished;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsProjectCategory()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsProjectCategory(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsProjectCategory withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for siteId
*******************************************************************************/
public Long getSiteId()
{
return (this.siteId);
}
/*******************************************************************************
** Setter for siteId
*******************************************************************************/
public void setSiteId(Long siteId)
{
this.siteId = siteId;
}
/*******************************************************************************
** Fluent setter for siteId
*******************************************************************************/
public CmsProjectCategory withSiteId(Long siteId)
{
this.siteId = siteId;
return (this);
}
/*******************************************************************************
** Getter for name
*******************************************************************************/
public String getName()
{
return (this.name);
}
/*******************************************************************************
** Setter for name
*******************************************************************************/
public void setName(String name)
{
this.name = name;
}
/*******************************************************************************
** Fluent setter for name
*******************************************************************************/
public CmsProjectCategory withName(String name)
{
this.name = name;
return (this);
}
/*******************************************************************************
** Getter for title
*******************************************************************************/
public String getTitle()
{
return (this.title);
}
/*******************************************************************************
** Setter for title
*******************************************************************************/
public void setTitle(String title)
{
this.title = title;
}
/*******************************************************************************
** Fluent setter for title
*******************************************************************************/
public CmsProjectCategory withTitle(String title)
{
this.title = title;
return (this);
}
/*******************************************************************************
** Getter for slug
*******************************************************************************/
public String getSlug()
{
return (this.slug);
}
/*******************************************************************************
** Setter for slug
*******************************************************************************/
public void setSlug(String slug)
{
this.slug = slug;
}
/*******************************************************************************
** Fluent setter for slug
*******************************************************************************/
public CmsProjectCategory withSlug(String slug)
{
this.slug = slug;
return (this);
}
/*******************************************************************************
** Getter for section
*******************************************************************************/
public String getSection()
{
return (this.section);
}
/*******************************************************************************
** Setter for section
*******************************************************************************/
public void setSection(String section)
{
this.section = section;
}
/*******************************************************************************
** Fluent setter for section
*******************************************************************************/
public CmsProjectCategory withSection(String section)
{
this.section = section;
return (this);
}
/*******************************************************************************
** Getter for description
*******************************************************************************/
public String getDescription()
{
return (this.description);
}
/*******************************************************************************
** Setter for description
*******************************************************************************/
public void setDescription(String description)
{
this.description = description;
}
/*******************************************************************************
** Fluent setter for description
*******************************************************************************/
public CmsProjectCategory withDescription(String description)
{
this.description = description;
return (this);
}
/*******************************************************************************
** Getter for featuredMediaId
*******************************************************************************/
public Long getFeaturedMediaId()
{
return (this.featuredMediaId);
}
/*******************************************************************************
** Setter for featuredMediaId
*******************************************************************************/
public void setFeaturedMediaId(Long featuredMediaId)
{
this.featuredMediaId = featuredMediaId;
}
/*******************************************************************************
** Fluent setter for featuredMediaId
*******************************************************************************/
public CmsProjectCategory withFeaturedMediaId(Long featuredMediaId)
{
this.featuredMediaId = featuredMediaId;
return (this);
}
/*******************************************************************************
** Getter for featuredImage
*******************************************************************************/
public String getFeaturedImage()
{
return (this.featuredImage);
}
/*******************************************************************************
** Setter for featuredImage
*******************************************************************************/
public void setFeaturedImage(String featuredImage)
{
this.featuredImage = featuredImage;
}
/*******************************************************************************
** Fluent setter for featuredImage
*******************************************************************************/
public CmsProjectCategory withFeaturedImage(String featuredImage)
{
this.featuredImage = featuredImage;
return (this);
}
/*******************************************************************************
** Getter for sortOrder
*******************************************************************************/
public Integer getSortOrder()
{
return (this.sortOrder);
}
/*******************************************************************************
** Setter for sortOrder
*******************************************************************************/
public void setSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
}
/*******************************************************************************
** Fluent setter for sortOrder
*******************************************************************************/
public CmsProjectCategory withSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
return (this);
}
/*******************************************************************************
** Getter for isPublished
*******************************************************************************/
public Boolean getIsPublished()
{
return (this.isPublished);
}
/*******************************************************************************
** Setter for isPublished
*******************************************************************************/
public void setIsPublished(Boolean isPublished)
{
this.isPublished = isPublished;
}
/*******************************************************************************
** Fluent setter for isPublished
*******************************************************************************/
public CmsProjectCategory withIsPublished(Boolean isPublished)
{
this.isPublished = isPublished;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsProjectCategory withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsProjectCategory withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,70 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.projects.model;
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.PossibleValueEnum;
/*******************************************************************************
** The state of a project. Its possible-value source gets the table prefix
** (cms_project_status).
*******************************************************************************/
public enum CmsProjectStatus implements PossibleValueEnum<String>
{
PLANNED("Planned"),
IN_PROGRESS("In progress"),
ACTIVE("Active"),
ARCHIVED("Archived");
/** The logical possible-value source name (the prefix is added). */
public static final String NAME = "project_status";
private final String label;
/*******************************************************************************
** Constructor.
*******************************************************************************/
CmsProjectStatus(String label)
{
this.label = label;
}
/*******************************************************************************
** The stored value.
*******************************************************************************/
@Override
public String getPossibleValueId()
{
return (name());
}
/*******************************************************************************
** The label.
*******************************************************************************/
@Override
public String getPossibleValueLabel()
{
return (label);
}
}
@@ -0,0 +1,535 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.projects.model;
import java.time.Instant;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.data.QField;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import com.kingsrook.qqq.backend.core.model.metadata.fields.DynamicDefaultValueBehavior;
import com.kingsrook.qqq.backend.core.model.metadata.fields.ValueTooLongBehavior;
/*******************************************************************************
** A dated update on a project.
**
** The physical table name is the configured prefix plus TABLE_NAME (for
** example cms_project_update); possible-value source names on the fields are
** logical and get the same prefix when the table is built.
*******************************************************************************/
public class CmsProjectUpdate extends QRecordEntity
{
public static final String TABLE_NAME = "project_update";
@QField(isEditable = false, isPrimaryKey = true)
private Long id;
@QField(isRequired = true, possibleValueSourceName = "project", label = "Project")
private Long projectId;
@QField(isRequired = true, maxLength = 100, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String slug;
@QField(isRequired = true, maxLength = 200, valueTooLongBehavior = ValueTooLongBehavior.ERROR)
private String title;
@QField(maxLength = 1000, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12)
private String excerpt;
@QField(isRequired = true, gridColumns = 12)
private String content;
@QField(isRequired = true)
private Instant updateDate;
@QField(isRequired = true, defaultValue = "false")
private Boolean isPublished;
@QField
private Instant publishDate;
@QField(isRequired = true, defaultValue = "0")
private Integer sortOrder;
@QField(possibleValueSourceName = "media", label = "Featured Media")
private Long featuredMediaId;
@QField(maxLength = 500, valueTooLongBehavior = ValueTooLongBehavior.ERROR, gridColumns = 12, label = "Featured Image URL")
private String featuredImage;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.CREATE_DATE)
private Instant createDate;
@QField(isEditable = false, dynamicDefaultValueBehavior = DynamicDefaultValueBehavior.MODIFY_DATE)
private Instant modifyDate;
/*******************************************************************************
** Default constructor
*******************************************************************************/
public CmsProjectUpdate()
{
}
/*******************************************************************************
** Constructor that takes a QRecord
*******************************************************************************/
public CmsProjectUpdate(QRecord record) throws QException
{
populateFromQRecord(record);
}
/*******************************************************************************
** Getter for id
*******************************************************************************/
public Long getId()
{
return (this.id);
}
/*******************************************************************************
** Setter for id
*******************************************************************************/
public void setId(Long id)
{
this.id = id;
}
/*******************************************************************************
** Fluent setter for id
*******************************************************************************/
public CmsProjectUpdate withId(Long id)
{
this.id = id;
return (this);
}
/*******************************************************************************
** Getter for projectId
*******************************************************************************/
public Long getProjectId()
{
return (this.projectId);
}
/*******************************************************************************
** Setter for projectId
*******************************************************************************/
public void setProjectId(Long projectId)
{
this.projectId = projectId;
}
/*******************************************************************************
** Fluent setter for projectId
*******************************************************************************/
public CmsProjectUpdate withProjectId(Long projectId)
{
this.projectId = projectId;
return (this);
}
/*******************************************************************************
** Getter for slug
*******************************************************************************/
public String getSlug()
{
return (this.slug);
}
/*******************************************************************************
** Setter for slug
*******************************************************************************/
public void setSlug(String slug)
{
this.slug = slug;
}
/*******************************************************************************
** Fluent setter for slug
*******************************************************************************/
public CmsProjectUpdate withSlug(String slug)
{
this.slug = slug;
return (this);
}
/*******************************************************************************
** Getter for title
*******************************************************************************/
public String getTitle()
{
return (this.title);
}
/*******************************************************************************
** Setter for title
*******************************************************************************/
public void setTitle(String title)
{
this.title = title;
}
/*******************************************************************************
** Fluent setter for title
*******************************************************************************/
public CmsProjectUpdate withTitle(String title)
{
this.title = title;
return (this);
}
/*******************************************************************************
** Getter for excerpt
*******************************************************************************/
public String getExcerpt()
{
return (this.excerpt);
}
/*******************************************************************************
** Setter for excerpt
*******************************************************************************/
public void setExcerpt(String excerpt)
{
this.excerpt = excerpt;
}
/*******************************************************************************
** Fluent setter for excerpt
*******************************************************************************/
public CmsProjectUpdate withExcerpt(String excerpt)
{
this.excerpt = excerpt;
return (this);
}
/*******************************************************************************
** Getter for content
*******************************************************************************/
public String getContent()
{
return (this.content);
}
/*******************************************************************************
** Setter for content
*******************************************************************************/
public void setContent(String content)
{
this.content = content;
}
/*******************************************************************************
** Fluent setter for content
*******************************************************************************/
public CmsProjectUpdate withContent(String content)
{
this.content = content;
return (this);
}
/*******************************************************************************
** Getter for updateDate
*******************************************************************************/
public Instant getUpdateDate()
{
return (this.updateDate);
}
/*******************************************************************************
** Setter for updateDate
*******************************************************************************/
public void setUpdateDate(Instant updateDate)
{
this.updateDate = updateDate;
}
/*******************************************************************************
** Fluent setter for updateDate
*******************************************************************************/
public CmsProjectUpdate withUpdateDate(Instant updateDate)
{
this.updateDate = updateDate;
return (this);
}
/*******************************************************************************
** Getter for isPublished
*******************************************************************************/
public Boolean getIsPublished()
{
return (this.isPublished);
}
/*******************************************************************************
** Setter for isPublished
*******************************************************************************/
public void setIsPublished(Boolean isPublished)
{
this.isPublished = isPublished;
}
/*******************************************************************************
** Fluent setter for isPublished
*******************************************************************************/
public CmsProjectUpdate withIsPublished(Boolean isPublished)
{
this.isPublished = isPublished;
return (this);
}
/*******************************************************************************
** Getter for publishDate
*******************************************************************************/
public Instant getPublishDate()
{
return (this.publishDate);
}
/*******************************************************************************
** Setter for publishDate
*******************************************************************************/
public void setPublishDate(Instant publishDate)
{
this.publishDate = publishDate;
}
/*******************************************************************************
** Fluent setter for publishDate
*******************************************************************************/
public CmsProjectUpdate withPublishDate(Instant publishDate)
{
this.publishDate = publishDate;
return (this);
}
/*******************************************************************************
** Getter for sortOrder
*******************************************************************************/
public Integer getSortOrder()
{
return (this.sortOrder);
}
/*******************************************************************************
** Setter for sortOrder
*******************************************************************************/
public void setSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
}
/*******************************************************************************
** Fluent setter for sortOrder
*******************************************************************************/
public CmsProjectUpdate withSortOrder(Integer sortOrder)
{
this.sortOrder = sortOrder;
return (this);
}
/*******************************************************************************
** Getter for featuredMediaId
*******************************************************************************/
public Long getFeaturedMediaId()
{
return (this.featuredMediaId);
}
/*******************************************************************************
** Setter for featuredMediaId
*******************************************************************************/
public void setFeaturedMediaId(Long featuredMediaId)
{
this.featuredMediaId = featuredMediaId;
}
/*******************************************************************************
** Fluent setter for featuredMediaId
*******************************************************************************/
public CmsProjectUpdate withFeaturedMediaId(Long featuredMediaId)
{
this.featuredMediaId = featuredMediaId;
return (this);
}
/*******************************************************************************
** Getter for featuredImage
*******************************************************************************/
public String getFeaturedImage()
{
return (this.featuredImage);
}
/*******************************************************************************
** Setter for featuredImage
*******************************************************************************/
public void setFeaturedImage(String featuredImage)
{
this.featuredImage = featuredImage;
}
/*******************************************************************************
** Fluent setter for featuredImage
*******************************************************************************/
public CmsProjectUpdate withFeaturedImage(String featuredImage)
{
this.featuredImage = featuredImage;
return (this);
}
/*******************************************************************************
** Getter for createDate
*******************************************************************************/
public Instant getCreateDate()
{
return (this.createDate);
}
/*******************************************************************************
** Setter for createDate
*******************************************************************************/
public void setCreateDate(Instant createDate)
{
this.createDate = createDate;
}
/*******************************************************************************
** Fluent setter for createDate
*******************************************************************************/
public CmsProjectUpdate withCreateDate(Instant createDate)
{
this.createDate = createDate;
return (this);
}
/*******************************************************************************
** Getter for modifyDate
*******************************************************************************/
public Instant getModifyDate()
{
return (this.modifyDate);
}
/*******************************************************************************
** Setter for modifyDate
*******************************************************************************/
public void setModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
}
/*******************************************************************************
** Fluent setter for modifyDate
*******************************************************************************/
public CmsProjectUpdate withModifyDate(Instant modifyDate)
{
this.modifyDate = modifyDate;
return (this);
}
}
@@ -0,0 +1,93 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.security;
import java.util.ArrayList;
import java.util.List;
import com.kingsrook.qqq.backend.core.actions.permissions.CustomPermissionChecker;
import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.exceptions.QPermissionDeniedException;
import com.kingsrook.qqq.backend.core.model.actions.AbstractActionInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.delete.DeleteInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.replace.ReplaceInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.update.UpdateInput;
import com.kingsrook.qqq.backend.core.model.metadata.permissions.MetaDataWithPermissionRules;
import com.kingsrook.qqq.backend.core.model.session.QSession;
/*******************************************************************************
** Table permissions when CmsQBitConfig.openReads is on: reading needs no
** permission; an insert, update, delete or replace needs the table's
** .insert, .edit or .delete permission (the same names as the standard
** READ_INSERT_EDIT_DELETE rules, so roles grant the same names either way).
**
** Only write inputs count as writes. Other permission questions (table meta
** data, which pass a plain table input) are answered as reads.
*******************************************************************************/
public class CmsOpenReadsPermissionChecker implements CustomPermissionChecker
{
/*******************************************************************************
** Throw if the current session may not perform the write the input describes.
*******************************************************************************/
@Override
public void checkPermissionsThrowing(AbstractActionInput actionInput, MetaDataWithPermissionRules metaDataWithPermissionRules) throws QPermissionDeniedException
{
QSession session = QContext.getQSession();
for(String suffix : requiredWriteSuffixes(actionInput))
{
if(session == null || !session.hasPermission(metaDataWithPermissionRules.getName() + "." + suffix))
{
throw (new QPermissionDeniedException("Permission denied."));
}
}
}
/*******************************************************************************
** The write permission suffixes an input requires (empty for reads).
*******************************************************************************/
static List<String> requiredWriteSuffixes(AbstractActionInput actionInput)
{
List<String> rs = new ArrayList<>();
if(actionInput instanceof InsertInput)
{
rs.add("insert");
}
else if(actionInput instanceof UpdateInput)
{
rs.add("edit");
}
else if(actionInput instanceof DeleteInput)
{
rs.add("delete");
}
else if(actionInput instanceof ReplaceInput replaceInput)
{
rs.add("insert");
rs.add("edit");
if(Boolean.TRUE.equals(replaceInput.getPerformDeletes()))
{
rs.add("delete");
}
}
return (rs);
}
}
@@ -0,0 +1,42 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.security;
/*******************************************************************************
** The CMS role bundles (spec section 6.2). A host maps its identity
** provider's groups to roles in CmsQBitConfig.roleMapping, and
** CmsSecurity.applySessionPermissions turns a user's groups into the
** permissions of their roles.
*******************************************************************************/
public enum CmsRole
{
/** Everything, including reference data (types) and the admin permission. */
ADMIN,
/** Read and write content; read reference data. No publishing. */
EDITOR,
/** EDITOR plus publishing. */
PUBLISHER,
/** Read content, create and edit drafts; no deletes, no publishing. */
DRAFTER,
/** Read everything. */
VIEWER
}
@@ -0,0 +1,167 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.security;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
import com.kingsrook.qbits.cms.CmsQBitConfig;
import com.kingsrook.qbits.cms.CmsTables;
import com.kingsrook.qbits.cms.metadata.CmsTableDefinition;
import com.kingsrook.qqq.backend.core.model.session.QSession;
/*******************************************************************************
** Turns identity-provider groups into CMS permissions (spec section 6.2).
** The host calls applySessionPermissions from its authentication customizer,
** the same integration point other qbits use; the qbit never talks to the
** identity provider itself.
**
** Permission names: each table's .read, .insert, .edit and .delete
** (cms_page.edit), plus permissionBaseName.admin and .publish.
*******************************************************************************/
public final class CmsSecurity
{
public static final String ADMIN = "admin";
public static final String PUBLISH = "publish";
/*******************************************************************************
** Not instantiable.
*******************************************************************************/
private CmsSecurity()
{
}
/*******************************************************************************
** The roles a user's groups map to.
**
** @param config the CMS config (its roleMapping)
** @param groups the user's identity-provider groups
** @return the roles
*******************************************************************************/
public static Set<CmsRole> rolesFor(CmsQBitConfig config, Collection<String> groups)
{
Set<CmsRole> roles = EnumSet.noneOf(CmsRole.class);
if(groups != null && config.getRoleMapping() != null)
{
for(String group : groups)
{
CmsRole role = config.getRoleMapping().get(group);
if(role != null)
{
roles.add(role);
}
}
}
return (roles);
}
/*******************************************************************************
** The permission names of a set of roles.
**
** @param config the CMS config
** @param roles the roles
** @return the permission names, sorted
*******************************************************************************/
public static Set<String> permissionsFor(CmsQBitConfig config, Set<CmsRole> roles)
{
Set<String> rs = new TreeSet<>();
for(CmsTableDefinition definition : CmsTables.definitions(config))
{
String table = config.applyPrefix(definition.logicalName());
boolean reference = definition.kind() == CmsTableDefinition.Kind.REFERENCE;
for(CmsRole role : roles)
{
rs.add(table + ".read");
switch(role)
{
case ADMIN -> addWrites(rs, table, true);
case EDITOR, PUBLISHER ->
{
if(!reference)
{
addWrites(rs, table, true);
}
}
case DRAFTER ->
{
if(!reference)
{
addWrites(rs, table, false);
}
}
default ->
{
//////////////////////////
// VIEWER: read only //
//////////////////////////
}
}
}
}
if(roles.contains(CmsRole.ADMIN))
{
rs.add(config.permission(ADMIN));
rs.add(config.permission(PUBLISH));
}
if(roles.contains(CmsRole.PUBLISHER))
{
rs.add(config.permission(PUBLISH));
}
return (rs);
}
/*******************************************************************************
** Add the permissions of a user's groups to a session.
**
** @param session the session
** @param groups the user's identity-provider groups
** @param config the CMS config
*******************************************************************************/
public static void applySessionPermissions(QSession session, Collection<String> groups, CmsQBitConfig config)
{
Set<String> permissions = new HashSet<>(session.getPermissions() == null ? Set.of() : session.getPermissions());
permissions.addAll(permissionsFor(config, rolesFor(config, groups)));
session.setPermissions(permissions);
}
/*******************************************************************************
**
*******************************************************************************/
private static void addWrites(Set<String> rs, String table, boolean delete)
{
rs.add(table + ".insert");
rs.add(table + ".edit");
if(delete)
{
rs.add(table + ".delete");
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,88 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.kingsrook.qbits.cms.security.CmsRole;
import com.kingsrook.qbits.cms.security.CmsSecurity;
import com.kingsrook.qqq.backend.core.actions.dashboard.RenderWidgetAction;
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
import com.kingsrook.qqq.backend.core.model.actions.widgets.RenderWidgetInput;
import com.kingsrook.qqq.backend.core.model.actions.widgets.RenderWidgetOutput;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.utils.JsonUtils;
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSBackendMetaData;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/*******************************************************************************
** Child-record lists on parent records render and serialize (the record
** screens' Sections, Child Pages, Domains and Items lists).
*******************************************************************************/
class CmsChildListTest
{
/*******************************************************************************
**
*******************************************************************************/
@AfterEach
void afterEach()
{
QContext.clear();
}
/*******************************************************************************
** Every child list renders to JSON for a real parent record.
*******************************************************************************/
@Test
void testChildListsSerialize() throws Exception
{
RDBMSBackendMetaData backend = CmsTestSupport.h2Backend();
CmsTestSupport.migrate(backend, Map.of());
QInstance qInstance = CmsTestSupport.blankInstance(backend);
CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND);
new CmsQBitProducer().withQBitConfig(config).produce(qInstance);
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.ADMIN)));
Integer siteId = new InsertAction().execute(new InsertInput("cms_site").withRecord(new QRecord().withValue("name", "S").withValue("shortName", "s")))
.getRecords().get(0).getValueInteger("id");
new InsertAction().execute(new InsertInput("cms_page").withRecord(new QRecord().withValue("name", "P").withValue("slug", "p").withValue("title", "P")
.withValue("pageTypeId", 1).withValue("siteId", siteId)
.withAssociatedRecord("sections", new QRecord().withValue("name", "A").withValue("sectionTypeId", 1))));
new InsertAction().execute(new InsertInput("cms_menu").withRecord(new QRecord().withValue("name", "M").withValue("slug", "m").withValue("menuType", "HEADER")
.withValue("siteId", siteId).withAssociatedRecord("items", new QRecord().withValue("name", "I").withValue("slug", "i").withValue("itemType", "LINK"))));
for(String widget : List.of("cms_page_cms_page_section_pageId", "cms_page_cms_page_parentPageId", "cms_site_cms_domain_siteId",
"cms_menu_cms_menu_item_menuId", "cms_menu_item_cms_menu_item_parentId"))
{
RenderWidgetOutput output = new RenderWidgetAction().execute(new RenderWidgetInput().withWidgetMetaData(qInstance.getWidget(widget))
.withUrlParams(new HashMap<>(Map.of("id", "1"))));
assertThat(JsonUtils.toJson(output.getWidgetData())).as(widget).isNotEmpty();
}
}
}
@@ -0,0 +1,596 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.Instant;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;
import com.kingsrook.qbits.cms.security.CmsRole;
import com.kingsrook.qbits.cms.security.CmsSecurity;
import com.kingsrook.qbits.cms.metadata.CmsValueListCheck;
import com.kingsrook.qqq.backend.core.actions.customizers.TableCustomizers;
import com.kingsrook.qqq.backend.core.actions.dashboard.RenderWidgetAction;
import com.kingsrook.qqq.backend.core.actions.tables.CountAction;
import com.kingsrook.qqq.backend.core.actions.tables.DeleteAction;
import com.kingsrook.qqq.backend.core.actions.tables.GetAction;
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
import com.kingsrook.qqq.backend.core.actions.tables.UpdateAction;
import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.exceptions.QPermissionDeniedException;
import com.kingsrook.qqq.backend.core.instances.QInstanceValidator;
import com.kingsrook.qqq.backend.core.model.actions.tables.count.CountInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.delete.DeleteInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QCriteriaOperator;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QFilterCriteria;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.update.UpdateInput;
import com.kingsrook.qqq.backend.core.model.actions.widgets.RenderWidgetInput;
import com.kingsrook.qqq.backend.core.model.actions.widgets.RenderWidgetOutput;
import com.kingsrook.qqq.backend.core.model.dashboard.widgets.RawHTML;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.fields.AdornmentType;
import com.kingsrook.qqq.backend.core.model.metadata.fields.FieldAdornment;
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldType;
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.permissions.PermissionLevel;
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.QPossibleValueSourceType;
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
import com.kingsrook.qqq.backend.core.utils.JsonUtils;
import com.kingsrook.qqq.backend.module.rdbms.jdbc.ConnectionManager;
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSBackendMetaData;
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSTableBackendDetails;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/*******************************************************************************
** The content features (MEDIA, BLOG, PROJECTS, PHOTOS): what they produce,
** how they depend on each other, their install on H2 and content written
** through QQQ's own actions.
*******************************************************************************/
class CmsContentFeaturesTest
{
private static final List<String> CONTENT_TABLES = List.of("cms_media_type", "cms_media", "cms_blog_type", "cms_blog", "cms_author", "cms_blog_tag", "cms_blog_post",
"cms_blog_post_tag_int", "cms_blog_post_media", "cms_blog_post_version", "cms_project_category", "cms_project", "cms_project_update", "cms_photo_album_folder",
"cms_photo_album", "cms_photo", "cms_photo_tag", "cms_photo_tag_int");
private static final List<String> VALUE_LISTS = List.of("cms_media_rendition_format", "cms_media_cache_class", "cms_content_channel", "cms_content_format",
"cms_content_version_status", "cms_project_status");
/*******************************************************************************
**
*******************************************************************************/
@AfterEach
void afterEach()
{
QContext.clear();
}
/*******************************************************************************
** Every content table is a standard, visible table with its own
** possible-value source; value lists, file previews, help text,
** associations, areas and the nav are as designed; the instance is valid.
*******************************************************************************/
@Test
void testProduce() throws Exception
{
QInstance qInstance = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
CmsQBitConfig config = config();
new CmsQBitProducer().withQBitConfig(config).produce(qInstance);
new QInstanceValidator().validate(qInstance);
assertThat(CmsTables.definitions()).hasSize(29);
assertThat(CmsTables.valueListNames()).hasSize(6).isSorted();
for(String name : CONTENT_TABLES)
{
QTableMetaData table = qInstance.getTable(name);
assertThat(table).as(name).isNotNull();
assertThat(((RDBMSTableBackendDetails) table.getBackendDetails()).getTableName()).isEqualTo(name);
assertThat(table.getPermissionRules().getLevel()).isEqualTo(PermissionLevel.READ_INSERT_EDIT_DELETE_PERMISSIONS);
assertThat(table.getIsHidden()).as(name + " is visible").isFalse();
assertThat(table.getField("createDate").getBackendName()).isEqualTo("create_date");
assertThat(table.getField("modifyDate").getIsEditable()).isFalse();
assertThat(qInstance.getPossibleValueSource(name)).as(name + " PVS").isNotNull();
}
for(String name : VALUE_LISTS)
{
assertThat(qInstance.getPossibleValueSource(name)).as(name).isNotNull();
assertThat(qInstance.getPossibleValueSource(name).getType()).isEqualTo(QPossibleValueSourceType.ENUM);
}
assertThat(qInstance.getTable("cms_media_type").getField("thumbnailFormat").getPossibleValueSourceName()).isEqualTo("cms_media_rendition_format");
assertThat(qInstance.getTable("cms_media_type").getField("cacheClass").getPossibleValueSourceName()).isEqualTo("cms_media_cache_class");
assertThat(qInstance.getTable("cms_project").getField("projectStatus").getPossibleValueSourceName()).isEqualTo("cms_project_status");
assertThat(qInstance.getTable("cms_blog_post_version").getField("channel").getPossibleValueSourceName()).isEqualTo("cms_content_channel");
assertThat(qInstance.getTable("cms_blog_post").getField("featuredMediaId").getPossibleValueSourceName()).isEqualTo("cms_media");
assertThat(qInstance.getTable("cms_blog_post").getField("content").getType()).isEqualTo(QFieldType.TEXT);
assertThat(qInstance.getTable("cms_author").getField("socialLinks").getType()).isEqualTo(QFieldType.TEXT);
assertThat(qInstance.getTable("cms_photo_album").getField("locationLatitude").getType()).isEqualTo(QFieldType.DECIMAL);
assertThat(qInstance.getTable("cms_photo_album").getField("photoAlbumFolderId").getBackendName()).isEqualTo("photo_album_folder_id");
assertThat(qInstance.getTable("cms_blog_post").getRecordLabelFields()).containsExactly("title");
assertThat(qInstance.getTable("cms_media").getLabel()).isEqualTo("Media");
assertThat(qInstance.getTable("cms_blog_post_media").getLabel()).isEqualTo("Blog Post Media");
assertThat(qInstance.getTable("cms_project_category").getLabel()).isEqualTo("Project Categories");
FieldAdornment stored = qInstance.getTable("cms_media").getField("publicUrl").getAdornment(AdornmentType.FILE_PREVIEW).orElseThrow();
assertThat(stored.getValues()).containsEntry(AdornmentType.FilePreviewValues.THUMBNAIL_URL_FIELD, "thumbnailUrl")
.containsEntry(AdornmentType.FilePreviewValues.FILE_NAME_FIELD, "fileName").containsEntry(AdornmentType.FilePreviewValues.ALT_TEXT_FIELD, "altText");
FieldAdornment image = qInstance.getTable("cms_blog_post").getField("featuredImage").getAdornment(AdornmentType.FILE_PREVIEW).orElseThrow();
assertThat(image.getValues()).containsEntry(AdornmentType.FilePreviewValues.DEFAULT_MIME_TYPE, "image/*")
.containsEntry(AdornmentType.FilePreviewValues.ALT_TEXT_FIELD, "title").doesNotContainKey(AdornmentType.FilePreviewValues.THUMBNAIL_URL_FIELD);
assertThat(qInstance.getTable("cms_media_type").getField("allowedMimeTypes").getHelpContents()).hasSize(1);
//////////////////////////////////////////////////////////////////
// a table with a value-list field checks it on every write //
//////////////////////////////////////////////////////////////////
for(String name : List.of("cms_media_type", "cms_blog_post_version", "cms_project"))
{
assertThat(qInstance.getTable(name).getCustomizer(TableCustomizers.PRE_INSERT_RECORD.getRole()).orElseThrow().getName()).isEqualTo(CmsValueListCheck.class.getName());
assertThat(qInstance.getTable(name).getCustomizer(TableCustomizers.PRE_UPDATE_RECORD.getRole()).orElseThrow().getName()).isEqualTo(CmsValueListCheck.class.getName());
}
assertThat(qInstance.getTable("cms_blog").getCustomizer(TableCustomizers.PRE_INSERT_RECORD.getRole())).isEmpty();
assertThat(qInstance.getTable("cms_blog").getAssociations()).extracting("name").containsExactly("tags");
assertThat(qInstance.getTable("cms_blog_post").getAssociations()).extracting("name").containsExactly("tags", "media");
assertThat(qInstance.getTable("cms_project").getAssociations()).extracting("name").containsExactly("updates");
assertThat(qInstance.getTable("cms_photo_album").getAssociations()).extracting("name").containsExactly("photos");
assertThat(qInstance.getTable("cms_project").getSections()).extracting("name")
.contains("cms_project_cms_project_update_projectId", "cms_project_cms_photo_album_projectId", "cms_project_cms_blog_post_version_projectId");
QAppMetaData top = qInstance.getApp("cms");
assertThat(top.getChildren()).extracting("name").containsExactly("cmsSites", "cmsPages", "cmsNavigation", "cmsMedia", "cmsBlogs", "cmsProjects", "cmsPhotos");
assertThat(qInstance.getApp("cmsBlogs").getWidgets()).containsExactly("cmsBlogsHome");
assertThat(navTables(qInstance)).contains("cms_media", "cms_media_type", "cms_blog_post", "cms_blog", "cms_author", "cms_blog_type", "cms_project",
"cms_project_category", "cms_photo_album", "cms_photo_album_folder", "cms_photo_tag")
.doesNotContain("cms_blog_tag", "cms_blog_post_tag_int", "cms_blog_post_media", "cms_blog_post_version", "cms_project_update", "cms_photo", "cms_photo_tag_int");
}
/*******************************************************************************
** A feature that is off produces nothing, and what refers to it loses its
** lookup and its list; blogs, projects and photos need media.
*******************************************************************************/
@Test
void testFeatureSubsets() throws Exception
{
QInstance blogs = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
new CmsQBitProducer().withQBitConfig(config().withFeatures(EnumSet.of(CmsFeature.CORE, CmsFeature.MEDIA, CmsFeature.BLOG))).produce(blogs);
new QInstanceValidator().validate(blogs);
assertThat(blogs.getTable("cms_project")).isNull();
assertThat(blogs.getTable("cms_photo_album")).isNull();
assertThat(blogs.getTable("cms_blog_post_version").getField("projectId").getPossibleValueSourceName()).isNull();
assertThat(blogs.getPossibleValueSource("cms_project_status")).isNull();
assertThat(blogs.getPossibleValueSource("cms_content_channel")).isNotNull();
assertThat(blogs.getApp("cms").getChildren()).extracting("name").containsExactly("cmsSites", "cmsPages", "cmsNavigation", "cmsMedia", "cmsBlogs");
QInstance projects = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
new CmsQBitProducer().withQBitConfig(config().withFeatures(EnumSet.of(CmsFeature.CORE, CmsFeature.MEDIA, CmsFeature.PROJECTS))).produce(projects);
new QInstanceValidator().validate(projects);
assertThat(projects.getTable("cms_blog")).isNull();
assertThat(projects.getTable("cms_project").getSections()).extracting("name").contains("cms_project_cms_project_update_projectId")
.doesNotContain("cms_project_cms_photo_album_projectId", "cms_project_cms_blog_post_version_projectId");
assertThat(projects.getPossibleValueSource("cms_content_channel")).isNull();
QInstance media = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
new CmsQBitProducer().withQBitConfig(config().withFeatures(EnumSet.of(CmsFeature.CORE, CmsFeature.MEDIA))).produce(media);
new QInstanceValidator().validate(media);
assertThat(media.getTable("cms_media")).isNotNull();
assertThat(media.getTable("cms_author")).isNull();
QInstance core = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
new CmsQBitProducer().withQBitConfig(config().withFeatures(EnumSet.of(CmsFeature.CORE))).produce(core);
assertThat(core.getTables().keySet()).noneMatch(CONTENT_TABLES::contains);
assertThat(core.getPossibleValueSources().keySet()).noneMatch(VALUE_LISTS::contains);
for(CmsFeature feature : List.of(CmsFeature.BLOG, CmsFeature.PROJECTS, CmsFeature.PHOTOS))
{
QInstance qInstance = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
assertThatThrownBy(() -> new CmsQBitProducer().withQBitConfig(config().withFeatures(EnumSet.of(CmsFeature.CORE, feature))).produce(qInstance))
.hasMessageContaining("feature " + feature + " requires MEDIA");
}
}
/*******************************************************************************
** Fresh install with every feature: the schema check passes, generic media
** and blog types are seeded, and content round-trips with its defaults,
** its children through associations and its unique keys.
*******************************************************************************/
@Test
void testInstallAndContent() throws Exception
{
RDBMSBackendMetaData backend = CmsTestSupport.h2Backend();
CmsTestSupport.migrate(backend, Map.of());
QInstance qInstance = CmsTestSupport.blankInstance(backend);
CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND);
new CmsQBitProducer().withQBitConfig(config).produce(qInstance);
new QInstanceValidator().validate(qInstance);
assertThat(config.getRuntime().getSchemaProblems()).isEmpty();
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.ADMIN)));
assertThat(count("cms_media_type")).isEqualTo(5);
assertThat(count("cms_blog_type")).isEqualTo(2);
QRecord imageType = one("cms_media_type", "code", "IMAGE");
assertThat(imageType.getValueString("allowedExtensions")).isEqualTo("jpg,jpeg,png,heic,heif");
assertThat(imageType.getValueInteger("maxFileSizeMb")).isEqualTo(25);
assertThat(imageType.getValueBoolean("stripMetadata")).isTrue();
assertThat(imageType.getValueString("thumbnailFormat")).isEqualTo("JPEG");
assertThat(one("cms_media_type", "code", "VIDEO").getValueBoolean("stripMetadata")).isFalse();
Integer siteId = insert("cms_site", new QRecord().withValue("name", "Example").withValue("shortName", "example"));
Integer mediaId = insert("cms_media", new QRecord().withValue("name", "Harbour at dawn").withValue("mediaTypeId", imageType.getValue("id")).withValue("siteId", siteId)
.withValue("publicUrl", "https://files.example.com/harbour.jpg").withValue("thumbnailUrl", "https://files.example.com/harbour-thumb.jpg")
.withValue("mimeType", "image/jpeg").withValue("altText", "Boats in a harbour at dawn"));
assertThat(get("cms_media", mediaId).getValueBoolean("isActive")).isTrue();
Integer blogId = insert("cms_blog", new QRecord().withValue("name", "News").withValue("shortName", "news").withValue("slug", "news")
.withValue("blogTypeId", one("cms_blog_type", "code", "SITE_BLOG").getValue("id")).withValue("siteId", siteId)
.withAssociatedRecord("tags", new QRecord().withValue("name", "Releases").withValue("slug", "releases")));
Integer tagId = one("cms_blog_tag", "slug", "releases").getValueInteger("id");
Integer authorId = insert("cms_author", new QRecord().withValue("name", "Ada Example").withValue("shortName", "ada").withValue("slug", "ada")
.withValue("profileMediaId", mediaId));
assertThat(get("cms_author", authorId).getValueBoolean("isActive")).isTrue();
Integer postId = insert("cms_blog_post", post("first", blogId, authorId).withValue("content", "x".repeat(5000)).withValue("featuredMediaId", mediaId)
.withAssociatedRecord("tags", new QRecord().withValue("blogTagId", tagId))
.withAssociatedRecord("media", new QRecord().withValue("mediaId", mediaId).withValue("url", "https://files.example.com/harbour.jpg")));
QRecord post = new GetAction().execute(new GetInput("cms_blog_post").withPrimaryKey(postId).withIncludeAssociations(true)).getRecord();
assertThat(post.getValueString("content")).hasSize(5000);
assertThat(post.getValueBoolean("isPublished")).isFalse();
assertThat(post.getValueBoolean("isFeatured")).isFalse();
assertThat(post.getValueInteger("readTime")).isEqualTo(4);
assertThat(post.getValueLong("viewCount")).isZero();
assertThat(post.getValue("createDate")).isNotNull();
assertThat(post.getAssociatedRecords().get("tags")).hasSize(1);
assertThat(post.getAssociatedRecords().get("media")).hasSize(1);
assertThat(post.getAssociatedRecords().get("media").get(0).getValueInteger("sortOrder")).isZero();
//////////////////////////////////////////////////////////////////
// a slug is unique within its blog: the second insert is an //
// error on the record, not a second row //
//////////////////////////////////////////////////////////////////
QRecord duplicate = new InsertAction().execute(new InsertInput("cms_blog_post").withRecord(post("first", blogId, authorId).withValue("name", "Other")
.withValue("shortName", "other"))).getRecords().get(0);
assertThat(duplicate.getErrors()).isNotEmpty();
assertThat(count("cms_blog_post")).isEqualTo(1);
Integer versionId = insert("cms_blog_post_version", new QRecord().withValue("blogPostId", postId).withValue("name", "LinkedIn").withValue("variantKey", "linkedin")
.withValue("channel", "LINKEDIN").withValue("content", "Short version"));
assertThat(get("cms_blog_post_version", versionId).getValueString("contentFormat")).isEqualTo("MARKDOWN");
assertThat(get("cms_blog_post_version", versionId).getValueString("status")).isEqualTo("DRAFT");
Integer categoryId = insert("cms_project_category", new QRecord().withValue("siteId", siteId).withValue("name", "Software").withValue("title", "Software projects")
.withValue("slug", "software"));
Integer projectId = insert("cms_project", new QRecord().withValue("name", "Harbour").withValue("shortName", "harbour").withValue("slug", "harbour")
.withValue("title", "The Harbour Project").withValue("siteId", siteId).withValue("categoryId", categoryId)
.withAssociatedRecord("updates", new QRecord().withValue("slug", "kickoff").withValue("title", "Kickoff").withValue("content", "We started.")
.withValue("updateDate", Instant.parse("2026-11-01T12:00:00Z"))));
QRecord project = new GetAction().execute(new GetInput("cms_project").withPrimaryKey(projectId).withIncludeAssociations(true)).getRecord();
assertThat(project.getValueString("projectStatus")).isEqualTo("ACTIVE");
assertThat(project.getValueInteger("imageFocalX")).isEqualTo(50);
assertThat(project.getValueBoolean("isPublished")).isFalse();
assertThat(project.getAssociatedRecords().get("updates")).hasSize(1);
//////////////////////////////////////////////////////////////////
// a value-list field takes only the values of its list: an //
// insert or an edit with another value is an error on the //
// record, and the database refuses it too //
//////////////////////////////////////////////////////////////////
QRecord odd = new InsertAction().execute(new InsertInput("cms_project").withRecord(new QRecord().withValue("name", "Odd").withValue("shortName", "odd")
.withValue("slug", "odd").withValue("title", "Odd").withValue("siteId", siteId).withValue("categoryId", categoryId).withValue("projectStatus", "NO_SUCH_STATUS")))
.getRecords().get(0);
assertThat(odd.getErrors()).extracting(Object::toString).anyMatch(e -> e.contains("must be one of: ACTIVE, ARCHIVED, IN_PROGRESS, PLANNED"));
assertThat(count("cms_project")).isEqualTo(1);
QRecord oddEdit = new UpdateAction().execute(new UpdateInput("cms_project").withRecord(new QRecord().withValue("id", projectId).withValue("projectStatus", "NOPE")))
.getRecords().get(0);
assertThat(oddEdit.getErrors()).isNotEmpty();
assertThat(get("cms_project", projectId).getValueString("projectStatus")).isEqualTo("ACTIVE");
assertThat(new UpdateAction().execute(new UpdateInput("cms_project").withRecord(new QRecord().withValue("id", projectId).withValue("projectStatus", "ARCHIVED")))
.getRecords().get(0).getErrors()).isEmpty();
assertThat(new UpdateAction().execute(new UpdateInput("cms_project").withRecord(new QRecord().withValue("id", projectId).withValue("title", "The Harbour Project")))
.getRecords().get(0).getErrors()).isEmpty();
assertThat(get("cms_project", projectId).getValueString("projectStatus")).isEqualTo("ARCHIVED");
try(Connection connection = ConnectionManager.getConnection(backend); Statement statement = connection.createStatement())
{
assertThatThrownBy(() -> statement.execute("UPDATE cms_project SET project_status = 'NOPE'")).isInstanceOf(SQLException.class);
assertThatThrownBy(() -> statement.execute("UPDATE cms_project SET image_focal_x = 101")).isInstanceOf(SQLException.class);
assertThatThrownBy(() -> statement.execute("UPDATE cms_media_type SET thumbnail_format = 'GIF'")).isInstanceOf(SQLException.class);
assertThatThrownBy(() -> statement.execute("UPDATE cms_blog_post_version SET channel = 'FAX'")).isInstanceOf(SQLException.class);
}
Integer folderId = insert("cms_photo_album_folder", new QRecord().withValue("siteId", siteId).withValue("name", "Travel").withValue("slug", "travel"));
Integer albumId = insert("cms_photo_album", new QRecord().withValue("siteId", siteId).withValue("photoAlbumFolderId", folderId).withValue("projectId", projectId)
.withValue("name", "Harbour mornings").withValue("shortName", "harbour").withValue("slug", "harbour").withValue("locationLatitude", new BigDecimal("41.878100"))
.withAssociatedRecord("photos", new QRecord().withValue("title", "First light").withValue("slug", "first-light").withValue("mediaId", mediaId)));
QRecord album = new GetAction().execute(new GetInput("cms_photo_album").withPrimaryKey(albumId).withIncludeAssociations(true)).getRecord();
assertThat(album.getValueBigDecimal("locationLatitude")).isEqualByComparingTo("41.8781");
assertThat(album.getAssociatedRecords().get("photos")).hasSize(1);
Integer photoId = album.getAssociatedRecords().get("photos").get(0).getValueInteger("id");
Integer photoTagId = insert("cms_photo_tag", new QRecord().withValue("name", "Dawn").withValue("slug", "dawn"));
insert("cms_photo_tag_int", new QRecord().withValue("photoId", photoId).withValue("photoTagId", photoTagId));
assertThat(new GetAction().execute(new GetInput("cms_photo").withPrimaryKey(photoId).withIncludeAssociations(true)).getRecord().getAssociatedRecords().get("tags"))
.hasSize(1);
/////////////////////////////////////////////////////////////////
// every child list of the content features renders for a row //
/////////////////////////////////////////////////////////////////
Map<String, Integer> lists = Map.ofEntries(Map.entry("cms_media_type_cms_media_mediaTypeId", imageType.getValueInteger("id")),
Map.entry("cms_blog_cms_blog_post_blogId", blogId), Map.entry("cms_blog_cms_blog_tag_blogId", blogId), Map.entry("cms_author_cms_blog_post_authorId", authorId),
Map.entry("cms_blog_tag_cms_blog_post_tag_int_blogTagId", tagId), Map.entry("cms_blog_post_cms_blog_post_tag_int_blogPostId", postId),
Map.entry("cms_blog_post_cms_blog_post_media_blogPostId", postId), Map.entry("cms_blog_post_cms_blog_post_version_blogPostId", postId),
Map.entry("cms_project_category_cms_project_categoryId", categoryId), Map.entry("cms_project_cms_project_update_projectId", projectId),
Map.entry("cms_project_cms_photo_album_projectId", projectId), Map.entry("cms_project_cms_blog_post_version_projectId", projectId),
Map.entry("cms_photo_album_folder_cms_photo_album_folder_parentId", folderId), Map.entry("cms_photo_album_folder_cms_photo_album_photoAlbumFolderId", folderId),
Map.entry("cms_photo_album_cms_photo_photoAlbumId", albumId), Map.entry("cms_photo_cms_photo_tag_int_photoId", photoId),
Map.entry("cms_photo_tag_cms_photo_tag_int_photoTagId", photoTagId));
for(Map.Entry<String, Integer> list : lists.entrySet())
{
assertThat(qInstance.getWidget(list.getKey())).as(list.getKey()).isNotNull();
RenderWidgetOutput output = new RenderWidgetAction().execute(new RenderWidgetInput().withWidgetMetaData(qInstance.getWidget(list.getKey()))
.withUrlParams(new HashMap<>(Map.of("id", String.valueOf(list.getValue())))));
assertThat(JsonUtils.toJson(output.getWidgetData())).as(list.getKey()).isNotEmpty();
}
/////////////////////////////////////////////////////////////////
// the homes count the new content and say what needs a look //
/////////////////////////////////////////////////////////////////
String top = html(qInstance, "cmsHome");
assertThat(top).contains("Media", "Blogs", "Projects", "Photos", "/app/cmsBlogs", "1 blog post");
String blogsHome = html(qInstance, "cmsBlogsHome");
assertThat(blogsHome).contains("Unpublished blog posts", "New blog post", "New author", "/app/cms_blog_post/");
assertThat(html(qInstance, "cmsMediaHome")).contains("Harbour at dawn", "New media").doesNotContain("medias");
assertThat(html(qInstance, "cmsProjectsHome")).contains("The Harbour Project", "Unpublished projects");
assertThat(html(qInstance, "cmsPhotosHome")).contains("Unpublished photo albums", "New album folder");
}
/*******************************************************************************
** Features can be installed later: a run that names a feature creates its
** tables, and the links between two features appear when both are there. A
** feature whose needs are not named installs nothing.
*******************************************************************************/
@Test
void testFeaturesInstalledLater() throws Exception
{
RDBMSBackendMetaData backend = CmsTestSupport.h2Backend();
CmsTestSupport.migrate(backend, Map.of("cms.features", "CORE,MEDIA,BLOG"));
CmsQBitConfig blogs = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withFeatures(EnumSet.of(CmsFeature.CORE, CmsFeature.MEDIA, CmsFeature.BLOG));
new CmsQBitProducer().withQBitConfig(blogs).produce(CmsTestSupport.blankInstance(backend));
assertThat(blogs.getRuntime().getSchemaProblems()).isEmpty();
assertThat(exists(backend, "TABLES", "TABLE_NAME", "cms_blog_post")).isTrue();
assertThat(exists(backend, "TABLES", "TABLE_NAME", "cms_project")).isFalse();
assertThat(exists(backend, "TABLE_CONSTRAINTS", "CONSTRAINT_NAME", "fk_cms_blog_post_version_project_id")).isFalse();
CmsQBitConfig all = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withStartupMode(CmsStartupMode.DEGRADED);
new CmsQBitProducer().withQBitConfig(all).produce(CmsTestSupport.blankInstance(backend));
assertThat(all.getRuntime().getSchemaProblems()).anyMatch(p -> p.contains("1.0.0-create-project") && p.contains("PROJECTS"))
.noneMatch(p -> p.contains("1.0.0-create-blog_post "));
CmsTestSupport.migrate(backend, Map.of());
CmsQBitConfig later = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND);
new CmsQBitProducer().withQBitConfig(later).produce(CmsTestSupport.blankInstance(backend));
assertThat(later.getRuntime().getSchemaProblems()).isEmpty();
assertThat(exists(backend, "TABLES", "TABLE_NAME", "cms_project")).isTrue();
assertThat(exists(backend, "TABLE_CONSTRAINTS", "CONSTRAINT_NAME", "fk_cms_blog_post_version_project_id")).isTrue();
assertThat(exists(backend, "TABLE_CONSTRAINTS", "CONSTRAINT_NAME", "fk_cms_photo_album_project_update_id")).isTrue();
RDBMSBackendMetaData incomplete = CmsTestSupport.h2Backend();
CmsTestSupport.migrate(incomplete, Map.of("cms.features", "CORE,BLOG"));
assertThat(exists(incomplete, "TABLES", "TABLE_NAME", "cms_page")).isTrue();
assertThat(exists(incomplete, "TABLES", "TABLE_NAME", "cms_blog")).isFalse();
assertThat(exists(incomplete, "TABLES", "TABLE_NAME", "cms_media")).isFalse();
}
/*******************************************************************************
** An existing table with a content-feature name halts the install; nothing
** is overwritten.
*******************************************************************************/
@Test
void testExistingContentTableHalts() throws Exception
{
RDBMSBackendMetaData backend = CmsTestSupport.h2Backend();
try(Connection connection = ConnectionManager.getConnection(backend); Statement statement = connection.createStatement())
{
statement.execute("CREATE TABLE cms_media (id INT PRIMARY KEY, name VARCHAR(10))");
statement.execute("INSERT INTO cms_media VALUES (1, 'theirs')");
}
assertThatThrownBy(() -> CmsTestSupport.migrate(backend, Map.of())).hasStackTraceContaining("was not created by qbit-cms");
try(Connection connection = ConnectionManager.getConnection(backend); Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT name FROM cms_media WHERE id = 1"))
{
assertThat(resultSet.next()).isTrue();
assertThat(resultSet.getString(1)).isEqualTo("theirs");
}
assertThat(exists(backend, "TABLES", "TABLE_NAME", "cms_blog")).isFalse();
}
/*******************************************************************************
** Role ceilings hold for content: editors write content and not the media
** and blog types, drafters do not delete, viewers only read, and a feature
** that is off grants nothing.
*******************************************************************************/
@Test
void testRoleCeilings() throws Exception
{
CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND);
Set<String> editor = CmsSecurity.permissionsFor(config, Set.of(CmsRole.EDITOR));
assertThat(editor).contains("cms_blog_post.insert", "cms_blog_post.delete", "cms_media.edit", "cms_photo.insert", "cms_project_update.edit", "cms_media_type.read")
.doesNotContain("cms_media_type.edit", "cms_blog_type.insert");
assertThat(CmsSecurity.permissionsFor(config, Set.of(CmsRole.DRAFTER))).contains("cms_blog_post.insert").doesNotContain("cms_blog_post.delete");
assertThat(CmsSecurity.permissionsFor(config, Set.of(CmsRole.VIEWER))).contains("cms_photo.read").allMatch(p -> p.endsWith(".read"));
CmsQBitConfig coreOnly = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withFeatures(EnumSet.of(CmsFeature.CORE));
assertThat(CmsSecurity.permissionsFor(coreOnly, Set.of(CmsRole.ADMIN))).noneMatch(p -> p.startsWith("cms_blog") || p.startsWith("cms_media"));
RDBMSBackendMetaData backend = CmsTestSupport.h2Backend();
CmsTestSupport.migrate(backend, Map.of());
QInstance qInstance = CmsTestSupport.blankInstance(backend);
qInstance.setEnforcePermissionsInCoreActions(true);
new CmsQBitProducer().withQBitConfig(config).produce(qInstance);
CmsTestSupport.session(qInstance, editor);
Integer siteId = insert("cms_site", new QRecord().withValue("name", "Example").withValue("shortName", "example"));
Integer mediaId = insert("cms_media", new QRecord().withValue("name", "Chart").withValue("mediaTypeId", 1).withValue("siteId", siteId));
assertThatThrownBy(() -> new UpdateAction().execute(new UpdateInput("cms_media_type").withRecord(new QRecord().withValue("id", 1).withValue("name", "X"))))
.isInstanceOf(QPermissionDeniedException.class);
assertThatThrownBy(() -> new InsertAction().execute(new InsertInput("cms_blog_type").withRecord(new QRecord().withValue("name", "X").withValue("code", "X"))))
.isInstanceOf(QPermissionDeniedException.class);
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.DRAFTER)));
assertThatThrownBy(() -> new DeleteAction().execute(new DeleteInput("cms_media").withPrimaryKey(mediaId))).isInstanceOf(QPermissionDeniedException.class);
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.VIEWER)));
assertThat(new QueryAction().execute(new QueryInput("cms_media")).getRecords()).hasSize(1);
assertThatThrownBy(() -> new InsertAction().execute(new InsertInput("cms_photo_tag").withRecord(new QRecord().withValue("name", "X").withValue("slug", "x"))))
.isInstanceOf(QPermissionDeniedException.class);
CmsTestSupport.session(qInstance, Set.of());
assertThatThrownBy(() -> new QueryAction().execute(new QueryInput("cms_blog_post"))).isInstanceOf(QPermissionDeniedException.class);
assertThat(html(qInstance, "cmsBlogsHome")).contains("do not have access to Blogs");
}
/*******************************************************************************
** The configuration without a database check.
*******************************************************************************/
private static CmsQBitConfig config()
{
return (new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withStartupMode(CmsStartupMode.SKIP));
}
/*******************************************************************************
** A post of a blog.
*******************************************************************************/
private static QRecord post(String slug, Integer blogId, Integer authorId)
{
return (new QRecord().withValue("name", slug).withValue("shortName", slug).withValue("title", "Post " + slug).withValue("slug", slug)
.withValue("content", "Text").withValue("authorId", authorId).withValue("blogId", blogId));
}
/*******************************************************************************
** The tables in the nav.
*******************************************************************************/
private static List<String> navTables(QInstance qInstance)
{
return (qInstance.getApps().values().stream().filter(a -> a.getSections() != null).flatMap(a -> a.getSections().stream())
.flatMap(s -> s.getTables() == null ? Stream.<String>empty() : s.getTables().stream()).toList());
}
/*******************************************************************************
** Whether the database catalog lists a name (H2 folds unquoted names to
** upper case).
*******************************************************************************/
private static boolean exists(RDBMSBackendMetaData backend, String catalogTable, String column, String name) throws Exception
{
try(Connection connection = ConnectionManager.getConnection(backend); Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT COUNT(*) FROM INFORMATION_SCHEMA." + catalogTable + " WHERE LOWER(" + column + ") = '" + name + "'"))
{
resultSet.next();
return (resultSet.getInt(1) > 0);
}
}
/*******************************************************************************
** A home widget's HTML.
*******************************************************************************/
private static String html(QInstance qInstance, String widgetName) throws QException
{
RawHTML html = (RawHTML) new RenderWidgetAction().execute(new RenderWidgetInput().withWidgetMetaData(qInstance.getWidget(widgetName))).getWidgetData();
return (html.getHtml());
}
/*******************************************************************************
** Insert a record that must be accepted.
*******************************************************************************/
private static Integer insert(String table, QRecord record) throws QException
{
List<QRecord> records = new InsertAction().execute(new InsertInput(table).withRecord(record)).getRecords();
assertThat(records.get(0).getErrors()).as(table).isEmpty();
return (records.get(0).getValueInteger("id"));
}
/*******************************************************************************
** One record by primary key.
*******************************************************************************/
private static QRecord get(String table, Integer id) throws QException
{
return (new GetAction().execute(new GetInput(table).withPrimaryKey(id)).getRecord());
}
/*******************************************************************************
** The one record with a field value.
*******************************************************************************/
private static QRecord one(String table, String field, String value) throws QException
{
List<QRecord> records = new QueryAction().execute(new QueryInput(table).withFilter(new QQueryFilter(new QFilterCriteria(field, QCriteriaOperator.EQUALS, value))))
.getRecords();
assertThat(records).as(table + " " + field + " " + value).hasSize(1);
return (records.get(0));
}
/*******************************************************************************
** The number of records of a table.
*******************************************************************************/
private static Integer count(String table) throws QException
{
return (new CountAction().execute(new CountInput(table)).getCount());
}
}
@@ -0,0 +1,110 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.math.BigDecimal;
import java.time.Instant;
import com.kingsrook.qbits.cms.metadata.CmsTableDefinition;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.data.QRecordEntity;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/*******************************************************************************
** Every CMS entity round-trips through QRecord with its getters, setters and
** fluent setters, and every definition's sections name real fields.
*******************************************************************************/
class CmsEntitiesTest
{
/*******************************************************************************
** Round trip each entity.
*******************************************************************************/
@Test
void testEntitiesRoundTrip() throws Exception
{
for(CmsTableDefinition definition : CmsTables.definitions())
{
Class<? extends QRecordEntity> entityClass = definition.entityClass();
QRecordEntity entity = entityClass.getConstructor().newInstance();
QRecord record = new QRecord();
for(Field field : entityClass.getDeclaredFields())
{
if(Modifier.isStatic(field.getModifiers()))
{
continue;
}
String name = field.getName();
String cap = Character.toUpperCase(name.charAt(0)) + name.substring(1);
Serializable value = sample(field.getType());
Method setter = entityClass.getMethod("set" + cap, field.getType());
Method getter = entityClass.getMethod("get" + cap);
Method wither = entityClass.getMethod("with" + cap, field.getType());
setter.invoke(entity, value);
assertThat(getter.invoke(entity)).as(entityClass.getSimpleName() + "." + name).isEqualTo(value);
assertThat(wither.invoke(entity, value)).isSameAs(entity);
record.setValue(name, value);
}
QRecordEntity copy = entityClass.getConstructor(QRecord.class).newInstance(record);
assertThat(copy.toQRecord().getValues()).as(entityClass.getSimpleName()).isEqualTo(entity.toQRecord().getValues());
for(CmsTableDefinition.Section section : definition.sections())
{
for(String fieldName : section.fields())
{
assertThat(entityClass.getDeclaredField(fieldName)).as(definition.logicalName() + " section field " + fieldName).isNotNull();
}
}
}
}
/*******************************************************************************
** A sample value of a field type.
*******************************************************************************/
private static Serializable sample(Class<?> type)
{
if(type == Long.class)
{
return (7L);
}
if(type == Integer.class)
{
return (3);
}
if(type == Boolean.class)
{
return (true);
}
if(type == BigDecimal.class)
{
return (new BigDecimal("41.5"));
}
if(type == Instant.class)
{
return (Instant.parse("2026-10-12T00:00:00Z"));
}
return ("value");
}
}
@@ -0,0 +1,52 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
import java.util.EnumSet;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/*******************************************************************************
** CmsFeature flags and their dependencies.
*******************************************************************************/
class CmsFeatureTest
{
/*******************************************************************************
** The default set is what this version implements; dependencies hold.
*******************************************************************************/
@Test
void testFeatures()
{
assertThat(CmsFeature.allAvailable()).containsExactly(CmsFeature.CORE, CmsFeature.MEDIA, CmsFeature.BLOG, CmsFeature.PROJECTS, CmsFeature.PHOTOS);
assertThat(CmsFeature.validate(CmsFeature.allAvailable())).isEmpty();
assertThat(CmsFeature.validate(null)).containsExactly("features must include CORE");
assertThat(CmsFeature.BLOG.getRequires()).containsExactly(CmsFeature.MEDIA);
assertThat(CmsFeature.CORE.isAvailable()).isTrue();
assertThat(CmsFeature.validate(EnumSet.of(CmsFeature.CORE, CmsFeature.BLOG))).containsExactly("feature BLOG requires MEDIA");
assertThat(CmsFeature.validate(EnumSet.of(CmsFeature.CORE, CmsFeature.MEDIA, CmsFeature.BLOG, CmsFeature.PROJECTS, CmsFeature.PHOTOS))).isEmpty();
assertThat(CmsFeature.validate(EnumSet.of(CmsFeature.CORE, CmsFeature.STREAM)))
.contains("feature STREAM requires BLOG", "feature STREAM is not available in this version of qbit-cms");
assertThat(CmsFeature.validate(EnumSet.of(CmsFeature.CORE, CmsFeature.PUBLISHING)))
.contains("feature PUBLISHING requires BLOG or PROJECTS");
assertThat(CmsFeature.validate(EnumSet.of(CmsFeature.CORE, CmsFeature.MEDIA, CmsFeature.BLOG, CmsFeature.STREAM, CmsFeature.PUBLISHING)))
.noneMatch(e -> e.contains("requires"));
}
}
@@ -0,0 +1,128 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
import java.util.EnumSet;
import java.util.List;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.help.bundles.HelpBundles;
import com.kingsrook.qqq.backend.core.testing.HelpBundleAssertions;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/*******************************************************************************
** The qbit ships its own help (help/qbit-cms.yaml): a host gets it with the
** jar and writes none of it. It covers every app, table, field, home, child
** list and value list of the qbit, names nothing that does not exist, and is
** registered only under the default names it is written for.
*******************************************************************************/
class CmsHelpTest
{
/*******************************************************************************
** With every feature: registered once as a QBIT layer bundle of this version,
** complete by the core's own gate, and every home, child list and value list
** has its text.
*******************************************************************************/
@Test
void testHelpCoversTheQBit() throws Exception
{
QInstance qInstance = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
new CmsQBitProducer().withQBitConfig(new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withStartupMode(CmsStartupMode.SKIP)).produce(qInstance);
assertThat(HelpBundles.of(qInstance).getBundles()).singleElement().satisfies(bundle ->
{
assertThat(bundle.getId()).isEqualTo("qbit-cms");
assertThat(bundle.getVersion()).isEqualTo(CmsQBitProducer.VERSION);
assertThat(bundle.getLayer().name()).isEqualTo("QBIT");
});
HelpBundleAssertions.forInstance(qInstance)
.bundles(CmsQBitProducer.HELP_BUNDLE)
.owning(target -> target.name().equals("cms") || target.name().startsWith("cms"))
.assertComplete();
var entries = HelpBundles.of(qInstance).resolveWinningEntries();
List<String> widgets = qInstance.getWidgets().keySet().stream().filter(name -> name.startsWith("cms")).sorted().toList();
assertThat(widgets).hasSizeGreaterThan(30);
for(String name : widgets)
{
assertThat(entries).as("the card " + name).containsKey(new HelpBundles.EntryKey("widget:" + name + ";slot:label", "ALL_SCREENS"));
}
List<String> sources = qInstance.getPossibleValueSources().keySet().stream().filter(name -> name.startsWith("cms_")).sorted().toList();
assertThat(sources).hasSize(36);
for(String name : sources)
{
assertThat(entries).as("the value source " + name).containsKey(new HelpBundles.EntryKey("possibleValueSource:" + name + ";slot:help", "ALL_SCREENS"));
}
}
/*******************************************************************************
** Every section of every table has its text too (the core's gate leaves
** sections optional).
*******************************************************************************/
@Test
void testEverySectionHasHelp() throws Exception
{
QInstance qInstance = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
new CmsQBitProducer().withQBitConfig(new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withStartupMode(CmsStartupMode.SKIP)).produce(qInstance);
var entries = HelpBundles.of(qInstance).resolveWinningEntries();
int sections = 0;
for(var table : qInstance.getTables().values())
{
if(!table.getName().startsWith("cms_"))
{
continue;
}
for(var section : table.getSections())
{
sections++;
assertThat(entries).as(table.getName() + " section " + section.getName())
.containsKey(new HelpBundles.EntryKey("table:" + table.getName() + ";section:" + section.getName(), "ALL_SCREENS"));
}
}
assertThat(sections).isGreaterThan(100);
}
/*******************************************************************************
** The text is written for the default names: an install under other
** prefixes does not register it, and with a feature off the entries of its
** tables are simply unused (the gate still passes for what is there).
*******************************************************************************/
@Test
void testOtherNamesAndFeatureSubsets() throws Exception
{
QInstance renamed = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
new CmsQBitProducer().withQBitConfig(new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withStartupMode(CmsStartupMode.SKIP)
.withTableNamePrefix("acme_cms_")).produce(renamed);
assertThat(HelpBundles.of(renamed).getBundles()).isEmpty();
QInstance core = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
new CmsQBitProducer().withQBitConfig(new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withStartupMode(CmsStartupMode.SKIP)
.withFeatures(EnumSet.of(CmsFeature.CORE))).produce(core);
assertThat(HelpBundles.of(core).getBundles()).hasSize(1);
assertThat(HelpBundleAssertions.forInstance(core).bundles(CmsQBitProducer.HELP_BUNDLE)
.owning(target -> target.name().equals("cms") || target.name().startsWith("cms")).report())
.as("with CORE alone nothing of CORE is missing; entries of the other features have no object and are reported as such")
.noneMatch(line -> line.toLowerCase(java.util.Locale.ROOT).contains("missing"));
}
}
@@ -0,0 +1,295 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
import java.sql.Connection;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.kingsrook.qbits.cms.security.CmsRole;
import com.kingsrook.qbits.cms.security.CmsSecurity;
import com.kingsrook.qqq.backend.core.actions.tables.CountAction;
import com.kingsrook.qqq.backend.core.actions.tables.GetAction;
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.instances.QInstanceValidator;
import com.kingsrook.qqq.backend.core.model.actions.tables.count.CountInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QCriteriaOperator;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QFilterCriteria;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.module.rdbms.jdbc.ConnectionManager;
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSBackendMetaData;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/*******************************************************************************
** Installing the qbit into a blank QQQ instance on H2: the host runs the
** changelog, produces the qbit (FAIL_FAST schema check), and the CMS tables
** work as ordinary QQQ tables.
*******************************************************************************/
class CmsInstallTest
{
/*******************************************************************************
**
*******************************************************************************/
@AfterEach
void afterEach()
{
QContext.clear();
}
/*******************************************************************************
** Fresh install: schema check passes, generic reference data is seeded,
** and content round-trips, including children through associations.
*******************************************************************************/
@Test
void testFreshInstall() throws Exception
{
RDBMSBackendMetaData backend = CmsTestSupport.h2Backend();
CmsTestSupport.migrate(backend, Map.of());
QInstance qInstance = CmsTestSupport.blankInstance(backend);
CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND);
new CmsQBitProducer().withQBitConfig(config).produce(qInstance);
new QInstanceValidator().validate(qInstance);
assertThat(config.getRuntime().getSchemaProblems()).isEmpty();
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.ADMIN)));
assertThat(count("cms_redirect_type")).isEqualTo(4);
assertThat(count("cms_page_type")).isEqualTo(4);
assertThat(count("cms_page_section_type")).isEqualTo(9);
Integer siteId = insert("cms_site", new QRecord().withValue("name", "Example").withValue("shortName", "example"));
insert("cms_domain", new QRecord().withValue("name", "www").withValue("shortName", "www").withValue("fqdn", "www.example.com")
.withValue("isPrimary", true).withValue("siteId", siteId));
Integer pageTypeId = idOf("cms_page_type", "code", "STATIC");
Integer sectionTypeId = idOf("cms_page_section_type", "code", "MARKDOWN");
QRecord page = new QRecord().withValue("name", "About").withValue("slug", "about").withValue("title", "About us")
.withValue("pageTypeId", pageTypeId).withValue("siteId", siteId).withValue("content", "x".repeat(5000))
.withAssociatedRecord("sections", new QRecord().withValue("name", "Intro").withValue("sectionTypeId", sectionTypeId).withValue("sortOrder", 1)
.withValue("content", "{\"content\": \"# Hello\"}"))
.withAssociatedRecord("sections", new QRecord().withValue("name", "Body").withValue("sectionTypeId", sectionTypeId).withValue("sortOrder", 2));
Integer pageId = insert("cms_page", page);
QRecord stored = new GetAction().execute(new GetInput("cms_page").withPrimaryKey(pageId).withIncludeAssociations(true)).getRecord();
assertThat(stored.getValueString("content")).hasSize(5000);
assertThat(stored.getValueBoolean("isPublished")).isFalse();
assertThat(stored.getValue("createDate")).isNotNull();
assertThat(stored.getAssociatedRecords().get("sections")).hasSize(2);
Integer menuId = insert("cms_menu", new QRecord().withValue("name", "Header").withValue("slug", "header").withValue("menuType", "HEADER").withValue("siteId", siteId)
.withAssociatedRecord("items", new QRecord().withValue("name", "About").withValue("slug", "about").withValue("itemType", "PAGE").withValue("routePath", "/about")));
assertThat(count("cms_menu_item")).isEqualTo(1);
assertThat(menuId).isNotNull();
}
/*******************************************************************************
** A host can choose any prefix; the changelog property and the config agree.
*******************************************************************************/
@Test
void testCustomPrefix() throws Exception
{
RDBMSBackendMetaData backend = CmsTestSupport.h2Backend();
CmsTestSupport.migrate(backend, Map.of("cms.tablePrefix", "acme_cms_"));
QInstance qInstance = CmsTestSupport.blankInstance(backend);
CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withTableNamePrefix("acme_cms_");
new CmsQBitProducer().withQBitConfig(config).produce(qInstance);
assertThat(qInstance.getTable("acme_cms_page")).isNotNull();
assertThat(qInstance.getTable("cms_page")).isNull();
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.ADMIN)));
assertThat(count("acme_cms_redirect_type")).isEqualTo(4);
}
/*******************************************************************************
** Running the changelog again changes nothing, the migration history
** included: a host whose migrations must be repeatable can include it. An
** install recorded by the earlier version, whose guard ran on every
** migration, migrates on without complaint.
*******************************************************************************/
@Test
void testRerunIsNoop() throws Exception
{
RDBMSBackendMetaData backend = CmsTestSupport.h2Backend();
CmsTestSupport.migrate(backend, Map.of());
List<String> history = history(backend);
CmsTestSupport.migrate(backend, Map.of());
assertThat(history(backend)).as("the migration history after a second run").isEqualTo(history);
assertThat(history).hasSizeGreaterThan(40).anyMatch(row -> row.startsWith("1.0.0-guard-existing-tables|"));
try(Connection connection = ConnectionManager.getConnection(backend); Statement statement = connection.createStatement())
{
statement.execute("UPDATE DATABASECHANGELOG SET MD5SUM = '9:00000000000000000000000000000000', EXECTYPE = 'RERAN' WHERE ID = '1.0.0-guard-existing-tables'");
}
List<String> earlier = history(backend);
CmsTestSupport.migrate(backend, Map.of());
assertThat(history(backend)).as("the history of an install the earlier version recorded").isEqualTo(earlier);
QInstance qInstance = CmsTestSupport.blankInstance(backend);
CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND);
new CmsQBitProducer().withQBitConfig(config).produce(qInstance);
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.ADMIN)));
assertThat(count("cms_redirect_type")).isEqualTo(4);
}
/*******************************************************************************
** An existing table with a qbit name halts the install; nothing is
** overwritten.
*******************************************************************************/
@Test
void testExistingTableHalts() throws Exception
{
RDBMSBackendMetaData backend = CmsTestSupport.h2Backend();
try(Connection connection = ConnectionManager.getConnection(backend); Statement statement = connection.createStatement())
{
statement.execute("CREATE TABLE cms_page (id INT PRIMARY KEY, title VARCHAR(10))");
statement.execute("INSERT INTO cms_page VALUES (1, 'theirs')");
}
assertThatThrownBy(() -> CmsTestSupport.migrate(backend, Map.of())).hasStackTraceContaining("was not created by qbit-cms");
try(Connection connection = ConnectionManager.getConnection(backend); Statement statement = connection.createStatement())
{
var resultSet = statement.executeQuery("SELECT title FROM cms_page WHERE id = 1");
assertThat(resultSet.next()).isTrue();
assertThat(resultSet.getString(1)).isEqualTo("theirs");
}
}
/*******************************************************************************
** Reference data is optional.
*******************************************************************************/
@Test
void testSeedOff() throws Exception
{
RDBMSBackendMetaData backend = CmsTestSupport.h2Backend();
CmsTestSupport.migrate(backend, Map.of("cms.seedReferenceData", "false"));
QInstance qInstance = CmsTestSupport.blankInstance(backend);
CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND);
new CmsQBitProducer().withQBitConfig(config).produce(qInstance);
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.ADMIN)));
assertThat(count("cms_redirect_type")).isZero();
}
/*******************************************************************************
** Without the changelog, FAIL_FAST refuses to start and names the problem;
** DEGRADED starts and records it.
*******************************************************************************/
@Test
void testSchemaCheck() throws Exception
{
RDBMSBackendMetaData backend = CmsTestSupport.h2Backend();
CmsQBitConfig failFast = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND);
assertThatThrownBy(() -> new CmsQBitProducer().withQBitConfig(failFast).produce(CmsTestSupport.blankInstance(backend)))
.isInstanceOf(QException.class)
.hasMessageContaining("not up to date")
.hasMessageContaining("DATABASECHANGELOG");
CmsQBitConfig degraded = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withStartupMode(CmsStartupMode.DEGRADED);
new CmsQBitProducer().withQBitConfig(degraded).produce(CmsTestSupport.blankInstance(backend));
assertThat(degraded.getRuntime().getSchemaProblems()).isNotEmpty();
////////////////////////////////////////////////////////////////
// changelog run without CORE (cms.features): tables missing //
////////////////////////////////////////////////////////////////
CmsTestSupport.migrate(backend, Map.of("cms.features", "MEDIA"));
CmsQBitConfig partial = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withStartupMode(CmsStartupMode.DEGRADED);
new CmsQBitProducer().withQBitConfig(partial).produce(CmsTestSupport.blankInstance(backend));
assertThat(partial.getRuntime().getSchemaProblems()).anyMatch(p -> p.contains("1.0.0-create-page") && p.contains("CORE"));
}
/*******************************************************************************
** The migration history: one line per recorded changeset, in the order run.
*******************************************************************************/
private static List<String> history(RDBMSBackendMetaData backend) throws Exception
{
List<String> rows = new ArrayList<>();
try(Connection connection = ConnectionManager.getConnection(backend); Statement statement = connection.createStatement();
var resultSet = statement.executeQuery("SELECT ID, ORDEREXECUTED, DATEEXECUTED, MD5SUM, EXECTYPE FROM DATABASECHANGELOG ORDER BY ORDEREXECUTED, ID"))
{
while(resultSet.next())
{
rows.add(resultSet.getString(1) + "|" + resultSet.getString(2) + "|" + resultSet.getString(3) + "|" + resultSet.getString(4) + "|" + resultSet.getString(5));
}
}
return (rows);
}
/*******************************************************************************
**
*******************************************************************************/
private static Integer insert(String table, QRecord record) throws QException
{
List<QRecord> records = new InsertAction().execute(new InsertInput(table).withRecord(record)).getRecords();
assertThat(records.get(0).getErrors()).as(table).isEmpty();
return (records.get(0).getValueInteger("id"));
}
/*******************************************************************************
**
*******************************************************************************/
private static int count(String table) throws QException
{
return (new CountAction().execute(new CountInput(table)).getCount());
}
/*******************************************************************************
**
*******************************************************************************/
private static Integer idOf(String table, String field, String value) throws QException
{
List<QRecord> records = new QueryAction().execute(new QueryInput(table).withFilter(new QQueryFilter(new QFilterCriteria(field, QCriteriaOperator.EQUALS, value)))).getRecords();
return (records.get(0).getValueInteger("id"));
}
}
@@ -0,0 +1,171 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.kingsrook.qbits.cms.security.CmsRole;
import com.kingsrook.qbits.cms.security.CmsSecurity;
import com.kingsrook.qqq.backend.core.actions.tables.GetAction;
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.module.postgres.model.metadata.PostgreSQLBackendMetaData;
import com.kingsrook.qqq.backend.module.rdbms.jdbc.ConnectionManager;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import static org.assertj.core.api.Assertions.assertThat;
/*******************************************************************************
** The install on PostgreSQL (the production database): the changelog creates
** the kof22-shaped schema (identity ids, the same column types and
** nullability), the schema check passes, and QQQ reads and writes it.
** Skipped when Docker is not available.
*******************************************************************************/
@Testcontainers(disabledWithoutDocker = true)
class CmsPostgresInstallTest
{
@Container
private static final PostgreSQLContainer<?> POSTGRES = new PostgreSQLContainer<>("postgres:17-alpine");
/*******************************************************************************
**
*******************************************************************************/
@AfterEach
void afterEach()
{
QContext.clear();
}
/*******************************************************************************
** Fresh install on PostgreSQL with the default prefix.
*******************************************************************************/
@Test
void testInstallOnPostgres() throws Exception
{
ConnectionManager.resetConnectionProviders();
PostgreSQLBackendMetaData backend = new PostgreSQLBackendMetaData()
.withName(CmsTestSupport.BACKEND)
.withHostName(POSTGRES.getHost())
.withPort(POSTGRES.getFirstMappedPort())
.withDatabaseName(POSTGRES.getDatabaseName())
.withUsername(POSTGRES.getUsername())
.withPassword(POSTGRES.getPassword());
CmsTestSupport.migrate(backend, Map.of());
QInstance qInstance = CmsTestSupport.blankInstance(backend);
CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND);
new CmsQBitProducer().withQBitConfig(config).produce(qInstance);
assertThat(config.getRuntime().getSchemaProblems()).isEmpty();
try(Connection connection = ConnectionManager.getConnection(backend); Statement statement = connection.createStatement())
{
assertThat(columns(statement, "cms_page")).contains(
"id bigint NO", "slug character varying(100) NO", "title character varying(200) NO", "content text YES", "is_published boolean NO",
"publish_date timestamp without time zone YES", "parent_page_id bigint YES", "create_date timestamp without time zone NO");
try(ResultSet resultSet = statement.executeQuery("SELECT pg_get_serial_sequence('cms_page', 'id'), "
+ "(SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_name = 'cms_page' AND constraint_type = 'FOREIGN KEY')"))
{
assertThat(resultSet.next()).isTrue();
assertThat(resultSet.getString(1)).isEqualTo("public.cms_page_id_seq");
assertThat(resultSet.getInt(2)).isEqualTo(3);
}
////////////////////////////////////////////////////////////////////
// the content features: column types, and the links between two //
// features (versions and albums of projects) //
////////////////////////////////////////////////////////////////////
assertThat(columns(statement, "cms_media")).contains(
"id bigint NO", "name character varying(200) NO", "media_type_id bigint NO", "public_url character varying(500) YES", "file_size bigint YES",
"is_active boolean NO", "site_id bigint NO");
assertThat(columns(statement, "cms_media_type")).contains("thumbnail_format character varying(10) NO", "max_file_size_mb integer YES", "strip_metadata boolean NO");
assertThat(columns(statement, "cms_blog_post")).contains(
"title character varying(100) YES", "content text NO", "excerpt text YES", "is_published boolean YES", "is_featured boolean NO", "view_count bigint YES");
assertThat(columns(statement, "cms_photo_album")).contains("location_latitude double precision YES", "album_date timestamp without time zone YES");
assertThat(columns(statement, "cms_project_update")).contains("update_date timestamp without time zone NO", "content text NO");
try(ResultSet resultSet = statement.executeQuery("SELECT table_name || ':' || COUNT(*) FROM information_schema.table_constraints "
+ "WHERE constraint_type = 'FOREIGN KEY' AND table_name IN ('cms_blog_post', 'cms_blog_post_version', 'cms_photo_album', 'cms_media') "
+ "GROUP BY table_name ORDER BY table_name"))
{
List<String> foreignKeys = new ArrayList<>();
while(resultSet.next())
{
foreignKeys.add(resultSet.getString(1));
}
assertThat(foreignKeys).containsExactly("cms_blog_post:3", "cms_blog_post_version:3", "cms_media:2", "cms_photo_album:5");
}
try(ResultSet resultSet = statement.executeQuery("SELECT COUNT(*) FROM information_schema.table_constraints WHERE constraint_type = 'CHECK' "
+ "AND constraint_name LIKE 'ck_cms_%'"))
{
assertThat(resultSet.next()).isTrue();
assertThat(resultSet.getInt(1)).isEqualTo(11);
}
try(ResultSet resultSet = statement.executeQuery("SELECT COUNT(*) FROM cms_media_type"))
{
assertThat(resultSet.next()).isTrue();
assertThat(resultSet.getInt(1)).isEqualTo(5);
}
}
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.ADMIN)));
Integer siteId = new InsertAction().execute(new InsertInput("cms_site").withRecord(new QRecord().withValue("name", "Example").withValue("shortName", "ex")))
.getRecords().get(0).getValueInteger("id");
Integer pageId = new InsertAction().execute(new InsertInput("cms_page").withRecord(new QRecord().withValue("name", "Home").withValue("slug", "home")
.withValue("title", "Home").withValue("pageTypeId", 1).withValue("siteId", siteId)
.withAssociatedRecord("sections", new QRecord().withValue("name", "Hero").withValue("sectionTypeId", 2).withValue("content", "{}")))).getRecords().get(0).getValueInteger("id");
QRecord page = new GetAction().execute(new GetInput("cms_page").withPrimaryKey(pageId).withIncludeAssociations(true)).getRecord();
assertThat(page.getAssociatedRecords().get("sections")).hasSize(1);
assertThat(page.getValue("createDate")).isNotNull();
}
/*******************************************************************************
** "name type nullable" for each column of a table.
*******************************************************************************/
private static List<String> columns(Statement statement, String table) throws Exception
{
List<String> rs = new ArrayList<>();
try(ResultSet resultSet = statement.executeQuery("SELECT column_name, data_type, character_maximum_length, is_nullable FROM information_schema.columns "
+ "WHERE table_name = '" + table + "' ORDER BY ordinal_position"))
{
while(resultSet.next())
{
Object length = resultSet.getObject(3);
rs.add(resultSet.getString(1) + " " + resultSet.getString(2) + (length == null ? "" : "(" + length + ")") + " " + resultSet.getString(4));
}
}
return (rs);
}
}
@@ -0,0 +1,258 @@
/*
* Copyright 2025 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Map;
import java.util.Set;
import com.kingsrook.qbits.cms.security.CmsRole;
import com.kingsrook.qbits.cms.security.CmsSecurity;
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.exceptions.QPermissionDeniedException;
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.module.postgres.model.metadata.PostgreSQLBackendMetaData;
import com.kingsrook.qqq.backend.module.rdbms.jdbc.ConnectionManager;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/*******************************************************************************
** The install as production runs it on PostgreSQL 17: a schema OWNER runs the
** changelog (Liquibase 4.33.0) with a prefix that cannot collide with a host's own
** CMS tables, and the application runs as a DML-only role that owns nothing, cannot
** read migration history and cannot run DDL. The startup check must work for that
** role (catalog verification), and the QQQ permission ceilings must hold on top of
** the database grants.
*******************************************************************************/
@Testcontainers(disabledWithoutDocker = true)
class CmsPostgresRuntimeIdentityTest
{
private static final String OWNER = "qcms_owner";
private static final String RUNTIME = "qcms_runtime";
private static final String PREFIX = "qcms_";
@Container
private static final PostgreSQLContainer<?> POSTGRES = new PostgreSQLContainer<>("postgres:17-alpine");
/*******************************************************************************
** Owner, runtime role, owner-run migration (twice), DML-only grants.
*******************************************************************************/
@BeforeAll
static void provision() throws Exception
{
try(Connection admin = connect(POSTGRES.getUsername(), POSTGRES.getPassword(), "postgres"); Statement statement = admin.createStatement())
{
statement.execute("CREATE ROLE " + OWNER + " LOGIN PASSWORD 'owner-synthetic'");
statement.execute("CREATE ROLE " + RUNTIME + " LOGIN PASSWORD 'runtime-synthetic'");
statement.execute("CREATE DATABASE cmsdb OWNER " + OWNER);
statement.execute("REVOKE ALL ON DATABASE cmsdb FROM PUBLIC");
statement.execute("GRANT CONNECT ON DATABASE cmsdb TO " + RUNTIME);
}
try(Connection owner = connect(OWNER, "owner-synthetic", "cmsdb"); Statement statement = owner.createStatement())
{
statement.execute("REVOKE ALL ON SCHEMA public FROM PUBLIC");
statement.execute("GRANT USAGE ON SCHEMA public TO " + RUNTIME);
}
ConnectionManager.resetConnectionProviders();
PostgreSQLBackendMetaData ownerBackend = backend(OWNER, "owner-synthetic");
CmsTestSupport.migrate(ownerBackend, Map.of("cms.tablePrefix", PREFIX));
CmsTestSupport.migrate(ownerBackend, Map.of("cms.tablePrefix", PREFIX));
try(Connection owner = connect(OWNER, "owner-synthetic", "cmsdb"); Statement statement = owner.createStatement())
{
statement.execute("DO $$ DECLARE t text; BEGIN FOR t IN SELECT tablename FROM pg_tables WHERE schemaname = 'public' AND tablename LIKE '" + PREFIX
+ "%' LOOP EXECUTE format('GRANT SELECT, INSERT, UPDATE, DELETE ON %I TO " + RUNTIME + "', t); END LOOP; END $$");
}
}
/*******************************************************************************
** Clear the context.
*******************************************************************************/
@AfterEach
void afterEach()
{
QContext.clear();
}
/*******************************************************************************
** The original history check cannot run as the DML-only role and must fail
** closed; the catalog check starts it.
*******************************************************************************/
@Test
void testStartupCheckAsRuntimeRole() throws Exception
{
CmsQBitConfig history = config().withSchemaVerification(CmsSchemaVerification.CHANGELOG_HISTORY);
assertThatThrownBy(() -> new CmsQBitProducer().withQBitConfig(history).produce(runtimeInstance()))
.isInstanceOf(QException.class).hasMessageContaining("not up to date");
CmsQBitConfig catalog = config().withSchemaVerification(CmsSchemaVerification.CATALOG);
new CmsQBitProducer().withQBitConfig(catalog).produce(runtimeInstance());
assertThat(catalog.getRuntime().getSchemaProblems()).isEmpty();
}
/*******************************************************************************
** The catalog check names a missing table and a missing column, and refuses to
** start in FAIL_FAST mode.
*******************************************************************************/
@Test
void testCatalogCheckFindsDrift() throws Exception
{
CmsQBitConfig unmigrated = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withTableNamePrefix("zcms_").withNamePrefix("zcms")
.withPermissionBaseName("zcms").withSchemaVerification(CmsSchemaVerification.CATALOG);
assertThatThrownBy(() -> new CmsQBitProducer().withQBitConfig(unmigrated).produce(runtimeInstance()))
.isInstanceOf(QException.class).hasMessageContaining("zcms_page is missing");
try(Connection owner = connect(OWNER, "owner-synthetic", "cmsdb"); Statement statement = owner.createStatement())
{
statement.execute("ALTER TABLE " + PREFIX + "page RENAME COLUMN title TO title_old");
try
{
CmsQBitConfig drifted = config().withSchemaVerification(CmsSchemaVerification.CATALOG);
assertThatThrownBy(() -> new CmsQBitProducer().withQBitConfig(drifted).produce(runtimeInstance()))
.isInstanceOf(QException.class).hasMessageContaining(PREFIX + "page.title is missing");
}
finally
{
statement.execute("ALTER TABLE " + PREFIX + "page RENAME COLUMN title_old TO title");
}
}
}
/*******************************************************************************
** The runtime role can do DML and nothing else: no DDL, no migration history.
*******************************************************************************/
@Test
void testRuntimeRoleIsDmlOnly() throws Exception
{
try(Connection runtime = connect(RUNTIME, "runtime-synthetic", "cmsdb"); Statement statement = runtime.createStatement())
{
assertThatThrownBy(() -> statement.execute("CREATE TABLE intruder (id int)")).isInstanceOf(SQLException.class).hasMessageContaining("permission denied");
assertThatThrownBy(() -> statement.execute("ALTER TABLE " + PREFIX + "site ADD COLUMN x int")).isInstanceOf(SQLException.class);
assertThatThrownBy(() -> statement.execute("DROP TABLE " + PREFIX + "site")).isInstanceOf(SQLException.class);
assertThatThrownBy(() -> statement.execute("TRUNCATE " + PREFIX + "site")).isInstanceOf(SQLException.class);
assertThatThrownBy(() -> statement.executeQuery("SELECT * FROM databasechangelog")).isInstanceOf(SQLException.class).hasMessageContaining("permission denied");
}
}
/*******************************************************************************
** Role ceilings over the DML grants, through QQQ's own actions on the native PG
** backend as the runtime role: an admin writes, a viewer reads only, an editor
** cannot change reference data, and a user with no CMS permission is refused.
*******************************************************************************/
@Test
void testRoleCeilingsAsRuntimeRole() throws Exception
{
CmsQBitConfig config = config().withSchemaVerification(CmsSchemaVerification.CATALOG);
QInstance instance = runtimeInstance();
instance.setEnforcePermissionsInCoreActions(true);
new CmsQBitProducer().withQBitConfig(config).produce(instance);
CmsTestSupport.session(instance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.ADMIN)));
Integer siteId = new InsertAction().execute(new InsertInput(PREFIX + "site").withRecord(new QRecord().withValue("name", "Example").withValue("shortName", "ex")))
.getRecords().get(0).getValueInteger("id");
assertThat(siteId).isNotNull();
CmsTestSupport.session(instance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.VIEWER)));
assertThat(new QueryAction().execute(new QueryInput(PREFIX + "site")).getRecords()).isNotEmpty();
assertThatThrownBy(() -> new InsertAction().execute(new InsertInput(PREFIX + "site").withRecord(new QRecord().withValue("name", "V").withValue("shortName", "v"))))
.isInstanceOf(QPermissionDeniedException.class);
CmsTestSupport.session(instance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.EDITOR)));
assertThatThrownBy(() -> new InsertAction().execute(new InsertInput(PREFIX + "page_type").withRecord(new QRecord().withValue("name", "X"))))
.isInstanceOf(QPermissionDeniedException.class);
CmsTestSupport.session(instance, Set.of());
assertThatThrownBy(() -> new QueryAction().execute(new QueryInput(PREFIX + "site"))).isInstanceOf(QPermissionDeniedException.class);
assertThatThrownBy(() -> new QueryAction().execute(new QueryInput(PREFIX + "page"))).isInstanceOf(QPermissionDeniedException.class);
}
/*******************************************************************************
** The configuration under test: a prefix of its own, never the default.
*******************************************************************************/
private static CmsQBitConfig config()
{
return (new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withTableNamePrefix(PREFIX).withNamePrefix("qcms").withPermissionBaseName("qcms"));
}
/*******************************************************************************
** An application instance on the runtime role.
*******************************************************************************/
private static QInstance runtimeInstance()
{
ConnectionManager.resetConnectionProviders();
return (CmsTestSupport.blankInstance(backend(RUNTIME, "runtime-synthetic")));
}
/*******************************************************************************
** A native PostgreSQL backend as a named role.
*******************************************************************************/
private static PostgreSQLBackendMetaData backend(String user, String password)
{
return (new PostgreSQLBackendMetaData()
.withName(CmsTestSupport.BACKEND)
.withHostName(POSTGRES.getHost())
.withPort(POSTGRES.getFirstMappedPort())
.withDatabaseName("cmsdb")
.withUsername(user)
.withPassword(password));
}
/*******************************************************************************
** A JDBC connection as a named role.
*******************************************************************************/
private static Connection connect(String user, String password, String database) throws SQLException
{
return (DriverManager.getConnection("jdbc:postgresql://" + POSTGRES.getHost() + ":" + POSTGRES.getFirstMappedPort() + "/" + database, user, password));
}
}
@@ -17,66 +17,218 @@
package com.kingsrook.qbits.cms;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.instances.QInstanceValidator;
import com.kingsrook.qqq.backend.core.model.metadata.QBackendMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.qbits.QBitConfigValidationException;
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppSection;
import com.kingsrook.qqq.backend.core.model.metadata.permissions.PermissionLevel;
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
import com.kingsrook.qqq.backend.core.modules.backend.implementations.memory.MemoryBackendModule;
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSTableBackendDetails;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/*******************************************************************************
** Unit test for CmsQBitProducer
** CmsQBitProducer: what it produces, validation, namespaces and collisions
** (no database: startupMode SKIP).
*******************************************************************************/
class CmsQBitProducerTest
{
private static final List<String> CORE_TABLES = List.of("cms_site", "cms_domain", "cms_redirect", "cms_redirect_type", "cms_page", "cms_page_type",
"cms_page_section", "cms_page_section_type", "cms_snippet", "cms_menu", "cms_menu_item");
/*******************************************************************************
** A configured qbit registers itself in the instance.
** The CORE feature alone: eleven standard tables named per the owner rule, a
** possible-value source each, child lists, apps with homes, and a valid
** instance.
*******************************************************************************/
@Test
void testProduce() throws Exception
void testProduceCore() throws Exception
{
QInstance qInstance = new QInstance();
CmsQBitConfig config = new CmsQBitConfig().withBackendName("rdbms");
CmsQBitProducer producer = new CmsQBitProducer().withQBitConfig(config).withNamespace("cms");
QInstance qInstance = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
CmsQBitConfig config = config().withFeatures(EnumSet.of(CmsFeature.CORE));
CmsQBitProducer producer = new CmsQBitProducer().withQBitConfig(config);
assertThat(producer.isEnabled()).isTrue();
assertThat(producer.getQBitConfig()).isSameAs(config);
assertThat(producer.getNamespace()).isEqualTo("cms");
assertThat(config.getDefaultBackendNameForTables()).isEqualTo("rdbms");
assertThat(producer.produce(qInstance).getEach(QTableMetaData.class)).isEmpty();
new QInstanceValidator().validate(qInstance);
producer.produce(qInstance);
assertThat(qInstance.getQBits()).hasSize(1);
assertThat(qInstance.getQBits().values().iterator().next().getArtifactId()).isEqualTo("qbit-cms");
for(String name : CORE_TABLES)
{
QTableMetaData table = qInstance.getTable(name);
assertThat(table).as(name).isNotNull();
assertThat(name).matches("^cms_[a-z][a-z_]*$");
assertThat(((RDBMSTableBackendDetails) table.getBackendDetails()).getTableName()).isEqualTo(name);
assertThat(table.getBackendName()).isEqualTo(CmsTestSupport.BACKEND);
assertThat(table.getPermissionRules().getLevel()).isEqualTo(PermissionLevel.READ_INSERT_EDIT_DELETE_PERMISSIONS);
assertThat(table.getIsHidden()).as(name + " is visible").isFalse();
assertThat(table.getField("createDate").getBackendName()).isEqualTo("create_date");
assertThat(qInstance.getPossibleValueSource(name)).as(name + " PVS").isNotNull();
}
assertThat(qInstance.getTable("cms_page").getField("pageTypeId").getBackendName()).isEqualTo("page_type_id");
assertThat(qInstance.getTable("cms_page").getField("siteId").getPossibleValueSourceName()).isEqualTo("cms_site");
assertThat(qInstance.getTable("cms_redirect").getField("matchType").getPossibleValueSourceName()).isEqualTo("cms_redirect_match_type");
assertThat(qInstance.getTable("cms_page").getAssociations()).extracting("name").contains("sections");
assertThat(qInstance.getTable("cms_menu").getAssociations()).extracting("name").contains("items");
QAppMetaData top = qInstance.getApp("cms");
assertThat(top.getLabel()).isEqualTo("CMS");
assertThat(qInstance.getTable("cms_page_section_type").getLabel()).isEqualTo("Page Section Types");
assertThat(top.getWidgets()).containsExactly("cmsHome");
assertThat(top.getChildren()).extracting("name").containsExactly("cmsSites", "cmsPages", "cmsNavigation");
assertThat(qInstance.getApp("cmsPages").getWidgets()).containsExactly("cmsPagesHome");
assertThat(qInstance.getWidget("cmsPagesHome")).isNotNull();
/////////////////////////////////////////////////////////////////////
// the nav lists main and reference tables only, never a child //
// table, and no processes //
/////////////////////////////////////////////////////////////////////
List<String> navTables = qInstance.getApps().values().stream().filter(a -> a.getSections() != null)
.flatMap(a -> a.getSections().stream()).flatMap(s -> s.getTables() == null ? java.util.stream.Stream.empty() : s.getTables().stream()).toList();
assertThat(navTables).containsExactlyInAnyOrder("cms_site", "cms_redirect", "cms_redirect_type", "cms_page", "cms_snippet", "cms_page_type",
"cms_page_section_type", "cms_menu");
for(QAppMetaData app : qInstance.getApps().values())
{
for(QAppSection section : app.getSections() == null ? List.<QAppSection>of() : app.getSections())
{
assertThat(section.getProcesses()).as(app.getName()).isNullOrEmpty();
}
}
assertThat(qInstance.getTable("cms_page").getSections()).extracting("name").contains("cms_page_cms_page_section_pageId");
}
/*******************************************************************************
** Without a config the producer is disabled; without a backend it fails.
** Validation lists every problem.
*******************************************************************************/
@Test
void testDisabledAndInvalid()
void testValidation()
{
assertThat(new CmsQBitProducer().isEnabled()).isFalse();
assertThatThrownBy(() -> new CmsQBitProducer().produce(new QInstance())).hasMessageContaining("no config");
CmsQBitConfig config = new CmsQBitConfig();
config.setBackendName(null);
assertThat(config.getBackendName()).isNull();
assertThatThrownBy(() -> new CmsQBitProducer().withQBitConfig(config).produce(new QInstance()))
.isInstanceOf(QBitConfigValidationException.class);
QInstance qInstance = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
qInstance.addBackend(new QBackendMetaData().withName("memory").withBackendType(MemoryBackendModule.class));
assertThatThrownBy(() -> produce(qInstance, new CmsQBitConfig())).hasMessageContaining("backendName is required");
assertThatThrownBy(() -> produce(qInstance, config().withBackendName("nope"))).hasMessageContaining("not a backend");
assertThatThrownBy(() -> produce(qInstance, config().withBackendName("memory"))).hasMessageContaining("must be an RDBMS backend");
assertThatThrownBy(() -> produce(qInstance, config().withTableNamePrefix("CMS"))).hasMessageContaining("tableNamePrefix");
assertThatThrownBy(() -> produce(qInstance, config().withNamePrefix("9x"))).hasMessageContaining("namePrefix");
assertThatThrownBy(() -> produce(qInstance, config().withPermissionBaseName(""))).hasMessageContaining("permissionBaseName");
assertThatThrownBy(() -> produce(qInstance, config().withParentAppName("content"))).hasMessageContaining("parentAppName content");
assertThatThrownBy(() -> produce(qInstance, config().withFeatures(EnumSet.of(CmsFeature.CORE, CmsFeature.PUBLISHING)))).hasMessageContaining("PUBLISHING is not available");
assertThatThrownBy(() -> produce(qInstance, config().withFeatures(Set.of()))).hasMessageContaining("must include CORE");
assertThatThrownBy(() -> produce(qInstance, config().withRoleMapping(null))).hasMessageContaining("roleMapping");
assertThatThrownBy(() -> produce(qInstance, config().withStartupMode(null))).hasMessageContaining("startupMode");
assertThat(qInstance.getQBits()).isNullOrEmpty();
}
/*******************************************************************************
** Names follow the owner rule: lowercase snake_case with the full qbit name.
** A second install needs a namespace, which becomes its prefixes.
*******************************************************************************/
@Test
void testNamespaceAndCollisions() throws Exception
{
QInstance qInstance = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
produce(qInstance, config());
assertThatThrownBy(() -> produce(qInstance, config()))
.isInstanceOf(QException.class)
.hasMessageContaining("collide")
.hasMessageContaining("table cms_site");
CmsQBitConfig second = config();
new CmsQBitProducer().withQBitConfig(second).withNamespace("siteTwo").produce(qInstance);
assertThat(second.getTableNamePrefix()).isEqualTo("site_two_");
assertThat(second.getNamePrefix()).isEqualTo("siteTwo");
assertThat(second.getPermissionBaseName()).isEqualTo("site_two");
assertThat(qInstance.getTable("site_two_page")).isNotNull();
assertThat(qInstance.getApp("siteTwo")).isNotNull();
assertThat(qInstance.getApp("siteTwoPages")).isNotNull();
assertThat(qInstance.getQBits()).hasSize(2);
assertThat(CmsRuntime.findConfig(qInstance, "siteTwo")).containsSame(second);
new QInstanceValidator().validate(qInstance);
}
/*******************************************************************************
** The host can nest the CMS under one of its apps.
*******************************************************************************/
@Test
void testParentApp() throws Exception
{
QInstance qInstance = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
qInstance.addApp(new QAppMetaData().withName("content").withLabel("Content"));
produce(qInstance, config().withParentAppName("content").withAppName("cmsApp").withAppLabel("Website"));
assertThat(qInstance.getApp("content").getChildren()).extracting("name").containsExactly("cmsApp");
assertThat(qInstance.getApp("cmsApp").getLabel()).isEqualTo("Website");
new QInstanceValidator().validate(qInstance);
}
/*******************************************************************************
** With openReads, tables keep their rule names and get the open-reads
** checker.
*******************************************************************************/
@Test
void testOpenReadsRules() throws Exception
{
QInstance qInstance = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
produce(qInstance, config().withOpenReads(true));
assertThat(qInstance.getTable("cms_page").getPermissionRules().getCustomPermissionChecker()).isNotNull();
}
/*******************************************************************************
** Naming constants follow the owner rule.
*******************************************************************************/
@Test
void testNaming()
{
assertThat(CmsQBitConfig.TABLE_NAME_PREFIX).isEqualTo("cms_").matches("^[a-z][a-z0-9_]*_$");
assertThat(CmsQBitConfig.PERMISSION_BASE_NAME).isEqualTo("cms");
CmsQBitConfig config = config();
assertThat(CmsQBitConfig.DEFAULT_TABLE_NAME_PREFIX).isEqualTo("cms_").matches("^[a-z][a-z0-9_]*_$");
assertThat(config.applyPrefix("page")).isEqualTo("cms_page");
assertThat(config.name("Pages")).isEqualTo("cmsPages");
assertThat(config.permission("admin")).isEqualTo("cms.admin");
assertThat(config.getEffectiveAppName()).isEqualTo("cms");
assertThat(config.toString()).contains("tableNamePrefix=cms_");
assertThat(config.getDefaultBackendNameForTables()).isEqualTo(CmsTestSupport.BACKEND);
}
/*******************************************************************************
**
*******************************************************************************/
private static CmsQBitConfig config()
{
return (new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withStartupMode(CmsStartupMode.SKIP));
}
/*******************************************************************************
**
*******************************************************************************/
private static void produce(QInstance qInstance, CmsQBitConfig config) throws QException
{
new CmsQBitProducer().withQBitConfig(config).produce(qInstance);
}
}
@@ -0,0 +1,169 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.kingsrook.qbits.cms.security.CmsRole;
import com.kingsrook.qbits.cms.security.CmsSecurity;
import com.kingsrook.qqq.backend.core.actions.tables.DeleteAction;
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
import com.kingsrook.qqq.backend.core.actions.tables.UpdateAction;
import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.exceptions.QPermissionDeniedException;
import com.kingsrook.qqq.backend.core.model.actions.tables.delete.DeleteInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.update.UpdateInput;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.session.QSession;
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSBackendMetaData;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/*******************************************************************************
** Roles, permissions and their enforcement (spec section 6) with QQQ core
** permission enforcement on, as QQQ 4.2 will default.
*******************************************************************************/
class CmsSecurityTest
{
/*******************************************************************************
**
*******************************************************************************/
@AfterEach
void afterEach()
{
QContext.clear();
}
/*******************************************************************************
** Role bundles.
*******************************************************************************/
@Test
void testRolePermissions()
{
CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND)
.withRole("cms-admins", CmsRole.ADMIN).withRole("writers", CmsRole.EDITOR).withRole("readers", CmsRole.VIEWER);
assertThat(CmsSecurity.rolesFor(config, List.of("writers", "unknown"))).containsExactly(CmsRole.EDITOR);
assertThat(CmsSecurity.rolesFor(config, null)).isEmpty();
Set<String> admin = CmsSecurity.permissionsFor(config, Set.of(CmsRole.ADMIN));
assertThat(admin).contains("cms_page.read", "cms_page.delete", "cms_page_type.edit", "cms.admin", "cms.publish");
Set<String> editor = CmsSecurity.permissionsFor(config, Set.of(CmsRole.EDITOR));
assertThat(editor).contains("cms_page.insert", "cms_page.edit", "cms_page.delete", "cms_page_type.read")
.doesNotContain("cms_page_type.edit", "cms.publish", "cms.admin");
assertThat(CmsSecurity.permissionsFor(config, Set.of(CmsRole.PUBLISHER))).contains("cms.publish").doesNotContain("cms.admin");
Set<String> drafter = CmsSecurity.permissionsFor(config, Set.of(CmsRole.DRAFTER));
assertThat(drafter).contains("cms_page.insert", "cms_page.edit").doesNotContain("cms_page.delete", "cms.publish");
Set<String> viewer = CmsSecurity.permissionsFor(config, Set.of(CmsRole.VIEWER));
assertThat(viewer).allMatch(p -> p.endsWith(".read")).contains("cms_menu_item.read");
QSession session = new QSession().withPermission("host.thing");
CmsSecurity.applySessionPermissions(session, List.of("readers"), config);
assertThat(session.getPermissions()).contains("host.thing", "cms_page.read").doesNotContain("cms_page.insert");
}
/*******************************************************************************
** Enforced: a viewer reads but cannot write; an editor writes content but
** not reference data; a session without CMS permissions cannot read.
*******************************************************************************/
@Test
void testEnforcement() throws Exception
{
CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND);
QInstance qInstance = install(config);
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.VIEWER)));
assertThat(new QueryAction().execute(new QueryInput("cms_redirect_type")).getRecords()).hasSize(4);
assertThatThrownBy(() -> insertSite("viewer")).isInstanceOf(QPermissionDeniedException.class);
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.EDITOR)));
Integer siteId = insertSite("editor");
assertThat(siteId).isNotNull();
assertThatThrownBy(() -> new UpdateAction().execute(new UpdateInput("cms_page_type").withRecord(new QRecord().withValue("id", 1).withValue("name", "X"))))
.isInstanceOf(QPermissionDeniedException.class);
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.DRAFTER)));
assertThatThrownBy(() -> new DeleteAction().execute(new DeleteInput("cms_site").withPrimaryKey(siteId))).isInstanceOf(QPermissionDeniedException.class);
CmsTestSupport.session(qInstance, Set.of());
assertThatThrownBy(() -> new QueryAction().execute(new QueryInput("cms_page"))).isInstanceOf(QPermissionDeniedException.class);
}
/*******************************************************************************
** openReads: anyone reads, writes still need the table permission.
*******************************************************************************/
@Test
void testOpenReads() throws Exception
{
CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withOpenReads(true);
QInstance qInstance = install(config);
CmsTestSupport.session(qInstance, Set.of());
assertThat(new QueryAction().execute(new QueryInput("cms_redirect_type")).getRecords()).hasSize(4);
assertThatThrownBy(() -> insertSite("anonymous")).isInstanceOf(QPermissionDeniedException.class);
CmsTestSupport.session(qInstance, Set.of("cms_site.insert"));
assertThat(insertSite("writer")).isNotNull();
assertThatThrownBy(() -> new DeleteAction().execute(new DeleteInput("cms_site").withPrimaryKey(1))).isInstanceOf(QPermissionDeniedException.class);
}
/*******************************************************************************
** A migrated, enforced install.
*******************************************************************************/
private static QInstance install(CmsQBitConfig config) throws Exception
{
RDBMSBackendMetaData backend = CmsTestSupport.h2Backend();
CmsTestSupport.migrate(backend, Map.of());
QInstance qInstance = CmsTestSupport.blankInstance(backend);
qInstance.setEnforcePermissionsInCoreActions(true);
new CmsQBitProducer().withQBitConfig(config).produce(qInstance);
return (qInstance);
}
/*******************************************************************************
**
*******************************************************************************/
private static Integer insertSite(String name) throws Exception
{
return (new InsertAction().execute(new InsertInput("cms_site").withRecord(new QRecord().withValue("name", name).withValue("shortName", name)))
.getRecords().get(0).getValueInteger("id"));
}
}
@@ -0,0 +1,116 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms;
import java.sql.Connection;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.model.metadata.QAuthenticationType;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.authentication.QAuthenticationMetaData;
import com.kingsrook.qqq.backend.core.model.session.QSession;
import com.kingsrook.qqq.backend.module.rdbms.jdbc.ConnectionManager;
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSBackendMetaData;
import liquibase.Contexts;
import liquibase.LabelExpression;
import liquibase.Liquibase;
import liquibase.database.Database;
import liquibase.database.DatabaseFactory;
import liquibase.database.jvm.JdbcConnection;
import liquibase.resource.ClassLoaderResourceAccessor;
/*******************************************************************************
** Test fixtures: a blank QQQ instance on a fresh in-memory H2 database (the
** "any running QQQ system" a host starts from), the qbit's changelog run the
** way a host runs it, and sessions with chosen permissions.
*******************************************************************************/
public final class CmsTestSupport
{
public static final String BACKEND = "rdbms";
/*******************************************************************************
** Not instantiable.
*******************************************************************************/
private CmsTestSupport()
{
}
/*******************************************************************************
** A fresh H2 backend (its own database). QQQ caches connection providers
** by backend name, so the cache is reset first.
*******************************************************************************/
public static RDBMSBackendMetaData h2Backend()
{
ConnectionManager.resetConnectionProviders();
return (new RDBMSBackendMetaData()
.withName(BACKEND)
.withVendor("h2")
.withHostName("mem")
.withDatabaseName("cms_" + UUID.randomUUID().toString().replace("-", ""))
.withUsername("sa"));
}
/*******************************************************************************
** A blank instance with one RDBMS backend and mock authentication.
*******************************************************************************/
public static QInstance blankInstance(RDBMSBackendMetaData backend)
{
QInstance qInstance = new QInstance();
qInstance.addBackend(backend);
qInstance.withInstanceDefaultAuthentication(new QAuthenticationMetaData().withName("mock").withType(QAuthenticationType.MOCK));
return (qInstance);
}
/*******************************************************************************
** Run the qbit's changelog against a backend, as a host's Liquibase would,
** with the given changelog properties.
*******************************************************************************/
public static void migrate(RDBMSBackendMetaData backend, Map<String, String> properties) throws Exception
{
Connection connection = ConnectionManager.getConnection(backend);
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
try(Liquibase liquibase = new Liquibase(CmsQBitConfig.CHANGELOG, new ClassLoaderResourceAccessor(), database))
{
properties.forEach(liquibase::setChangeLogParameter);
liquibase.update(new Contexts(), new LabelExpression());
}
}
/*******************************************************************************
** Start a context on an instance with a session holding these permissions.
*******************************************************************************/
public static QSession session(QInstance qInstance, Collection<String> permissions) throws Exception
{
QSession session = new QSession().withPermissions(permissions);
QContext.init(qInstance, session);
return (session);
}
}
@@ -0,0 +1,93 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.demo;
import com.kingsrook.qbits.cms.CmsQBitConfig;
import com.kingsrook.qbits.cms.CmsQBitProducer;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.instances.AbstractQQQApplication;
import com.kingsrook.qqq.backend.core.model.metadata.QAuthenticationType;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.authentication.QAuthenticationMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.branding.QBrandingMetaData;
import com.kingsrook.qqq.backend.module.postgres.model.metadata.PostgreSQLBackendMetaData;
import com.kingsrook.qqq.middleware.javalin.QApplicationJavalinServer;
/*******************************************************************************
** A local demo host for looking at the CMS in the Next UI (screenshots): a
** blank QQQ app with one PostgreSQL backend and the qbit, nothing else.
** Not part of the build; run it from the IDE or with exec:java against a
** database the qbit's changelog has run on:
**
** CMS_DEMO_DB_PORT (default 55433), CMS_DEMO_DB_NAME (cmsdemo),
** CMS_DEMO_DB_USER (postgres), CMS_DEMO_DB_PASSWORD, CMS_DEMO_PORT (8000).
**
** It signs everyone in anonymously, so it runs the CMS with openReads.
*******************************************************************************/
public class CmsDemoServer extends AbstractQQQApplication
{
/*******************************************************************************
** Start the demo.
*******************************************************************************/
public static void main(String[] args) throws Exception
{
new QApplicationJavalinServer(new CmsDemoServer())
.withServeFrontendNext(true)
.withServeFrontendMaterialDashboard(false)
.withPort(Integer.parseInt(env("CMS_DEMO_PORT", "8000")))
.start();
}
/*******************************************************************************
** The demo instance.
*******************************************************************************/
@Override
public QInstance defineQInstance() throws QException
{
QInstance qInstance = new QInstance();
qInstance.addBackend(new PostgreSQLBackendMetaData()
.withName("database")
.withHostName("localhost")
.withPort(Integer.parseInt(env("CMS_DEMO_DB_PORT", "55433")))
.withDatabaseName(env("CMS_DEMO_DB_NAME", "cmsdemo"))
.withUsername(env("CMS_DEMO_DB_USER", "postgres"))
.withPassword(env("CMS_DEMO_DB_PASSWORD", "")));
qInstance.withInstanceDefaultAuthentication(new QAuthenticationMetaData().withName("anonymous").withType(QAuthenticationType.FULLY_ANONYMOUS));
qInstance.setBranding(new QBrandingMetaData().withAppName("QBit CMS demo").withCompanyName("QRun-IO"));
new CmsQBitProducer()
.withQBitConfig(new CmsQBitConfig().withBackendName("database").withOpenReads(true))
.produce(qInstance);
return (qInstance);
}
/*******************************************************************************
**
*******************************************************************************/
private static String env(String name, String defaultValue)
{
String value = System.getenv(name);
return (value == null || value.isEmpty() ? defaultValue : value);
}
}
@@ -0,0 +1,191 @@
/*
* Copyright 2026 Kingsrook, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kingsrook.qbits.cms.home;
import java.util.Map;
import java.util.Set;
import com.kingsrook.qbits.cms.CmsQBitConfig;
import com.kingsrook.qbits.cms.CmsQBitProducer;
import com.kingsrook.qbits.cms.CmsStartupMode;
import com.kingsrook.qbits.cms.CmsTestSupport;
import com.kingsrook.qbits.cms.metadata.CmsTableDefinition;
import com.kingsrook.qbits.cms.security.CmsRole;
import com.kingsrook.qbits.cms.security.CmsSecurity;
import com.kingsrook.qqq.backend.core.actions.dashboard.RenderWidgetAction;
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
import com.kingsrook.qqq.backend.core.model.actions.widgets.RenderWidgetInput;
import com.kingsrook.qqq.backend.core.model.dashboard.widgets.RawHTML;
import com.kingsrook.qqq.backend.core.model.data.QRecord;
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
import com.kingsrook.qqq.backend.core.model.metadata.dashboard.QWidgetMetaData;
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSBackendMetaData;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/*******************************************************************************
** The CMS homes render real data read as the user, honest empty states, and
** leave out what the user may not read.
*******************************************************************************/
class CmsHomeRendererTest
{
/*******************************************************************************
**
*******************************************************************************/
@AfterEach
void afterEach()
{
QContext.clear();
}
/*******************************************************************************
** Empty install: area homes say so honestly; settings show seeded types.
*******************************************************************************/
@Test
void testEmptyInstall() throws Exception
{
CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND);
QInstance qInstance = install(config);
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.ADMIN)));
String top = render(qInstance, "cmsHome");
assertThat(top).contains("Sites", "Pages", "Navigation", "/app/cmsPages", "0 pages");
String sites = render(qInstance, "cmsSitesHome");
assertThat(sites).contains("Nothing yet", "Needs attention", "everything here is published and active", "New site", "New redirect");
}
/*******************************************************************************
** With content: counts, drafts, inactive rows and recently changed records.
*******************************************************************************/
@Test
void testWithContent() throws Exception
{
CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND);
QInstance qInstance = install(config);
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.ADMIN)));
Integer siteId = insert("cms_site", new QRecord().withValue("name", "Example").withValue("shortName", "ex"));
insert("cms_page", new QRecord().withValue("name", "Home").withValue("slug", "home").withValue("title", "Welcome <home>")
.withValue("pageTypeId", 1).withValue("siteId", siteId).withValue("isPublished", true));
insert("cms_page", new QRecord().withValue("name", "Draft").withValue("slug", "draft").withValue("title", "Work in progress")
.withValue("pageTypeId", 1).withValue("siteId", siteId));
insert("cms_snippet", new QRecord().withValue("name", "Footer").withValue("shortName", "footer").withValue("siteId", siteId).withValue("isActive", false));
String top = render(qInstance, "cmsHome");
assertThat(top).contains("2 pages", "1 unpublished", "1 site");
String pages = render(qInstance, "cmsPagesHome");
assertThat(pages).contains("Welcome &lt;home&gt;", "Work in progress", "/app/cms_page/", "Unpublished pages", "Inactive snippets", "Recently changed", "New page");
assertThat(pages).doesNotContain("Welcome <home>");
CmsTestSupport.session(qInstance, CmsSecurity.permissionsFor(config, Set.of(CmsRole.VIEWER)));
assertThat(render(qInstance, "cmsPagesHome")).contains("Work in progress").doesNotContain("New page");
}
/*******************************************************************************
** A user who may read nothing sees that, not zeros; DEGRADED shows the
** schema problem.
*******************************************************************************/
@Test
void testNoAccessAndDegraded() throws Exception
{
CmsQBitConfig config = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND);
QInstance qInstance = install(config);
CmsTestSupport.session(qInstance, Set.of());
assertThat(render(qInstance, "cmsHome")).contains("do not have access");
assertThat(render(qInstance, "cmsNavigationHome")).contains("do not have access to Navigation");
RDBMSBackendMetaData backend = CmsTestSupport.h2Backend();
QInstance unmigrated = CmsTestSupport.blankInstance(backend);
CmsQBitConfig degraded = new CmsQBitConfig().withBackendName(CmsTestSupport.BACKEND).withStartupMode(CmsStartupMode.DEGRADED);
new CmsQBitProducer().withQBitConfig(degraded).produce(unmigrated);
CmsTestSupport.session(unmigrated, Set.of());
assertThat(render(unmigrated, "cmsHome")).contains("not up to date");
QWidgetMetaData orphan = new QWidgetMetaData().withName("x").withDefaultValue(CmsHomeRenderer.KEY_NAME_PREFIX, "nope");
assertThatThrownBy(() -> new CmsHomeRenderer().render(new RenderWidgetInput().withWidgetMetaData(orphan))).hasMessageContaining("No CMS install");
}
/*******************************************************************************
** Pluralizing labels.
*******************************************************************************/
@Test
void testPlural()
{
assertThat(CmsHomeRenderer.plural(1, "Page")).isEqualTo("1 page");
assertThat(CmsHomeRenderer.plural(2, "Page Type")).isEqualTo("2 page types");
assertThat(CmsTableDefinition.pluralize("Category")).isEqualTo("Categories");
assertThat(CmsTableDefinition.pluralize("Key")).isEqualTo("Keys");
assertThat(CmsTableDefinition.pluralize("Media")).isEqualTo("Media");
assertThat(CmsTableDefinition.pluralize("Blog Post Media")).isEqualTo("Blog Post Media");
assertThat(CmsHomeRenderer.plural(2, "Media")).isEqualTo("2 media");
assertThat(CmsHtml.escape(null)).isEmpty();
assertThat(CmsHtml.escape("<a href='x'>&\"")).isEqualTo("&lt;a href=&#39;x&#39;&gt;&amp;&quot;");
}
/*******************************************************************************
**
*******************************************************************************/
private static QInstance install(CmsQBitConfig config) throws Exception
{
RDBMSBackendMetaData backend = CmsTestSupport.h2Backend();
CmsTestSupport.migrate(backend, Map.of());
QInstance qInstance = CmsTestSupport.blankInstance(backend);
qInstance.setEnforcePermissionsInCoreActions(true);
new CmsQBitProducer().withQBitConfig(config).produce(qInstance);
return (qInstance);
}
/*******************************************************************************
**
*******************************************************************************/
private static String render(QInstance qInstance, String widgetName) throws QException
{
RawHTML html = (RawHTML) new RenderWidgetAction().execute(new RenderWidgetInput().withWidgetMetaData(qInstance.getWidget(widgetName))).getWidgetData();
return (html.getHtml());
}
/*******************************************************************************
**
*******************************************************************************/
private static Integer insert(String table, QRecord record) throws QException
{
return (new InsertAction().execute(new InsertInput(table).withRecord(record)).getRecords().get(0).getValueInteger("id"));
}
}