private void AddPlaceholderTag(ICollection <IAbstractMarkupData> segmentContent, IText text) { var processedData = Anonymizer(text.Properties.Text, false); var tag = _factory.CreatePlaceholderTag(_propertiesFactory.CreatePlaceholderTagProperties(processedData)); tag.Properties.SetMetaData("Anonymizer", "Anonymizer"); segmentContent.Add(tag); }
private IPlaceholderTag CreatePlaceholder(string content, SegmentationHint segmentationHint) { var placeholderProperties = _propertiesFactory.CreatePlaceholderTagProperties(content); placeholderProperties.TagContent = content; placeholderProperties.DisplayText = content; placeholderProperties.SegmentationHint = segmentationHint; return(_itemFactory.CreatePlaceholderTag(placeholderProperties)); }
public IAbstractMarkupData CreatePlaceholder(string tagId, string text) { var textProperties = _propertiesFactory.CreatePlaceholderTagProperties(text); //if (!string.IsNullOrEmpty(tagId)) //{ // textProperties.TagId = new TagId(tagId); //} return(_factory.CreatePlaceholderTag(textProperties)); }
public void VisitText_WhenTextIsPlaceholderInlineType_ShouldAddPlaceholder() { // Arrange var testee = CreateTestee(); A.CallTo(() => _textProcessorMock.Process(TexBeforeProcessing)).Returns(new List <IFragment> { new Fragment(InlineType.Placeholder, "{0}") }); var placeholderTagPropertiesMock = A.Fake <IPlaceholderTagProperties>(); A.CallTo(() => _propertiesFactoryMock.CreatePlaceholderTagProperties("{0}")).Returns(placeholderTagPropertiesMock); var newPlactholderMock = A.Fake <IPlaceholderTag>(); A.CallTo(() => _itemFactoryMock.CreatePlaceholderTag(placeholderTagPropertiesMock)).Returns(newPlactholderMock); // Act testee.VisitText(_textMock); // Assert A.CallTo(() => _sourceParagraphMock.Add(newPlactholderMock)).MustHaveHappened(); }
internal IPlaceholderTagProperties CreatePlaceholderTagProperties(IPropertiesFactory factory, string tagContent, IMatchRule rule) { var placeholderProps = factory.CreatePlaceholderTagProperties(tagContent); ApplyInlineTagProperties(placeholderProps, rule); placeholderProps.DisplayText = GetDisplayName(tagContent); placeholderProps.SegmentationHint = rule.SegmentationHint; placeholderProps.TagContent = tagContent; if (!string.IsNullOrEmpty(rule.TextEquivalent)) { placeholderProps.TextEquivalent = rule.TextEquivalent; } return(placeholderProps); }
public IAbstractMarkupData CreatePlaceholder(string tagId, string text) { var textProperties = _propertiesFactory.CreatePlaceholderTagProperties(text); if (ExistingPlaceholderIds.Contains(textProperties.TagId.Id)) { if (!ExistingPlaceholderIds.Contains(tagId)) { textProperties.TagId = new TagId(tagId); } else { textProperties.TagId = new TagId(GetUniqueTagPairId()); } } if (!ExistingPlaceholderIds.Contains(textProperties.TagId.Id)) { ExistingPlaceholderIds.Add(textProperties.TagId.Id); } return(_factory.CreatePlaceholderTag(textProperties)); }
private void AddPlaceholderTag(ICollection <IAbstractMarkupData> segmentContent, IText text, List <AnonymizedData> anonymizedDataList) { var currentData = anonymizedDataList?.FirstOrDefault(ad => ad.MatchText == text.Properties.Text); var processedData = text.Properties.Text; if (currentData?.EncryptedText != null) { processedData = currentData.EncryptedText; } if (processedData == null) { return; } var tag = _documentItemFactory.CreatePlaceholderTag( _propertiesFactory.CreatePlaceholderTagProperties(processedData)); tag.Properties.SetMetaData("Anonymizer", "Anonymizer"); segmentContent.Add(tag); }
private void GetSubsegmentPi(IText segmentText, List <IAbstractMarkupData> segmentContent, List <AnonymizedData> anonymizedDataList) { //this means we have PI data + text if (segmentText.Properties.Text.Length > anonymizedDataList[0].MatchText.Length) { //check if PI data is on first position split the segment after the PI if (anonymizedDataList[0].PositionInOriginalText.Equals(0)) { var remainingSegmentText = segmentText.Split(anonymizedDataList[0].MatchText.Length); //check if we should encrypt or only tag the data var processedData = Anonymizer(segmentText.Properties.Text, false); var tag = _factory.CreatePlaceholderTag( _propertiesFactory.CreatePlaceholderTagProperties(processedData)); tag.Properties.SetMetaData("Anonymizer", "Anonymizer"); //Add encrypted tag to collection segmentContent.Add(tag); if (ShouldAnonymize(remainingSegmentText.Properties.Text)) { var remainingData = GetAnonymizedData(remainingSegmentText.Properties.Text); GetSubsegmentPi(remainingSegmentText, segmentContent, remainingData); } else { segmentContent.Add(remainingSegmentText); } } else { var remainingSegmentText = segmentText.Split(anonymizedDataList[0].PositionInOriginalText); if (ShouldAnonymize(segmentText.Properties.Text)) { var remainingData = GetAnonymizedData(segmentText.Properties.Text); GetSubsegmentPi(segmentText, segmentContent, remainingData); } else { segmentContent.Add(segmentText); } if (ShouldAnonymize(remainingSegmentText.Properties.Text)) { var remainingData = GetAnonymizedData(remainingSegmentText.Properties.Text); GetSubsegmentPi(remainingSegmentText, segmentContent, remainingData); } else { var processedData = Anonymizer(remainingSegmentText.Properties.Text, false); var tag = _factory.CreatePlaceholderTag( _propertiesFactory.CreatePlaceholderTagProperties(processedData)); tag.Properties.SetMetaData("Anonymizer", "Anonymizer"); segmentContent.Add(tag); } } } //segment contains only PI data else { var processedData = Anonymizer(segmentText.Properties.Text, false); var tag = _factory.CreatePlaceholderTag( _propertiesFactory.CreatePlaceholderTagProperties(processedData)); tag.Properties.SetMetaData("Anonymizer", "Anonymizer"); segmentContent.Add(tag); } }