Adds models for each child state of the state

        :param bool load_meta_data: Whether to load the meta data of the child state
334913
def _load_child_state_models(self, load_meta_data):
        
        self.states = {}
        # Create model for each child class
        child_states = self.state.states
        for child_state in child_states.values():
            # Create hierarchy
            model_class = get_state_model_class_for_state(child_state)
            if model_class is not None:
                self._add_model(self.states, child_state, model_class, child_state.state_id, load_meta_data)
            else:
                logger.error("Unknown state type '{type:s}'. Cannot create model.".format(type=type(child_state)))
392091
def load_models(module):
    """"""
    modules = _import_submodules(module)
    return {m for module in modules for m in filter(
        _check_model, (getattr(module, name) for name in dir(module))
    )}
528485
def _load_outcome_models(self):
        
        self.outcomes = []
        for outcome in self.state.outcomes.values():
            self._add_model(self.outcomes, outcome, OutcomeModel)
1217673
def add_children(self, *children, **kwargs):
        """"""
        for child in children:
            self.add_child(child, **kwargs)
1215425
protected function loadMetaData()
    {
        // Retrieve the transient
        $transientKey = sprintf('WPMVC\Models\Post(%d)::loadMetaData', $this->id());
        $metaData = WP::getTransient($transientKey);
        // If it doesn't exist
        if (!$metaData) {
            $keys = WP::getPostCustom($this->id());
            $metaData = array();
            if ($keys && is_array($keys) && count($keys)) {
                foreach ($keys as $key => $value) {
                    // If only 1 value, it's a string
                    if (is_array($value) && count($value) == 1) {
                        $metaData[$key] = $value[0];
                    } else {
                        $metaData[$key] = $value;
                    }
                }
            }
            WP::setTransient($transientKey, $metaData, static::$transientTimeout);
        }
        $this->metaData = $metaData;
    }
773300
def add_to_fields(self):
        ''''''
        meta = self.model._meta
        meta.scalarfields.append(self)
        if self.index:
            meta.indices.append(self)
229907
def update_child_models(self, _, name, info):
        

        # Update is_start flag in child states if the start state has changed (eventually)
        if info.method_name in ['start_state_id', 'add_transition', 'remove_transition']:
            self.update_child_is_start()

        if info.method_name in ["add_transition", "remove_transition", "transitions"]:
            (model_list, data_list, model_name, model_class, model_key) = self._get_model_info("transition")
        elif info.method_name in ["add_data_flow", "remove_data_flow", "data_flows"]:
            (model_list, data_list, model_name, model_class, model_key) = self._get_model_info("data_flow")
        elif info.method_name in ["add_state", "remove_state", "states"]:
            (model_list, data_list, model_name, model_class, model_key) = self._get_model_info("state", info)
        elif info.method_name in ["add_scoped_variable", "remove_scoped_variable", "scoped_variables"]:
            (model_list, data_list, model_name, model_class, model_key) = self._get_model_info("scoped_variable")
        else:
            return

        if isinstance(info.result, Exception):
            # Do nothing if the observed function raised an exception
            pass
        elif "add" in info.method_name:
            self.add_missing_model(model_list, data_list, model_name, model_class, model_key)
        elif "remove" in info.method_name:
            destroy = info.kwargs.get('destroy', True)
            recursive = info.kwargs.get('recursive', True)
            self.remove_specific_model(model_list, info.result, model_key, recursive, destroy)
        elif info.method_name in ["transitions", "data_flows", "states", "scoped_variables"]:
            self.re_initiate_model_list(model_list, data_list, model_name, model_class, model_key)
1075080
def add_meta(self, name, value):
        
        for mt in self.metas:
            if mt.name == name:
                mt.value = value
                return self
        self.metas.append(MetaDef(name, value))
        return self
974383
def process_models(attrs, base_model_class):
        
        attrs.update(base_model_class._DEFAULT_BASE_FIELDS)
        attrs['_instance_registry'] = set()
        attrs['_is_unpermitted_fields_set'] = False
        attrs['save_meta_data'] = None
        attrs['_pre_save_hook_called'] = False
        attrs['_post_save_hook_called'] = False
        DEFAULT_META = {'bucket_type': settings.DEFAULT_BUCKET_TYPE,
                        'field_permissions': {},
                        'app': 'main',
                        'list_fields': [],
                        'list_filters': [],
                        'search_fields': [],
                        'fake_model': False,
                        }
        if 'Meta' not in attrs:
            attrs['Meta'] = type('Meta', (object,), DEFAULT_META)
        else:
            for k, v in DEFAULT_META.items():
                if k not in attrs['Meta'].__dict__:
                    setattr(attrs['Meta'], k, v)
