Skip to content

Commit

Permalink
Merge pull request #99 from GeoWerkstatt/include-title-tag
Browse files Browse the repository at this point in the history
Include title tag
  • Loading branch information
MiraGeowerkstatt authored Sep 14, 2022
2 parents ba27a4f + d5a612d commit c974625
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 34 deletions.
7 changes: 7 additions & 0 deletions src/ClientApp/src/components/Detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import LinkIcon from "@mui/icons-material/Link";
import InsertDriveFileIcon from "@mui/icons-material/InsertDriveFile";
import ArrowBackIosIcon from "@mui/icons-material/ArrowBackIos";
import AutoStoriesIcon from "@mui/icons-material/AutoStories";
import TitleIcon from "@mui/icons-material/Title";
import { SchemaLanguages } from "./SchemaLanguages";
import { useTranslation } from "react-i18next";
import { getAllModels } from "./Utils";
Expand Down Expand Up @@ -119,6 +120,12 @@ export function Detail() {
<Box>{model.tags && model.tags.map((tag) => <Chip key={tag} sx={{ margin: 1 }} label={tag} />)}</Box>
</Stack>
<Stack direction="column" alignItems="flex-start" sx={{ color: "text.secondary" }}>
{!!model.title && (
<Box ml={1} mt={1}>
<TitleIcon sx={{ marginBottom: -0.5, marginRight: 0.5 }} />
{t("title")}: {model.title}
</Box>
)}
<Box ml={1} mt={1}>
<SellIcon sx={{ marginBottom: -0.5, marginRight: 0.5 }} />
{t("schema-language")}: {SchemaLanguages[model.schemaLanguage]}
Expand Down
7 changes: 7 additions & 0 deletions src/ClientApp/src/components/Results.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import InfoIcon from "@mui/icons-material/Info";
import RestoreIcon from "@mui/icons-material/Restore";
import FilterAltIcon from "@mui/icons-material/FilterAlt";
import FlagIcon from "@mui/icons-material/Flag";
import TitleIcon from "@mui/icons-material/Title";
import InsertDriveFileIcon from "@mui/icons-material/InsertDriveFile";
import HubIcon from "@mui/icons-material/Hub";
import { useTranslation } from "react-i18next";
Expand Down Expand Up @@ -94,6 +95,12 @@ export function Results(props) {
flexWrap="wrap"
sx={{ color: "text.secondary" }}
>
{!!model.title && (
<Box ml={1} mt={1}>
<TitleIcon sx={{ marginBottom: -0.5, marginRight: 0.5 }} />
{t("title")}: {model.title}
</Box>
)}
<Box ml={1} mt={1}>
<SellIcon sx={{ marginBottom: -0.5, marginRight: 0.5 }} />
{t("schema-language")}: {SchemaLanguages[model.schemaLanguage]}
Expand Down
3 changes: 2 additions & 1 deletion src/ClientApp/src/translations/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"hide-results-for-depends-on-models": "Resultate die sich auf referenzierte Modelle beziehen ausblenden",
"catalogue-files": "Zugehörige Katalogdateien",
"impressum": "Impressum",
"open-impressum": "Impressum öffnen"
"open-impressum": "Impressum öffnen",
"title": "Titel"
}
3 changes: 2 additions & 1 deletion src/ClientApp/src/translations/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"hide-results-for-depends-on-models": "Masquer les résultats liés aux modèles référencés",
"catalogue-files": "Fichiers de catalogue associés",
"impressum": "Empreinte",
"open-impressum": "Ouvrir l'empreinte"
"open-impressum": "Ouvrir l'empreinte",
"title": "Titre"
}
3 changes: 2 additions & 1 deletion src/ClientApp/src/translations/it/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"hide-results-for-depends-on-models": "Nascondi i risultati relativi ai modelli di riferimento",
"catalogue-files": "File di catalogo correlati",
"impressum": "Impressum",
"open-impressum": "Aprire impressum"
"open-impressum": "Aprire impressum",
"title": "Titolo"
}
3 changes: 3 additions & 0 deletions src/Controllers/SearchController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ private Task<Dictionary<string, Repository>> SearchRepositories(string query, st
if (dependsOnModels != null && dependsOnModels.All(string.IsNullOrEmpty)) dependsOnModels = null;
if (issuers != null && issuers.All(string.IsNullOrEmpty)) issuers = null;

#pragma warning disable CS8604 // Possible null reference argument.
return context.Repositories
.Include(r => r.SubsidiarySites)
.Include(r => r.ParentSites)
Expand All @@ -184,11 +185,13 @@ private Task<Dictionary<string, Repository>> SearchRepositories(string query, st
EF.Functions.ILike(m.Name, searchPattern, @"\")
|| EF.Functions.ILike(m.Version, searchPattern, @"\")
|| EF.Functions.ILike(m.File, searchPattern, @"\")
|| EF.Functions.ILike(m.Title, searchPattern, @"\")
|| modelsNamesFoundFromCatalogs.Contains(m.Name)
|| m.Tags.Contains(query)
|| m.DependsOnModel.Contains(query)))
.AsNoTracking()
.ToDictionaryAsync(r => r.HostNameId);
#pragma warning restore CS8604 // Possible null reference argument.
}

/// <summary>
Expand Down
29 changes: 15 additions & 14 deletions src/Crawler/RepositoryCrawler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,21 @@ private async Task<ISet<Model>> CrawlIlimodels(Uri repositoryUri)
{
var models = RepositoryFilesDeserializer.ParseIliModels(ilimodelsStream)
.Select(model => new Model
{
Name = model.Name,
SchemaLanguage = model.SchemaLanguage,
File = model.File,
Version = model.Version,
PublishingDate = model.publishingDate.ToUniversalTime(),
DependsOnModel = model.dependsOnModel.Where(s => !string.IsNullOrEmpty(s?.value)).Select(m => m.value!).ToList(),
ShortDescription = model.shortDescription,
Issuer = model.Issuer,
TechnicalContact = model.technicalContact,
FurtherInformation = model.furtherInformation,
MD5 = model.md5,
Tags = model.Tags?.Split(',').Distinct().ToList() ?? new List<string>(),
})
{
Name = model.Name,
SchemaLanguage = model.SchemaLanguage,
File = model.File,
Version = model.Version,
PublishingDate = model.publishingDate.ToUniversalTime(),
DependsOnModel = model.dependsOnModel.Where(s => !string.IsNullOrEmpty(s?.value)).Select(m => m.value!).ToList(),
ShortDescription = model.shortDescription,
Title = model.Title,
Issuer = model.Issuer,
TechnicalContact = model.technicalContact,
FurtherInformation = model.furtherInformation,
MD5 = model.md5,
Tags = model.Tags?.Split(',').Distinct().ToList() ?? new List<string>(),
})
.ToHashSet();

foreach (var model in models)
Expand Down
2 changes: 2 additions & 0 deletions src/Crawler/XmlModels/IliModelsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class ModelMetadata
[XmlElement(DataType = "date")]
public DateTime publishingDate { get; set; }

public string? Title { get; set; }

[XmlArray("dependsOnModel")]
[XmlArrayItem("IliRepository09.ModelName_", typeof(DependsOnModel09))]
[XmlArrayItem("IliRepository20.ModelName_", typeof(DependsOnModel20))]
Expand Down
2 changes: 2 additions & 0 deletions src/Models/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class Model

public DateTime? PublishingDate { get; set; }

public string? Title { get; set; }

public List<string> DependsOnModel { get; set; }

public List<string> Tags { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions tests/ModelControllerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public void ModelDetails()
Assert.AreEqual("Cotton_Officer", model.Name);
Assert.AreEqual("544a7e2f91f51172f1d471dc3b3ce10c", model.MD5);
Assert.AreEqual("home/scalable_assistant_georgia.json5", model.File);
Assert.AreEqual("Papua New Guinea interactive Tasty Sleek navigate", model.Title);
Assert.IsNotNull(model.ModelRepository, "ModelRepository has to be included.");
Assert.AreEqual("white", model.ModelRepository.Name);
}
Expand All @@ -47,6 +48,7 @@ public void ModelDetailsWithCatalogs()
Assert.AreEqual("Borders_Home Loan Account", model.Name);
Assert.AreEqual("2abd30d77a016df846307c50a621139b", model.MD5);
Assert.AreEqual("usr/libexec/agp.bz2", model.File);
Assert.AreEqual("copy orange IB Regional Refined", model.Title);
Assert.IsNotNull(model.ModelRepository, "ModelRepository has to be included.");
Assert.AreEqual("g7yn9ioz927y65aoioyjvb4v3b84", model.CatalogueFiles[0]);
}
Expand Down
1 change: 1 addition & 0 deletions tests/RepoBrowserContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public static void SeedData(this RepoBrowserContext context)
.RuleFor(m => m.FurtherInformation, f => f.Lorem.Sentence())
.RuleFor(m => m.ModelRepository, f => f.PickRandom(repositories))
.RuleFor(m => m.IsDependOnModelResult, _ => false)
.RuleFor(m => m.Title, f => f.Random.Words(5))
.RuleFor(m => m.CatalogueFiles, _ => new List<string>());
Model SeededModel(int seed) => fakeModels.UseSeed(seed).Generate();
var models = modelRange.Select(SeededModel);
Expand Down
48 changes: 31 additions & 17 deletions tests/SearchControllerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task SearchName()
Assert.IsNotNull(searchResult);
searchResult
.GetAllModels()
.AssertCount(2)
.AssertCount(3)
.AssertSingleItem(m => m.Id == 22, m => Assert.AreEqual("Kentucky", m.Name));
}

Expand Down Expand Up @@ -110,17 +110,17 @@ public async Task SearchTag()
Assert.IsNotNull(searchResult);
searchResult
.GetAllModels()
.AssertCount(3)
.AssertCount(4)
.AssertSingleItem(m => m.Id == 23, m => m.Tags.AssertContains("Specialist"));

// Tags must match exactly
searchResult = await controller.Search("pecialist");
Assert.IsNotNull(searchResult);
searchResult.GetAllModels().AssertCount(2);
searchResult.GetAllModels().AssertCount(3);

searchResult = await controller.Search("SpecialiST");
Assert.IsNotNull(searchResult);
searchResult.GetAllModels().AssertCount(2);
searchResult.GetAllModels().AssertCount(3);
}

