-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOrcidImportService.cs
More file actions
2367 lines (2208 loc) · 145 KB
/
OrcidImportService.cs
File metadata and controls
2367 lines (2208 loc) · 145 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using api.Models.Log;
using api.Models.Orcid;
using api.Models.Ttv;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Constants = api.Models.Common.Constants;
namespace api.Services
{
/*
* OrcidImportService imports ORCID data into user profile.
*/
public class OrcidImportService : IOrcidImportService
{
private readonly TtvContext _ttvContext;
private readonly IUserProfileService _userProfileService;
private readonly IOrcidApiService _orcidApiService;
private readonly IOrcidJsonParserService _orcidJsonParserService;
private readonly IOrganizationHandlerService _organizationHandlerService;
private readonly IDataSourceHelperService _dataSourceHelperService;
private readonly IUtilityService _utilityService;
private readonly ILogger<OrcidImportService> _logger;
public OrcidImportService(
TtvContext ttvContext, IUserProfileService userProfileService, IOrcidApiService orcidApiService, IOrcidJsonParserService orcidJsonParserService,
IOrganizationHandlerService organizationHandlerService, IUtilityService utilityService, IDataSourceHelperService dataSourceHelperService, ILogger<OrcidImportService> logger)
{
_ttvContext = ttvContext;
_userProfileService = userProfileService;
_orcidApiService = orcidApiService;
_orcidJsonParserService = orcidJsonParserService;
_organizationHandlerService = organizationHandlerService;
_utilityService = utilityService;
_dataSourceHelperService = dataSourceHelperService;
_logger = logger;
}
/*
* Add DimDates entities needed in ORCID record.
*
* For performance improvements, Entity Framework change tracker is disabled when adding new entities in foreach loop.
* _ttvContext.ChangeTracker.AutoDetectChangesEnabled = false;
*/
public async Task AddDimDates(string orcidRecordJson, DateTime currentDateTime, LogUserIdentification logUserIdentification)
{
// Education DimDates
List<OrcidEducation> educations = new();
try
{
educations = _orcidJsonParserService.GetEducations(orcidRecordJson);
}
catch (Exception ex)
{
_logger.LogError(
LogContent.MESSAGE_TEMPLATE,
logUserIdentification,
new LogApiInfo(
action: LogContent.Action.ORCID_RECORD_PARSE,
state: LogContent.ActionState.IN_PROGRESS,
error: true,
message: $"{ex.ToString()}"));
}
try
{
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = false;
foreach (OrcidEducation education in educations)
{
// Start date
DimDate educationStartDate =
await _ttvContext.DimDates.FirstOrDefaultAsync(
dd => dd.Year == education.StartDate.Year &&
dd.Month == education.StartDate.Month &&
dd.Day == education.StartDate.Day);
if (educationStartDate == null)
{
educationStartDate = new DimDate()
{
Year = education.StartDate.Year,
Month = education.StartDate.Month,
Day = education.StartDate.Day,
SourceId = Constants.SourceIdentifiers.PROFILE_API,
SourceDescription = Constants.SourceDescriptions.PROFILE_API,
Created = currentDateTime,
Modified = currentDateTime
};
_ttvContext.DimDates.Add(educationStartDate);
}
// End date
DimDate educationEndDate =
await _ttvContext.DimDates.FirstOrDefaultAsync(
ed => ed.Year == education.EndDate.Year &&
ed.Month == education.EndDate.Month &&
ed.Day == education.EndDate.Day);
if (educationEndDate == null)
{
educationEndDate = new DimDate()
{
Year = education.EndDate.Year,
Month = education.EndDate.Month,
Day = education.EndDate.Day,
SourceId = Constants.SourceIdentifiers.PROFILE_API,
SourceDescription = Constants.SourceDescriptions.PROFILE_API,
Created = currentDateTime,
Modified = currentDateTime
};
_ttvContext.DimDates.Add(educationEndDate);
}
}
}
finally
{
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = true;
await _ttvContext.SaveChangesAsync();
}
// Employment DimDates
List<OrcidEmployment> employments = new();
try
{
employments = _orcidJsonParserService.GetEmployments(orcidRecordJson);
}
catch (Exception ex)
{
_logger.LogError(
LogContent.MESSAGE_TEMPLATE,
logUserIdentification,
new LogApiInfo(
action: LogContent.Action.ORCID_RECORD_PARSE,
state: LogContent.ActionState.IN_PROGRESS,
error: true,
message: $"{ex.ToString()}"));
}
try
{
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = false;
foreach (OrcidEmployment employment in employments)
{
// Start date
DimDate employmentStartDate =
await _ttvContext.DimDates.FirstOrDefaultAsync(
dd => dd.Year == employment.StartDate.Year &&
dd.Month == employment.StartDate.Month &&
dd.Day == employment.StartDate.Day);
if (employmentStartDate == null)
{
employmentStartDate = new DimDate()
{
Year = employment.StartDate.Year,
Month = employment.StartDate.Month,
Day = employment.StartDate.Day,
SourceId = Constants.SourceIdentifiers.PROFILE_API,
SourceDescription = Constants.SourceDescriptions.PROFILE_API,
Created = currentDateTime,
Modified = currentDateTime
};
_ttvContext.DimDates.Add(employmentStartDate);
}
// End date
DimDate employmentEndDate = await _ttvContext.DimDates.FirstOrDefaultAsync(
dd => dd.Year == employment.EndDate.Year &&
dd.Month == employment.EndDate.Month &&
dd.Day == employment.EndDate.Day);
if (employmentEndDate == null)
{
employmentEndDate = new DimDate()
{
Year = employment.EndDate.Year,
Month = employment.EndDate.Month,
Day = employment.EndDate.Day,
SourceId = Constants.SourceIdentifiers.PROFILE_API,
SourceDescription = Constants.SourceDescriptions.PROFILE_API,
Created = currentDateTime,
Modified = currentDateTime
};
_ttvContext.DimDates.Add(employmentEndDate);
}
}
}
finally
{
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = true;
await _ttvContext.SaveChangesAsync();
}
// Funding DimDates
List<OrcidFunding> fundings = new();
try
{
fundings = _orcidJsonParserService.GetFundings(orcidRecordJson);
}
catch (Exception ex)
{
_logger.LogError(
LogContent.MESSAGE_TEMPLATE,
logUserIdentification,
new LogApiInfo(
action: LogContent.Action.ORCID_RECORD_PARSE,
state: LogContent.ActionState.IN_PROGRESS,
error: true,
message: $"{ex.ToString()}"));
}
try
{
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = false;
foreach (OrcidFunding funding in fundings)
{
// Start data
DimDate fundingStartDate =
await _ttvContext.DimDates.FirstOrDefaultAsync(
dd => dd.Year == funding.StartDate.Year &&
dd.Month == funding.StartDate.Month &&
dd.Day == funding.StartDate.Day);
if (fundingStartDate == null)
{
fundingStartDate = new DimDate()
{
Year = funding.StartDate.Year,
Month = funding.StartDate.Month,
Day = funding.StartDate.Day,
SourceId = Constants.SourceIdentifiers.PROFILE_API,
SourceDescription = Constants.SourceDescriptions.PROFILE_API,
Created = currentDateTime,
Modified = currentDateTime
};
_ttvContext.DimDates.Add(fundingStartDate);
}
// End date
DimDate fundingEndDate = await _ttvContext.DimDates.FirstOrDefaultAsync(
dd => dd.Year == funding.EndDate.Year &&
dd.Month == funding.EndDate.Month &&
dd.Day == funding.EndDate.Day);
if (fundingEndDate == null)
{
fundingEndDate = new DimDate()
{
Year = funding.EndDate.Year,
Month = funding.EndDate.Month,
Day = funding.EndDate.Day,
SourceId = Constants.SourceIdentifiers.PROFILE_API,
SourceDescription = Constants.SourceDescriptions.PROFILE_API,
Created = currentDateTime,
Modified = currentDateTime
};
_ttvContext.DimDates.Add(fundingEndDate);
}
}
}
finally
{
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = true;
await _ttvContext.SaveChangesAsync();
}
// Research activity DimDates
List <OrcidResearchActivity> orcidResearchActivity_invitedPositionsAndDistinctionsMembershipsServices = new();
try
{
orcidResearchActivity_invitedPositionsAndDistinctionsMembershipsServices = _orcidJsonParserService.GetProfileOnlyResearchActivityItems(orcidRecordJson);
}
catch (Exception ex)
{
_logger.LogError(
LogContent.MESSAGE_TEMPLATE,
logUserIdentification,
new LogApiInfo(
action: LogContent.Action.ORCID_RECORD_PARSE,
state: LogContent.ActionState.IN_PROGRESS,
error: true,
message: $"{ex.ToString()}"));
}
List<OrcidResearchActivity> orcidResearchActivity_works = new();
try
{
orcidResearchActivity_works = _orcidJsonParserService.GetWorks(orcidRecordJson, processOnlyResearchActivities: true).ResearchActivities;
}
catch (Exception ex)
{
_logger.LogError(
LogContent.MESSAGE_TEMPLATE,
logUserIdentification,
new LogApiInfo(
action: LogContent.Action.ORCID_RECORD_PARSE,
state: LogContent.ActionState.IN_PROGRESS,
error: true,
message: $"{ex.ToString()}"));
}
try
{
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = false;
foreach (OrcidResearchActivity researchActivity in orcidResearchActivity_invitedPositionsAndDistinctionsMembershipsServices.Concat(orcidResearchActivity_works))
{
// Start date
DimDate researchActivityStartDate =
await _ttvContext.DimDates.FirstOrDefaultAsync(
dd => dd.Year == researchActivity.StartDate.Year &&
dd.Month == researchActivity.StartDate.Month &&
dd.Day == researchActivity.StartDate.Day);
if (researchActivityStartDate == null)
{
researchActivityStartDate = new DimDate()
{
Year = researchActivity.StartDate.Year,
Month = researchActivity.StartDate.Month,
Day = researchActivity.StartDate.Day,
SourceId = Constants.SourceIdentifiers.PROFILE_API,
SourceDescription = Constants.SourceDescriptions.PROFILE_API,
Created = currentDateTime,
Modified = currentDateTime
};
_ttvContext.DimDates.Add(researchActivityStartDate);
}
// End date
DimDate researchActivityEndDate =
await _ttvContext.DimDates.FirstOrDefaultAsync(
dd => dd.Year == researchActivity.EndDate.Year &&
dd.Month == researchActivity.EndDate.Month &&
dd.Day == researchActivity.EndDate.Day);
if (researchActivityEndDate == null)
{
researchActivityEndDate = new DimDate()
{
Year = researchActivity.EndDate.Year,
Month = researchActivity.EndDate.Month,
Day = researchActivity.EndDate.Day,
SourceId = Constants.SourceIdentifiers.PROFILE_API,
SourceDescription = Constants.SourceDescriptions.PROFILE_API,
Created = currentDateTime,
Modified = currentDateTime
};
_ttvContext.DimDates.Add(researchActivityEndDate);
}
}
}
finally
{
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = true;
await _ttvContext.SaveChangesAsync();
}
}
/*
* Helper method, add DimWebLink
*/
private DimWebLink GetDimWebLink(
string url,
DateTime currentDateTime,
string label=null,
DimKnownPerson dimKnownPerson=null,
DimProfileOnlyDataset dimProfileOnlyDataset=null,
DimProfileOnlyFundingDecision dimProfileOnlyFundingDecision=null,
DimProfileOnlyResearchActivity dimProfileOnlyResearchActivity=null
)
{
return new DimWebLink()
{
Url = url.Length > 511 ? url.Substring(0, 511) : url, // nvarchar(511) in the DB
LinkLabel = label,
DimKnownPerson = dimKnownPerson,
DimProfileOnlyDataset = dimProfileOnlyDataset,
DimProfileOnlyFundingDecision = dimProfileOnlyFundingDecision,
DimProfileOnlyResearchActivity = dimProfileOnlyResearchActivity,
SourceId = Constants.SourceIdentifiers.PROFILE_API,
SourceDescription = Constants.SourceDescriptions.PROFILE_API,
Created = currentDateTime,
Modified = currentDateTime
};
}
/*
* Import ORCID record json into user profile.
*
* For performance improvements, Entity Framework change tracker is disabled when adding new entities in foreach loop.
* _ttvContext.ChangeTracker.AutoDetectChangesEnabled = false;
*/
public async Task<bool> ImportOrcidRecordJsonIntoUserProfile(int userprofileId, string orcidRecordJson, LogUserIdentification logUserIdentification)
{
// Add DimDates.
DateTime currentDateTime = _utilityService.GetCurrentDateTime();
await AddDimDates(orcidRecordJson, currentDateTime, logUserIdentification);
_ttvContext.ChangeTracker.Clear(); // Detach tracked DimDate entities to free memory
// Get ORCID registered data source id.
int orcidRegisteredDataSourceId = _dataSourceHelperService.DimRegisteredDataSourceId_ORCID;
// Get DimUserProfile and related entities
string queryTag = $"Insert ORCID data, dim_user_profile.id={userprofileId}";
DimUserProfile dimUserProfile = await _ttvContext.DimUserProfiles.TagWith(queryTag).Where(dup => dup.Id == userprofileId)
.Include(dup => dup.DimFieldDisplaySettings)
// DimKnownPerson
.Include(dup => dup.DimKnownPerson)
// DimRegisteredDataSource
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimRegisteredDataSource)
.ThenInclude(drds => drds.DimOrganization)
// DimName
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimName)
// DimWebLink
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimWebLink)
// DimFundingDecision
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimFundingDecision)
// DimProfileOnlyFundingDecision
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimProfileOnlyFundingDecision)
.ThenInclude(fd => fd.DimOrganizationIdFunderNavigation)
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimProfileOnlyFundingDecision)
.ThenInclude(fd => fd.DimWebLinks)
// DimProfileOnlyDataset
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimProfileOnlyDataset)
.ThenInclude(ds => ds.DimWebLinks)
// DimProfileOnlyResearchActivity
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimProfileOnlyResearchActivity)
.ThenInclude(ra => ra.DimOrganization)
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimProfileOnlyResearchActivity)
.ThenInclude(ra => ra.DimWebLinks)
// DimProfileOnlyPublication
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimProfileOnlyPublication)
// DimPid
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimPid)
// DimPidIdOrcidPutCodeNavigation
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimPidIdOrcidPutCodeNavigation)
// DimResearchActivity
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimResearchActivity)
// DimEducation
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimEducation)
.ThenInclude(de => de.DimStartDateNavigation)
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimEducation)
.ThenInclude(de => de.DimEndDateNavigation)
// DimAffiliation
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimAffiliation)
.ThenInclude(da => da.DimOrganization)
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimAffiliation)
.ThenInclude(da => da.StartDateNavigation)
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimAffiliation)
.ThenInclude(da => da.EndDateNavigation)
// DimTelephoneNumber
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimTelephoneNumber)
// DimEmailAddrress
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimEmailAddrress)
// DimResearcherDescription
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimResearcherDescription)
// DimIdentifierlessData
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimIdentifierlessData)
.ThenInclude(did => did.InverseDimIdentifierlessData) // DimIdentifierlessData can have a child entity.
// DimKeyword
.Include(dup => dup.FactFieldValues.Where(ffv => ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId))
.ThenInclude(ffv => ffv.DimKeyword).FirstOrDefaultAsync();
// Helper object to store processed IDs, used when deciding what data needs to be removed.
OrcidImportHelper orcidImportHelper = new();
// Name
DimFieldDisplaySetting dimFieldDisplaySettingsName =
dimUserProfile.DimFieldDisplaySettings.FirstOrDefault(dimFieldDisplaysettingsName => dimFieldDisplaysettingsName.FieldIdentifier == Constants.FieldIdentifiers.PERSON_NAME);
// FactFieldValues
FactFieldValue factFieldValuesName =
dimUserProfile.FactFieldValues.FirstOrDefault(
ffv => ffv.DimFieldDisplaySettings.Id == dimFieldDisplaySettingsName.Id && ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId);
if (factFieldValuesName != null)
{
// Update existing DimName
DimName dimName = factFieldValuesName.DimName;
dimName.LastName = _orcidJsonParserService.GetFamilyName(orcidRecordJson).Value;
dimName.FirstNames = _orcidJsonParserService.GetGivenNames(orcidRecordJson).Value;
dimName.Modified = currentDateTime;
// Update existing FactFieldValue
factFieldValuesName.Modified = currentDateTime;
// Mark as processed
orcidImportHelper.dimNameIds.Add(factFieldValuesName.DimName.Id);
}
else
{
// Create new DimName
DimName dimName = new()
{
LastName = _orcidJsonParserService.GetFamilyName(orcidRecordJson).Value,
FirstNames = _orcidJsonParserService.GetGivenNames(orcidRecordJson).Value,
DimKnownPersonIdConfirmedIdentity = dimUserProfile.DimKnownPersonId,
DimRegisteredDataSourceId = orcidRegisteredDataSourceId,
SourceId = Constants.SourceIdentifiers.PROFILE_API,
SourceDescription = Constants.SourceDescriptions.PROFILE_API,
Created = currentDateTime,
Modified = currentDateTime
};
_ttvContext.DimNames.Add(dimName);
// Create FactFieldValues for name
factFieldValuesName = _userProfileService.GetEmptyFactFieldValue();
factFieldValuesName.DimUserProfile = dimUserProfile;
factFieldValuesName.DimFieldDisplaySettings = dimFieldDisplaySettingsName;
factFieldValuesName.DimRegisteredDataSourceId = orcidRegisteredDataSourceId;
factFieldValuesName.DimName = dimName;
factFieldValuesName.Show = true; // ORCID name is selected by default.
_ttvContext.FactFieldValues.Add(factFieldValuesName);
}
// Other names
List<OrcidOtherName> otherNames = new();
try
{
otherNames = _orcidJsonParserService.GetOtherNames(orcidRecordJson);
}
catch (Exception ex)
{
_logger.LogError(
LogContent.MESSAGE_TEMPLATE,
logUserIdentification,
new LogApiInfo(
action: LogContent.Action.ORCID_RECORD_PARSE,
state: LogContent.ActionState.IN_PROGRESS,
error: true,
message: $"{ex.ToString()}"));
}
// Get DimFieldDisplaySettings for other name
DimFieldDisplaySetting dimFieldDisplaySettingsOtherName =
dimUserProfile.DimFieldDisplaySettings.FirstOrDefault(dfdsOtherName => dfdsOtherName.FieldIdentifier == Constants.FieldIdentifiers.PERSON_OTHER_NAMES);
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = false;
foreach (OrcidOtherName otherName in otherNames)
{
// Check if FactFieldValues contains entry, which points to ORCID put code value in DimPid
FactFieldValue factFieldValuesOtherName =
dimUserProfile.FactFieldValues.FirstOrDefault(ffv =>
ffv.DimFieldDisplaySettings == dimFieldDisplaySettingsOtherName &&
ffv.DimPidIdOrcidPutCode > 0 &&
ffv.DimPidIdOrcidPutCodeNavigation.PidContent == otherName.PutCode.Value.ToString());
if (factFieldValuesOtherName != null)
{
// Update existing DimName
DimName dimName_otherName = factFieldValuesOtherName.DimName;
dimName_otherName.FullName = otherName.Value;
dimName_otherName.Modified = currentDateTime;
// Update existing FactFieldValue
factFieldValuesOtherName.Modified = currentDateTime;
// Mark as processed
orcidImportHelper.dimNameIds.Add(factFieldValuesOtherName.DimName.Id);
}
else
{
// Create new DimName for other name
DimName dimName_otherName = new()
{
FullName = otherName.Value,
DimKnownPersonIdConfirmedIdentity = dimUserProfile.DimKnownPersonId,
DimRegisteredDataSourceId = orcidRegisteredDataSourceId,
SourceId = Constants.SourceIdentifiers.PROFILE_API,
SourceDescription = Constants.SourceDescriptions.PROFILE_API,
Created = currentDateTime,
Modified = currentDateTime
};
_ttvContext.DimNames.Add(dimName_otherName);
// Add other name ORCID put code into DimPid
DimPid dimPidOrcidPutCodeOtherName = _userProfileService.GetEmptyDimPid();
dimPidOrcidPutCodeOtherName.PidContent = otherName.PutCode.GetDbValue();
dimPidOrcidPutCodeOtherName.PidType = Constants.PidTypes.ORCID_PUT_CODE;
dimPidOrcidPutCodeOtherName.DimKnownPersonId = dimUserProfile.DimKnownPersonId;
dimPidOrcidPutCodeOtherName.SourceId = Constants.SourceIdentifiers.PROFILE_API;
_ttvContext.DimPids.Add(dimPidOrcidPutCodeOtherName);
// Create FactFieldValues for other name
factFieldValuesOtherName = _userProfileService.GetEmptyFactFieldValue();
factFieldValuesOtherName.DimUserProfile = dimUserProfile;
factFieldValuesOtherName.DimFieldDisplaySettings = dimFieldDisplaySettingsOtherName;
factFieldValuesOtherName.DimRegisteredDataSourceId = orcidRegisteredDataSourceId;
factFieldValuesOtherName.DimName = dimName_otherName;
factFieldValuesOtherName.DimPidIdOrcidPutCodeNavigation = dimPidOrcidPutCodeOtherName;
factFieldValuesOtherName.Show = _userProfileService.SetFactFieldValuesShow(dimUserProfile, Constants.FieldIdentifiers.PERSON_OTHER_NAMES, logUserIdentification);
_ttvContext.FactFieldValues.Add(factFieldValuesOtherName);
}
}
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = true;
otherNames = null;
// Researcher urls
List<OrcidResearcherUrl> researcherUrls = new();
try
{
researcherUrls = _orcidJsonParserService.GetResearcherUrls(orcidRecordJson);
}
catch (Exception ex)
{
_logger.LogError(
LogContent.MESSAGE_TEMPLATE,
logUserIdentification,
new LogApiInfo(
action: LogContent.Action.ORCID_RECORD_PARSE,
state: LogContent.ActionState.IN_PROGRESS,
error: true,
message: $"{ex.ToString()}"));
}
// Get DimFieldDisplaySettings for weblink
DimFieldDisplaySetting dimFieldDisplaySettingsWebLink =
dimUserProfile.DimFieldDisplaySettings.FirstOrDefault(dfdsWebLink => dfdsWebLink.FieldIdentifier == Constants.FieldIdentifiers.PERSON_WEB_LINK);
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = false;
foreach (OrcidResearcherUrl researchUrl in researcherUrls)
{
// Check if FactFieldValues contains entry, which points to ORCID put code value in DimPid
FactFieldValue factFieldValuesWebLink =
dimUserProfile.FactFieldValues.FirstOrDefault(ffv =>
ffv.DimFieldDisplaySettings == dimFieldDisplaySettingsWebLink &&
ffv.DimPidIdOrcidPutCode > 0 &&
ffv.DimPidIdOrcidPutCodeNavigation.PidContent == researchUrl.PutCode.Value.ToString());
if (factFieldValuesWebLink != null)
{
// Update existing DimWebLink
DimWebLink dimWebLink = factFieldValuesWebLink.DimWebLink;
dimWebLink.Url = researchUrl.Url;
dimWebLink.LinkLabel = researchUrl.UrlName;
dimWebLink.Modified = currentDateTime;
// Update existing FactFieldValue
factFieldValuesWebLink.Modified = currentDateTime;
// Mark as processed
orcidImportHelper.dimWebLinkIds.Add(factFieldValuesWebLink.DimWebLink.Id);
}
else
{
// Create new DimWebLink
DimWebLink dimWebLink = GetDimWebLink(
url: researchUrl.Url,
label: researchUrl.UrlName,
currentDateTime: currentDateTime,
dimKnownPerson: dimUserProfile.DimKnownPerson);
_ttvContext.DimWebLinks.Add(dimWebLink);
// Add web link ORCID put code into DimPid
DimPid dimPidOrcidPutCodeWebLink = _userProfileService.GetEmptyDimPid();
dimPidOrcidPutCodeWebLink.PidContent = researchUrl.PutCode.GetDbValue();
dimPidOrcidPutCodeWebLink.PidType = Constants.PidTypes.ORCID_PUT_CODE;
dimPidOrcidPutCodeWebLink.DimKnownPersonId = dimUserProfile.DimKnownPersonId;
dimPidOrcidPutCodeWebLink.SourceId = Constants.SourceIdentifiers.PROFILE_API;
_ttvContext.DimPids.Add(dimPidOrcidPutCodeWebLink);
// Create FactFieldValues for weblink
factFieldValuesWebLink = _userProfileService.GetEmptyFactFieldValue();
factFieldValuesWebLink.DimUserProfile = dimUserProfile;
factFieldValuesWebLink.DimFieldDisplaySettings = dimFieldDisplaySettingsWebLink;
factFieldValuesWebLink.DimWebLink = dimWebLink;
factFieldValuesWebLink.DimRegisteredDataSourceId = orcidRegisteredDataSourceId;
factFieldValuesWebLink.DimPidIdOrcidPutCodeNavigation = dimPidOrcidPutCodeWebLink;
factFieldValuesWebLink.Show = _userProfileService.SetFactFieldValuesShow(dimUserProfile, Constants.FieldIdentifiers.PERSON_WEB_LINK, logUserIdentification);
_ttvContext.FactFieldValues.Add(factFieldValuesWebLink);
}
}
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = true;
researcherUrls = null;
// Researcher description
OrcidBiography biography = null;
try
{
biography = _orcidJsonParserService.GetBiography(orcidRecordJson);
}
catch (Exception ex)
{
_logger.LogError(
LogContent.MESSAGE_TEMPLATE,
logUserIdentification,
new LogApiInfo(
action: LogContent.Action.ORCID_RECORD_PARSE,
state: LogContent.ActionState.IN_PROGRESS,
error: true,
message: $"{ex.ToString()}"));
}
// Get DimFieldDisplaySettings for researcher description
DimFieldDisplaySetting dimFieldDisplaySettingsResearcherDescription =
dimUserProfile.DimFieldDisplaySettings.FirstOrDefault(
dimFieldDisplaySettingsResearcherDescription => dimFieldDisplaySettingsResearcherDescription.FieldIdentifier == Constants.FieldIdentifiers.PERSON_RESEARCHER_DESCRIPTION);
if (biography != null)
{
// Check if FactFieldValues contains entry pointing to DimResearcherDescriptions, which has ORCID as data source
FactFieldValue factFieldValuesResearcherDescription =
dimUserProfile.FactFieldValues.FirstOrDefault(ffv =>
ffv.DimFieldDisplaySettings == dimFieldDisplaySettingsResearcherDescription &&
ffv.DimResearcherDescriptionId > 0 &&
ffv.DimRegisteredDataSourceId == orcidRegisteredDataSourceId);
if (factFieldValuesResearcherDescription != null)
{
// Update existing DimResearcherDescription
factFieldValuesResearcherDescription.DimResearcherDescription.ResearchDescriptionEn = biography.Value;
factFieldValuesResearcherDescription.DimResearcherDescription.Modified = currentDateTime;
// Update existing FactFieldValue
factFieldValuesResearcherDescription.Modified = currentDateTime;
// Mark as processed
orcidImportHelper.dimResearcherDescriptionIds.Add(factFieldValuesResearcherDescription.DimResearcherDescription.Id);
}
else
{ // Create new DimResearcherDescription
DimResearcherDescription dimResearcherDescription = new ()
{
ResearchDescriptionFi = "",
ResearchDescriptionEn = biography.Value,
ResearchDescriptionSv = "",
SourceId = Constants.SourceIdentifiers.PROFILE_API,
SourceDescription = Constants.SourceDescriptions.PROFILE_API,
Created = currentDateTime,
Modified = currentDateTime,
DimKnownPersonId = dimUserProfile.DimKnownPersonId,
DimRegisteredDataSourceId = orcidRegisteredDataSourceId
};
_ttvContext.DimResearcherDescriptions.Add(dimResearcherDescription);
// Create FactFieldValues for researcher description
factFieldValuesResearcherDescription = _userProfileService.GetEmptyFactFieldValue();
factFieldValuesResearcherDescription.DimUserProfile = dimUserProfile;
factFieldValuesResearcherDescription.DimFieldDisplaySettings = dimFieldDisplaySettingsResearcherDescription;
factFieldValuesResearcherDescription.DimResearcherDescription = dimResearcherDescription;
factFieldValuesResearcherDescription.DimRegisteredDataSourceId = orcidRegisteredDataSourceId;
factFieldValuesResearcherDescription.Show = _userProfileService.SetFactFieldValuesShow(dimUserProfile, Constants.FieldIdentifiers.PERSON_RESEARCHER_DESCRIPTION, logUserIdentification);
_ttvContext.FactFieldValues.Add(factFieldValuesResearcherDescription);
}
}
biography = null;
// Email
List<OrcidEmail> emails = new();
try
{
emails = _orcidJsonParserService.GetEmails(orcidRecordJson);
}
catch (Exception ex)
{
_logger.LogError(
LogContent.MESSAGE_TEMPLATE,
logUserIdentification,
new LogApiInfo(
action: LogContent.Action.ORCID_RECORD_PARSE,
state: LogContent.ActionState.IN_PROGRESS,
error: true,
message: $"{ex.ToString()}"));
}
// Email: DimFieldDisplaySettings
DimFieldDisplaySetting dimFieldDisplaySettingsEmailAddress =
dimUserProfile.DimFieldDisplaySettings.FirstOrDefault(
dimFieldDisplaySettingsEmailAddress => dimFieldDisplaySettingsEmailAddress.FieldIdentifier == Constants.FieldIdentifiers.PERSON_EMAIL_ADDRESS);
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = false;
foreach (OrcidEmail email in emails)
{
// Check if email already exists
FactFieldValue factFieldValuesEmail =
dimUserProfile.FactFieldValues.FirstOrDefault(ffv =>
ffv.DimFieldDisplaySettings == dimFieldDisplaySettingsEmailAddress &&
ffv.DimEmailAddrress.Email == email.Value);
if (factFieldValuesEmail != null)
{
// Email address is matched by value, so no modification is made here.
// Update existing FactFieldValue
factFieldValuesEmail.Modified = currentDateTime;
// Mark as processed
orcidImportHelper.dimEmailAddressIds.Add(factFieldValuesEmail.DimEmailAddrressId);
}
else
{
// Create new DimEmailAddrress
DimEmailAddrress dimEmailAddress = new()
{
Email = email.Value,
SourceId = Constants.SourceIdentifiers.PROFILE_API,
SourceDescription = Constants.SourceDescriptions.PROFILE_API,
Created = currentDateTime,
Modified = currentDateTime,
DimKnownPersonId = dimUserProfile.DimKnownPersonId,
DimRegisteredDataSourceId = orcidRegisteredDataSourceId
};
_ttvContext.DimEmailAddrresses.Add(dimEmailAddress);
// Email: FactFieldValues
factFieldValuesEmail = _userProfileService.GetEmptyFactFieldValue();
factFieldValuesEmail.DimUserProfile = dimUserProfile;
factFieldValuesEmail.DimFieldDisplaySettings = dimFieldDisplaySettingsEmailAddress;
factFieldValuesEmail.DimRegisteredDataSourceId = orcidRegisteredDataSourceId;
factFieldValuesEmail.DimEmailAddrress = dimEmailAddress;
// Add email address ORCID put code into DimPid.
// In ORCID data the email has field put code, but it seems to be always null.
if (email.PutCode.Value != null)
{
DimPid dimPidOrcidPutCodeEmail = _userProfileService.GetEmptyDimPid();
dimPidOrcidPutCodeEmail.PidContent = email.PutCode.GetDbValue();
dimPidOrcidPutCodeEmail.PidType = Constants.PidTypes.ORCID_PUT_CODE;
dimPidOrcidPutCodeEmail.DimKnownPersonId = dimUserProfile.DimKnownPersonId;
dimPidOrcidPutCodeEmail.SourceId = Constants.SourceIdentifiers.PROFILE_API;
_ttvContext.DimPids.Add(dimPidOrcidPutCodeEmail);
factFieldValuesEmail.DimPidIdOrcidPutCodeNavigation = dimPidOrcidPutCodeEmail;
}
factFieldValuesEmail.Show = _userProfileService.SetFactFieldValuesShow(dimUserProfile, Constants.FieldIdentifiers.PERSON_EMAIL_ADDRESS, logUserIdentification);
_ttvContext.FactFieldValues.Add(factFieldValuesEmail);
}
}
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = true;
emails = null;
// Keyword
List<OrcidKeyword> keywords = new();
try
{
keywords = _orcidJsonParserService.GetKeywords(orcidRecordJson);
}
catch (Exception ex)
{
_logger.LogError(
LogContent.MESSAGE_TEMPLATE,
logUserIdentification,
new LogApiInfo(
action: LogContent.Action.ORCID_RECORD_PARSE,
state: LogContent.ActionState.IN_PROGRESS,
error: true,
message: $"{ex.ToString()}"));
}
// Get DimFieldDisplaySettings for keyword
DimFieldDisplaySetting dimFieldDisplaySettingsKeyword =
dimUserProfile.DimFieldDisplaySettings.FirstOrDefault(dfdsKeyword => dfdsKeyword.FieldIdentifier == Constants.FieldIdentifiers.PERSON_KEYWORD);
// Collect list of processed FactFieldValues related to keyword. Needed when deleting keywords.
List<FactFieldValue> processedKeywordFactFieldValues = new();
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = false;
foreach (OrcidKeyword keyword in keywords)
{
// Check if FactFieldValues contains entry, which points to ORCID put code value in DimKeyword
FactFieldValue factFieldValuesKeyword =
dimUserProfile.FactFieldValues.FirstOrDefault(ffv =>
ffv.DimFieldDisplaySettings == dimFieldDisplaySettingsKeyword &&
ffv.DimPidIdOrcidPutCode > 0 &&
ffv.DimPidIdOrcidPutCodeNavigation.PidContent == keyword.PutCode.Value.ToString());
if (factFieldValuesKeyword != null)
{
// Update existing DimKeyword
DimKeyword dimKeyword = factFieldValuesKeyword.DimKeyword;
dimKeyword.Keyword = keyword.Value;
dimKeyword.Modified = currentDateTime;
// Update existing FactFieldValue
factFieldValuesKeyword.Modified = currentDateTime;
// Mark as processed
orcidImportHelper.dimKeywordIds.Add(factFieldValuesKeyword.DimKeywordId);
}
else
{
// Create new DimKeyword
DimKeyword dimKeyword = new()
{
Keyword = keyword.Value,
SourceId = Constants.SourceIdentifiers.PROFILE_API,
SourceDescription = Constants.SourceDescriptions.PROFILE_API,
DimRegisteredDataSourceId = orcidRegisteredDataSourceId,
Created = currentDateTime,
Modified = currentDateTime
};
_ttvContext.DimKeywords.Add(dimKeyword);
// Add keyword ORCID put code into DimPid
DimPid dimPidOrcidPutCodeKeyword = _userProfileService.GetEmptyDimPid();
dimPidOrcidPutCodeKeyword.PidContent = keyword.PutCode.GetDbValue();
dimPidOrcidPutCodeKeyword.PidType = Constants.PidTypes.ORCID_PUT_CODE;
dimPidOrcidPutCodeKeyword.DimKnownPersonId = dimUserProfile.DimKnownPersonId;
dimPidOrcidPutCodeKeyword.SourceId = Constants.SourceIdentifiers.PROFILE_API;
_ttvContext.DimPids.Add(dimPidOrcidPutCodeKeyword);
// Create FactFieldValues for keyword
factFieldValuesKeyword = _userProfileService.GetEmptyFactFieldValue();
factFieldValuesKeyword.DimUserProfile = dimUserProfile;
factFieldValuesKeyword.DimFieldDisplaySettings = dimFieldDisplaySettingsKeyword;
factFieldValuesKeyword.DimRegisteredDataSourceId = orcidRegisteredDataSourceId;
factFieldValuesKeyword.DimKeyword = dimKeyword;
factFieldValuesKeyword.DimPidIdOrcidPutCodeNavigation = dimPidOrcidPutCodeKeyword;
factFieldValuesKeyword.Show = _userProfileService.SetFactFieldValuesShow(dimUserProfile, Constants.FieldIdentifiers.PERSON_KEYWORD, logUserIdentification);
_ttvContext.FactFieldValues.Add(factFieldValuesKeyword);
}
processedKeywordFactFieldValues.Add(factFieldValuesKeyword);
}
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = true;
keywords = null;
// External identifier (=DimPid)
List<OrcidExternalIdentifier> externalIdentifiers = new();
try
{
externalIdentifiers = _orcidJsonParserService.GetExternalIdentifiers(orcidRecordJson);
}
catch (Exception ex)
{
_logger.LogError(
LogContent.MESSAGE_TEMPLATE,
logUserIdentification,
new LogApiInfo(
action: LogContent.Action.ORCID_RECORD_PARSE,
state: LogContent.ActionState.IN_PROGRESS,
error: true,
message: $"{ex.ToString()}"));
}
// Get DimFieldDisplaySettings for keyword
DimFieldDisplaySetting dimFieldDisplaySettingsExternalIdentifier =
dimUserProfile.DimFieldDisplaySettings.FirstOrDefault(dfdsKeyword => dfdsKeyword.FieldIdentifier == Constants.FieldIdentifiers.PERSON_EXTERNAL_IDENTIFIER);
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = false;
foreach (OrcidExternalIdentifier externalIdentifier in externalIdentifiers)
{
// Check if FactFieldValues contains entry, which points to ORCID put code value in DimPid
FactFieldValue factFieldValuesExternalIdentifier =
dimUserProfile.FactFieldValues.FirstOrDefault(ffv =>
ffv.DimFieldDisplaySettings == dimFieldDisplaySettingsExternalIdentifier &&
ffv.DimPidIdOrcidPutCode > 0 &&
ffv.DimPidIdOrcidPutCodeNavigation.PidContent == externalIdentifier.PutCode.Value.ToString());
if (factFieldValuesExternalIdentifier != null)
{
// Update existing DimPid
DimPid dimPid = factFieldValuesExternalIdentifier.DimPid;
dimPid.PidContent = externalIdentifier.ExternalIdValue;
dimPid.PidType = externalIdentifier.ExternalIdType;
dimPid.Modified = currentDateTime;
// Update existing FactFieldValue
factFieldValuesExternalIdentifier.Modified = currentDateTime;
// Mark as processed
orcidImportHelper.dimPidIds.Add(factFieldValuesExternalIdentifier.DimPidId);
}
else
{
// Create new DimPid (external identifier is stored into DimPid)
DimPid dimPid = _userProfileService.GetEmptyDimPid();
dimPid.PidContent = externalIdentifier.ExternalIdValue;
dimPid.PidType = externalIdentifier.ExternalIdType;
dimPid.DimKnownPersonId = dimUserProfile.DimKnownPersonId;
dimPid.SourceId = Constants.SourceIdentifiers.PROFILE_API;
_ttvContext.DimPids.Add(dimPid);
// Add ORCID put code into DimPid
DimPid dimPidOrcidPutCodeExternalIdentifier = _userProfileService.GetEmptyDimPid();
dimPidOrcidPutCodeExternalIdentifier.PidContent = externalIdentifier.PutCode.GetDbValue();
dimPidOrcidPutCodeExternalIdentifier.PidType = Constants.PidTypes.ORCID_PUT_CODE;
dimPidOrcidPutCodeExternalIdentifier.DimKnownPersonId = dimUserProfile.DimKnownPersonId;
dimPidOrcidPutCodeExternalIdentifier.SourceId = Constants.SourceIdentifiers.PROFILE_API;
_ttvContext.DimPids.Add(dimPidOrcidPutCodeExternalIdentifier);
// Create FactFieldValues for external identifier
factFieldValuesExternalIdentifier = _userProfileService.GetEmptyFactFieldValue();
factFieldValuesExternalIdentifier.DimUserProfile = dimUserProfile;
factFieldValuesExternalIdentifier.DimFieldDisplaySettings = dimFieldDisplaySettingsExternalIdentifier;
factFieldValuesExternalIdentifier.DimRegisteredDataSourceId = orcidRegisteredDataSourceId;
factFieldValuesExternalIdentifier.DimPid = dimPid;
factFieldValuesExternalIdentifier.DimPidIdOrcidPutCodeNavigation = dimPidOrcidPutCodeExternalIdentifier;
factFieldValuesExternalIdentifier.Show = _userProfileService.SetFactFieldValuesShow(dimUserProfile, Constants.FieldIdentifiers.PERSON_EXTERNAL_IDENTIFIER, logUserIdentification);
_ttvContext.FactFieldValues.Add(factFieldValuesExternalIdentifier);
}
}
_ttvContext.ChangeTracker.AutoDetectChangesEnabled = true;
externalIdentifiers = null;
// Education
List<OrcidEducation> educations = new();
try
{
educations = _orcidJsonParserService.GetEducations(orcidRecordJson);
}
catch (Exception ex)