in pyqldbsamples/transfer_vehicle_ownership.py [0:0]
def validate_and_update_registration(driver, vin, current_owner, new_owner):
"""
Validate the current owner of the given vehicle and transfer its ownership to a new owner.
:type driver: :py:class:`pyqldb.driver.qldb_driver.QldbDriver`
:param driver: An instance of the QldbDriver class.
:type vin: str
:param vin: The VIN of the vehicle to transfer ownership of.
:type current_owner: str
:param current_owner: The GovId of the current owner of the vehicle.
:type new_owner: str
:param new_owner: The GovId of the new owner of the vehicle.
:raises RuntimeError: If unable to verify primary owner.
"""
primary_owner = find_primary_owner_for_vehicle(driver, vin)
if primary_owner is None or primary_owner['GovId'] != current_owner:
raise RuntimeError('Incorrect primary owner identified for vehicle, unable to transfer.')
document_ids = driver.execute_lambda(lambda executor: get_document_ids(executor, Constants.PERSON_TABLE_NAME,
'GovId', new_owner))
update_vehicle_registration(driver, vin, document_ids[0])