@@ -4431,66 +4431,44 @@ async def query_da_personal_data_in_wallet(self, personal_data_id: str = None, m
4431
4431
4432
4432
try :
4433
4433
4434
- # Query for the old data agreement record by id
4435
- personal_data_records : typing .List [DataAgreementPersonalDataRecord ] = await DataAgreementPersonalDataRecord .query (
4436
- self .context ,
4437
- )
4434
+ # Query all data agreements (non-deleted)
4435
+ data_agreement_records : typing .List [DataAgreementV1Record ] = await DataAgreementV1Record .retrieve_all_non_deleted_data_agreements (self .context )
4438
4436
4439
- matched_personal_data_records = []
4437
+ personal_data = []
4440
4438
4441
- if personal_data_id :
4442
- for pd in personal_data_records :
4443
- if pd .personal_data_id == personal_data_id :
4444
- matched_personal_data_records .append (pd )
4445
- else :
4446
- matched_personal_data_records = personal_data_records
4447
-
4448
- serialised_personal_data_records = []
4439
+ for data_agreement_record in data_agreement_records :
4440
+ data_agreement_dict : DataAgreementV1 = DataAgreementV1Schema ().load (
4441
+ data_agreement_record .data_agreement )
4449
4442
4450
- # Iterate through personal data
4451
- for pd in matched_personal_data_records :
4452
-
4453
- try :
4454
-
4455
- # Fetch data agreement template.
4456
- data_agreement_record : DataAgreementV1Record = await DataAgreementV1Record .retrieve_non_deleted_data_agreement_by_id (
4457
- self .context ,
4458
- pd .da_template_id
4459
- )
4460
-
4461
- data_agreement_dict : DataAgreementV1 = DataAgreementV1Schema ().load (
4462
- data_agreement_record .data_agreement )
4443
+ # Query personal data
4444
+ for pd in data_agreement_dict .personal_data :
4463
4445
4464
4446
temp_pd = {
4465
- "attribute_id" : pd .personal_data_id ,
4447
+ "attribute_id" : pd .attribute_id ,
4466
4448
"attribute_name" : pd .attribute_name ,
4467
4449
"attribute_description" : pd .attribute_description ,
4468
4450
"data_agreement" : {
4469
4451
"data_agreement_id" : data_agreement_record .data_agreement_record_id ,
4470
4452
"method_of_use" : data_agreement_record .method_of_use ,
4471
4453
"data_agreement_usage_purpose" : data_agreement_dict .usage_purpose ,
4472
- "publish_flag" : data_agreement_record .is_published
4454
+ "publish_flag" : data_agreement_record .is_published
4473
4455
},
4474
- "created_at" : str_to_epoch (pd .created_at ),
4475
- "updated_at" : str_to_epoch (pd .updated_at ),
4456
+ "created_at" : str_to_epoch (data_agreement_record .created_at ),
4457
+ "updated_at" : str_to_epoch (data_agreement_record .updated_at ),
4476
4458
}
4477
-
4478
4459
if method_of_use :
4479
4460
if data_agreement_record .method_of_use == method_of_use :
4480
- serialised_personal_data_records .append (temp_pd )
4461
+ personal_data .append (temp_pd )
4481
4462
else :
4482
- serialised_personal_data_records .append (temp_pd )
4463
+ personal_data .append (temp_pd )
4483
4464
4484
- except (StorageNotFoundError , StorageDuplicateError ) as e :
4485
- # Continue to other personal data records.
4486
- continue
4487
4465
4488
4466
return self .serialize_personal_data_record (
4489
- personal_data_records = serialised_personal_data_records ,
4467
+ personal_data_records = personal_data ,
4490
4468
is_list = True
4491
4469
)
4492
4470
4493
- except (StorageSearchError ) as e :
4471
+ except (StorageSearchError , StorageNotFoundError , StorageDuplicateError ) as e :
4494
4472
# Raise an error
4495
4473
raise ADAManagerError (
4496
4474
f"Failed to fetch all data agreements from wallet: { e } "
0 commit comments