def __init__(self, dao, site_dao): """ Initialize an Options data model instance. :param dao: the data access object for communicating with the RAMSTK Program database. :type dao: :class:`ramstk.dao.DAO.DAO` """ RAMSTKDataModel.__init__(self, dao) # Initialize private dictionary attributes. # Initialize private list attributes. # Initialize private scalar attributes. # Initialize public dictionary attributes. # Initialize public list attributes. # Initialize public scalar attributes. self.dtm_site_options = SiteOptionsDataModel(site_dao) self.dtm_program_options = ProgramOptionsDataModel(dao) self.site_options = None self.program_options = None
def do_select_all(self, **kwargs): """ Retrieve and build the Physics of Failure tree for Hardware ID. :param str parent_id: the Hardware ID to retrieve the Physics of Failure information and build trees for. :return: tree; the PhysicsOfFailure treelib Tree(). :rtype: :class:`treelib.Tree` """ _mode_id = kwargs['parent_id'] RAMSTKDataModel.do_select_all(self) _modes = self.dtm_mode.do_select_all( parent_id=_mode_id, functional=False).nodes for _key in _modes: _mode = _modes[_key].data if _mode is not None: _node_id = '0.{0:d}'.format(_mode.mode_id) self.tree.create_node( tag=_mode.description, identifier=_node_id, parent=0, data=_mode) self._do_add_mechanisms(_mode.mode_id, _node_id) return self.tree
def do_select_all(self, **kwargs): """ Retrieve and build the FMEA tree for Parent ID. The Parent ID is one of Function ID (functional FMEA) or Hardware ID (hardware FMEA). :return: tree; the FMEA treelib Tree(). :rtype: :class:`treelib.Tree` """ _parent_id = kwargs['parent_id'] self._functional = kwargs['functional'] RAMSTKDataModel.do_select_all(self) _modes = self.dtm_mode.do_select_all( parent_id=_parent_id, functional=self._functional).nodes for _key in _modes: _mode = _modes[_key].data if _mode is not None: _node_id = '0.' + str(_mode.mode_id) self.tree.create_node( tag=_mode.description, identifier=_node_id, parent=0, data=_mode) if self._functional: self._do_add_causes(_mode.mode_id, _node_id, True) else: self._do_add_mechanisms(_mode.mode_id, _node_id) return self.tree
def __init__(self, dao): """ Initialize a FMEA data model instance. :param dao: the data access object for communicating with the RAMSTK Program database. :type dao: :py:class:`ramstk.dao.DAO.DAO` """ RAMSTKDataModel.__init__(self, dao) # Initialize private dictionary attributes. # Initialize private list attributes. # Initialize private scalar attributes. self._functional = False # Initialize public dictionary attributes. self.item_criticality = {} # Initialize public list attributes. # Initialize public scalar attributes. self.dtm_mode = ModeDataModel(dao) self.dtm_mechanism = MechanismDataModel(dao) self.dtm_cause = CauseDataModel(dao) self.dtm_control = ControlDataModel(dao) self.dtm_action = ActionDataModel(dao)
def __init__(self, dao, site_dao, configuration): """ Initialize a user Preferences data model instance. :param dao: the data access object for communicating with the RAMSTK Program database. :type dao: :class:`ramstk.dao.DAO.DAO` """ RAMSTKDataModel.__init__(self, dao) # Initialize private dictionary attributes. # Initialize private list attributes. # Initialize private scalar attributes. # Initialize public dictionary attributes. self.site_preferences = {} self.user_preferences = {} # Initialize public list attributes. # Initialize public scalar attributes. self.dtm_site_preferences = SitePreferencesDataModel(site_dao) self.dtm_user_preferences = UserPreferencesDataModel( dao, configuration)
def __init__(self, dao): """ Initialize a Validation data model instance. :param dao: the data access object for communicating with the RAMSTK Program database. :type dao: :class:`ramstk.dao.DAO.DAO` """ RAMSTKDataModel.__init__(self, dao) # Initialize private dictionary attributes. # Initialize private list attributes. # Initialize private scalar attributes. # Initialize public dictionary attributes. self.dic_status = {} # Initialize public list attributes. # Initialize public scalar attributes. self.status_tree = Tree() # Add the root to the status Tree(). This is neccessary to allow # multiple entries at the top level as there can only be one root in a # treelib Tree(). Manipulation and viewing of a RAMSTK module tree needs # to ignore the root of the tree. try: self.status_tree.create_node( tag='Program Status', identifier=0, parent=None) except (tree.MultipleRootError, tree.NodeIDAbsentError, tree.DuplicatedNodeIdError): pass
def __init__(self, dao): """ Initialize a PhysicsOfFailure data model instance. :param dao: the data access object for communicating with the RAMSTK Program database. :type dao: :class:`ramstk.dao.DAO.DAO` """ RAMSTKDataModel.__init__(self, dao) # Initialize private dictionary attributes. # Initialize private list attributes. # Initialize private scalar attributes. self._functional = False # Initialize public dictionary attributes. # Initialize public list attributes. # Initialize public scalar attributes. self.dtm_mode = dtmMode(dao) self.dtm_mechanism = dtmMechanism(dao) self.dtm_opload = OpLoadDataModel(dao) self.dtm_opstress = OpStressDataModel(dao) self.dtm_testmethod = TestMethodDataModel(dao)
def __init__(self, dao): """ Initialize a Requirement data model instance. :param dao: the data access object for communicating with the RAMSTK Program database. :type dao: :class:`ramstk.dao.DAO.DAO` """ RAMSTKDataModel.__init__(self, dao)
def __init__(self, dao): """ Initialize a Site Preferences data model instance. :param dao: the data access object for communicating with the RAMSTK Program database. :type dao: :class:`ramstk.dao.DAO.DAO` """ RAMSTKDataModel.__init__(self, dao) # Initialize private dictionary attributes. self._site_preferences = {}
def do_insert(self, **kwargs): """ Add a record to the RAMSTKSimilarItem table. :return: (_error_code, _msg); the error code and associated message. :rtype: (int, str) """ _similar_item = RAMSTKSimilarItem() _similar_item.revision_id = kwargs['revision_id'] _similar_item.hardware_id = kwargs['hardware_id'] _similar_item.parent_id = kwargs['parent_id'] _error_code, _msg = RAMSTKDataModel.do_insert(self, entities=[ _similar_item, ]) self.tree.create_node('SimilarItem ID: {0:d}'.format( _similar_item.hardware_id), _similar_item.hardware_id, parent=_similar_item.parent_id, data=_similar_item) self.last_id = max(self.last_id, _similar_item.hardware_id) return _error_code, _msg
def do_select_all(self, **kwargs): """ Retrieve all the SimilarItems from the RAMSTK Program database. This method retrieves all the records from the RAMSTKSimilarItem table in the connected RAMSTK Program database. It then adds each to the SimilarItem data model treelib.Tree(). :param int revision_id: the Revision ID the SimilarItems are associated with. :return: tree; the Tree() of RAMSTKSimilarItem data models. :rtype: :class:`treelib.Tree` """ _revision_id = kwargs['revision_id'] _session = RAMSTKDataModel.do_select_all(self) for _similar_item in _session.query(RAMSTKSimilarItem).filter( RAMSTKSimilarItem.revision_id == _revision_id).all(): # We get and then set the attributes to replace any None values # (NULL fields in the database) with their default value. _attributes = _similar_item.get_attributes() _similar_item.set_attributes(_attributes) self.tree.create_node('SimilarItem ID: {0:d}'.format( _similar_item.hardware_id), _similar_item.hardware_id, parent=_similar_item.parent_id, data=_similar_item) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = max(self.last_id, _similar_item.hardware_id) _session.close() return self.tree
def do_insert(self, **kwargs): """ Add a record to the RAMSTKFunction table. :return: (_error_code, _msg); the error code and associated message. :rtype: (int, str) """ _function = RAMSTKFunction() _function.revision_id = kwargs['revision_id'] _function.parent_id = kwargs['parent_id'] _error_code, _msg = RAMSTKDataModel.do_insert(self, entities=[ _function, ]) if _error_code == 0: self.tree.create_node(_function.name, _function.function_id, parent=_function.parent_id, data=_function) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = _function.function_id # If we're not running a test, let anyone who cares know a new # Function was inserted. if not self._test: pub.sendMessage('inserted_function', tree=self.tree) return _error_code, _msg
def do_insert(self, **kwargs): """ Add a record to the RAMSTKAction table. :return: (_error_code, _msg); the error code and associated message. :rtype: (int, str) """ _action = RAMSTKAction() _action.cause_id = kwargs['cause_id'] _error_code, _msg = RAMSTKDataModel.do_insert( self, entities=[ _action, ]) if _error_code == 0: self.tree.create_node( _action.action_status, _action.action_id, parent=0, data=_action) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = max(self.last_id, _action.action_id) return _error_code, _msg
def __init__(self, dao): """ Initialize an Export data model instance. :param dao: the data access object for communicating with the RAMSTK Program database. :type dao: :class:`ramstk.dao.DAO.DAO` """ RAMSTKDataModel.__init__(self, dao) # Initialize private dictionary attributes. # Initialize private list attributes. # Initialize private scalar attributes. self._output_data = None
def do_insert(self, **kwargs): """ Add a record to the RAMSTKEnvironment table in the RAMSTK Program database. :return: (_error_code, _msg); the error code and associated message. :rtype: (int, str) """ _phase_id = kwargs['phase_id'] _environment = RAMSTKEnvironment() _environment.phase_id = _phase_id _error_code, _msg = RAMSTKDataModel.do_insert(self, entities=[ _environment, ]) if _error_code == 0: self.tree.create_node(_environment.name, _environment.environment_id, parent=0, data=_environment) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = _environment.environment_id return _error_code, _msg
def do_select_all(self, **kwargs): """ Retrieve all the Actions from the RAMSTK Program database. This method retrieves all the records from the RAMSTKAction table in the connected RAMSTK Program database. It then add each to the Action data model treelib.Tree(). :return: tree; the Tree() of RAMSTKAction data models. :rtype: :class:`treelib.Tree` """ _parent_id = kwargs['parent_id'] _session = RAMSTKDataModel.do_select_all(self) _actions = _session.query(RAMSTKAction).filter( RAMSTKAction.cause_id == _parent_id).all() for _action in _actions: # We get and then set the attributes to replace any None values # (NULL fields in the database) with their default value. _attributes = _action.get_attributes() _action.set_attributes(_attributes) self.tree.create_node( _action.action_status, _action.action_id, parent=0, data=_action) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = max(self.last_id, _action.action_id) _session.close() return self.tree
def do_select_all(self, **kwargs): """ Retrieve all the RAMSTKMission records from the RAMSTK Program database. This method retrieves all the records from the RAMSTKMIssion table in the connected RAMSTK Program database. It then add each to the Mission data model treelib.Tree(). :param int revision_id: the ID of the Revision to retrieve the Mission. :return: tree; the treelib Tree() of RAMSTKMission data models that comprise the Mission tree. :rtype: :class:`treelib.Tree` """ _revision_id = kwargs['revision_id'] _session = RAMSTKDataModel.do_select_all(self, **kwargs) for _mission in _session.query(RAMSTKMission).\ filter(RAMSTKMission.revision_id == _revision_id).all(): self.tree.create_node(_mission.description, _mission.mission_id, parent=0, data=_mission) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = max(self.last_id, _mission.mission_id) _session.close() return self.tree
def do_insert(self, **kwargs): # pylint: disable=unused-argument """ Add a record to the RAMSTKTestMethod table. :return: (_error_code, _msg); the error code and associated message. :rtype: (int, str) """ _testmethod = RAMSTKTestMethod() _testmethod.load_id = kwargs['load_id'] _error_code, _msg = RAMSTKDataModel.do_insert( self, entities=[ _testmethod, ]) if _error_code == 0: self.tree.create_node( _testmethod.description, _testmethod.test_id, parent=0, data=_testmethod) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = max(self.last_id, _testmethod.test_id) return _error_code, _msg
def do_select_all(self, **kwargs): """ Retrieve all the Requirements from the RAMSTK Program database. This method retrieves all the records from the RAMSTKRequirement table in the connected RAMSTK Program database. It then adds each to the Requirement data model treelib.Tree(). :return: tree; the Tree() of RAMSTKRequirement data models. :rtype: :class:`treelib.Tree` """ _revision_id = kwargs['revision_id'] _session = RAMSTKDataModel.do_select_all(self) for _requirement in _session.query(RAMSTKRequirement).filter( RAMSTKRequirement.revision_id == _revision_id).all(): # We get and then set the attributes to replace any None values # (NULL fields in the database) with their default value. _attributes = _requirement.get_attributes() _requirement.set_attributes(_attributes) self.tree.create_node(_requirement.requirement_code, _requirement.requirement_id, parent=_requirement.parent_id, data=_requirement) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = max(self.last_id, _requirement.requirement_id) _session.close() return self.tree
def do_insert(self, **kwargs): """ Add a record to the RAMSTKMissionPhase table in the RAMSTK Program database. :param int mission_id: the Mission ID to add the Mission Phase to. :return: (_error_code, _msg); the error code and associated message. :rtype: (int, str) """ _mission_id = kwargs['mission_id'] _phase = RAMSTKMissionPhase() _phase.mission_id = _mission_id _error_code, _msg = RAMSTKDataModel.do_insert(self, entities=[ _phase, ]) if _error_code == 0: self.tree.create_node(_phase.name, _phase.phase_id, parent=0, data=_phase) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = _phase.phase_id return _error_code, _msg
def do_insert(self, **kwargs): # pylint: disable=unused-argument """ Add a record to the RAMSTKValidation table. :return: (_error_code, _msg); the error code and associated message. :rtype: (int, str) """ _validation = RAMSTKValidation() _validation.revision_id = kwargs['revision_id'] _error_code, _msg = RAMSTKDataModel.do_insert( self, entities=[ _validation, ]) if _error_code == 0: self.tree.create_node( _validation.description, _validation.validation_id, parent=0, data=_validation) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = _validation.validation_id return _error_code, _msg
def do_insert(self, **kwargs): """ Add a record to the RAMSTKAllocation table. :return: (_error_code, _msg); the error code and associated message. :rtype: (int, str) """ _allocation = RAMSTKAllocation() _allocation.revision_id = kwargs['revision_id'] _allocation.hardware_id = kwargs['hardware_id'] _allocation.parent_id = kwargs['parent_id'] _error_code, _msg = RAMSTKDataModel.do_insert(self, entities=[ _allocation, ]) if _error_code == 0: try: self.tree.create_node('Allocation ID: {0:d}'.format( _allocation.hardware_id), _allocation.hardware_id, parent=_allocation.parent_id, data=_allocation) self.last_id = max(self.last_id, _allocation.hardware_id) except DuplicatedNodeIdError: _error_code = 1 _msg = ('RAMSTK ERROR: Node ID {0:s} already exists in the ' 'Allocation tree for Hardware ID {1:s}').format( str(_allocation.hardware_id), str(_allocation.parent_id)) return _error_code, _msg
def do_select_all(self, **kwargs): """ Retrieve all the Stakeholders from the RAMSTK Program database. This method retrieves all the records from the RAMSTKStakeholder table in the connected RAMSTK Program database. It then add each to the Stakeholder data model treelib.Tree(). :return: tree; the treelib Tree() of RAMSTKStakeholder data models. :rtype: :class:`treelib.Tree` """ _revision_id = kwargs['revision_id'] _session = RAMSTKDataModel.do_select_all(self, **kwargs) for _stakeholder in _session.query(RAMSTKStakeholder).filter( RAMSTKStakeholder.revision_id == _revision_id).all(): self.tree.create_node(_stakeholder.description, _stakeholder.stakeholder_id, parent=0, data=_stakeholder) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = max(self.last_id, _stakeholder.stakeholder_id) _session.close() return self.tree
def do_delete(self, node_id): """ Remove a record from the RAMSTKFunction table. :param int node_id: the ID of the RAMSTKFunction record to be removed from the RAMSTK Program database. :return: (_error_code, _msg); the error code and associated message. :rtype: (int, str) """ _error_code, _msg = RAMSTKDataModel.do_delete(self, node_id) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ if _error_code != 0: _error_code = 2005 _msg = ("RAMSTK ERROR: Attempted to delete non-existent Function " "ID {0:s}.").format(str(node_id)) else: self.last_id = max(self.tree.nodes.keys()) # If we're not running a test, let anyone who cares know a Function # was deleted. if not self._test: pub.sendMessage('deleted_function', tree=self.tree) return _error_code, _msg
def do_insert(self, **kwargs): """ Add a record to the RAMSTKStakeholder table. :param int revision_id: the Revision ID to add the Failure Definition against. :return: (_error_code, _msg); the error code and associated message. :rtype: (int, str) """ _revision_id = kwargs['revision_id'] _stakeholder = RAMSTKStakeholder() _stakeholder.revision_id = _revision_id _error_code, _msg = RAMSTKDataModel.do_insert(self, entities=[ _stakeholder, ]) if _error_code == 0: self.tree.create_node(_stakeholder.description, _stakeholder.stakeholder_id, parent=0, data=_stakeholder) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = max(self.last_id, _stakeholder.stakeholder_id) return _error_code, _msg
def __init__(self, dao, **kwargs): """ Initialize a Function data model instance. :param dao: the data access object for communicating with the RAMSTK Program database. :type dao: :class:`ramstk.dao.DAO.DAO` """ RAMSTKDataModel.__init__(self, dao) # Initialize private dictionary attributes. # Initialize private list attributes. # Initialize private scalar attributes. self._test = kwargs['test']
def do_select_all(self, **kwargs): """ Retrieve all the operating loads from the RAMSTK Program database. This method retrieves all the records from the RAMSTKOpLoad table in the connected RAMSTK Program database. It then add each to the OpLoad data model treelib.Tree(). :param int parent_id: the Mechanism ID the operating loads are associated with. :return: tree; the Tree() of RAMSTKOpLoad data models. :rtype: :class:`treelib.Tree` """ _parent_id = kwargs['parent_id'] _session = RAMSTKDataModel.do_select_all(self) _oploads = _session.query(RAMSTKOpLoad).filter( RAMSTKOpLoad.mechanism_id == _parent_id).all() for _opload in _oploads: # We get and then set the attributes to replace any None values # (NULL fields in the database) with their default value. _attributes = _opload.get_attributes() _opload.set_attributes(_attributes) self.tree.create_node( _opload.description, _opload.load_id, parent=0, data=_opload) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = max(self.last_id, _opload.load_id) _session.close() return self.tree
def do_select_all(self, **kwargs): """ Retrieve all the RAMSTKEnvironment records from the RAMSTK Program database. :param int phase_id: the Mission Phase ID to select the Environments for. :return: tree; the treelib Tree() of RAMSTKEnvironment data models that comprise the Environment tree. :rtype: :py:class:`treelib.Tree` """ _phase_id = kwargs['phase_id'] _session = RAMSTKDataModel.do_select_all(self) for _environment in _session.query(RAMSTKEnvironment).\ filter(RAMSTKEnvironment.phase_id == _phase_id).all(): self.tree.create_node(_environment.name, _environment.environment_id, parent=0, data=_environment) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = max(self.last_id, _environment.environment_id) _session.close() return self.tree
def do_insert(self, **kwargs): """ Add a record to the RAMSTKRequirement table. :return: (_error_code, _msg); the error code and associated message. :rtype: (int, str) """ _requirement = RAMSTKRequirement() _requirement.revision_id = kwargs['revision_id'] _requirement.parent_id = kwargs['parent_id'] _error_code, _msg = RAMSTKDataModel.do_insert(self, entities=[ _requirement, ]) if _error_code == 0: self.tree.create_node(_requirement.requirement_code, _requirement.requirement_id, parent=_requirement.parent_id, data=_requirement) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = _requirement.requirement_id return _error_code, _msg
def do_insert(self, **kwargs): """ Add a record to the RAMSTKMechanism table. :return: (_error_code, _msg); the error code and associated message. :rtype: (int, str) """ _mechanism = RAMSTKMechanism() _mechanism.mode_id = kwargs['mode_id'] _error_code, _msg = RAMSTKDataModel.do_insert( self, entities=[ _mechanism, ]) if _error_code == 0: self.tree.create_node( _mechanism.description, _mechanism.mechanism_id, parent=0, data=_mechanism) # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKDataModel.__init__ self.last_id = max(self.last_id, _mechanism.mechanism_id) return _error_code, _msg