Skip to content

Commit

Permalink
Added data checking option: search for notes and sources without links
Browse files Browse the repository at this point in the history
  • Loading branch information
Serg-Norseman committed Jun 7, 2024
1 parent 6ed1910 commit 67d2973
Show file tree
Hide file tree
Showing 30 changed files with 324 additions and 140 deletions.
3 changes: 3 additions & 0 deletions locales/Afrikaans.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/Belarusian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/Chinese Simplified.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/Dutch.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/English.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/Hungarian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Kép gyorsítótár törlés
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/Icelandic.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/Japanese.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=画像のキャッシュを消去する
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/Kazakh (Cyrillic).lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/Portuguese.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/Serbian (Latin).lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/Spanish.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/czech.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/french.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/german.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Bilder-Cache leeren
957=Auswahllinien hervorheben
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
1 change: 1 addition & 0 deletions locales/help_enu/gkhHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h1>Change log</h1>

<p>
<b>14.06.2024 [v2.30.1 &amp; v3.6.1]</b><ul>
<li>Added data checking option: search for notes and sources without links.
<li>Added a call to detailed information about sources and persons in the lists of citations to sources, children, parents and spouses (pop-up menu).
<li>Added display of multimedia and notes on the info-panel for events.
<li>Fixed multiple lines in the Author column of source citation lists (GKv3).
Expand Down
1 change: 1 addition & 0 deletions locales/help_rus/gkhHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h1>История версий</h1>

<p>
<b>14.06.2024 [v2.30.1 &amp; v3.6.1]</b><ul>
<li>Добавлена опция проверки данных: поиск записей заметок и источников без ссылок.
<li>Добавлен вызов детальной информации об источниках и персонах в списки ссылок на источники, детей, родителей и супругов (всплывающее меню).
<li>Добавлено отображение мультимедиа и заметок на инфо-панели для событий.
<li>Устранены множественные строки в столбце "Автор" списков ссылок на источники (GKv3).
Expand Down
3 changes: 3 additions & 0 deletions locales/italian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/polish.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
3 changes: 3 additions & 0 deletions locales/russian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Очистить кеш изображений
957=Подсветка линий выделенного
958=Отслеживать совпадающие источники
959=Заметка без ссылок
960=Источник без ссылок
961=Проверить связи
3 changes: 3 additions & 0 deletions locales/ukrainian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,6 @@
956=Clean images cache
957=Highlight the lines of the selection
958=Track matching sources
959=Note without links
960=Source without links
961=Check links
4 changes: 3 additions & 1 deletion projects/GKCore/GKCore/Controllers/TreeCheckController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2023 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -54,6 +54,7 @@ public void CheckBase()
{
fOptions.CheckIndividualPlaces = GetControl<ICheckBox>("chkCheckPersonPlaces").Checked;
fOptions.CheckCensuses = GetControl<ICheckBox>("chkCheckCensuses").Checked;
fOptions.CheckLinks = GetControl<ICheckBox>("chkCheckLinks").Checked;

AppHost.Instance.ExecuteWork((controller) => {
TreeInspector.CheckBase(fBase, fChecksList, controller, fOptions);
Expand Down Expand Up @@ -170,6 +171,7 @@ public override void SetLocale()
GetControl<ITabPage>("pageOptions").Text = LangMan.LS(LSID.MIOptions);
GetControl<ICheckBox>("chkCheckPersonPlaces").Text = LangMan.LS(LSID.CheckPersonPlaces);
GetControl<ICheckBox>("chkCheckCensuses").Text = LangMan.LS(LSID.CensusAnalysis);
GetControl<ICheckBox>("chkCheckLinks").Text = LangMan.LS(LSID.CheckLinks);

fView.ChecksList.AddColumn(LangMan.LS(LSID.Record), 400, false);
fView.ChecksList.AddColumn(LangMan.LS(LSID.Problem), 200, false);
Expand Down
8 changes: 7 additions & 1 deletion projects/GKCore/GKCore/LangMan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1030,8 +1030,11 @@ public enum LSID
/* 956 */ CleanImagesCache,
/* 957 */ TrackSelectedLines,
/* 958 */ TrackMatchedSources,
/* 959 */ NoteWithoutLinks,
/* 960 */ SourceWithoutLinks,
/* 961 */ CheckLinks,

/* 000 */ Last = TrackMatchedSources
/* 000 */ Last = CheckLinks
}


Expand Down Expand Up @@ -2015,6 +2018,9 @@ public static class LangMan
/* 956 */ "Clean images cache",
/* 957 */ "Highlight the lines of the selection",
/* 958 */ "Track matching sources",
/* 959 */ "Note without links",
/* 960 */ "Source without links",
/* 961 */ "Check links",
};

private static readonly LangManager fLangMan = new LangManager();
Expand Down
105 changes: 104 additions & 1 deletion projects/GKCore/GKCore/Tools/TreeInspector.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2023 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -35,6 +35,7 @@ public class TreeInspectionOptions
{
public bool CheckIndividualPlaces;
public bool CheckCensuses;
public bool CheckLinks;
}

/// <summary>
Expand Down Expand Up @@ -74,6 +75,8 @@ public enum CheckDiag
cdHighSpousesDifference,
cdHighSiblingsDifference,
cdMatchedCensus,
cdNoteWithoutLinks,
cdSourceWithoutLinks,
}