208041
def modelresource_factory(model, resource_class=ModelResource):
    
    attrs = {'model': model}
    Meta = type(str('Meta'), (object,), attrs)

    class_name = model.__name__ + str('Resource')

    class_attrs = {
        'Meta': Meta,
    }

    metaclass = ModelDeclarativeMetaclass
    return metaclass(class_name, (resource_class,), class_attrs)
1124682
def add(self, child):
        

        if isinstance(child, With):
            self.add_with(child)
        elif isinstance(child, EventConnection):
            self.add_event_connection(child)
        elif isinstance(child, ChildInstance):
            self.add_child_instance(child)
        elif isinstance(child, MultiInstantiate):
            self.add_multi_instantiate(child)
        elif isinstance(child, ForEach):
            self.add_for_each(child)
        else:
            raise ModelError('Unsupported child element')
638201
def update(self, changed_state_model=None, with_expand=False):
        
        if not self.view_is_registered:
            return

        # define initial state-model for update
        if changed_state_model is None:
            # reset all
            parent_row_iter = None
            self.state_row_iter_dict_by_state_path.clear()
            self.tree_store.clear()
            if self._selected_sm_model:
                changed_state_model = self._selected_sm_model.root_state
            else:
                return
        else:  # pick
            if changed_state_model.state.is_root_state:
                parent_row_iter = self.state_row_iter_dict_by_state_path[changed_state_model.state.get_path()]
            else:
                if changed_state_model.state.is_root_state_of_library:
                    # because either lib-state or lib-state-root is in tree the next higher hierarchy state is updated
                    changed_upper_state_m = changed_state_model.parent.parent
                else:
                    changed_upper_state_m = changed_state_model.parent
                # TODO check the work around of the next 2 lines while refactoring -> it is a check to be more robust
                while changed_upper_state_m.state.get_path() not in self.state_row_iter_dict_by_state_path:
                    # show Warning because because avoided method states_update
                    logger.warning("Take a parent state because this is not in.")
                    changed_upper_state_m = changed_upper_state_m.parent
                parent_row_iter = self.state_row_iter_dict_by_state_path[changed_upper_state_m.state.get_path()]

        # do recursive update
        self.insert_and_update_recursively(parent_row_iter, changed_state_model, with_expand)
162781
public function add_meta( $meta_key, $meta_value ) {
		return add_metadata( $this->meta_type, $this->get_id(), $meta_key, $meta_value, true );
	}
706268
public function fill_meta($meta_data) {
	foreach ($meta_data as $key => $single_meta_data) {
		$this->add_meta($key, $single_meta_data);
	}
}
20154
def load_state_dict(self, state_dict: Dict[str, Any]) -> None:
        
        self.__dict__.update(state_dict)
784262
def _load_output_data_port_models(self):
        
        self.output_data_ports = []
        for output_data_port in self.state.output_data_ports.values():
            self._add_model(self.output_data_ports, output_data_port, DataPortModel)
931586
def add_model(self, model_type: str, model_uuid: str, meta: dict,
                  template_model: Template, update_default: bool=False):
        """"""
        if update_default or model_type not in self.meta:
            self.meta[model_type] = meta["default"]
        model_meta = meta["model"]
        self.models.setdefault(model_type, {})[model_uuid] = model_meta
        model_directory = os.path.join(self.cached_repo, model_type)
        os.makedirs(model_directory, exist_ok=True)
        model = os.path.join(model_directory, model_uuid + ".md")
        if os.path.exists(model):
            os.remove(model)
        links = {}
        for m_type, items in self.models.items():
            for uuid in items:
                if uuid in model_meta["dependencies"]:
                    links[uuid] = os.path.join("/", m_type, "%s.md" % uuid)
        with open(model, "w") as fout:
            fout.write(template_model.render(model_type=model_type, model_uuid=model_uuid,
                                             meta=model_meta, links=links))
        git.add(self.cached_repo, [model])
        self._log.info("Added %s", model)