CodamAIDocs
Topicdone

Modeling in the hub

What you define in the hub: system, folder, model, field, relation, rules, endpoints, roles. And which modeling rules apply.

Variants
System (module)Folder and enumerationData model, abstract model, file modelPrimitive field, enum field, relation fieldRules on the fieldEndpointsRolesAccess filters and hooks

What this is about

Before there is code, there is a model. In the hub you describe which things your application knows (customer, order, invoice), which fields they have, how they are connected and who may do what. Later the build generates all the code from this description, see Code generation in the build.

So you model here, you do not program. Everything you define is data in the hub: the metadata of your application.

The meta model

This is how the things you create in the hub fit together:

flowchart TD
    P["Project"] --> S["System<br/>(one CDMS application)"]
    S --> F["Folder"]
    S --> E["Enumeration"]
    S --> M["Model"]
    F -. "contains" .-> M
    F -. "contains" .-> E
    E --> EI["Enum value"]
    M --> FD["Field"]
    M --> EP["Endpoint"]
    M --> R["Role"]
    M --> AF["Access filter"]
    M --> H["Hook"]
    M -. "inherits from" .-> AM["abstract model"]
    FD --> RU["Rule"]
    FD --> FR["Field role"]
    FD -. "enum field" .-> E
    FD -. "relation field" .-> M
Building blockwhat it isimportant settings
Systemone CDMS application. In the hub overview it is called module, in the modeling UI servicename, version, database, login, storage, monitoring, CIAS. These settings control the project scaffold
Foldergroups models and enumerationsname. The path (/crm/vertrieb) later becomes the API path and the Java package
Enumerationa fixed list of values, e.g. CUSTOMER_STATUSenum values in UPPERCASE
Modela thing in your subject area, e.g. Customerkind, level, singleton, auditing, base model
Fielda property of the modelkind, type, length, default value, rules, field roles
Endpointan operation that should existtype: CREATE, READ, UPDATE, DELETE, LIST, HISTORY_*, UPLOAD, DOWNLOAD
Rolemarks an operation as requiring a roleCREATE, READ, UPDATE, DELETE
Access filtershows only rows that match a user attributeprofile attribute → field
Hookannounces custom logic–

Three kinds of models

Which kind of model?
Data model
the normal case
  • has a table and endpoints
  • can inherit from an abstract model
  • can be a singleton: exactly one object
Abstract model
shared base
  • cannot be created itself
  • passes its fields on to data models
  • a search on it finds all subtypes
File model
record with a file
  • comes with file fields already (name, MIME type, size)
  • endpoints UPLOAD and DOWNLOAD
  • needs storage on the system

A model can inherit from only one abstract model. More in Abstract models, Singleton and The file model.

For each model you also define:

SettingValueseffect
Level (modelType)TENANT (default), SYSTEM, USERwhere the data lives and who sees it, see Model levels
Singletonyes / noexactly one object per tenant, own endpoints without id
Auditingyes / noevery change is stored as a revision, history and rollback become possible

Fields

Every field is one of three kinds:

Three kinds of fields

When: a simple value

You choose a type: STRING, INTEGER, FLOAT, DOUBLE, BOOLEAN, DATE, TIME or DATE_TIME. For STRING you set a length. Optionally you set a default value that must match the type (true/false, whole number, number).

When: a value from a fixed list

The field points to an enumeration. Optionally you choose an enum value as the default value.

When: a reference to another model

You choose the relation type (ONE_TO_ONE, ONE_TO_MANY, MANY_TO_ONE, MANY_TO_MANY) and the target model. The hub creates the other side on the target model automatically. Under recursion you define whether the relation may be used to create (CREATE), change (UPDATE) or delete (DELETE) along with it.

Result: See Relation types and The four cases of nested writing

In the hub a relation is always a pair of fields. If you add the field customer to Order (MANY_TO_ONE to Customer), the opposite field with the reverse type (ONE_TO_MANY) appears on Customer. Both are saved in one transaction. If you delete one side, the hub deletes the other one too.

you createother side becomes
ONE_TO_ONEONE_TO_ONE
MANY_TO_ONEONE_TO_MANY
ONE_TO_MANYMANY_TO_ONE
MANY_TO_MANYMANY_TO_MANY

Some fields you never create yourself, because every model already has them: id, _createdOn, _updatedOn and, depending on the level, _userId. See System fields.

Rules on the field

Rules say which values a field may take. CDMS checks them when writing, see Validation.