public enum CheckSolve
Expand Down Expand Up @@ -121,6 +124,14 @@ public string GetRecordName(GDMTree tree)
case GDMRecordType.rtFamily:
result = GKUtils.GetFamilyString(tree, (GDMFamilyRecord)Rec);
break;

case GDMRecordType.rtNote:
result = ((GDMNoteRecord)Rec).Lines[0]; // TODO: bad solution?!
break;

case GDMRecordType.rtSource:
result = ((GDMSourceRecord)Rec).ShortTitle;
break;
}

result = string.Concat(result, " [ ", Rec.XRef, " ]");
Expand Down Expand Up @@ -470,6 +481,85 @@ private static void CheckMultimediaRecord(IBaseContext baseContext, GDMMultimedi
}
}

private static bool CheckStructLinks(IGDMStructWithLists strWL, GDMRecord subject)
{
switch (subject.RecordType) {
case GDMRecordType.rtNote:
if (strWL.HasNotes) {
for (int i = 0, num = strWL.Notes.Count; i < num; i++) {
if (strWL.Notes[i].XRef == subject.XRef) {
return true;
}
}
}
break;

case GDMRecordType.rtMultimedia:
if (strWL.HasMultimediaLinks) {
for (int i = 0, num = strWL.MultimediaLinks.Count; i < num; i++) {
if (strWL.MultimediaLinks[i].XRef == subject.XRef) {
return true;
}
}
}
break;

case GDMRecordType.rtSource:
if (strWL.HasSourceCitations) {
for (int i = 0, num = strWL.SourceCitations.Count; i < num; i++) {
var sourCit = strWL.SourceCitations[i];
if (sourCit.XRef == subject.XRef) {
return true;
}
}
}
break;
}

return false;
}

private static bool CheckRecordLinks(IBaseContext baseContext, GDMRecord subject)
{
var tree = baseContext.Tree;
for (int k = 0, num2 = tree.RecordsCount; k < num2; k++) {
GDMRecord record = tree[k];

if (CheckStructLinks(record, subject))
return true;

var evsRec = record as GDMRecordWithEvents;
if (evsRec != null && evsRec.HasEvents) {
for (int i = 0, num = evsRec.Events.Count; i < num; i++) {
if (CheckStructLinks(evsRec.Events[i], subject))
return true;
}
}
}

return false;
}

private static void CheckNoteRecord(IBaseContext baseContext, GDMNoteRecord noteRec, List<CheckObj> checksList)
{
if (!CheckRecordLinks(baseContext, noteRec)) {
CheckObj checkObj = new CheckObj(noteRec, CheckDiag.cdNoteWithoutLinks, CheckSolve.csRemove);
checkObj.Comment = LangMan.LS(LSID.NoteWithoutLinks);
checksList.Add(checkObj);
return;
}
}

private static void CheckSourceRecord(IBaseContext baseContext, GDMSourceRecord sourRec, List<CheckObj> checksList)
{
if (!CheckRecordLinks(baseContext, sourRec)) {
CheckObj checkObj = new CheckObj(sourRec, CheckDiag.cdSourceWithoutLinks, CheckSolve.csRemove);
checkObj.Comment = LangMan.LS(LSID.SourceWithoutLinks);
checksList.Add(checkObj);
return;
}
}

public static void CheckBase(IBaseWindow baseWin, List<CheckObj> checksList, IProgressController progress, TreeInspectionOptions options = null)
{
if (baseWin == null)
Expand Down Expand Up @@ -501,6 +591,14 @@ public static void CheckBase(IBaseWindow baseWin, List<CheckObj> checksList, IPr
case GDMRecordType.rtMultimedia:
CheckMultimediaRecord(baseWin.Context, rec as GDMMultimediaRecord, checksList);
break;

case GDMRecordType.rtNote:
if (options.CheckLinks) CheckNoteRecord(baseWin.Context, rec as GDMNoteRecord, checksList);
break;

case GDMRecordType.rtSource:
if (options.CheckLinks) CheckSourceRecord(baseWin.Context, rec as GDMSourceRecord, checksList);
break;
}
}
} finally {
Expand Down Expand Up @@ -654,6 +752,11 @@ public static async Task RepairProblem(IView owner, IBaseWindow baseWin, CheckOb
CheckAndRepairGarbledSpouses(tree, famRec);
}
break;

case CheckDiag.cdNoteWithoutLinks:
case CheckDiag.cdSourceWithoutLinks:
tree.DeleteRecord(checkObj.Rec);
break;
}
}

Expand Down
Loading

0 comments on commit 67d2973

Please sign in to comment.