Back to bricks list
Introduction Version

ResourceModel

ResourceModel class.

Attributes

data: Dict[str, Any]flagged: boolfolder: SpaceFolderfs_node_model: FSNodeModelgenerated_by_port_name: strid: strname: strorigin: ResourceOriginparent_resource_id: strscenario: Scenariostyle: TypingStyletask_model: TaskModel

Functions

__INIT__

Initialize self. See help(type(self)) for accurate signature.

ARCHIVE
CLONE
COERCE
Parameters:
NameTypeDefault valueDescription
_coercebool True
DELETE_INSTANCE
DELETE_RESOURCE_CONTENT
DEPENDENCIES
Parameters:
NameTypeDefault valueDescription
search_nullablebool False
ENTITY_IS_VALIDATED
Return type:
bool
EXPORT_CONFIG
Return type:
dict
GET_AND_CHECK_RESOURCE_TYPE
Return type:
Type[Resource]
GET_ENTITY_NAME
Return type:
str
GET_ENTITY_TYPE
Return type:
EntityType
GET_ID
GET_KV_STORE
Return type:
Optional[KVStore]
GET_RESOURCE

Returns the resource created from the data and resource_typing_name if new_instance, it forces to rebuild the resource

Parameters:
NameTypeDefault valueDescription
new_instancebool False
Return type:
Resource
GET_RESOURCE_TYPE
Return type:
Optional[Type[Resource]]
GET_TECHNICAL_INFO
Return type:
TechnicalInfoDict
INIT_FS_NODE_MODEL
Parameters:
NameTypeDefault valueDescription
resourceFSNode
Return type:
FSNode
IS_ALIAS
IS_DIRTY
IS_MANUALLY_GENERATED
Return type:
bool
IS_SAVED

Returns True if the model is saved in db, False otherwise

Return type:
bool
RECEIVE_FIELDS_FROM_RESOURCE

for each BaseRField of the resource, store its value to the data or kvstore

Parameters:
NameTypeDefault valueDescription
resourceResource [description]
REFRESH
Return type:
ModelType
REMOVE_KV_STORE

Remove the kv store if it exists

SAVE

Sets the data set force_insert to True to force creation of the object set skip_hook to True to skip the before insert or update hook

:raises Exception: If the input data is not a dict

Return type:
ModelType
SAVE_FULL
SET_RESOURCE_TYPING_NAME
Parameters:
NameTypeDefault valueDescription
typing_namestr
TO_DTO
Return type:
ResourceDTO
TO_SIMPLE_DTO
Return type:
ResourceSimpleDTO
UNWRAP
ADD_INDEX - @classmethod
Parameters:
NameTypeDefault valueDescription
fieldsAny
AFTER_ALL_TABLES_INIT - @classmethod

Create the foreign keys because it was deffered

AFTER_TABLE_CREATION - @classmethod

Method call after the table is created

Usefull to create the full text indexes

ALIAS - @classmethod
Parameters:
NameTypeDefault valueDescription
aliasAny
BIND - @classmethod
Parameters:
NameTypeDefault valueDescription
databaseAny
bind_refsbool True
bind_backrefsbool True
_excludeAny
BIND_CTX - @classmethod
Parameters:
NameTypeDefault valueDescription
databaseAny
bind_refsbool True
bind_backrefsbool True
BULK_CREATE - @classmethod
Parameters:
NameTypeDefault valueDescription
model_listAny
batch_sizeAny
BULK_UPDATE - @classmethod
Parameters:
NameTypeDefault valueDescription
model_listAny
fieldsAny
batch_sizeAny
CLASSNAME - @classmethod

Returns the name of the class

Parameters:
NameTypeDefault valueDescription
slugifybool False True to slugify the class name if true, defaults to false , optional
snakefybool False True to snakefy the class name if true, defaults to false , optional
replace_uppercasebool False Replace upper cases by "-" if true, defaults to false , optional
Return type:
str
CLEAR_FOLDER - @classmethod

Clear folders from all the entities that have the folder

