xia_composer.pattern.Pattern

class xia_composer.pattern.Pattern(**kwargs)

Bases: EmbeddedDocument

__init__(**kwargs)

Methods

__init__(**kwargs)

action(action_name[, acl, payload])

Doing an action of a document

apply()

Apply pattern: From design space to code space

apply_node(path, nodes)

Apply changes of a node

assign_holder(holders_to_set, holder)

Assign holder

calculate_id()

Calculate document id from current attributes

collection_action(action_name[, acl, payload])

Doing a collection level action

could_be_merged(filepath)

If the file could be merged

dict_to_id(key_values)

Calculate document id from key_values

dict_to_id_list(key_values)

Calculate document id from key_values.

fill_pattern(pattern_dict)

fill_runtime(pattern_dict)

from_db([_engine])

Transform database data to internal data

from_display(**kwargs)

Transform Display data to internal data

get_actions()

Get action supported by this document

get_all_fields()

Get All fields of current class

get_code_list()

Get potential impacted files of this pattern

get_design_runtime_mapping()

Get mapping from design time node to runtime node

get_display_data([lazy, catalog, show_hidden])

Get Display data (visualized form of data)

get_holder()

get_meta_data()

get_raw_data()

Get Raw data (materialized form of data)

get_runtime_data()

Get Runtime data (calculated from raw data when runtime is activated)

get_sample()

Get a sample document data

id_to_dict(doc_id)

From document id to key

parse()

Parse pattern: From code space to design space

prepare()

Prepare pattern: Save Pattern value into .prepare/.pattern_name space

purge_prepare()

Purge prepare workspace

regularize(node_name, node_value)

Regularize design node value

render_init_dir(runtime_content)

Copy Initial Directory to Prepare space

render_template_dir(runtime_content)

More complex render process

set_holder(holder)

to_db(*[, catalog, ignore_unknown, engine])

Translate the runtime data into raw data (materialized form of data)

validate()

Validate if all of the component of document follows the predefined rules

Attributes

OPERATORS

name

pattern_type

target

action(action_name: str, acl=None, payload: Optional[dict] = None)

Doing an action of a document

Parameters
  • action_name – The action name

  • acl – Access Control List

  • payload – Parameters of action

apply()

Apply pattern: From design space to code space

apply_node(path: str, nodes: dict)

Apply changes of a node

Parameters
  • path – Path for target code space

  • nodes – The dictionary of prepare node, pattern node and runtime node

classmethod assign_holder(holders_to_set: list, holder)

Assign holder

Parameters
  • holders_to_set (list) – The holder must be attached to the given list

  • holder – Holder

calculate_id() Optional[str]

Calculate document id from current attributes

Returns

Document id as string if having key field defined else None

classmethod collection_action(action_name, acl=None, payload: Optional[dict] = None)

Doing a collection level action

Parameters
  • action_name – The action name

  • acl – Access Control List

  • payload – Parameters of action

classmethod could_be_merged(filepath: str) bool

If the file could be merged

Parameters

filepath – filename

Returns

True if could be merged else False

classmethod dict_to_id(key_values: dict) str

Calculate document id from key_values

Parameters

key_values (dict) – Key value dictionary

Returns

Document id as string

classmethod dict_to_id_list(key_values: dict) list

Calculate document id from key_values. Accepting list as value. Output will always be list

Parameters

key_values (dict) – Key value dictionary

Returns

Document id as string

classmethod from_db(_engine: Optional[Type[BaseEngine]] = None, **kwargs)

Transform database data to internal data

Parameters
  • _engine – engine to be used for convert data

  • **kwargs (object) – python dict got from system

Returns

python dict object

classmethod from_display(**kwargs)

Transform Display data to internal data

Parameters

**kwargs (object) – display object got from front end

Returns

python dict object

classmethod get_actions()

Get action supported by this document

Returns

Base]

Return type

dictionary[str

classmethod get_all_fields() dict

Get All fields of current class

get_code_list() list

Get potential impacted files of this pattern

Returns

value, errors

classmethod get_design_runtime_mapping() dict

Get mapping from design time node to runtime node

get_display_data(lazy: bool = True, catalog: Optional[dict] = None, show_hidden: bool = False)

Get Display data (visualized form of data)

Parameters
  • lazy (bool) – Left the fields as is if they are not explicitly loaded

  • catalog (dict) – The catalog of display field in the following format: * {field1: false, field2: false, field3: {sub-field1: true, sub-field2: true}} * field1, field2 is the top-level normal field * field3 is an embedded field/reference field/external field while sub-field1, sub-field2 is its fields * True or false will override the lazy setting, none means using lazy settings

  • show_hidden (bool) – If hidden value should be shown or not

Returns

python dict object

Notes

We will return the detail form if it is possible

get_raw_data()

Get Raw data (materialized form of data)

Returns

python dict object

get_runtime_data()

Get Runtime data (calculated from raw data when runtime is activated)

Returns

python dict object

classmethod get_sample()

Get a sample document data

classmethod id_to_dict(doc_id: str) dict

From document id to key

Parameters

doc_id (str) – Document ID

Returns

A dictionary who holds the key fields and the values

parse()

Parse pattern: From code space to design space

prepare() dict

Prepare pattern: Save Pattern value into .prepare/.pattern_name space

Returns

prepare node dictionary, key is the path

purge_prepare()

Purge prepare workspace

regularize(node_name: str, node_value)

Regularize design node value

Parameters
  • node_name – node name

  • node_value – node value

Returns

value, errors

render_init_dir(runtime_content: dict) dict

Copy Initial Directory to Prepare space

Parameters

runtime_content (dict) – The runtime content to be used to render

Returns

initialized content nodes dictionary

render_template_dir(runtime_content: dict) dict

More complex render process

Parameters

runtime_content

Returns

template_dict

to_db(*, catalog: Optional[dict] = None, ignore_unknown: bool = False, engine: Optional[Type[BaseEngine]] = None)

Translate the runtime data into raw data (materialized form of data)

Parameters
  • catalog (dict) – Data catalog to be parsed

  • ignore_unknown (bool) – When a field is not defined in the document, should we send it back to the database

  • engine – engine to be used for db data conversion

Returns

python dict object

validate()

Validate if all of the component of document follows the predefined rules

Returns

Always None. No exception raised means the validation passed