11using LcmCrdt . Changes ;
22using SIL . Harmony ;
3+ using UUIDNext ;
34
45namespace LcmCrdt . Objects ;
56
@@ -15,20 +16,38 @@ public static class PreDefinedData
1516 public static readonly Guid AdjectivePartOfSpeechId = new ( "30d07580-5052-4d91-bc24-469b8b2d7df9" ) ;
1617 public static readonly Guid AdverbPartOfSpeechId = new ( "46e4fe08-ffa0-4c8b-bf98-2c56f38904d9" ) ;
1718
18- internal static async Task AddPredefinedComplexFormTypes ( DataModel dataModel , Guid clientId )
19+ // Seed commit-ids are derived per-project (UUIDv5 namespaced on projectId) so each project
20+ // owns its own row in LexBox's CrdtCommits table — a shared constant id would collide on the
21+ // primary key and the seed would get attributed to whichever project pushed first.
22+ public static Guid ComplexFormTypesSeedCommitId ( Guid projectId ) =>
23+ Uuid . NewNameBased ( projectId , "complex-form-types-seed" ) ;
24+
25+ public static Guid SemanticDomainsSeedCommitId ( Guid projectId ) =>
26+ Uuid . NewNameBased ( projectId , "semantic-domains-seed" ) ;
27+
28+ public static Guid PartsOfSpeechSeedCommitId ( Guid projectId ) =>
29+ Uuid . NewNameBased ( projectId , "parts-of-speech-seed" ) ;
30+
31+ public static Guid CustomViewsSeedCommitId ( Guid projectId ) =>
32+ Uuid . NewNameBased ( projectId , "custom-views-seed" ) ;
33+
34+ public static Guid MorphTypesSeedCommitId ( Guid projectId ) =>
35+ Uuid . NewNameBased ( projectId , "morph-types-seed" ) ;
36+
37+ internal static async Task AddPredefinedComplexFormTypes ( DataModel dataModel , ProjectData projectData )
1938 {
20- await dataModel . AddChanges ( clientId ,
39+ await dataModel . AddChanges ( projectData . ClientId ,
2140 [
2241 new CreateComplexFormType ( CompoundComplexFormTypeId , new MultiString ( ) { { "en" , "Compound" } } ) ,
2342 new CreateComplexFormType ( UnspecifiedComplexFormTypeId , new MultiString ( ) { { "en" , "Unspecified" } } )
2443 ] ,
25- new Guid ( "dc60d2a9-0cc2-48ed-803c-a238a14b6eae" ) ) ;
44+ ComplexFormTypesSeedCommitId ( projectData . Id ) ) ;
2645 }
2746
28- internal static async Task AddPredefinedSemanticDomains ( DataModel dataModel , Guid clientId )
47+ internal static async Task AddPredefinedSemanticDomains ( DataModel dataModel , ProjectData projectData )
2948 {
3049 //todo load from xml instead of hardcoding and use real IDs
31- await dataModel . AddChanges ( clientId ,
50+ await dataModel . AddChanges ( projectData . ClientId ,
3251 [
3352 new CreateSemanticDomainChange ( new Guid ( "63403699-07c1-43f3-a47c-069d6e4316e5" ) , new MultiString ( ) { { "en" , "Universe, Creation" } } , "1" , true ) ,
3453 new CreateSemanticDomainChange ( new Guid ( "999581c4-1611-4acb-ae1b-5e6c1dfe6f0c" ) , new MultiString ( ) { { "en" , "Sky" } } , "1.1" , true ) ,
@@ -38,25 +57,25 @@ await dataModel.AddChanges(clientId,
3857 new CreateSemanticDomainChange ( new Guid ( "46e4fe08-ffa0-4c8b-bf88-2c56f38904d5" ) , new MultiString ( ) { { "en" , "Head" } } , "2.1.1" , false ) ,
3958 new CreateSemanticDomainChange ( new Guid ( "46e4fe08-ffa0-4c8b-bf88-2c56f38904d6" ) , new MultiString ( ) { { "en" , "Eye" } } , "2.1.1.1" , false ) ,
4059 ] ,
41- new Guid ( "023faebb-711b-4d2f-a14f-a15621fc66bc" ) ) ;
60+ SemanticDomainsSeedCommitId ( projectData . Id ) ) ;
4261 }
4362
44- public static async Task AddPredefinedPartsOfSpeech ( DataModel dataModel , Guid clientId )
63+ public static async Task AddPredefinedPartsOfSpeech ( DataModel dataModel , ProjectData projectData )
4564 {
4665 //todo load from xml instead of hardcoding
47- await dataModel . AddChanges ( clientId ,
66+ await dataModel . AddChanges ( projectData . ClientId ,
4867 [
4968 new CreatePartOfSpeechChange ( NounPartOfSpeechId , new MultiString ( ) { { "en" , "Noun" } } , true ) ,
5069 new CreatePartOfSpeechChange ( VerbPartOfSpeechId , new MultiString ( ) { { "en" , "Verb" } } , true ) ,
5170 new CreatePartOfSpeechChange ( AdjectivePartOfSpeechId , new MultiString ( ) { { "en" , "Adjective" } } , true ) ,
5271 new CreatePartOfSpeechChange ( AdverbPartOfSpeechId , new MultiString ( ) { { "en" , "Adverb" } } , true ) ,
5372 ] ,
54- new Guid ( "023faebb-711b-4d2f-b34f-a15621fc66bb" ) ) ;
73+ PartsOfSpeechSeedCommitId ( projectData . Id ) ) ;
5574 }
5675
57- internal static async Task AddPredefinedCustomViews ( DataModel dataModel , Guid clientId )
76+ internal static async Task AddPredefinedCustomViews ( DataModel dataModel , ProjectData projectData )
5877 {
59- await dataModel . AddChanges ( clientId ,
78+ await dataModel . AddChanges ( projectData . ClientId ,
6079 [
6180 new CreateCustomViewChange (
6281 new Guid ( "a1b2c3d4-e5f6-7890-abcd-ef1234567890" ) ,
@@ -82,15 +101,13 @@ await dataModel.AddChanges(clientId,
82101 Analysis = [ new ViewWritingSystem { WsId = "en" } ]
83102 } )
84103 ] ,
85- new Guid ( "b2c3d4e5-f6a7-8901-bcde-f12345678901" ) ) ;
104+ CustomViewsSeedCommitId ( projectData . Id ) ) ;
86105 }
87106
88- public static readonly Guid MorphTypesSeedCommitId = new ( "a7b2c3d4-e5f6-4a8b-9c0d-1e2f3a4b5c6d" ) ;
89-
90- internal static async Task AddPredefinedMorphTypes ( DataModel dataModel , Guid clientId )
107+ internal static async Task AddPredefinedMorphTypes ( DataModel dataModel , ProjectData projectData )
91108 {
92- await dataModel . AddChanges ( clientId ,
109+ await dataModel . AddChanges ( projectData . ClientId ,
93110 [ .. CanonicalMorphTypes . All . Values . Select ( mt => new CreateMorphTypeChange ( mt ) ) ] ,
94- MorphTypesSeedCommitId ) ;
111+ MorphTypesSeedCommitId ( projectData . Id ) ) ;
95112 }
96113}
0 commit comments