Parameters:
NameTypeDefault valueDescription
foldersList
COLUMN_EXISTS - @classmethod

Returns True if the column exists in the table

Parameters:
NameTypeDefault valueDescription
column_namestr The column name ``
Return type:
bool
CREATE - @classmethod
Parameters:
NameTypeDefault valueDescription
queryAny
CREATE_FOREIGN_KEY_IF_NOT_EXIST - @classmethod

Create a foreign key for a Foreign key field only if the foreign key does not exists

Parameters:
NameTypeDefault valueDescription
fieldForeignKeyField [description]
CREATE_FULL_TEXT_INDEX - @classmethod

Method to create a full text index

Parameters:
NameTypeDefault valueDescription
columnsList [description] [str]
index_namestr
CREATE_TABLE - @classmethod

Create model table

DECORATED_METHOD_NAMES - @classmethod
Parameters:
NameTypeDefault valueDescription
decorator_nameAny
DELETE - @classmethod
DELETE_BY_ID - @classmethod
Parameters:
NameTypeDefault valueDescription
pkAny
DELETE_LIST - @classmethod
Parameters:
NameTypeDefault valueDescription
resource_model_idsstr
Return type:
ModelDelete
DELETE_MULTIPLE_RESOURCES - @classmethod
Parameters:
NameTypeDefault valueDescription
resourcesList[ResourceModel]
DELETE_RESOURCE_BY_TASK_MODEL - @classmethod
Parameters:
NameTypeDefault valueDescription
task_model_idstr
DROP_TABLE - @classmethod

Drop model table

EXECUTE_SQL - @classmethod

Execute a raw SQL query. Can use the [TABLE_NAME] to replace by the table name

Parameters:
NameTypeDefault valueDescription
querystr The query to execute ``
FILTER - @classmethod
Parameters:
NameTypeDefault valueDescription
dq_nodesAny
filtersAny
FIND_BY_FS_NODE_ID - @classmethod
Parameters:
NameTypeDefault valueDescription
fs_node_idstr
Return type:
Optional['ResourceModel']
FOREIGN_KEY_EXISTS - @classmethod
Parameters:
NameTypeDefault valueDescription
column_namestr
Return type:
bool
FROM_RESOURCE - @classmethod

Create a new ResourceModel from a resource

Don't set the resource here so it is regenerate on next get (avoid using same instance)

Parameters:
NameTypeDefault valueDescription
resourceResource
originResourceOrigin ResourceOrigin.GENERATED
scenarioOptional[Scenario]
task_modelOptional[TaskModel]
port_namestr
flaggedbool
Return type:
ResourceModel
FULL_CLASSNAME - @classmethod

Returns the full name of the class

Parameters:
NameTypeDefault valueDescription
slugifybool False Slugify the returned class name if true, defaults to false , optional
snakefybool False Snakefy the returned class name if true, defaults to false ``
Return type:
str
GET - @classmethod
Parameters:
NameTypeDefault valueDescription
queryAny
filtersAny
GET_BY_ID - @classmethod
Parameters:
NameTypeDefault valueDescription
idstr
Return type:
Optional
GET_BY_ID_AND_CHECK - @classmethod

Get by ID and throw 404 error if object not found

Parameters:
NameTypeDefault valueDescription
idstr [description]
Return type:
ModelType
GET_BY_IDS - @classmethod
Parameters:
NameTypeDefault valueDescription
idsList
Return type:
List
GET_BY_SCENARIO - @classmethod
Parameters:
NameTypeDefault valueDescription
scenario_idstr
Return type:
ModelSelect
GET_BY_SCENARIOS - @classmethod
Parameters:
NameTypeDefault valueDescription
scenario_idsList[str]
Return type:
ModelSelect
GET_BY_TASK_MODEL - @classmethod
Parameters:
NameTypeDefault valueDescription
task_model_idstr
Return type:
ModelSelect
GET_BY_TASK_MODELS - @classmethod
Parameters:
NameTypeDefault valueDescription
task_model_idsList[str]
Return type:
ModelSelect
GET_BY_TYPES_AND_SUB - @classmethod
Parameters:
NameTypeDefault valueDescription
typing_namesList[str]
Return type:
ModelSelect
GET_BY_TYPES_AND_SUB_EXPRESSION - @classmethod