[TestMethod]
Expand All @@ -130,15 +130,15 @@ public async Task SearchDependsOnModel()
Assert.IsNotNull(searchResult);
var models = searchResult.GetAllModels();
models.Where(m => m.IsDependOnModelResult == true).AssertCount(2);
models.Where(m => m.IsDependOnModelResult == false).AssertCount(1);
models.Where(m => m.IsDependOnModelResult == false).AssertCount(4);
models.AssertSingleItem(m => m.Id == 86, m => m.DependsOnModel.AssertContains("Home Loan Account"));

// DependsOnModel must match exactly
searchResult = await controller.Search("home loan account");
searchResult!.GetAllModels().AssertCount(1);
searchResult!.GetAllModels().AssertCount(4);

searchResult = await controller.Search("HOme Loan Account");
searchResult!.GetAllModels().AssertCount(1);
searchResult!.GetAllModels().AssertCount(4);
}

[TestMethod]
Expand All @@ -158,7 +158,7 @@ public async Task SearchWithWildcardsDisabled()
{
var searchResult = await controller.Search("Kentucky");
Assert.IsNotNull(searchResult);
searchResult.GetAllModels().AssertCount(2);
searchResult.GetAllModels().AssertCount(3);

searchResult = await controller.Search("Kent_cky");
Assert.AreEqual(null, searchResult);
Expand Down Expand Up @@ -188,20 +188,20 @@ public async Task SearchRepositoryTreeResult()
var searchResult = await controller.Search("ga");

Assert.IsNotNull(searchResult);
searchResult.GetAllModels().AssertCount(11);
searchResult.GetAllModels().AssertCount(21);
Assert.AreEqual("delores.com", searchResult.HostNameId);
Assert.AreEqual(1, searchResult.Models.Count);

searchResult.SubsidiarySites
.AssertCount(5)
.AssertSingleItem("eldora.net", 1)
.AssertSingleItem("geovany.org", 1)
.AssertSingleItem("eldora.net", 2)
.AssertSingleItem("geovany.org", 2)
.AssertSingleItem("valentine.net", 0, r => r
.AssertCount(5)
.AssertCount(7)
.AssertSingleItem("arvel.name", 1)
.AssertSingleItem("breana.com", 1)
.AssertSingleItem("jaquelin.com", 2)
.AssertSingleItem("lenny.net", 1)
.AssertSingleItem("breana.com", 2)
.AssertSingleItem("jaquelin.com", 3)
.AssertSingleItem("lenny.net", 3)
.AssertSingleItem("mack.info", 1));
}

