src/pds_doi_service/core/outputs/doi_validator.py
def _check_for_preexisting_doi(self, doi: Doi):
        """
        For Doi objects with DOI already assigned, this check ensures the DOI
        value is not already in use for a different PDS identifier.

        Parameters
        ----------
        doi : Doi
            The Doi object to validate.

        Raises
        ------
        ValueError
            If the provided Doi object does not have a DOI value assigned to check.
        UnexpectedDOIActionException
            If the check fails.

        """
        if not doi.doi:
            raise ValueError(f"Provided DOI object (id {doi.pds_identifier}) does not have a DOI value assigned.")

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

        # Query database for rows with given DOI value (should only ever be
        # at most one)
        columns, rows = self._database_obj.select_latest_rows(query_criterias)

        for row in rows:
            existing_record = dict(zip(columns, row))

            if doi.pds_identifier != existing_record["identifier"]:
                raise UnexpectedDOIActionException(
                    f"The DOI ({doi.doi}) provided for record identifier "
                    f"{doi.pds_identifier} is already in use for record "
                    f"{rows[0][columns.index('identifier')]}.\n"
                    f"Are you sure you want to assign the new identifier {doi.pds_identifier}?\n"
                    f"If so, use the --force flag to bypass this check."
                )

        For Doi objects with DOI already assigned, this check ensures the DOI
        value is not already in use for a different PDS identifier.

        Parameters
        ----------
        doi : Doi
            The Doi object to validate.

        Raises
        ------
        ValueError
            If the provided Doi object does not have a DOI value assigned to check.
        UnexpectedDOIActionException
            If the check fails.

        
For Doi objects with DOI already assigned, this check ensures the DOI
value is not already in use for a different PDS identifier.

Parameters

doi : Doi
The Doi object to validate.

Raises

ValueError
If the provided Doi object does not have a DOI value assigned to check.
UnexpectedDOIActionException
If the check fails.
For Doi objects with DOI already assigned this check ensures the DOI value is not already in use for a different PDS identifier . Parameters doi : Doi The Doi object to validate . Raises ValueError If the provided Doi object does not have a DOI value assigned to check . UnexpectedDOIActionException If the check fails .
def _check_for_preexisting_doi(self, doi: Doi):
        if not doi.doi:
            raise ValueError(f"Provided DOI object (id {doi.pds_identifier}) does not have a DOI value assigned.")
        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))
            if doi.pds_identifier != existing_record["identifier"]:
                raise UnexpectedDOIActionException(
                    f"The DOI ({doi.doi}) provided for record identifier "
                    f"{doi.pds_identifier} is already in use for record "
                    f"{rows[0][columns.index('identifier')]}.\n"
                    f"Are you sure you want to assign the new identifier {doi.pds_identifier}?\n"
                    f"If so, use the --force flag to bypass this check."
                )
def _check_for_preexisting_doi ( self , doi : Doi ) : if not doi . doi : raise ValueError ( f"Provided DOI object (id {doi.pds_identifier}) does not have a DOI value assigned." ) 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 ) ) if doi . pds_identifier != existing_record [ "identifier" ] : raise UnexpectedDOIActionException ( f"The DOI ({doi.doi}) provided for record identifier " f"{doi.pds_identifier} is already in use for record " f"{rows[0][columns.index('identifier')]}.\n" f"Are you sure you want to assign the new identifier {doi.pds_identifier}?\n" f"If so, use the --force flag to bypass this check." )
For Doi objects with DOI already assigned, this check ensures the DOI
value is not already in use for a different PDS identifier.
For Doi objects with DOI already assigned this check ensures the DOI value is not already in use for a different PDS identifier .
"""
        For Doi objects with DOI already assigned, this check ensures the DOI
        value is not already in use for a different PDS identifier.

        Parameters
        ----------
        doi : Doi
            The Doi object to validate.

        Raises
        ------
        ValueError
            If the provided Doi object does not have a DOI value assigned to check.
        UnexpectedDOIActionException
            If the check fails.

        """ # The database expects each field to be a list. # Query database for rows with given DOI value (should only ever be # at most one)
self
doi
Doi