Return the expression to search resource base on a type and all its subtypes.

If the Resource type is provided, it returns None

Parameters:
NameTypeDefault valueDescription
typing_namesList[str]
Return type:
Expression
GET_DB - @classmethod
Return type:
DatabaseProxy
GET_DB_MANAGER - @classmethod

Returns the (current) DbManager of this model

Return type:
Type
GET_OR_CREATE - @classmethod
GET_OR_NONE - @classmethod
Parameters:
NameTypeDefault valueDescription
queryAny
filtersAny
GET_RESOURCE_BY_SCENARIO_AND_FLAG - @classmethod
Parameters:
NameTypeDefault valueDescription
scenario_idstr
flaggedbool
Return type:
ModelSelect
GET_TABLE_NAME - @classmethod

Returns the table name of this class

Return type:
str
INDEX - @classmethod
Parameters:
NameTypeDefault valueDescription
fieldsAny
INDEX_EXISTS - @classmethod

Returns True if the index exists in the table

Parameters:
NameTypeDefault valueDescription
index_namestr The index name ``
Return type:
bool
INHERITORS - @classmethod

Get all the classes that inherit this class

Return type:
List
INSERT - @classmethod
Parameters:
NameTypeDefault valueDescription
_Model__dataAny
insertAny
INSERT_FROM - @classmethod
Parameters:
NameTypeDefault valueDescription
queryAny
fieldsAny
INSERT_MANY - @classmethod
Parameters:
NameTypeDefault valueDescription
rowsAny
fieldsAny
IS_MYSQL_ENGINE - @classmethod
METHOD_NAMES - @classmethod

Returns the list of the methods

Return type:
List
MODULE_NAME - @classmethod

Returns the module name of the class

Return type:
str
NOOP - @classmethod
PROPERTY_METHOD_NAMES - @classmethod
PROPERTY_NAMES - @classmethod

Retrieves the property names

Parameters:
NameTypeDefault valueDescription
instancetype The s of the properties to retrieve. set `none` to retrieve all. `type` or `union[type]`
excludetype
Return type:
List
RAW - @classmethod
Parameters:
NameTypeDefault valueDescription
sqlAny
paramsAny
REPLACE - @classmethod
Parameters:
NameTypeDefault valueDescription
_Model__dataAny
insertAny
REPLACE_MANY - @classmethod
Parameters:
NameTypeDefault valueDescription
rowsAny
fieldsAny
SAVE_ALL - @classmethod
SAVE_FROM_RESOURCE - @classmethod

Create the ResourceModel from the Resource and save it

Parameters:
NameTypeDefault valueDescription
resourceResource
originResourceOrigin ResourceOrigin.GENERATED
scenarioScenario
task_modelTaskModel
port_namestr
flaggedbool
Return type:
ResourceModel
SELECT - @classmethod
Parameters:
NameTypeDefault valueDescription
fieldsAny
SELECT_BY_RESOURCE_TYPING_NAME - @classmethod
Parameters:
NameTypeDefault valueDescription
resource_typing_namestr
Return type:
ModelSelect
SELECT_BY_TYPE_AND_SUB_TYPES - @classmethod

select resource by type of any subclass of this type

Parameters:
NameTypeDefault valueDescription
type_Type[Resource] _description_
Return type:
ModelSelect
SET_BY_ID - @classmethod
Parameters:
NameTypeDefault valueDescription
keyAny
valueAny
TABLE_EXISTS - @classmethod
TRUNCATE_TABLE - @classmethod
Parameters:
NameTypeDefault valueDescription
optionsAny
UPDATE - @classmethod
Parameters:
NameTypeDefault valueDescription
_Model__dataAny
updateAny
VALIDATE_MODEL - @classmethod
COPY - @staticmethod
Parameters:
NameTypeDefault valueDescription
methodAny