Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
    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
Exemplo n.º 7
0
    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
Exemplo n.º 8
0
    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
Exemplo n.º 9
0
    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
Exemplo n.º 10
0
    def do_select_all(self, **kwargs):
        """
        Retrieve all the Hazard Analysis from the RAMSTK Program database.

        This method retrieves all the records from the RAMSTKHazardAnalysis table
        in the connected RAMSTK Program database.  It then adds each to the
        HazardAnalysis data model treelib.Tree().

        :param int hardware_id: the Hardware ID the Hazards are associated
                                with.
        :return: tree; the Tree() of RAMSTKHazardAnalysis data models.
        :rtype: :class:`treelib.Tree`
        """
        _revision_id = kwargs['revision_id']
        _session = RAMSTKDataModel.do_select_all(self)

        for _hazard_analysis in _session.query(RAMSTKHazardAnalysis).filter(
                RAMSTKHazardAnalysis.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 = _hazard_analysis.get_attributes()
            _hazard_analysis.set_attributes(_attributes)
            try:
                self.tree.create_node(
                    'Hardware ID: {0:d}'.format(_hazard_analysis.hardware_id),
                    _hazard_analysis.hardware_id,
                    0,
                    data=None)
            except tree.DuplicatedNodeIdError:
                pass
            _id = '{0:d}.{1:d}'.format(_hazard_analysis.hardware_id,
                                       _hazard_analysis.hazard_id)
            self.tree.create_node(
                _hazard_analysis.potential_hazard,
                _id,
                parent=_hazard_analysis.hardware_id,
                data=_hazard_analysis)

            # pylint: disable=attribute-defined-outside-init
            # It is defined in RAMSTKDataModel.__init__
            self.last_id = max(self.last_id, _hazard_analysis.hazard_id)

        _session.close()

        return self.tree
Exemplo n.º 11
0
    def do_select_all(self, **kwargs):
        """
        Retrieve all the failure Modes from the RAMSTK Program database.

        This method retrieves all the records from the RAMSTKMode table in the
        connected RAMSTK Program database.  It then add each to the Mode data
        model treelib.Tree().

        :param int parent_id: the Function ID or Hardware ID the failure Modes
                              are associated with.
        :return: tree; the Tree() of RAMSTKMode data models.
        :rtype: :class:`treelib.Tree`
        """
        _parent_id = kwargs['parent_id']
        _functional = kwargs['functional']

        _session = RAMSTKDataModel.do_select_all(self)

        if _functional:
            _modes = _session.query(RAMSTKMode).filter(
                RAMSTKMode.function_id == _parent_id).all()
        else:
            _modes = _session.query(RAMSTKMode).filter(
                RAMSTKMode.hardware_id == _parent_id).all()

        for _mode in _modes:
            # We get and then set the attributes to replace any None values
            # (NULL fields in the database) with their default value.
            _attributes = _mode.get_attributes()
            _mode.set_attributes(_attributes)
            self.tree.create_node(
                _mode.description, _mode.mode_id, parent=0, data=_mode)

            # pylint: disable=attribute-defined-outside-init
            # It is defined in RAMSTKDataModel.__init__
            self.last_id = max(self.last_id, _mode.mode_id)

        _session.close()

        return self.tree
Exemplo n.º 12
0
    def do_select_all(self, **kwargs):
        """
        Retrieve all the Functions from the RAMSTK Program database.

        This method retrieves all the records from the RAMSTKFunction table in
        the connected RAMSTK Program database.  It then add each to the
        Function data model treelib.Tree().

        :param int revision_id: the Revision ID to select the Functions for.
        :return: None
        :rtype: None
        """
        _revision_id = kwargs['revision_id']
        _session = RAMSTKDataModel.do_select_all(self)

        for _function in _session.query(RAMSTKFunction).filter(
                RAMSTKFunction.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 = _function.get_attributes()
            _function.set_attributes(_attributes)
            self.tree.create_node(tag=_function.name,
                                  identifier=_function.function_id,
                                  parent=_function.parent_id,
                                  data=_function)

            # pylint: disable=attribute-defined-outside-init
            # It is defined in RAMSTKDataModel.__init__
            self.last_id = max(self.last_id, _function.function_id)

        _session.close()

        # If we're not running a test and there were functions returned,
        # let anyone who cares know the Functions have been selected.
        if not self._test and self.tree.size() > 1:
            pub.sendMessage('retrieved_functions', tree=self.tree)

        return None
Exemplo n.º 13
0
    def do_select_all(self, **kwargs):
        """
        Retrieve all the Validations from the RAMSTK Program database.

        This method retrieves all the records from the RAMSTKValidation table in
        the connected RAMSTK Program database.  It then add each to the Validation
        data model treelib.Tree().

        :return: tree; the Tree() of RAMSTKValidation data models.
        :rtype: :class:`treelib.Tree`
        """
        _revision_id = kwargs['revision_id']
        _session = RAMSTKDataModel.do_select_all(self)

        for _validation in _session.query(RAMSTKValidation).filter(
                RAMSTKValidation.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 = _validation.get_attributes()
            _validation.set_attributes(_attributes)
            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 = max(self.last_id, _validation.validation_id)

        # Now select all the status updates.
        _today = False
        for _status in _session.query(RAMSTKProgramStatus).filter(
                RAMSTKProgramStatus.revision_id == _revision_id).all():
            _attributes = _status.get_attributes()
            _status.set_attributes(_attributes)
            try:
                self.status_tree.create_node(
                    _status.date_status,
                    date_to_ordinal(_status.date_status),
                    parent=0,
                    data=_status)
            except tree.DuplicatedNodeIdError:
                pass
            if _status.date_status == date.today():
                _today = True

        if not _today:
            _status = RAMSTKProgramStatus()
            _status.revision_id = _revision_id
            _status.date_status = date.today()
            _error_code, _msg = RAMSTKDataModel.do_insert(
                self, entities=[
                    _status,
                ])

            if _error_code == 0:
                self.status_tree.create_node(
                    _status.date_status,
                    date_to_ordinal(_status.date_status),
                    parent=0,
                    data=_status)

        _session.close()

        return self.tree
Exemplo n.º 14
0
    def do_select_all(self, **kwargs):
        """
        Retrieve and build the Usage Profile tree for Revision ID.

        :param int revision_id: the Revision ID to retrieve the Usage Profile
                                and build trees for.
        :return: tree; the Usage Profile treelib Tree().
        :rtype: :py:class:`treelib.Tree`
        """
        _revision_id = kwargs['revision_id']
        RAMSTKDataModel.do_select_all(self, **kwargs)

        # Build the tree.  We concatenate the Mission ID and the Phase ID to
        # create the Node() identifier for Mission Phases.  This prevents the
        # likely case when the first Mission and Phase have the same ID (1) in
        # the database from causing problems when building the tree.  Do the
        # same for the environment by concatenating the Environment ID with the
        # Mission ID and Phase ID.
        _missions = self.dtm_mission.do_select_all(
            revision_id=_revision_id).nodes

        # pylint: disable=too-many-nested-blocks
        for _mkey in _missions:
            _mission = _missions[_mkey].data
            if _mission is not None:
                self.tree.create_node(tag=_mission.description,
                                      identifier=_mission.mission_id,
                                      parent=0,
                                      data=_mission)

                # Add the phases, if any, to the mission.
                _phases = self.dtm_phase.do_select_all(
                    mission_id=_mission.mission_id).nodes
                for _pkey in _phases:
                    _phase = _phases[_pkey].data
                    if _phase is not None:
                        _phase_id = int(
                            str(_mission.mission_id) + str(_phase.phase_id))
                        self.tree.create_node(tag=_phase.description,
                                              identifier=_phase_id,
                                              parent=_mission.mission_id,
                                              data=_phase)

                        # Add the environments, if any, to the phase.
                        _environments = self.dtm_environment.do_select_all(
                            phase_id=_phase.phase_id).nodes
                        for _ekey in _environments:
                            _environment = _environments[_ekey].data
                            if _environment is not None:
                                _env_id = int(
                                    str(_mission.mission_id) +
                                    str(_phase.phase_id) +
                                    str(_environment.environment_id))
                                # The parent must be the concatenated phase ID
                                # used in the tree above, not the Phase ID
                                # attribute of the RAMSTKPhase object.
                                self.tree.create_node(tag=_environment.name,
                                                      identifier=_env_id,
                                                      parent=_phase_id,
                                                      data=_environment)

        return self.tree