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
james.maesandCodex bb1e6527a1 ci: centralize QBit source scanning (#12)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 10:45:12 -05:00
james.maesandCodex d38ba3f9db ci: adopt central orb 0.7.12 and stable gates (#11)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 08:54:04 -05:00
james.maesandCodex c7a84b1146 ci: centralize rc release completion in qqq orb (#10)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 02:25:37 -05:00
james.maesandCodex f0d72e0e4b ci: adopt shared orb 0.7.11 (#9)
Co-authored-by: Codex <noreply@openai.com>
2026-10-21 00:57:40 -05:00
james.maes 37d4dc9ef1 Merge pull request #8 from QRun-IO/feature/central-ci
ci: adopt shared QQQ orb standard
2026-10-20 19:04:49 -05:00
james.maesandCodex a3c7c91c50 ci: adopt verified central QQQ orb 0.7.3
Co-Authored-By: Codex <noreply@openai.com>
2026-10-20 19:02:37 -05:00
james.maes f441a6992c Merge pull request #6 from QRun-IO/ci/release-rc-secrets-inherit
ci(release-rc): pass secrets so the shared workflow can sign the RC tag
2026-10-16 08:03:41 -05:00
james.maesandClaude Opus 5.5 4a8b78b846 ci(release-rc): pass secrets to the shared workflow so it can sign the RC tag
QRun-IO/.github#2 adds a tag-and-release job that signs vX with the
QRUN_TAG_SIGNING_KEY secret after Maven Central confirms the artifact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 16:21:21 -05:00
james.maes 91b28925a9 Merge pull request #5 from QRun-IO/feature/orb-0.6.9
ci: qqq-orb 0.6.9 (refresh SNAPSHOT dependencies)
2026-10-14 10:56:50 -05:00
james.maesandClaude Opus 5.5 f9320e595f ci: qqq-orb 0.6.9 (refresh SNAPSHOT dependencies)
Moves qqq-orb@0.6.8 to qqq-orb@0.6.9, which passes --update-snapshots so cached SNAPSHOT dependencies are re-checked on every build (QRun-IO/qqq-orb#22).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 10:06:27 -05:00
james.maes c0405acd0c Merge pull request #4 from QRun-IO/feature/release-rc-automation
ci: automate RC releases; hotfix/* pushes no longer publish
2026-10-13 14:43:54 -05:00
james.maesandClaude Opus 5.5 33d8539f5a ci: automate RC releases; hotfix/* pushes no longer publish
Removes publish_hotfix_release: a hotfix/* branch push published a GA
release to Maven Central with no tag or review (QRun-IO/qbit-cdn#12,
QRun-IO/qqq#1121). hotfix/* branches now run test_only. Adds
.github/workflows/release-rc.yml (reusable QRun-IO/.github
qbit-release-rc). Also writes the GA tag filter without brackets
(standard C5): [0-9] inside a YAML flow sequence does not parse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 14:38:54 -05:00
57 changed files with 17508 additions and 121 deletions

No files matched your search

+11 -68
View File
@@ -1,71 +1,14 @@
version: 2.1
setup: true
orbs:
qqq-orb: kingsrook/qqq-orb@0.6.8
commands:
configure-package-install:
steps:
- run:
name: Keep package installation unattended
command: |
# These build machines are discarded after the job.
sudo install -d /etc/needrestart/conf.d
printf '%s\n' '$nrconf{restart} = "l";' | sudo tee /etc/needrestart/conf.d/99-qqq-ci.conf >/dev/null
qqq-orb: kingsrook/qqq-orb@0.8
workflows:
test_only:
jobs:
- qqq-orb/mvn_test_only:
pre-steps:
- configure-package-install
context: [qqq-maven-registry-credentials]
filters:
branches:
ignore: /(develop|release\/.*|hotfix\/.*)/
publish_snapshot:
jobs:
- qqq-orb/mvn_publish:
pre-steps:
- configure-package-install
context: [qqq-maven-registry-credentials]
branch_type: snapshot
filters:
branches:
only: [develop]
publish_release_candidate:
jobs:
- qqq-orb/mvn_publish:
pre-steps:
- configure-package-install
context: [qqq-maven-registry-credentials]
branch_type: release_candidate
filters:
branches:
only: [/release\/.*/]
publish_release:
jobs:
- qqq-orb/mvn_publish:
pre-steps:
- configure-package-install
context: [qqq-maven-registry-credentials]
branch_type: release
filters:
branches:
ignore: /.*/
tags:
only: [/^v[0-9]+\.[0-9]+\.[0-9]+$/]
publish_hotfix_release:
jobs:
- qqq-orb/mvn_publish:
pre-steps:
- configure-package-install
context: [qqq-maven-registry-credentials]
branch_type: hotfix
filters:
branches:
only: [/hotfix\/.*/]
setup:
jobs:
- qqq-orb/generate_pipeline:
orb_version: '0.8'
filters:
branches:
ignore: automation/qbit-rc-pending
tags:
only: /^v\d+\.\d+\.\d+$/
+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
+23
View File
@@ -0,0 +1,23 @@
name: CodeQL
'on':
push:
branches:
- main
- develop
- release/**
- hotfix/**
pull_request: {}
schedule:
- cron: 41 16 * * 0
workflow_dispatch: {}
permissions:
contents: read
actions: read
security-events: write
packages: read
concurrency:
group: codeql-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
analyze:
uses: QRun-IO/qqq-orb/.github/workflows/qbit-codeql.yml@c288a8864fe9054f68410e1d78f5863aea4c4d22
+74
View File
@@ -0,0 +1,74 @@
name: Release candidate
'on':
workflow_dispatch:
inputs:
dry_run:
description: Plan a cut without changing release state
type: boolean
default: false
finalize:
description: Retry finalization of an existing cut; do not cut another RC
type: boolean
default: false
recover:
description: Recover the same published RC after a deployment timeout; never
reupload
type: boolean
default: false
circle_build:
description: Original Circle publisher build number (recovery only)
type: string
default: ''
merge_sha:
description: Existing cut merge_sha (finalize retry only)
type: string
default: ''
bump_sha:
description: Existing cut bump_sha (finalize retry only)
type: string
default: ''
branch:
description: Existing cut branch (finalize retry only)
type: string
default: ''
version:
description: Existing cut version (finalize retry only)
type: string
default: ''
pull_request:
types:
- closed
branches:
- develop
repository_dispatch:
types:
- qbit-rc-published
permissions:
contents: write
actions: read
checks: read
jobs:
release-rc:
if: github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch'
|| (github.event_name == 'pull_request' && github.event.pull_request.merged
== true && github.event.pull_request.base.ref == 'develop' && contains(github.event.pull_request.labels.*.name,
'release:rc'))
uses: QRun-IO/qqq-orb/.github/workflows/qbit-release-rc.yml@cc30f599e63c8e41629c99d23395bac1adb8bc44
with:
dry_run: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run || false
}}
finalize: ${{ github.event_name == 'repository_dispatch' || (github.event_name
== 'workflow_dispatch' && inputs.finalize) }}
recover: ${{ github.event_name == 'workflow_dispatch' && inputs.recover || false
}}
circle_build: ${{ github.event_name == 'workflow_dispatch' && inputs.circle_build
|| '' }}
merge_sha: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.merge_sha
|| inputs.merge_sha || '' }}
bump_sha: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.bump_sha
|| inputs.bump_sha || '' }}
branch: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.branch
|| inputs.branch || '' }}
version: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.version
|| inputs.version || '' }}
secrets: inherit
+16
View File
@@ -0,0 +1,16 @@
profile: qbit
orb_version: '0.8'
default_branch: develop
java_version: '21'
browsers: true
api_checks: false
docs_only: false
release_on_main: false
release_tag_policy: stable
test_branch_policy: non-release
publish:
snapshot: true
release_candidate: true
release: true
asciidoc: false
release_completion: true
+1
View File
@@ -22,6 +22,7 @@ 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`.
+11
View File
@@ -12,6 +12,17 @@ All notable changes to this project are documented here. The format follows Keep
- 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.
+1
View File
@@ -22,6 +22,7 @@ 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`.
+22 -6
View File
@@ -5,7 +5,7 @@
> QQQ QBit: a headless CMS (sites, pages, menus, blog, media, projects, photos and publishing) as standard QQQ tables.
**Status:** design approved in [QRun-IO/qqq#1083](https://github.com/QRun-IO/qqq/pull/1083) (see [docs/DESIGN.md](docs/DESIGN.md)). The CORE feature is implemented; MEDIA, BLOG, PROJECTS, PHOTOS, PUBLISHING and STREAM are next. 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.
@@ -24,11 +24,11 @@ The CMS is extracted from the kof22 website, which runs it in production. Its da
```yaml
databaseChangeLog:
- property: { name: cms.tablePrefix, value: cms_ } # must equal CmsQBitConfig.tableNamePrefix
- property: { name: cms.features, value: CORE } # the features you install
- property: { name: cms.features, value: "CORE,MEDIA,BLOG" } # the features you install (default: all)
- include: { file: qbit-cms/db/changelog/qbit-cms.changelog.yaml }
```
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 and section types); set `cms.seedReferenceData` to `false` to skip that.
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:
```java
@@ -65,9 +65,15 @@ A namespace (`withNamespace("siteTwo")`) fills in all three prefixes for a secon
| 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, storage SPI (`qbit-object-storage` for S3) | next |
| `BLOG` | blog, blog type, post, tags, authors, post media, versions | next |
| `PROJECTS`, `PHOTOS`, `PUBLISHING`, `STREAM`, `DATA_HEALTH_RULES` | see the design | planned |
| `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
@@ -76,9 +82,19 @@ The qbit adds one app (`CMS`) with a home, and one sub-app per area, each with i
- **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`.
+793 -2
View File
@@ -4,6 +4,202 @@
CREATE TABLE public.cms_author (
id bigint NOT NULL,
name character varying(40) NOT NULL,
short_name character varying(20) NOT NULL,
description character varying(255),
slug character varying(40) NOT NULL,
email character varying(255),
profile_media_id bigint,
profile_image_url character varying(500),
website character varying(255),
social_links text,
is_active boolean,
display_order integer,
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
ALTER TABLE public.cms_author ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_author_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_blog (
id bigint NOT NULL,
short_name character varying(20) NOT NULL,
name character varying(40) NOT NULL,
description character varying(255),
slug character varying(40) NOT NULL,
blog_type_id bigint NOT NULL,
meta_title character varying(255),
meta_description character varying(500),
meta_keywords character varying(255),
site_id bigint NOT NULL,
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
ALTER TABLE public.cms_blog ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_blog_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_blog_post (
id bigint NOT NULL,
name character varying(40) NOT NULL,
short_name character varying(20) NOT NULL,
description character varying(255),
title character varying(100),
slug character varying(100) NOT NULL,
content text NOT NULL,
author_id bigint NOT NULL,
blog_id bigint NOT NULL,
is_published boolean,
publish_date timestamp without time zone,
featured_media_id bigint,
featured_image character varying(255),
meta_title character varying(255),
meta_description character varying(500),
meta_keywords character varying(255),
read_time integer,
view_count bigint,
is_featured boolean NOT NULL,
excerpt text,
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
ALTER TABLE public.cms_blog_post ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_blog_post_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_blog_post_media (
id bigint NOT NULL,
blog_post_id bigint NOT NULL,
media_id bigint NOT NULL,
sort_order integer NOT NULL,
alt_text character varying(1000),
caption character varying(2000),
url character varying(1000) NOT NULL,
thumbnail_url character varying(1000),
width integer,
height integer,
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
ALTER TABLE public.cms_blog_post_media ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_blog_post_media_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_blog_post_tag_int (
id bigint NOT NULL,
blog_post_id bigint NOT NULL,
blog_tag_id bigint NOT NULL,
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
ALTER TABLE public.cms_blog_post_tag_int ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_blog_post_tag_int_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_blog_post_version (
id bigint NOT NULL,
blog_post_id bigint,
project_id bigint,
project_update_id bigint,
name character varying(100) NOT NULL,
variant_key character varying(100) NOT NULL,
channel character varying(40) NOT NULL,
title character varying(200),
content text NOT NULL,
content_format character varying(20) NOT NULL,
status character varying(20) NOT NULL,
source_digest character varying(64),
source_commit character varying(64),
published_url character varying(2000),
published_date timestamp without time zone,
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL,
CONSTRAINT ck_cms_blog_post_version_channel CHECK (((channel)::text = ANY ((ARRAY['WEBSITE'::character varying, 'LINKEDIN'::character varying, 'MEDIUM'::character varying, 'FACEBOOK'::character varying, 'OTHER'::character varying])::text[]))),
CONSTRAINT ck_cms_blog_post_version_content_format CHECK (((content_format)::text = ANY ((ARRAY['MARKDOWN'::character varying, 'PLAIN_TEXT'::character varying])::text[]))),
CONSTRAINT ck_cms_blog_post_version_status CHECK (((status)::text = ANY ((ARRAY['DRAFT'::character varying, 'READY'::character varying, 'PUBLISHED'::character varying, 'ARCHIVED'::character varying])::text[])))
);
ALTER TABLE public.cms_blog_post_version ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_blog_post_version_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_blog_tag (
id bigint NOT NULL,
name character varying(40) NOT NULL,
slug character varying(40) NOT NULL,
description character varying(255),
blog_id bigint NOT NULL,
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
ALTER TABLE public.cms_blog_tag ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_blog_tag_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_blog_type (
id bigint NOT NULL,
name character varying(100) NOT NULL,
code character varying(50) NOT NULL,
description character varying(255),
is_active boolean NOT NULL,
sort_order integer NOT NULL,
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
ALTER TABLE public.cms_blog_type ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_blog_type_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_domain (
id bigint NOT NULL,
name character varying(40) NOT NULL,
@@ -25,6 +221,91 @@ ALTER TABLE public.cms_domain ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTI
CACHE 1
);
CREATE TABLE public.cms_media (
id bigint NOT NULL,
name character varying(200) NOT NULL,
slug character varying(100),
description character varying(500),
alt_text character varying(1000),
caption character varying(2000),
credit character varying(500),
license character varying(500),
media_type_id bigint NOT NULL,
file_name character varying(255),
file_extension character varying(20),
mime_type character varying(100),
file_size bigint,
width integer,
height integer,
duration integer,
checksum character varying(64),
is_active boolean NOT NULL,
public_url character varying(500),
storage_key character varying(500),
thumbnail_url character varying(500),
gallery_url character varying(500),
slideshow_url character varying(500),
site_id bigint NOT NULL,
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
ALTER TABLE public.cms_media ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_media_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_media_type (
id bigint NOT NULL,
name character varying(100) NOT NULL,
code character varying(50) NOT NULL,
description character varying(500),
is_active boolean NOT NULL,
sort_order integer NOT NULL,
allowed_mime_types character varying(1000),
allowed_extensions character varying(500),
max_file_size_mb integer,
thumbnail_enabled boolean NOT NULL,
thumbnail_width integer,
thumbnail_format character varying(10) NOT NULL,
thumbnail_quality integer,
gallery_enabled boolean NOT NULL,
gallery_width integer,
gallery_format character varying(10) NOT NULL,
gallery_quality integer,
slideshow_enabled boolean NOT NULL,
slideshow_width integer,
slideshow_format character varying(10) NOT NULL,
slideshow_quality integer,
strip_metadata boolean NOT NULL,
require_alt_text boolean NOT NULL,
require_caption boolean NOT NULL,
default_credit character varying(500),
default_license character varying(500),
cache_class character varying(20) NOT NULL,
storage_prefix character varying(100) NOT NULL,
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL,
CONSTRAINT ck_cms_media_type_cache_class CHECK (((cache_class)::text = ANY ((ARRAY['IMMUTABLE'::character varying, 'MUTABLE'::character varying])::text[]))),
CONSTRAINT ck_cms_media_type_gallery_format CHECK (((gallery_format)::text = ANY ((ARRAY['JPEG'::character varying, 'PNG'::character varying, 'WEBP'::character varying])::text[]))),
CONSTRAINT ck_cms_media_type_max_file_size_mb CHECK (((max_file_size_mb IS NULL) OR (max_file_size_mb > 0))),
CONSTRAINT ck_cms_media_type_slideshow_format CHECK (((slideshow_format)::text = ANY ((ARRAY['JPEG'::character varying, 'PNG'::character varying, 'WEBP'::character varying])::text[]))),
CONSTRAINT ck_cms_media_type_thumbnail_format CHECK (((thumbnail_format)::text = ANY ((ARRAY['JPEG'::character varying, 'PNG'::character varying, 'WEBP'::character varying])::text[])))
);
ALTER TABLE public.cms_media_type ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_media_type_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_menu (
id bigint NOT NULL,
name character varying(100) NOT NULL,
@@ -164,6 +445,246 @@ ALTER TABLE public.cms_page_type ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDE
CACHE 1
);
CREATE TABLE public.cms_photo (
id bigint NOT NULL,
photo_album_id bigint NOT NULL,
media_id bigint,
title character varying(200) NOT NULL,
slug character varying(100) NOT NULL,
caption character varying(500),
description character varying(1000),
score integer,
is_favorite boolean NOT NULL,
is_album_cover boolean NOT NULL,
sort_order integer NOT NULL,
is_published boolean NOT NULL,
publish_date timestamp without time zone,
original_url character varying(500),
gallery_url character varying(500),
slideshow_url character varying(500),
thumbnail_url character varying(500),
original_filename character varying(255),
storage_key character varying(500),
mime_type character varying(100),
file_size bigint,
width integer,
height integer,
exif_date_taken timestamp without time zone,
exif_camera_make character varying(100),
exif_camera_model character varying(100),
exif_lens_model character varying(200),
exif_focal_length character varying(20),
exif_aperture character varying(20),
exif_shutter_speed character varying(20),
exif_iso integer,
exif_white_balance character varying(50),
exif_flash character varying(50),
exif_gps_latitude double precision,
exif_gps_longitude double precision,
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
CREATE TABLE public.cms_photo_album (
id bigint NOT NULL,
site_id bigint NOT NULL,
photo_album_folder_id bigint,
project_id bigint,
project_update_id bigint,
name character varying(100) NOT NULL,
short_name character varying(40) NOT NULL,
slug character varying(100) NOT NULL,
title character varying(200),
description character varying(1000),
cover_photo_id bigint,
cover_image_url character varying(500),
is_published boolean NOT NULL,
publish_date timestamp without time zone,
sort_order integer NOT NULL,
location character varying(200),
location_latitude double precision,
location_longitude double precision,
album_date timestamp without time zone,
album_end_date timestamp without time zone,
primary_camera character varying(100),
primary_lens character varying(100),
weather character varying(100),
meta_title character varying(255),
meta_description character varying(500),
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
CREATE TABLE public.cms_photo_album_folder (
id bigint NOT NULL,
site_id bigint NOT NULL,
parent_id bigint,
name character varying(100) NOT NULL,
slug character varying(100) NOT NULL,
description character varying(500),
folder_image_url character varying(500),
is_published boolean NOT NULL,
sort_order integer NOT NULL,
meta_title character varying(255),
meta_description character varying(500),
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
ALTER TABLE public.cms_photo_album_folder ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_photo_album_folder_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
ALTER TABLE public.cms_photo_album ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_photo_album_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
ALTER TABLE public.cms_photo ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_photo_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_photo_tag (
id bigint NOT NULL,
name character varying(100) NOT NULL,
slug character varying(100) NOT NULL,
description character varying(255),
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
ALTER TABLE public.cms_photo_tag ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_photo_tag_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_photo_tag_int (
id bigint NOT NULL,
photo_id bigint NOT NULL,
photo_tag_id bigint NOT NULL,
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
ALTER TABLE public.cms_photo_tag_int ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_photo_tag_int_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_project (
id bigint NOT NULL,
name character varying(100) NOT NULL,
short_name character varying(20) NOT NULL,
slug character varying(100) NOT NULL,
title character varying(200) NOT NULL,
description text,
content text,
project_status character varying(20) NOT NULL,
github_url character varying(255),
live_url character varying(255),
featured_media_id bigint,
featured_image character varying(255),
image_alt character varying(500),
image_caption character varying(1000),
image_focal_x integer,
image_focal_y integer,
start_date timestamp without time zone,
end_date timestamp without time zone,
is_featured boolean NOT NULL,
sort_order integer NOT NULL,
site_id bigint NOT NULL,
category_id bigint NOT NULL,
is_published boolean NOT NULL,
publish_date timestamp without time zone,
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL,
CONSTRAINT ck_cms_project_image_focal_x CHECK (((image_focal_x >= 0) AND (image_focal_x <= 100))),
CONSTRAINT ck_cms_project_image_focal_y CHECK (((image_focal_y >= 0) AND (image_focal_y <= 100))),
CONSTRAINT ck_cms_project_project_status CHECK (((project_status)::text = ANY ((ARRAY['PLANNED'::character varying, 'IN_PROGRESS'::character varying, 'ACTIVE'::character varying, 'ARCHIVED'::character varying])::text[])))
);
CREATE TABLE public.cms_project_category (
id bigint NOT NULL,
site_id bigint NOT NULL,
name character varying(100) NOT NULL,
title character varying(200) NOT NULL,
slug character varying(100) NOT NULL,
section character varying(20),
description character varying(1000),
featured_media_id bigint,
featured_image character varying(500),
sort_order integer NOT NULL,
is_published boolean NOT NULL,
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
ALTER TABLE public.cms_project_category ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_project_category_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
ALTER TABLE public.cms_project ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_project_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_project_update (
id bigint NOT NULL,
project_id bigint NOT NULL,
slug character varying(100) NOT NULL,
title character varying(200) NOT NULL,
excerpt character varying(1000),
content text NOT NULL,
update_date timestamp without time zone NOT NULL,
is_published boolean NOT NULL,
publish_date timestamp without time zone,
sort_order integer NOT NULL,
featured_media_id bigint,
featured_image character varying(500),
create_date timestamp without time zone NOT NULL,
modify_date timestamp without time zone NOT NULL
);
ALTER TABLE public.cms_project_update ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cms_project_update_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
CREATE TABLE public.cms_redirect (
id bigint NOT NULL,
name character varying(100) NOT NULL,
@@ -253,9 +774,39 @@ ALTER TABLE public.cms_snippet ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENT
CACHE 1
);
ALTER TABLE ONLY public.cms_author
ADD CONSTRAINT pk_cms_author PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_blog
ADD CONSTRAINT pk_cms_blog PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_blog_post
ADD CONSTRAINT pk_cms_blog_post PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_blog_post_media
ADD CONSTRAINT pk_cms_blog_post_media PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_blog_post_tag_int
ADD CONSTRAINT pk_cms_blog_post_tag_int PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_blog_post_version
ADD CONSTRAINT pk_cms_blog_post_version PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_blog_tag
ADD CONSTRAINT pk_cms_blog_tag PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_blog_type
ADD CONSTRAINT pk_cms_blog_type PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_domain
ADD CONSTRAINT pk_cms_domain PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_media
ADD CONSTRAINT pk_cms_media PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_media_type
ADD CONSTRAINT pk_cms_media_type PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_menu
ADD CONSTRAINT pk_cms_menu PRIMARY KEY (id);
@@ -274,6 +825,30 @@ ALTER TABLE ONLY public.cms_page_section_type
ALTER TABLE ONLY public.cms_page_type
ADD CONSTRAINT pk_cms_page_type PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_photo
ADD CONSTRAINT pk_cms_photo PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_photo_album
ADD CONSTRAINT pk_cms_photo_album PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_photo_album_folder
ADD CONSTRAINT pk_cms_photo_album_folder PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_photo_tag
ADD CONSTRAINT pk_cms_photo_tag PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_photo_tag_int
ADD CONSTRAINT pk_cms_photo_tag_int PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_project
ADD CONSTRAINT pk_cms_project PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_project_category
ADD CONSTRAINT pk_cms_project_category PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_project_update
ADD CONSTRAINT pk_cms_project_update PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_redirect
ADD CONSTRAINT pk_cms_redirect PRIMARY KEY (id);
@@ -286,6 +861,57 @@ ALTER TABLE ONLY public.cms_site
ALTER TABLE ONLY public.cms_snippet
ADD CONSTRAINT pk_cms_snippet PRIMARY KEY (id);
ALTER TABLE ONLY public.cms_author
ADD CONSTRAINT uq_cms_author_name UNIQUE (name);
ALTER TABLE ONLY public.cms_author
ADD CONSTRAINT uq_cms_author_slug UNIQUE (slug);
ALTER TABLE ONLY public.cms_blog
ADD CONSTRAINT uq_cms_blog_name UNIQUE (name);
ALTER TABLE ONLY public.cms_blog_post_media
ADD CONSTRAINT uq_cms_blog_post_media_blog_post_id_media_id UNIQUE (blog_post_id, media_id);
ALTER TABLE ONLY public.cms_blog_post
ADD CONSTRAINT uq_cms_blog_post_name_blog_id UNIQUE (name, blog_id);
ALTER TABLE ONLY public.cms_blog_post
ADD CONSTRAINT uq_cms_blog_post_short_name_blog_id UNIQUE (short_name, blog_id);
ALTER TABLE ONLY public.cms_blog_post
ADD CONSTRAINT uq_cms_blog_post_slug_blog_id UNIQUE (slug, blog_id);
ALTER TABLE ONLY public.cms_blog_post_tag_int
ADD CONSTRAINT uq_cms_blog_post_tag_int_blog_post_id_blog_tag_id UNIQUE (blog_post_id, blog_tag_id);
ALTER TABLE ONLY public.cms_blog_post_version
ADD CONSTRAINT uq_cms_blog_post_version_blog_post_id_variant_key UNIQUE (blog_post_id, variant_key);
ALTER TABLE ONLY public.cms_blog_post_version
ADD CONSTRAINT uq_cms_blog_post_version_project_id_variant_key UNIQUE (project_id, variant_key);
ALTER TABLE ONLY public.cms_blog_post_version
ADD CONSTRAINT uq_cms_blog_post_version_project_update_id_variant_key UNIQUE (project_update_id, variant_key);
ALTER TABLE ONLY public.cms_blog
ADD CONSTRAINT uq_cms_blog_short_name UNIQUE (short_name);
ALTER TABLE ONLY public.cms_blog
ADD CONSTRAINT uq_cms_blog_slug_site_id UNIQUE (slug, site_id);
ALTER TABLE ONLY public.cms_blog_tag
ADD CONSTRAINT uq_cms_blog_tag_name_blog_id UNIQUE (name, blog_id);
ALTER TABLE ONLY public.cms_blog_tag
ADD CONSTRAINT uq_cms_blog_tag_slug_blog_id UNIQUE (slug, blog_id);
ALTER TABLE ONLY public.cms_blog_type
ADD CONSTRAINT uq_cms_blog_type_code UNIQUE (code);
ALTER TABLE ONLY public.cms_blog_type
ADD CONSTRAINT uq_cms_blog_type_name UNIQUE (name);
ALTER TABLE ONLY public.cms_domain
ADD CONSTRAINT uq_cms_domain_fqdn UNIQUE (fqdn);
@@ -295,6 +921,9 @@ ALTER TABLE ONLY public.cms_domain
ALTER TABLE ONLY public.cms_domain
ADD CONSTRAINT uq_cms_domain_short_name UNIQUE (short_name);
ALTER TABLE ONLY public.cms_media_type
ADD CONSTRAINT uq_cms_media_type_code UNIQUE (code);
ALTER TABLE ONLY public.cms_menu
ADD CONSTRAINT uq_cms_menu_slug_site_id UNIQUE (slug, site_id);
@@ -316,6 +945,36 @@ ALTER TABLE ONLY public.cms_page_type
ALTER TABLE ONLY public.cms_page_type
ADD CONSTRAINT uq_cms_page_type_name UNIQUE (name);
ALTER TABLE ONLY public.cms_photo_album_folder
ADD CONSTRAINT uq_cms_photo_album_folder_slug_site_id UNIQUE (slug, site_id);
ALTER TABLE ONLY public.cms_photo_album
ADD CONSTRAINT uq_cms_photo_album_short_name_site_id UNIQUE (short_name, site_id);
ALTER TABLE ONLY public.cms_photo_album
ADD CONSTRAINT uq_cms_photo_album_slug_site_id UNIQUE (slug, site_id);
ALTER TABLE ONLY public.cms_photo
ADD CONSTRAINT uq_cms_photo_slug_photo_album_id UNIQUE (slug, photo_album_id);
ALTER TABLE ONLY public.cms_photo_tag_int
ADD CONSTRAINT uq_cms_photo_tag_int_photo_id_photo_tag_id UNIQUE (photo_id, photo_tag_id);
ALTER TABLE ONLY public.cms_photo_tag
ADD CONSTRAINT uq_cms_photo_tag_name UNIQUE (name);
ALTER TABLE ONLY public.cms_photo_tag
ADD CONSTRAINT uq_cms_photo_tag_slug UNIQUE (slug);
ALTER TABLE ONLY public.cms_project_category
ADD CONSTRAINT uq_cms_project_category_slug_site_id UNIQUE (slug, site_id);
ALTER TABLE ONLY public.cms_project
ADD CONSTRAINT uq_cms_project_slug_site_id UNIQUE (slug, site_id);
ALTER TABLE ONLY public.cms_project_update
ADD CONSTRAINT uq_cms_project_update_slug_project_id UNIQUE (slug, project_id);
ALTER TABLE ONLY public.cms_redirect_type
ADD CONSTRAINT uq_cms_redirect_type_code UNIQUE (code);
@@ -325,17 +984,97 @@ ALTER TABLE ONLY public.cms_site
ALTER TABLE ONLY public.cms_snippet
ADD CONSTRAINT uq_cms_snippet_short_name_site_id UNIQUE (short_name, site_id);
CREATE INDEX idx_cms_blog_post_author_id ON public.cms_blog_post USING btree (author_id);
CREATE INDEX idx_cms_blog_post_blog_id_is_published ON public.cms_blog_post USING btree (blog_id, is_published);
CREATE INDEX idx_cms_blog_post_media_blog_post_id_sort_order ON public.cms_blog_post_media USING btree (blog_post_id, sort_order);
CREATE INDEX idx_cms_blog_post_tag_int_blog_tag_id ON public.cms_blog_post_tag_int USING btree (blog_tag_id);
CREATE INDEX idx_cms_blog_post_version_blog_post_id_channel ON public.cms_blog_post_version USING btree (blog_post_id, channel);
CREATE INDEX idx_cms_media_media_type_id ON public.cms_media USING btree (media_type_id);
CREATE INDEX idx_cms_media_site_id_name ON public.cms_media USING btree (site_id, name);
CREATE INDEX idx_cms_menu_item_menu_id ON public.cms_menu_item USING btree (menu_id);
CREATE INDEX idx_cms_page_section_page_id ON public.cms_page_section USING btree (page_id);
CREATE INDEX idx_cms_page_site_id_is_published ON public.cms_page USING btree (site_id, is_published);
CREATE INDEX idx_cms_photo_album_folder_parent_id ON public.cms_photo_album_folder USING btree (parent_id);
CREATE INDEX idx_cms_photo_album_is_published ON public.cms_photo_album USING btree (is_published);
CREATE INDEX idx_cms_photo_album_photo_album_folder_id ON public.cms_photo_album USING btree (photo_album_folder_id);
CREATE INDEX idx_cms_photo_album_project_id ON public.cms_photo_album USING btree (project_id);
CREATE INDEX idx_cms_photo_album_project_update_id ON public.cms_photo_album USING btree (project_update_id);
CREATE INDEX idx_cms_photo_photo_album_id_sort_order ON public.cms_photo USING btree (photo_album_id, sort_order);
CREATE INDEX idx_cms_photo_tag_int_photo_tag_id ON public.cms_photo_tag_int USING btree (photo_tag_id);
CREATE INDEX idx_cms_project_category_id_is_published_sort_order ON public.cms_project USING btree (category_id, is_published, sort_order);
CREATE INDEX idx_cms_project_update_project_id_is_published_update_date ON public.cms_project_update USING btree (project_id, is_published, update_date);
CREATE INDEX idx_cms_redirect_site_id_source_path ON public.cms_redirect USING btree (site_id, source_path);
ALTER TABLE ONLY public.cms_author
ADD CONSTRAINT fk_cms_author_profile_media_id FOREIGN KEY (profile_media_id) REFERENCES public.cms_media(id);
ALTER TABLE ONLY public.cms_blog
ADD CONSTRAINT fk_cms_blog_blog_type_id FOREIGN KEY (blog_type_id) REFERENCES public.cms_blog_type(id);
ALTER TABLE ONLY public.cms_blog_post
ADD CONSTRAINT fk_cms_blog_post_author_id FOREIGN KEY (author_id) REFERENCES public.cms_author(id);
ALTER TABLE ONLY public.cms_blog_post
ADD CONSTRAINT fk_cms_blog_post_blog_id FOREIGN KEY (blog_id) REFERENCES public.cms_blog(id);
ALTER TABLE ONLY public.cms_blog_post
ADD CONSTRAINT fk_cms_blog_post_featured_media_id FOREIGN KEY (featured_media_id) REFERENCES public.cms_media(id);
ALTER TABLE ONLY public.cms_blog_post_media
ADD CONSTRAINT fk_cms_blog_post_media_blog_post_id FOREIGN KEY (blog_post_id) REFERENCES public.cms_blog_post(id);
ALTER TABLE ONLY public.cms_blog_post_media
ADD CONSTRAINT fk_cms_blog_post_media_media_id FOREIGN KEY (media_id) REFERENCES public.cms_media(id);
ALTER TABLE ONLY public.cms_blog_post_tag_int
ADD CONSTRAINT fk_cms_blog_post_tag_int_blog_post_id FOREIGN KEY (blog_post_id) REFERENCES public.cms_blog_post(id);
ALTER TABLE ONLY public.cms_blog_post_tag_int
ADD CONSTRAINT fk_cms_blog_post_tag_int_blog_tag_id FOREIGN KEY (blog_tag_id) REFERENCES public.cms_blog_tag(id);
ALTER TABLE ONLY public.cms_blog_post_version
ADD CONSTRAINT fk_cms_blog_post_version_blog_post_id FOREIGN KEY (blog_post_id) REFERENCES public.cms_blog_post(id);
ALTER TABLE ONLY public.cms_blog_post_version
ADD CONSTRAINT fk_cms_blog_post_version_project_id FOREIGN KEY (project_id) REFERENCES public.cms_project(id);
ALTER TABLE ONLY public.cms_blog_post_version
ADD CONSTRAINT fk_cms_blog_post_version_project_update_id FOREIGN KEY (project_update_id) REFERENCES public.cms_project_update(id);
ALTER TABLE ONLY public.cms_blog
ADD CONSTRAINT fk_cms_blog_site_id FOREIGN KEY (site_id) REFERENCES public.cms_site(id);
ALTER TABLE ONLY public.cms_blog_tag
ADD CONSTRAINT fk_cms_blog_tag_blog_id FOREIGN KEY (blog_id) REFERENCES public.cms_blog(id);
ALTER TABLE ONLY public.cms_domain
ADD CONSTRAINT fk_cms_domain_site_id FOREIGN KEY (site_id) REFERENCES public.cms_site(id);
ALTER TABLE ONLY public.cms_media
ADD CONSTRAINT fk_cms_media_media_type_id FOREIGN KEY (media_type_id) REFERENCES public.cms_media_type(id);
ALTER TABLE ONLY public.cms_media
ADD CONSTRAINT fk_cms_media_site_id FOREIGN KEY (site_id) REFERENCES public.cms_site(id);
ALTER TABLE ONLY public.cms_menu_item
ADD CONSTRAINT fk_cms_menu_item_menu_id FOREIGN KEY (menu_id) REFERENCES public.cms_menu(id);
@@ -360,6 +1099,60 @@ ALTER TABLE ONLY public.cms_page_section
ALTER TABLE ONLY public.cms_page
ADD CONSTRAINT fk_cms_page_site_id FOREIGN KEY (site_id) REFERENCES public.cms_site(id);
ALTER TABLE ONLY public.cms_photo_album
ADD CONSTRAINT fk_cms_photo_album_cover_photo_id FOREIGN KEY (cover_photo_id) REFERENCES public.cms_photo(id);
ALTER TABLE ONLY public.cms_photo_album_folder
ADD CONSTRAINT fk_cms_photo_album_folder_parent_id FOREIGN KEY (parent_id) REFERENCES public.cms_photo_album_folder(id);
ALTER TABLE ONLY public.cms_photo_album_folder
ADD CONSTRAINT fk_cms_photo_album_folder_site_id FOREIGN KEY (site_id) REFERENCES public.cms_site(id);
ALTER TABLE ONLY public.cms_photo_album
ADD CONSTRAINT fk_cms_photo_album_photo_album_folder_id FOREIGN KEY (photo_album_folder_id) REFERENCES public.cms_photo_album_folder(id);
ALTER TABLE ONLY public.cms_photo_album
ADD CONSTRAINT fk_cms_photo_album_project_id FOREIGN KEY (project_id) REFERENCES public.cms_project(id);
ALTER TABLE ONLY public.cms_photo_album
ADD CONSTRAINT fk_cms_photo_album_project_update_id FOREIGN KEY (project_update_id) REFERENCES public.cms_project_update(id);
ALTER TABLE ONLY public.cms_photo_album
ADD CONSTRAINT fk_cms_photo_album_site_id FOREIGN KEY (site_id) REFERENCES public.cms_site(id);
ALTER TABLE ONLY public.cms_photo
ADD CONSTRAINT fk_cms_photo_media_id FOREIGN KEY (media_id) REFERENCES public.cms_media(id);
ALTER TABLE ONLY public.cms_photo
ADD CONSTRAINT fk_cms_photo_photo_album_id FOREIGN KEY (photo_album_id) REFERENCES public.cms_photo_album(id);
ALTER TABLE ONLY public.cms_photo_tag_int
ADD CONSTRAINT fk_cms_photo_tag_int_photo_id FOREIGN KEY (photo_id) REFERENCES public.cms_photo(id);
ALTER TABLE ONLY public.cms_photo_tag_int
ADD CONSTRAINT fk_cms_photo_tag_int_photo_tag_id FOREIGN KEY (photo_tag_id) REFERENCES public.cms_photo_tag(id);
ALTER TABLE ONLY public.cms_project_category
ADD CONSTRAINT fk_cms_project_category_featured_media_id FOREIGN KEY (featured_media_id) REFERENCES public.cms_media(id);
ALTER TABLE ONLY public.cms_project
ADD CONSTRAINT fk_cms_project_category_id FOREIGN KEY (category_id) REFERENCES public.cms_project_category(id);
ALTER TABLE ONLY public.cms_project_category
ADD CONSTRAINT fk_cms_project_category_site_id FOREIGN KEY (site_id) REFERENCES public.cms_site(id);
ALTER TABLE ONLY public.cms_project
ADD CONSTRAINT fk_cms_project_featured_media_id FOREIGN KEY (featured_media_id) REFERENCES public.cms_media(id);
ALTER TABLE ONLY public.cms_project
ADD CONSTRAINT fk_cms_project_site_id FOREIGN KEY (site_id) REFERENCES public.cms_site(id);
ALTER TABLE ONLY public.cms_project_update
ADD CONSTRAINT fk_cms_project_update_featured_media_id FOREIGN KEY (featured_media_id) REFERENCES public.cms_media(id);
ALTER TABLE ONLY public.cms_project_update
ADD CONSTRAINT fk_cms_project_update_project_id FOREIGN KEY (project_id) REFERENCES public.cms_project(id);
ALTER TABLE ONLY public.cms_redirect
ADD CONSTRAINT fk_cms_redirect_redirect_type_id FOREIGN KEY (redirect_type_id) REFERENCES public.cms_redirect_type(id);
@@ -368,5 +1161,3 @@ ALTER TABLE ONLY public.cms_redirect
ALTER TABLE ONLY public.cms_snippet
ADD CONSTRAINT fk_cms_snippet_site_id FOREIGN KEY (site_id) REFERENCES public.cms_site(id);
+6 -4
View File
@@ -18,6 +18,7 @@
<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>
@@ -29,7 +30,7 @@
<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>
@@ -109,7 +110,7 @@
<dependency>
<groupId>com.kingsrook.qqq</groupId>
<artifactId>qqq-frontend-next</artifactId>
<version>1.0.0-RC.14</version>
<version>1.0.0-RC.38</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -216,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>
@@ -38,17 +38,17 @@ public enum CmsFeature
/** Sites, domains, redirects, pages, page sections, snippets, menus. */
CORE(true),
/** The media library, media types and the storage SPI. */
MEDIA(false),
/** 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 versions. */
BLOG(false, MEDIA),
/** Blogs, posts, tags, authors, post media and related versions. */
BLOG(true, MEDIA),
/** Projects, project categories and project updates. */
PROJECTS(false, MEDIA),
PROJECTS(true, MEDIA),
/** Photo albums, folders, photos and photo tags. */
PHOTOS(false, MEDIA),
PHOTOS(true, MEDIA),
/** Publishing processes, publications and receipts. */
PUBLISHING(false),
@@ -65,6 +65,7 @@ public class CmsQBitConfig implements QBitConfig
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;
@@ -98,6 +99,7 @@ public class CmsQBitConfig implements QBitConfig
}
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);
}
@@ -465,6 +467,37 @@ public class CmsQBitConfig implements QBitConfig
/*******************************************************************************
** 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
*******************************************************************************/
@@ -27,6 +27,7 @@ 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;
@@ -66,6 +67,9 @@ public class CmsQBitProducer implements QBitMetaDataProducer<CmsQBitConfig>
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;
@@ -189,6 +193,16 @@ public class CmsQBitProducer implements QBitMetaDataProducer<CmsQBitConfig>
}
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()));
@@ -29,6 +29,8 @@ 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;
@@ -68,6 +70,10 @@ public final class CmsSchemaCheck
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)
{
@@ -99,6 +105,65 @@ public final class CmsSchemaCheck
/*******************************************************************************
** 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.
*******************************************************************************/
@@ -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
}
@@ -18,7 +18,19 @@ 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;
@@ -30,8 +42,22 @@ 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;
@@ -43,17 +69,36 @@ import com.kingsrook.qqq.backend.core.model.metadata.tables.Tier;
*******************************************************************************/
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 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)
@@ -116,8 +161,180 @@ public final class CmsTables
.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());
/*******************************************************************************
@@ -156,4 +373,25 @@ public final class CmsTables
{
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);
}
}
@@ -110,7 +110,7 @@ public final class CmsHtml
*******************************************************************************/
public static String muted(String html)
{
return ("<span style=\"" + MUTED + ";font-size:13px\">" + html + "</span>");
return ("<span style=\"" + MUTED + ";font-size:.875rem\">" + html + "</span>");
}
@@ -120,7 +120,7 @@ public final class CmsHtml
*******************************************************************************/
public static String heading(String text)
{
return ("<div style=\"margin:18px 0 8px;font-size:13px;font-weight:600;text-transform:uppercase;letter-spacing:.04em;" + MUTED + "\">" + escape(text) + "</div>");
return ("<div style=\"margin:18px 0 8px;font-size:.875rem;font-weight:600;text-transform:uppercase;letter-spacing:.04em;" + MUTED + "\">" + escape(text) + "</div>");
}
@@ -134,13 +134,13 @@ public final class CmsHtml
for(Tile tile : tiles)
{
html.append("<div style=\"").append(CARD).append("\">");
html.append("<div style=\"font-size:13px;").append(MUTED).append(';').append(WRAP).append("\">").append(escape(tile.label())).append("</div>");
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:26px;font-weight:700;line-height:1.3;").append(WRAP).append("\">").append(value).append("</div>");
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:13px;").append(WRAP).append("\">").append(note).append("</div>");
html.append("<div style=\"font-size:.875rem;").append(WRAP).append("\">").append(note).append("</div>");
}
html.append("</div>");
}
@@ -159,7 +159,7 @@ public final class CmsHtml
{
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:13px;").append(MUTED).append(';').append(WRAP).append("\">").append(escape(row.detail())).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());
@@ -172,7 +172,7 @@ public final class CmsHtml
*******************************************************************************/
public static String empty(String messageHtml)
{
return ("<div style=\"padding:14px 2px;font-size:14px;" + MUTED + ';' + WRAP + "\">" + messageHtml + "</div>");
return ("<div style=\"padding:14px 2px;font-size:.875rem;" + MUTED + ';' + WRAP + "\">" + messageHtml + "</div>");
}
@@ -182,7 +182,7 @@ public final class CmsHtml
*******************************************************************************/
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:14px;"
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
@@ -67,7 +67,11 @@ public final class CmsAreas
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("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()));
@@ -27,6 +27,7 @@ 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;
@@ -36,8 +37,11 @@ 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;
@@ -57,7 +61,7 @@ import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSTableBackendDe
/*******************************************************************************
** 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, joins and child-record lists for child
** 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
@@ -115,6 +119,14 @@ public class CmsTableBuilder
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()));
@@ -154,10 +166,12 @@ public class CmsTableBuilder
.withRecordLabelFields(definition.recordLabelFields())
.withPermissionRules(permissionRules());
boolean valueLists = false;
for(QFieldMetaData field : table.getFields().values())
{
String pvsName = field.getPossibleValueSourceName();
if(pvsName != null && logicals.contains(pvsName))
valueLists |= pvsName != null && CmsTables.valueList(pvsName).isPresent();
if(pvsName != null && (logicals.contains(pvsName) || CmsTables.valueList(pvsName).isPresent()))
{
field.setPossibleValueSourceName(config.applyPrefix(pvsName));
}
@@ -177,6 +191,19 @@ public class CmsTableBuilder
{
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())
@@ -198,6 +225,42 @@ public class CmsTableBuilder
/*******************************************************************************
** 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.
@@ -18,8 +18,10 @@ 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;
@@ -29,7 +31,8 @@ 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 and which fields hold long text.
** 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
@@ -42,10 +45,12 @@ import com.kingsrook.qqq.backend.core.model.metadata.tables.Tier;
** @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<List<String>> uniqueKeys, Set<String> textFields, List<Preview> previews, Map<String, String> helpTexts)
{
/*******************************************************************************
** How a table appears in the admin.
@@ -94,6 +99,22 @@ public record CmsTableDefinition(String logicalName, Class<? extends QRecordEnti
/*******************************************************************************
** 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".
*******************************************************************************/
@@ -106,11 +127,15 @@ public record CmsTableDefinition(String logicalName, Class<? extends QRecordEnti
/*******************************************************************************
** English plural of a label's last word ("Page Type" to "Page Types",
** "Category" to "Categories").
** "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");
}
@@ -142,6 +167,8 @@ public record CmsTableDefinition(String logicalName, Class<? extends QRecordEnti
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<>();
@@ -215,13 +242,47 @@ public record CmsTableDefinition(String logicalName, Class<? extends QRecordEnti
/*******************************************************************************
** 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(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);
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -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());
}
}
@@ -21,6 +21,7 @@ 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;
@@ -96,6 +97,10 @@ class CmsEntitiesTest
{
return (true);
}
if(type == BigDecimal.class)
{
return (new BigDecimal("41.5"));
}
if(type == Instant.class)
{
return (Instant.parse("2026-10-12T00:00:00Z"));
@@ -34,14 +34,16 @@ class CmsFeatureTest
@Test
void testFeatures()
{
assertThat(CmsFeature.allAvailable()).containsExactly(CmsFeature.CORE);
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)))
.contains("feature BLOG requires MEDIA", "feature BLOG is not available in this version of qbit-cms");
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)))
@@ -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"));
}
}
@@ -19,6 +19,7 @@ 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;
@@ -137,15 +138,28 @@ class CmsInstallTest
/*******************************************************************************
** Running the changelog again changes nothing (the guard runs every time
** and passes for tables this changelog created).
** 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);
@@ -229,6 +243,25 @@ class CmsInstallTest
/*******************************************************************************
** 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);
}
/*******************************************************************************
**
*******************************************************************************/
@@ -101,6 +101,41 @@ class CmsPostgresInstallTest
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)));
@@ -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));
}
}
@@ -47,7 +47,7 @@ class CmsQBitProducerTest
/*******************************************************************************
** The CORE feature: eleven standard tables named per the owner rule, a
** 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.
*******************************************************************************/
@@ -55,7 +55,7 @@ class CmsQBitProducerTest
void testProduceCore() throws Exception
{
QInstance qInstance = CmsTestSupport.blankInstance(CmsTestSupport.h2Backend());
CmsQBitConfig config = config();
CmsQBitConfig config = config().withFeatures(EnumSet.of(CmsFeature.CORE));
CmsQBitProducer producer = new CmsQBitProducer().withQBitConfig(config);
assertThat(producer.isEnabled()).isTrue();
assertThat(producer.getQBitConfig()).isSameAs(config);
@@ -128,7 +128,7 @@ class CmsQBitProducerTest
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.MEDIA)))).hasMessageContaining("MEDIA is not available");
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");
@@ -146,6 +146,9 @@ class CmsHomeRendererTest
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;");
}