Skip to content

Commit

Permalink
remove the ReplaceComplexFormComponent API since it would never be us…
Browse files Browse the repository at this point in the history
…ed and would be better to just delete and recreate the component anyway
  • Loading branch information
hahn-kev committed Nov 6, 2024
1 parent b8391eb commit 94c94aa
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 54 deletions.
14 changes: 0 additions & 14 deletions backend/FwLite/FwDataMiniLcmBridge/Api/FwDataMiniLcmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,20 +546,6 @@ public Task DeleteComplexFormComponent(ComplexFormComponent complexFormComponent
return Task.CompletedTask;
}

public Task ReplaceComplexFormComponent(ComplexFormComponent old, ComplexFormComponent @new)
{
UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW("Replace Complex Form Component",
"Replace Complex Form Component",
Cache.ServiceLocator.ActionHandler,
() =>
{
var lexEntry = EntriesRepository.GetObject(old.ComplexFormEntryId);
RemoveComplexFormComponent(lexEntry, old);
AddComplexFormComponent(lexEntry, @new);
});
return Task.CompletedTask;
}

public Task AddComplexFormType(Guid entryId, Guid complexFormTypeId)
{
UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW("Add Complex Form Type",
Expand Down
6 changes: 0 additions & 6 deletions backend/FwLite/FwLiteProjectSync/DryRunMiniLcmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,6 @@ public Task DeleteComplexFormComponent(ComplexFormComponent complexFormComponent
return Task.CompletedTask;
}

public Task ReplaceComplexFormComponent(ComplexFormComponent old, ComplexFormComponent @new)
{
DryRunRecords.Add(new DryRunRecord(nameof(ReplaceComplexFormComponent), $"Replace complex form component complex entry: {old.ComplexFormHeadword}, component entry: {old.ComponentHeadword} with complex entry: {@new.ComplexFormHeadword}, component entry: {@new.ComponentHeadword}"));
return Task.CompletedTask;
}

public async Task AddComplexFormType(Guid entryId, Guid complexFormTypeId)
{
DryRunRecords.Add(new DryRunRecord(nameof(AddComplexFormType), $"Add complex form type {complexFormTypeId}, to entry {entryId}"));
Expand Down
24 changes: 0 additions & 24 deletions backend/FwLite/LcmCrdt/CrdtMiniLcmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,30 +120,6 @@ public async Task DeleteComplexFormComponent(ComplexFormComponent complexFormCom
await dataModel.AddChange(ClientId, new DeleteChange<ComplexFormComponent>(complexFormComponent.Id));
}

public async Task ReplaceComplexFormComponent(ComplexFormComponent old, ComplexFormComponent @new)
{
IChange change;
if (old.ComplexFormEntryId != @new.ComplexFormEntryId)
{
change = SetComplexFormComponentChange.NewComplexForm(old.Id, @new.ComplexFormEntryId);
}
else if (old.ComponentEntryId != @new.ComponentEntryId)
{
change = SetComplexFormComponentChange.NewComponent(old.Id, @new.ComponentEntryId);
}
else if (old.ComponentSenseId != @new.ComponentSenseId)
{
change = SetComplexFormComponentChange.NewComponentSense(old.Id,
@new.ComponentEntryId,
@new.ComponentSenseId);
}
else
{
return;
}
await dataModel.AddChange(ClientId, change);
}

public async Task AddComplexFormType(Guid entryId, Guid complexFormTypeId)
{
await dataModel.AddChange(ClientId, new AddComplexFormTypeChange(entryId, await ComplexFormTypes.SingleAsync(ct => ct.Id == complexFormTypeId)));
Expand Down
1 change: 0 additions & 1 deletion backend/FwLite/MiniLcm/IMiniLcmWriteApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Task<WritingSystem> UpdateWritingSystem(WritingSystemId id,
Task DeleteEntry(Guid id);
Task<ComplexFormComponent> CreateComplexFormComponent(ComplexFormComponent complexFormComponent);
Task DeleteComplexFormComponent(ComplexFormComponent complexFormComponent);
Task ReplaceComplexFormComponent(ComplexFormComponent old, ComplexFormComponent @new);
Task AddComplexFormType(Guid entryId, Guid complexFormTypeId);
Task RemoveComplexFormType(Guid entryId, Guid complexFormTypeId);
#endregion
Expand Down
5 changes: 0 additions & 5 deletions backend/FwLite/MiniLcm/InMemoryApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,6 @@ public Task DeleteComplexFormComponent(ComplexFormComponent complexFormComponent
throw new NotImplementedException();
}

public Task ReplaceComplexFormComponent(ComplexFormComponent old, ComplexFormComponent @new)
{
throw new NotImplementedException();
}

public Task AddComplexFormType(Guid entryId, Guid complexFormTypeId)
{
throw new NotImplementedException();
Expand Down
7 changes: 3 additions & 4 deletions backend/FwLite/MiniLcm/SyncHelpers/EntrySync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,15 @@ static async (api, beforeComponent) =>
await api.DeleteComplexFormComponent(beforeComponent);
return 1;
},
static async (api, beforeComponent, afterComponent) =>
static (api, beforeComponent, afterComponent) =>
{
if (beforeComponent.ComplexFormEntryId == afterComponent.ComplexFormEntryId &&
beforeComponent.ComponentEntryId == afterComponent.ComponentEntryId &&
beforeComponent.ComponentSenseId == afterComponent.ComponentSenseId)
{
return 0;
return Task.FromResult(0);
}
await api.ReplaceComplexFormComponent(beforeComponent, afterComponent);
return 1;
throw new InvalidOperationException($"changing complex form components is not supported, they should just be deleted and recreated");
}
);
}
Expand Down

0 comments on commit 94c94aa

Please sign in to comment.