src/pds_doi_service/core/outputs/doi_validator.py
def _check_field_workflow(self, doi: Doi):
        """
        Check that there is not a record in the Sqlite database with same
        identifier but a higher status than the current action (see workflow_order)

        Parameters
        ----------
        doi : Doi
            The parsed Doi object to check the status of.

        Raises
        ------
        UnexpectedDOIActionException
            If the provided Doi object has an unrecognized status assigned, or if
            the previous status for the Doi is higher in the workflow ordering than
            the current status.

        """
        if doi.status is not None and doi.status not in self.workflow_order:
            msg = (
                f"Unexpected DOI status of '{doi.status.value}' from label. "
                f"Valid values are "
                f"{[DoiStatus(key).value for key in self.workflow_order.keys()]}"
            )
            logger.error(msg)
            raise UnexpectedDOIActionException(msg)

        # The database expects each field to be a list.
        query_criterias = {"doi": [doi.doi]}

        # Query database for rows with given doi value.
        columns, rows = self._database_obj.select_latest_rows(query_criterias)

        for row in rows:
            existing_record = dict(zip(columns, row))
            doi_str = existing_record["doi"]
            prev_status = existing_record["status"]

            # Check the rankings of the current and previous status to see if
            # we're moving backwards through the workflow. For example, a status
            # of 'Findable' (5) is higher than 'Review' (3), so a released
            # DOI record being moved back to review would trip this warning.
            if self.workflow_order[prev_status] > self.workflow_order[doi.status]:  # type: ignore
                msg = (
                    f"There is a record for identifier {doi.pds_identifier} "
                    f"(DOI: {doi_str}) with status: '{prev_status.lower()}'.\n"
                    f"Are you sure you want to restart the workflow from step "
                    f"'{doi.status}'?\nIf so, use the --force flag to bypass the "
                    f"results of this check."
                )

                raise UnexpectedDOIActionException(msg)

        Check that there is not a record in the Sqlite database with same
        identifier but a higher status than the current action (see workflow_order)

        Parameters
        ----------
        doi : Doi
            The parsed Doi object to check the status of.

        Raises
        ------
        UnexpectedDOIActionException
            If the provided Doi object has an unrecognized status assigned, or if
            the previous status for the Doi is higher in the workflow ordering than
            the current status.

        
Check that there is not a record in the Sqlite database with same
identifier but a higher status than the current action

Parameters

doi : Doi
The parsed Doi object to check the status of.

Raises

UnexpectedDOIActionException
If the provided Doi object has an unrecognized status assigned, or if
the previous status for the Doi is higher in the workflow ordering than
the current status.
Check that there is not a record in the Sqlite database with same identifier but a higher status than the current action Parameters doi : Doi The parsed Doi object to check the status of . Raises UnexpectedDOIActionException If the provided Doi object has an unrecognized status assigned or if the previous status for the Doi is higher in the workflow ordering than the current status .
def _check_field_workflow(self, doi: Doi):
        if doi.status is not None and doi.status not in self.workflow_order:
            msg = (
                f"Unexpected DOI status of '{doi.status.value}' from label. "
                f"Valid values are "
                f"{[DoiStatus(key).value for key in self.workflow_order.keys()]}"
            )
            logger.error(msg)
            raise UnexpectedDOIActionException(msg)
        query_criterias = {"doi": [doi.doi]}
        columns, rows = self._database_obj.select_latest_rows(query_criterias)
        for row in rows:
            existing_record = dict(zip(columns, row))
            doi_str = existing_record["doi"]
            prev_status = existing_record["status"]
            if self.workflow_order[prev_status] > self.workflow_order[doi.status]:  
                msg = (
                    f"There is a record for identifier {doi.pds_identifier} "
                    f"(DOI: {doi_str}) with status: '{prev_status.lower()}'.\n"
                    f"Are you sure you want to restart the workflow from step "
                    f"'{doi.status}'?\nIf so, use the --force flag to bypass the "
                    f"results of this check."
                )
                raise UnexpectedDOIActionException(msg)
def _check_field_workflow ( self , doi : Doi ) : if doi . status is not None and doi . status not in self . workflow_order : msg = ( f"Unexpected DOI status of '{doi.status.value}' from label. " f"Valid values are " f"{[DoiStatus(key).value for key in self.workflow_order.keys()]}" ) logger . error ( msg ) raise UnexpectedDOIActionException ( msg ) query_criterias = { "doi" : [ doi . doi ] } columns , rows = self . _database_obj . select_latest_rows ( query_criterias ) for row in rows : existing_record = dict ( zip ( columns , row ) ) doi_str = existing_record [ "doi" ] prev_status = existing_record [ "status" ] if self . workflow_order [ prev_status ] > self . workflow_order [ doi . status ] : msg = ( f"There is a record for identifier {doi.pds_identifier} " f"(DOI: {doi_str}) with status: '{prev_status.lower()}'.\n" f"Are you sure you want to restart the workflow from step " f"'{doi.status}'?\nIf so, use the --force flag to bypass the " f"results of this check." ) raise UnexpectedDOIActionException ( msg )
Check that there is not a record in the Sqlite database with same
identifier but a higher status than the current action (see workflow_order)
Check that there is not a record in the Sqlite database with same identifier but a higher status than the current action ( see workflow_order )
"""
        Check that there is not a record in the Sqlite database with same
        identifier but a higher status than the current action (see workflow_order)

        Parameters
        ----------
        doi : Doi
            The parsed Doi object to check the status of.

        Raises
        ------
        UnexpectedDOIActionException
            If the provided Doi object has an unrecognized status assigned, or if
            the previous status for the Doi is higher in the workflow ordering than
            the current status.

        """ # The database expects each field to be a list. # Query database for rows with given doi value. # Check the rankings of the current and previous status to see if # we're moving backwards through the workflow. For example, a status # of 'Findable' (5) is higher than 'Review' (3), so a released # DOI record being moved back to review would trip this warning. # type: ignore
self
doi
Doi