-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Faster ChorusNotes handling for LfMerge (#401)
* Move some LfMerge model classes into LfMergeBridge This will allow these classes to be passed by reference into the ChorusNotes action handler, saving two large JSON serialization steps. * Allow passing comments to/from LfMerge w/o JSON We use the ConditionalWeakTable class, designed to allow compilers to attach metadata to objects, as an extra input/output mechanism that doesn't require serializing the comments and replies to JSON strings. This will save quite a lot of RAM when doing a Send/Receive of a project with lots and lots of comments. This implements the LfMergeBridge side of the process; a corresponding change will be needed in LfMerge. * Allow FLExBridge to compile on Linux Linux requires GenerateResourceUsePreserializedResources to be set to true before `dotnet build` will allow non-string resources to be compiled into assemblies.
- Loading branch information
Showing
20 changed files
with
291 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) 2010-2024 SIL International | ||
// This software is licensed under the MIT License (http://opensource.org/licenses/MIT) | ||
|
||
using System.Collections.Generic; | ||
using LfMergeBridge.LfMergeModel; | ||
|
||
namespace LfMergeBridge | ||
{ | ||
public class GetChorusNotesInput | ||
{ | ||
public List<LfComment> LfComments; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) 2010-2024 SIL International | ||
// This software is licensed under the MIT License (http://opensource.org/licenses/MIT) | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using LfMergeBridge.LfMergeModel; | ||
|
||
namespace LfMergeBridge | ||
{ | ||
public class GetChorusNotesResponse | ||
{ | ||
public List<LfComment> LfComments; | ||
public List<Tuple<string, List<LfCommentReply>>> LfReplies; | ||
public List<KeyValuePair<string, Tuple<string, string>>> LfStatusChanges; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace LfMergeBridge.LfMergeModel | ||
{ | ||
public interface IHasNullableGuid | ||
{ | ||
// [BsonRepresentation(BsonType.String)] | ||
Guid? Guid { get; set; } | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using MongoDB.Bson; | ||
|
||
namespace LfMergeBridge.LfMergeModel | ||
{ | ||
public class LfAuthorInfo | ||
{ | ||
public ObjectId? CreatedByUserRef { get; set; } | ||
public DateTime CreatedDate { get; set; } | ||
public ObjectId? ModifiedByUserRef { get; set; } | ||
public DateTime ModifiedDate { get; set; } | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using MongoDB.Bson; | ||
using MongoDB.Bson.Serialization.Attributes; | ||
|
||
namespace LfMergeBridge.LfMergeModel | ||
{ | ||
public class LfComment : IHasNullableGuid | ||
{ | ||
public ObjectId Id { get; set; } | ||
[BsonRepresentation(BsonType.String)] | ||
public Guid? Guid { get; set; } | ||
public LfAuthorInfo AuthorInfo { get; set; } | ||
public string AuthorNameAlternate { get; set; } // Used in sending comments to FW; should be null when serializing to Mongo | ||
public LfCommentRegarding Regarding { get; set; } | ||
public DateTime DateCreated { get; set; } | ||
public DateTime DateModified { get; set; } | ||
public string Content { get; set; } | ||
public string Status { get; set; } | ||
[BsonRepresentation(BsonType.String)] | ||
public Guid? StatusGuid { get; set; } | ||
public bool IsDeleted { get; set; } | ||
public List<LfCommentReply> Replies { get; set; } | ||
public ObjectId EntryRef { get; set; } | ||
public int Score { get; set; } | ||
public string ContextGuid { get; set; } // not really a GUID | ||
|
||
public bool ShouldSerializeGuid() { return (Guid != null && Guid.Value != System.Guid.Empty); } | ||
public bool ShouldSerializeDateCreated() { return true; } | ||
public bool ShouldSerializeDateModified() { return true; } | ||
public bool ShouldSerializeContent() { return ( ! String.IsNullOrEmpty(Content)); } | ||
public bool ShouldSerializeAuthorNameAlternate() { return ( ! String.IsNullOrEmpty(AuthorNameAlternate)); } | ||
public bool ShouldSerializeStatusGuid() { return (StatusGuid != null && StatusGuid.Value != System.Guid.Empty); } | ||
public bool ShouldSerializeReplies() { return (Replies != null && Replies.Count > 0); } | ||
|
||
public LfComment() { | ||
Replies = new List<LfCommentReply>(); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
|
||
namespace LfMergeBridge.LfMergeModel | ||
{ | ||
public class LfCommentRegarding | ||
{ | ||
public string TargetGuid { get; set; } | ||
public string Field { get; set; } | ||
public string FieldNameForDisplay { get; set; } | ||
public string FieldValue { get; set; } | ||
public string InputSystem { get; set; } | ||
public string InputSystemAbbreviation { get; set; } | ||
public string Word { get; set; } | ||
public string Meaning { get; set; } | ||
|
||
public bool ShouldSerializeEntryGuid() { return ( ! String.IsNullOrEmpty(TargetGuid)); } | ||
public bool ShouldSerializeField() { return ( ! String.IsNullOrEmpty(Field)); } | ||
public bool ShouldSerializeFieldNameForDisplay() { return ( ! String.IsNullOrEmpty(FieldNameForDisplay)); } | ||
public bool ShouldSerializeFieldValue() { return ( ! String.IsNullOrEmpty(FieldValue)); } | ||
public bool ShouldSerializeInputSystem() { return ( ! String.IsNullOrEmpty(InputSystem)); } | ||
public bool ShouldSerializeInputSystemAbbreviation() { return ( ! String.IsNullOrEmpty(InputSystemAbbreviation)); } | ||
public bool ShouldSerializeWord() { return ( ! String.IsNullOrEmpty(Word)); } | ||
public bool ShouldSerializeMeaning() { return ( ! String.IsNullOrEmpty(Meaning)); } | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using MongoDB.Bson; | ||
using MongoDB.Bson.Serialization.Attributes; | ||
|
||
namespace LfMergeBridge.LfMergeModel | ||
{ | ||
[BsonIgnoreExtraElements] // WARNING: Beware of using FindOneAndReplace() with IgnoreExtraElements, as you can lose data | ||
public class LfCommentReply : IHasNullableGuid | ||
{ | ||
[BsonRepresentation(BsonType.String)] | ||
public Guid? Guid { get; set; } | ||
public LfAuthorInfo AuthorInfo { get; set; } | ||
public string AuthorNameAlternate { get; set; } // Used in sending comments to FW; should be null when serializing to Mongo | ||
public string Content { get; set; } | ||
[BsonElement("id")] | ||
public string UniqId { get; set; } // If we name this field "Id", the C# driver tries to map it to _id and always thinks it is null | ||
public bool IsDeleted { get; set; } | ||
|
||
public bool ShouldSerializeGuid() { return (Guid != null && Guid.Value != System.Guid.Empty); } | ||
public bool ShouldSerializeContent() { return ( ! String.IsNullOrEmpty(Content)); } | ||
public bool ShouldSerializeAuthorNameAlternate() { return ( ! String.IsNullOrEmpty(AuthorNameAlternate)); } | ||
public bool ShouldSerializeId() { return ( ! String.IsNullOrEmpty(UniqId)); } | ||
// We almost always want to store the IsDeleted value, unless the reply is pretty much empty of any useful content. | ||
public bool ShouldSerializeIsDeleted() { return IsDeleted || ShouldSerializeGuid() || ShouldSerializeContent() || ShouldSerializeId(); } | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using MongoDB.Bson.Serialization.Attributes; | ||
|
||
namespace LfMergeBridge.LfMergeModel | ||
{ | ||
[BsonIgnoreExtraElements] | ||
public class LfInputSystemRecord | ||
{ | ||
public string Abbreviation { get; set; } | ||
public string Tag { get; set; } | ||
public string LanguageName { get; set; } | ||
public bool IsRightToLeft { get; set; } | ||
|
||
// We'll store vernacular / analysis writing system info when | ||
// importing LCM projects, but LF won't be using this information | ||
public bool VernacularWS { get; set; } | ||
public bool AnalysisWS { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using MongoDB.Bson; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace LfMergeBridge.LfMergeModel | ||
{ | ||
public class LfOptionList | ||
{ | ||
public ObjectId Id { get; set; } | ||
public string Name { get; set; } | ||
public string Code { get; set; } | ||
public DateTime DateCreated { get; set; } | ||
public DateTime DateModified { get; set; } | ||
public List<LfOptionListItem> Items { get; set; } | ||
public string DefaultItemKey { get; set; } | ||
public bool CanDelete { get; set; } | ||
|
||
public LfOptionList() | ||
{ | ||
Items = new List<LfOptionListItem>(); | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.