gws_core

Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
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
_coerce : bool - True
delete_instance
delete_resource_content
dependencies
search_nullable : bool - 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

new_instance : bool - False
Return type : Resource
get_resource_type
Return type : Optional[Type[Resource]]
get_technical_info
Return type : TechnicalInfoDict
init_fs_node_model
resource : FSNode
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

resource : Resource
[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

Return type : ModelType
save_full
set_parent_and_save
parent_resource_id : str
Return type : 'ResourceModel'
set_resource_typing_name
typing_name : str
to_dto
Return type : ResourceModelDTO
to_simple_dto
Return type : ResourceSimpleDTO
unwrap
add_index @classmethod
fields : Any
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
alias : Any
bind @classmethod
database : Any
bind_refs : bool - True
bind_backrefs : bool - True
_exclude : Any
bind_ctx @classmethod
database : Any
bind_refs : bool - True
bind_backrefs : bool - True
bulk_create @classmethod
model_list : Any
batch_size : Any
bulk_update @classmethod
model_list : Any
fields : Any
batch_size : Any
classname @classmethod

Returns the name of the class

slugify : bool - False
True to slugify the class name if True
snakefy : bool - False
True to snakefy the class name if True
replace_uppercase : bool - False
Replace upper cases by "-" if True
Return type : str
clear_folder @classmethod

Clear folders from all the entities that have the folder

folders : List
column_exists @classmethod

Returns True if the column exists in the table

column_name : str
The column name
Return type : bool
create @classmethod
query : Any
create_foreign_key_if_not_exist @classmethod

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

field : ForeignKeyField
[description]
create_full_text_index @classmethod

Method to create a full text index

columns : List
[description]
index_name : str
create_table @classmethod

Create model table

delete @classmethod
delete_by_id @classmethod
pk : Any
delete_list @classmethod
resource_model_ids : str
Return type : ModelDelete
delete_multiple_resources @classmethod
resources : List[ResourceModel]
delete_resource_by_task_model @classmethod
task_model_id : str
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

query : str
The query to execute
filter @classmethod
dq_nodes : Any
filters : Any
find_by_fs_node_id @classmethod
fs_node_id : str
Return type : Optional['ResourceModel']
foreign_key_exists @classmethod
column_name : str
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)

resource : Resource
origin : ResourceOrigin - ResourceOrigin.GENERATED
scenario : Optional[Scenario]
task_model : Optional[TaskModel]
port_name : str
flagged : bool
Return type : ResourceModel
full_classname @classmethod

Returns the full name of the class

slugify : bool - False
Slugify the returned class name if True
snakefy : bool - False
Snakefy the returned class name if True
Return type : str
get @classmethod
query : Any
filters : Any
get_by_id @classmethod
id : str
Return type : Optional
get_by_id_and_check @classmethod

Get by ID and throw 404 error if object not found

id : str
[description]
Return type : ModelType
get_by_ids @classmethod
ids : List
Return type : List
get_by_scenario @classmethod
scenario_id : str
Return type : ModelSelect
get_by_scenarios @classmethod
scenario_ids : List[str]
Return type : ModelSelect
get_by_task_model @classmethod
task_model_id : str
Return type : ModelSelect
get_by_task_models @classmethod
task_model_ids : List[str]
Return type : ModelSelect
get_by_types_and_sub @classmethod
typing_names : List[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

typing_names : List[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
query : Any
filters : Any
get_resource_by_scenario_and_flag @classmethod
scenario_id : str
flagged : bool
Return type : ModelSelect
get_table_name @classmethod

Returns the table name of this class

Return type : str
index @classmethod
fields : Any
index_exists @classmethod

Returns True if the index exists in the table

index_name : str
The index name
Return type : bool
inheritors @classmethod

Get all the classes that inherit this class

Return type : List
insert @classmethod
_Model__data : Any
insert : Any
insert_from @classmethod
query : Any
fields : Any
insert_many @classmethod
rows : Any
fields : Any
is_mysql_engine @classmethod
noop @classmethod
raw @classmethod
sql : Any
params : Any
replace @classmethod
_Model__data : Any
insert : Any
replace_many @classmethod
rows : Any
fields : Any
save_all @classmethod
save_from_resource @classmethod

Create the ResourceModel from the Resource and save it

resource : Resource
origin : ResourceOrigin - ResourceOrigin.GENERATED
scenario : Scenario
task_model : TaskModel
port_name : str
flagged : bool
Return type : ResourceModel
select @classmethod
fields : Any
select_by_resource_typing_name @classmethod
resource_typing_name : str
Return type : ModelSelect
select_by_type_and_sub_types @classmethod

select resource by type of any subclass of this type

type_ : Type[Resource]
_description_
Return type : ModelSelect
set_by_id @classmethod
key : Any
value : Any
table_exists @classmethod
truncate_table @classmethod
options : Any
update @classmethod
_Model__data : Any
update : Any
validate_model @classmethod
copy @staticmethod
method : Any