src/app/utils/test-utils/TestEntity.ts
Basic Entity type for unit tests, so that we don't have to create custom entity classes for every test.
No results matching.
Properties |
|
Methods |
|
| category |
Type : ConfigurableEnumValue
|
Decorators :
@DatabaseField({label: 'Category', dataType: undefined, additional: 'genders'})
|
|
Defined in src/app/utils/test-utils/TestEntity.ts:60
|
| dateOfBirth |
Type : DateWithAge
|
Decorators :
@DatabaseField({label: 'Date of Birth'})
|
|
Defined in src/app/utils/test-utils/TestEntity.ts:65
|
| Static ENTITY_TYPE |
Type : string
|
Default value : "TestEntity"
|
|
Inherited from
Entity
|
| Static hasPII |
Type : unknown
|
Default value : true
|
|
Inherited from
Entity
|
| Static icon |
Type : IconName
|
Default value : "child"
|
|
Inherited from
Entity
|
| Static label |
Type : string
|
Default value : "Test Entity"
|
|
Inherited from
Entity
|
| Static labelPlural |
Type : string
|
Default value : "Test Entities"
|
|
Defined in src/app/utils/test-utils/TestEntity.ts:21
|
| name |
Type : string
|
Decorators :
@DatabaseField({label: 'Name'})
|
|
Defined in src/app/utils/test-utils/TestEntity.ts:33
|
| other |
Type : string
|
Decorators :
@DatabaseField({label: 'Other'})
|
|
Defined in src/app/utils/test-utils/TestEntity.ts:38
|
| rating |
Type : number
|
Decorators :
@DatabaseField({label: 'Rating', dataType: 'number'})
|
|
Defined in src/app/utils/test-utils/TestEntity.ts:71
|
| ref |
Type : string
|
Decorators :
@DatabaseField({label: 'Reference', dataType: undefined, additional: undefined})
|
|
Defined in src/app/utils/test-utils/TestEntity.ts:45
|
| refMixed |
Type : string[]
|
Decorators :
@DatabaseField({label: 'Reference (multi, mixed)', dataType: undefined, additional: undefined, isArray: true})
|
|
Defined in src/app/utils/test-utils/TestEntity.ts:53
|
| Static route |
Type : string
|
Default value : "test-entity"
|
|
Defined in src/app/utils/test-utils/TestEntity.ts:23
|
| Static toBlockDetailsAttributes |
Type : EntityBlockConfig
|
Default value : {
title: "name",
fields: ["other", "category"],
}
|
|
Inherited from
Entity
|
| Static toStringAttributes |
Type : []
|
Default value : ["name"]
|
|
Inherited from
Entity
|
| Static Optional _isCustomizedType |
| todo: This property is no longer used and will be removed in future versions. |
Type : boolean
|
|
Inherited from
Entity
|
|
True if this type's schema has been customized dynamically from the config. |
| _rev |
Type : string
|
Decorators :
@DatabaseField({anonymize: 'retain', isInternalField: true})
|
|
Inherited from
Entity
|
|
internal database doc revision, used to detect conflicts by PouchDB/CouchDB |
| anonymized |
Type : boolean
|
Decorators :
@DatabaseField({anonymize: 'retain', isInternalField: true})
|
|
Inherited from
Entity
|
|
Whether this entity has been anonymized and therefore cannot be re-activated. |
| Static color |
Type : string | ColorMapping[]
|
|
Inherited from
Entity
|
|
color used for to highlight this entity type across the app. Can be either:
|
| created |
Type : UpdateMetadata
|
Decorators :
@DatabaseField({anonymize: 'retain', isInternalField: true})
|
|
Inherited from
Entity
|
| Static DATABASE |
Type : string
|
Default value : "app"
|
|
Inherited from
Entity
|
|
The database where these entities are stored. |
| Static Optional enableUserAccounts |
Type : boolean
|
|
Inherited from
Entity
|
|
Whether to enable user account creation for this entity type. When true, the UI will allow management of user accounts associated with this entity. |
| inactive |
Type : boolean
|
Decorators :
@DatabaseField({anonymize: 'retain', isInternalField: true})
|
|
Inherited from
Entity
|
| Static Optional isInternalEntity |
Type : boolean
|
|
Inherited from
Entity
|
|
if this entity type is an internal entity, i.e. only defined in the code base to store internal system data and not visible to the user for customization. |
| Static schema |
Type : EntitySchema
|
|
Inherited from
Entity
|
|
EntitySchema defining property transformations from/to the database.
This is auto-generated from the property annotations see /additional-documentation/how-to-guides/create-a-new-entity-type.html |
| updated |
Type : UpdateMetadata
|
Decorators :
@DatabaseField({anonymize: 'retain', isInternalField: true})
|
|
Inherited from
Entity
|
| Static create | ||||||
create(data: Partial
|
||||||
|
Defined in src/app/utils/test-utils/TestEntity.ts:73
|
||||||
|
Parameters :
Returns :
TestEntity
|
| assertValid |
assertValid()
|
|
Inherited from
Entity
|
|
Checks if the entity is valid and if the check fails, throws an error explaining the failed check.
Returns :
void
|
| Public copy | ||||||||||
copy(newId: string | boolean)
|
||||||||||
|
Inherited from
Entity
|
||||||||||
|
Deep copy of the entity. The resulting entity will be of the same type as this (taking into account subclassing). All schema field values that are objects or arrays are deep-cloned to avoid shared mutable state between original and copy.
Parameters :
Returns :
unknown
|
| Static createPrefixedId | ||||||||||||
createPrefixedId(type: string, id: string)
|
||||||||||||
|
Inherited from
Entity
|
||||||||||||
|
Create a prefixed id by adding the type prefix if it isn't already part of the given id.
Parameters :
Returns :
string
|
| Static extractEntityIdFromId | ||||||||
extractEntityIdFromId(id: string)
|
||||||||
|
Inherited from
Entity
|
||||||||
|
Extract entityId without prefix.
Parameters :
Returns :
string
|
| Static extractTypeFromId | ||||||||
extractTypeFromId(id: string)
|
||||||||
|
Inherited from
Entity
|
||||||||
|
Extract the ENTITY_TYPE from an id.
Parameters :
Returns :
string
|
| Public getColor |
getColor()
|
|
Inherited from
Entity
|
|
Used by some generic UI components to set the color for the entity instance. Override this method as needed.
Returns :
string
|
| Static getColorWithConditions | ||||||
getColorWithConditions(entity: Entity)
|
||||||
|
Inherited from
Entity
|
||||||
|
Static method to evaluate conditional colors for an entity based on ColorMapping configuration.
Parameters :
Returns :
string
|
| getConstructor |
getConstructor()
|
|
Inherited from
Entity
|
|
Get the class (Entity or the actual subclass of the instance) to call static methods on the correct class considering inheritance
Returns :
EntityConstructor<unknown>
|
| Public getId | ||||||||
getId(withoutPrefix: unknown)
|
||||||||
|
Inherited from
Entity
|
||||||||
|
Returns the id of this entity. Note that an id is final and can't be changed after the object has been instantiated, hence there is no
Parameters :
Returns :
string
the unique id of this entity |
| getSchema |
getSchema()
|
|
Inherited from
Entity
|
|
Get the entity schema of this class
Returns :
EntitySchema
|
| Public getType |
getType()
|
|
Inherited from
Entity
|
|
Returns the type which is used to categorize this entity in the database. Important: Do not overwrite this method! Types are handled internally.
Returns :
string
the entity's type (which is the class name). |
| Public getWarningLevel |
getWarningLevel()
|
|
Inherited from
Entity
|
|
Override getWarningLevel() to define when the entity is in a critical condition and should be color-coded and highlighted in generic components of the UI.
Returns :
WarningLevel
|
import { DatabaseEntity } from "../../core/entity/database-entity.decorator";
import { Entity } from "../../core/entity/model/entity";
import { DatabaseField } from "../../core/entity/database-field.decorator";
import { EntityDatatype } from "../../core/basic-datatypes/entity/entity.datatype";
import { ConfigurableEnumDatatype } from "../../core/basic-datatypes/configurable-enum/configurable-enum-datatype/configurable-enum.datatype";
import { DateWithAge } from "../../core/basic-datatypes/date-with-age/dateWithAge";
import { IconName } from "@fortawesome/fontawesome-svg-core";
import { EntityBlockConfig } from "../../core/basic-datatypes/entity/entity-block/entity-block-config";
import { ConfigurableEnumValue } from "app/core/basic-datatypes/configurable-enum/configurable-enum.types";
/**
* Basic Entity type for unit tests, so that we don't have to create custom entity classes for every test.
*/
@DatabaseEntity("TestEntity")
export class TestEntity extends Entity {
static override ENTITY_TYPE = "TestEntity";
static override toStringAttributes = ["name"];
static override label = "Test Entity";
static override labelPlural = "Test Entities";
static override icon: IconName = "child";
static override route = "test-entity";
static override toBlockDetailsAttributes: EntityBlockConfig = {
title: "name",
fields: ["other", "category"],
};
static override hasPII = true;
@DatabaseField({
label: "Name",
})
name: string;
@DatabaseField({
label: "Other",
})
other: string;
@DatabaseField({
label: "Reference",
dataType: EntityDatatype.dataType,
additional: TestEntity.ENTITY_TYPE,
})
ref: string;
@DatabaseField({
label: "Reference (multi, mixed)",
dataType: EntityDatatype.dataType,
additional: ["Note", "Todo"],
isArray: true,
})
refMixed: string[];
@DatabaseField({
label: "Category",
dataType: ConfigurableEnumDatatype.dataType,
additional: "genders",
})
category: ConfigurableEnumValue;
@DatabaseField({
label: "Date of Birth",
})
dateOfBirth: DateWithAge;
@DatabaseField({
label: "Rating",
dataType: "number",
})
rating: number;
static create(data: Partial<TestEntity> | string): TestEntity {
if (typeof data === "string") {
data = { name: data };
}
return Object.assign(new TestEntity(), data);
}
}