Rule in the UIRule IDapplies to
required field@nullableall fields
required only on create / update@notNullOnCreate, @notNullOnUpdateall fields
not empty@notEmptySTRING, list relations
cannot be changed later@noUpdateprimitive and enum fields
unique@uniqueprimitive and enum fields
pattern (regular expression)@patternSTRING
long text@lobSTRING
encrypted, see Encrypted fields@encryptedSTRING, not together with “unique”
minimum / maximum value@min, @maxINTEGER, FLOAT, DOUBLE
field hook@hook with the class name, see Field hooksprimitive and enum fields

The maximum length of a text is not a rule. It is the length property of the field.

You can limit some rules to a scope: ALWAYS (default), only CREATE or only UPDATE. This works for “not empty”, “pattern” and “minimum / maximum value”. For the required field, the operation is already part of the rule itself.

Endpoints and roles

In the Endpoints tab you define which operations exist for the model. The UI always offers the five basic operations (CREATE, READ, UPDATE, DELETE, LIST). The history endpoints exist only for audited models, UPLOAD and DOWNLOAD only for file models. What each type generates in the code is described in Which endpoints a model has.

In the Permissions tab you mark which operations require a role of their own. You only set one checkbox per operation. The generator builds the role name from folder, model and operation using a fixed pattern. In the same way there are field roles on a single field. See Model roles, Field roles and Role names.

In the Filters tab you connect a profile attribute of the user to a field. Then everyone sees only the rows whose field matches their attribute, see Attribute filter.

Which rules the hub enforces

When you save, the hub checks your input. A violation is rejected, and the UI shows you the reason at the field.

RuleExample of a violationResponse
Names of system, folder, model, enumeration: letter first, then letters, digits, _, at least 2 characters1Kunde422 with a list of violations
Field name: letter first, at most 51 characters, no Java keywordclass, new400 invalid-field-name
Field name unique in the model (case does not matter)name and Name409 duplicated-field
Enum value in uppercase, unique in the enumerationaktiv400 invalid-enum-value / 409 duplicated-enum-value
Name unique in the foldertwo Customer models in /crm409
Length only for STRING, default value matches the typelength on INTEGER400
File model: name, size, mimeType are already takenown field name400
a model does not inherit from itselfCustomer inherits from Customer400

The hub calculates the path of a folder itself. If you rename or move a folder, it updates the paths of the whole subtree.

Some things are allowed but are usually a mistake. For these, the UI shows a warning sign at the field:

Warningwhat it is about
Audit gapan audited model points to a model that is not audited. Its changes do not show up in the history
Level conflicta SYSTEM model is connected to a TENANT or USER model. The data lives in different databases
List to singletona list relation points to a singleton, which has only one object

Checklist: a new model

  1. 1
    Developer→Hub
    opens the system in the project and checks its settings: database, login, storage, monitoring
    For a file model, storage must be set to FILESYSTEM.
  2. 2
    Developer→Hub
    creates folders and enumerations first, if needed
  3. 3
    Developer→Hub
    creates the model: kind (data model, abstract, file), name, description, folder
  4. 4
    Developer→Hub
    sets the model properties: level, base model, singleton, auditing
    With auditing, the UI creates the history endpoints right away.
  5. 5
    Developer→Hub
    creates the fields, with type, length, default value, rules and field roles. For relations: type, target and recursion
    Do not create: id, timestamps, inherited fields.
  6. 6
    Developer→Hub
    checks the endpoints. For a file model, turn on UPLOAD and DOWNLOAD
  7. 7
    Developer→Hub
    marks which operations require a role and creates access filters if needed
  8. 8
    Hub
    Warning signs on the fields?
  9. 9
    Build→Hub
    fetches the metadata on the next build and generates the code
    Result: The model has arrived in the application

Instead of doing it by hand, an AI client can also change the model, through the hub’s MCP server.

Pitfalls

Sources in the code and the knowledge base
  • hub-backend – structure/models.yaml, structure/enumerations.yaml (the meta model)
  • hub-backend – services/CdmsNaming, AbstractFieldHook, EnumItemHook, FolderHook, ModelFieldHook, ModelDesignApi, ModelDesignService
  • hub-backend – mcp/capabilities/CdmsCapabilitiesService (system fields, file model)
  • CDMS/frontend – components/cdms/ItemCreateDialog.vue, ModelFormFields.vue, FieldDialog.vue, ModelView.vue
  • CDMS/frontend – shared/utils/cdmsFieldRules.ts, cdmsEndpoints.ts, cdmsAccessFilters.ts, server/utils/cdmsFields.ts, cdmsItemName.ts
  • CDMS/cdms-generator – loader/CdmsYamlLoader (applyRuleList)
  • documentation/90-hub/01-modellierung.md, 10-cdms-grundlagen/02-modelle-und-metadaten.md
Search