Expand Down Expand Up @@ -262,20 +262,34 @@ public async Task GetSearchSuggestions()
CollectionAssert.AreEquivalent(new[]
{
"back-end_grey_JBOD",
"transition_vortals",
"Iceland Krona_New Israeli Sheqel_matrix_Oklahoma",
"Handcrafted Fresh Hat_metrics_invoice",
"Handcrafted Rubber Tuna_Sudanese Pound_syndicate",
"Iowa_Junctions",
"Handcrafted Granite Ball_Associate_haptic_Money Market Account_Beauty",
"bandwidth_auxiliary_Incredible",
"violet_Metal_calculating",
"maroon_synthesizing_Awesome",
"index_transmitting_generate_24/7_Run",
"Virgin Islands, U.S._withdrawal_CFA Franc BCEAO_THX",
"capability_Unbranded Granite Table_Intelligent Cotton Table_static",
"deposit",
"circuit_impactful_Organic",
"SSL_cutting-edge_Global_platforms",
"Interactions_convergence_static",
"Via_West Virginia_withdrawal",
"back-end_benchmark_Legacy_Future_Crescent",
"deposit",
"Soft_Health_facilitate_Cotton",
"bandwidth_Refined Fresh Shoes",
"back-end_benchmark_Legacy_Future_Crescent",
"North Dakota_bypass_Gorgeous Steel Keyboard",
"full-range_Kenyan Shilling_experiences_Money Market Account_Officer",
"connecting_Distributed_Florida_mission-critical_Awesome Wooden Bacon",
"Global_Licensed",
"Generic Plastic Cheese_Infrastructure_Intelligent_quantify",
"IB_Health_sky blue",
"Small_withdrawal_transition_Response_Response",
"initiatives_Customer_neural_Bedfordshire_integrate",
},
suggestions.ToArray());

Expand Down

0 comments on commit c974625

Please sign in to comment.