In-memory representation of a DataGraphs domain model schema.
| Static Method | create |
Create a Schema from a dictionary. |
| Method | __init__ |
Create a new empty schema. |
| Method | assign |
Set or change the parent (base) class for an existing class. |
| Method | assign |
Set or clear the description of a class. |
| Method | assign |
Set an auto-generation pattern on the label property of a class. |
| Method | assign |
Designate an existing property as the label property for a class. |
| Method | assign |
Reorder properties within classes. |
| Method | clone |
Create a deep copy of the schema. |
| Method | create |
Create a new class in the schema. |
| Method | create |
Create a new property on a class. |
| Method | create |
Create a subclass that inherits all properties from the parent class. |
| Method | delete |
Delete a class from the schema. |
| Method | delete |
Remove a property from a class. |
| Method | find |
Find a class definition by name. |
| Method | find |
Find a property by name within a list of property dicts. |
| Method | find |
Find all direct subclasses of a given class. |
| Method | rename |
Rename a property. |
| Method | to |
Convert the schema to a plain dictionary. |
| Method | to |
Serialise the schema to a JSON string. |
| Method | update |
Update a class's name, description, or parent class. |
| Method | update |
Update an existing property on a class. |
| Constant | ALL |
Undocumented |
| Property | classes |
The list of class definitions in the schema. |
| Property | version |
The schema version string. |
| Static Method | _is |
Detect whether a schema dict uses the legacy (old) format. |
| Method | _assign |
Undocumented |
| Method | _assign |
Undocumented |
| Method | _assign |
Undocumented |
| Method | _assign |
Undocumented |
| Method | _assign |
Undocumented |
| Method | _assign |
Undocumented |
| Method | _assign |
Undocumented |
| Method | _assign |
Undocumented |
| Method | _delete |
Undocumented |
| Method | _get |
Extract plain text from a description (handles both str and dict). |
| Method | _is |
Undocumented |
| Method | _make |
Create a description dict in the new format. |
| Method | _set |
Undocumented |
| Method | _update |
Undocumented |
| Method | _validate |
Undocumented |
| Instance Variable | _schema |
Undocumented |
| Instance Variable | _version |
Undocumented |
Create a new empty schema.
| Parameters | |
name:str | Model name. Defaults to 'Domain Model' if empty. |
version:str | Schema version. Defaults to '1.0' if empty. |
| Raises | |
TypeError | If a dict is passed instead of keyword arguments. |
Set or change the parent (base) class for an existing class.
| Parameters | |
classstr | The class to modify. |
parentstr | The new parent class name. |
| Raises | |
ClassNotFoundError | If class_name does not exist. |
Set or clear the description of a class.
| Parameters | |
classstr | Class name. |
description:str | New description. Pass an empty string to remove it. |
| Raises | |
ClassNotFoundError | If the class does not exist. |
Set an auto-generation pattern on the label property of a class.
| Parameters | |
classstr | Class name. |
pattern:str | Auto-generation expression. |
| Raises | |
ClassNotFoundError | If the class does not exist. |
PropertyNotFoundError | If the label property does not exist. |
Designate an existing property as the label property for a class.
The property is also marked as required (isOptional=False).
| Parameters | |
classstr | Class name. |
propstr | Property name to use as the label. |
isbool | Whether the label supports multiple languages. |
| Raises | |
ClassNotFoundError | If the class does not exist. |
PropertyNotFoundError | If the property does not exist on the class. |
Reorder properties within classes.
Properties not listed in the order are appended at the end.
| Parameters | |
propertydict | A dict mapping class names to ordered lists of property names. |
str, description: str = '', parent_class_name: str = '', label_prop_name: str = 'label', is_label_prop_lang_string: bool = True):
¶
Create a new class in the schema.
| Parameters | |
classstr | Name of the new class. |
description:str | Human-readable description. |
parentstr | Name of the parent class (for inheritance). |
labelstr | Name of the label property created by default. |
isbool | Whether the label property supports multiple languages. |
| Raises | |
SchemaError | If a class with the same name already exists. |
str, prop_name: str, datatype: DATATYPE | str, description: str = '', is_optional: bool = True, is_array: bool = False, is_nested: bool = False, is_lang_string: bool = True, inverse_of: str = '', enums: list | None = None, is_synonym: bool = False, is_filterable: bool = False, apply_to_subclasses: bool = False):
¶
Create a new property on a class.
| Parameters | |
classstr | Class to add the property to. |
propstr | Property name. |
datatype:DATATYPE | str | A DATATYPE enum value for primitive types, or a class
name string for object (relationship) properties. |
description:str | Human-readable description. |
isbool | Whether the property is optional. |
isbool | Whether the property holds multiple values. |
isbool | Whether an object property is nested (embedded). |
isbool | For text properties, whether to support multiple languages. |
inversestr | Name of the inverse property on the target class (object properties only). |
enums:list | None | Allowed values for DATATYPE.ENUM properties. |
isbool | Whether this property is a label synonym. |
isbool | Whether the property is available as a facet/filter. |
applybool | If True, also creates the property on all existing subclasses. |
| Raises | |
ClassNotFoundError | If the class (or referenced class) does not exist. |
PropertyExistsError | If a property with the same name already exists. |
InvalidInversePropertyError | If the inverse property specification is invalid. |
Create a subclass that inherits all properties from the parent class.
| Parameters | |
classstr | Name of the new subclass. |
description:str | Description for the subclass. |
parentstr | Name of the parent class to inherit from. |
| Raises | |
ClassNotFoundError | If the parent class does not exist. |
str, include_linked_properties: bool = False, cascade_to_subclasses: bool = True):
¶
Delete a class from the schema.
| Parameters | |
classstr | Name of the class to delete. |
includebool | If True, also removes ObjectProperties on other classes that reference this class. |
cascadebool | If True, removes subClassOf links from any subclasses of the deleted class. |
| Raises | |
ClassNotFoundError | If the class does not exist. |
Remove a property from a class.
| Parameters | |
classstr | Class containing the property. |
propstr | Property name to delete. |
| Raises | |
ClassNotFoundError | If the class does not exist. |
PropertyNotFoundError | If the property does not exist. |
Find a class definition by name.
| Parameters | |
name:str | The class name to look up. |
| Returns | |
dict | None | The class dict, or None if not found. |
Find a property by name within a list of property dicts.
| Parameters | |
props:list | List of property dicts to search. |
name:str | The property name to look up. |
| Returns | |
dict | None | The property dict, or None if not found. |
Find all direct subclasses of a given class.
| Parameters | |
baseclass:str | The parent class name. |
| Returns | |
list[ | A list of class dicts whose subClassOf matches baseclass. |
Rename a property.
If the property is the class's label property, the label property reference is updated automatically.
| Parameters | |
classstr | Class containing the property. |
oldstr | Current property name. |
newstr | New property name. |
| Raises | |
ClassNotFoundError | If the class does not exist. |
PropertyNotFoundError | If old_prop_name does not exist. |
PropertyExistsError | If new_prop_name is already in use. |
str, new_name: str = '', new_description: str = '', parent_class_name: str = ''):
¶
Update a class's name, description, or parent class.
| Parameters | |
classstr | Current class name. |
newstr | New class name, or empty to leave unchanged. |
newstr | New description, or empty to leave unchanged. |
parentstr | New parent class. Empty string removes the parent. |
| Raises | |
ClassNotFoundError | If the class does not exist. |
str, prop_name: str, datatype: DATATYPE | str = None, description: str = None, is_optional: bool = None, is_array: bool = None, is_nested: bool = None, is_lang_string: bool = None, inverse_of: str = '', enums: list | None = None, is_synonym: bool = False, is_filterable: bool = None, apply_to_subclasses: bool = None):
¶
Update an existing property on a class.
Only parameters that are explicitly provided (non-None) will be changed.
| Parameters | |
classstr | Class containing the property. |
propstr | Property name to update. |
datatype:DATATYPE | str | New data type. |
description:str | New description. |
isbool | Whether the property is optional. |
isbool | Whether the property holds multiple values. |
isbool | Whether an object property is nested. |
isbool | Whether the property supports multiple languages. |
inversestr | Name of the inverse property on the target class. |
enums:list | None | Allowed enumeration values. |
isbool | Whether this property is a label synonym. |
isbool | Whether the property is available as a filter. |
applybool | If True, also updates the property on all existing subclasses. |
| Raises | |
ClassNotFoundError | If the class does not exist. |
PropertyNotFoundError | If the property does not exist. |
dict, datatype: DATATYPE | str, is_nested: bool = False, is_lang_string: bool = True):
¶
Undocumented
dict, class_name: str, inverse_of: str, datatype: DATATYPE | str):
¶
Undocumented
str, inverse_of: str, datatype: DATATYPE | str) -> bool:
¶
Undocumented