Skip to content

Commit

Permalink
Merge pull request #1412 from Artsdatabanken/feature/translateHabitat…
Browse files Browse the repository at this point in the history
…AndNotEnumFilters

Feature/translate habitat and not enum filters
  • Loading branch information
AneMarlene authored May 23, 2024
2 parents 4ebba88 + ed8a4cb commit cb25dbc
Show file tree
Hide file tree
Showing 16 changed files with 1,516 additions and 317 deletions.
16 changes: 16 additions & 0 deletions Assessments.Frontend.Web/Assessments.Frontend.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,20 @@
<ProjectReference Include="..\Assessments.Mapping\Assessments.Mapping.csproj" />
<ProjectReference Include="..\Assessments.Shared\Assessments.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Resources\SharedResources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>SharedResources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Resources\SharedResources.en.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Resources\SharedResources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>SharedResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>
382 changes: 139 additions & 243 deletions Assessments.Frontend.Web/Infrastructure/AlienSpecies/FilterItemHelpers.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ private static IQueryable<AlienSpeciesAssessment2023> ApplyCategoryChange(string
{
var assessments = change switch
{
nameof(CategoryChangeEnum.ccvf) => query.Where(x => (x.PreviousAssessments.Count == 0 || x.PreviousAssessments.Any(y => y.RevisionYear == 2018 && y.Category == AlienSpeciesAssessment2023Category.NR)) && x.Category != AlienSpeciesAssessment2023Category.NR),
nameof(CategoryChangeEnum.ccsk) => query.Where(x => x.PreviousAssessments.Count > 0 && x.PreviousAssessments.Any(y => y.RevisionYear == 2018 && y.Category != AlienSpeciesAssessment2023Category.NR && x.Category == y.Category)),
nameof(Constants.SearchAndFiltersAlienSpecies.AssessedFirstTime) => query.Where(x => (x.PreviousAssessments.Count == 0 || x.PreviousAssessments.Any(y => y.RevisionYear == 2018 && y.Category == AlienSpeciesAssessment2023Category.NR)) && x.Category != AlienSpeciesAssessment2023Category.NR),
nameof(Constants.SearchAndFiltersAlienSpecies.AssessedChangedCategory) => query.Where(x => x.PreviousAssessments.Count > 0 && x.PreviousAssessments.Any(y => y.RevisionYear == 2018 && y.Category != AlienSpeciesAssessment2023Category.NR && x.Category == y.Category)),
nameof(AlienSpeciesAssessment2023ReasonForChangeOfCategory.NewKnowledge) => query.Where(x => x.PreviousAssessments.Any(y => y.RevisionYear == 2018 && y.Category != AlienSpeciesAssessment2023Category.NR && x.Category != y.Category && x.ReasonForChangeOfCategory.Contains(AlienSpeciesAssessment2023ReasonForChangeOfCategory.NewKnowledge))),
nameof(AlienSpeciesAssessment2023ReasonForChangeOfCategory.NewInterpretation) => query.Where(x => x.PreviousAssessments.Any(y => y.RevisionYear == 2018 && y.Category != AlienSpeciesAssessment2023Category.NR && x.Category != y.Category && x.ReasonForChangeOfCategory.Contains(AlienSpeciesAssessment2023ReasonForChangeOfCategory.NewInterpretation))),
nameof(AlienSpeciesAssessment2023ReasonForChangeOfCategory.ChangedGuidelines) => query.Where(x => x.PreviousAssessments.Any(y => y.RevisionYear == 2018 && y.Category != AlienSpeciesAssessment2023Category.NR && x.Category != y.Category && x.ReasonForChangeOfCategory.Contains(AlienSpeciesAssessment2023ReasonForChangeOfCategory.ChangedGuidelines))),
Expand Down Expand Up @@ -237,8 +237,8 @@ private static IQueryable<AlienSpeciesAssessment2023> ApplyGeographicVariation(s
{
var assessments = variation switch
{
nameof(GeographicVariation.GeographicVariationEnum.Gvv) => query.Where(x => x.GeographicVariationInCategory == true),
nameof(GeographicVariation.GeographicVariationEnum.Gvn) => query.Where(x => x.GeographicVariationInCategory == false),
nameof(Constants.SearchAndFiltersAlienSpecies.GeographicVariationNotEqual) => query.Where(x => x.GeographicVariationInCategory == true),
nameof(Constants.SearchAndFiltersAlienSpecies.GeographicVariationEqual) => query.Where(x => x.GeographicVariationInCategory == false),
_ => null
};

Expand All @@ -256,10 +256,10 @@ private static IQueryable<AlienSpeciesAssessment2023> ApplyClimateEffects(string
{
var assessments = effect switch
{
nameof(ClimateEffects.ClimateEffectsEnum.Cepi) => query.Where(x => x.ClimateEffectsInvasionpotential == true),
nameof(ClimateEffects.ClimateEffectsEnum.Cepo) => query.Where(x => x.ClimateEffectsEcoEffect == true),
nameof(ClimateEffects.ClimateEffectsEnum.Ceii) => query.Where(x => x.ClimateEffectsInvasionpotential == false),
nameof(ClimateEffects.ClimateEffectsEnum.Ceio) => query.Where(x => x.ClimateEffectsEcoEffect == false),
nameof(Constants.SearchAndFiltersAlienSpecies.ClimateInvasionPotentialAffected) => query.Where(x => x.ClimateEffectsInvasionpotential == true),
nameof(Constants.SearchAndFiltersAlienSpecies.ClimateEcologicalEffectAffected) => query.Where(x => x.ClimateEffectsEcoEffect == true),
nameof(Constants.SearchAndFiltersAlienSpecies.ClimateInvasionPotentialNotAffected) => query.Where(x => x.ClimateEffectsInvasionpotential == false),
nameof(Constants.SearchAndFiltersAlienSpecies.ClimateEcologicalEffectNotAffected) => query.Where(x => x.ClimateEffectsEcoEffect == false),
_ => null
};

Expand Down Expand Up @@ -301,17 +301,17 @@ private static IQueryable<AlienSpeciesAssessment2023> ApplyRegionallyAlien(strin
foreach (var regionFilter in regionFilters)
{
IQueryable<AlienSpeciesAssessment2023> assessments;
// Rae and Rai are not regions, so they are treated differently
if (regionFilter != nameof(RegionallyAlien.RegionallyAlienEnum.Rae) && regionFilter != nameof(RegionallyAlien.RegionallyAlienEnum.Rai) && Enum.TryParse(regionFilter, out RegionallyAlien.RegionallyAlienEnum filterEnum))
// ExcludeRegionallyAlien and OnlyRegionallyAlien are not regions, so they are treated differently
if (regionFilter != nameof(Constants.SearchAndFiltersAlienSpecies.ExcludeRegionallyAlien) && regionFilter != nameof(Constants.SearchAndFiltersAlienSpecies.OnlyRegionallyAlien) && Enum.TryParse(regionFilter, out RegionallyAlien.RegionallyAlienEnum filterEnum))
{
assessments = query.Where(x => x.FreshWaterRegionModel.FreshWaterRegions.Any(y => y.WaterRegionName == filterEnum.DisplayName() && y.IsIncludedInAssessmentArea == true && (y.IsKnown || y.IsAssumedToday || y.IsAssumedInFuture)));
}
else
{
assessments = regionFilter switch
{
nameof(RegionallyAlien.RegionallyAlienEnum.Rae) => query.Where(x => x.AlienSpeciesCategory != AlienSpeciecAssessment2023AlienSpeciesCategory.RegionallyAlien && x.AlienSpeciesCategory != AlienSpeciecAssessment2023AlienSpeciesCategory.RegionallyAlienEstablishedBefore1800),
nameof(RegionallyAlien.RegionallyAlienEnum.Rai) => query.Where(x => x.AlienSpeciesCategory == AlienSpeciecAssessment2023AlienSpeciesCategory.RegionallyAlien || x.AlienSpeciesCategory == AlienSpeciecAssessment2023AlienSpeciesCategory.RegionallyAlienEstablishedBefore1800),
nameof(Constants.SearchAndFiltersAlienSpecies.ExcludeRegionallyAlien) => query.Where(x => x.AlienSpeciesCategory != AlienSpeciecAssessment2023AlienSpeciesCategory.RegionallyAlien && x.AlienSpeciesCategory != AlienSpeciecAssessment2023AlienSpeciesCategory.RegionallyAlienEstablishedBefore1800),
nameof(Constants.SearchAndFiltersAlienSpecies.OnlyRegionallyAlien) => query.Where(x => x.AlienSpeciesCategory == AlienSpeciecAssessment2023AlienSpeciesCategory.RegionallyAlien || x.AlienSpeciesCategory == AlienSpeciecAssessment2023AlienSpeciesCategory.RegionallyAlienEstablishedBefore1800),
_ => null
};
}
Expand Down
54 changes: 54 additions & 0 deletions Assessments.Frontend.Web/Infrastructure/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,60 @@ public static class TaxonCategoriesEn

// Alien species constants

public class SearchAndFiltersAlienSpecies
{
public string ChooseArea = Resources.SharedResources.area;
public string InvasionPotentialAxis = Resources.SharedResources.invasion_potential_x_axis;
public string InvasionPotentialDescription = Resources.SharedResources.invasion_potential_description;
public string EcologicalEffectAxis = Resources.SharedResources.ecological_effect_y_axis;
public string EcologicalEffectDescription = Resources.SharedResources.ecological_effect_description;
public string ImpactCategory = Resources.SharedResources.impact_category;
public string AssessedFirstTime = Resources.SharedResources.first_time_assessed;
public string AssessedChangedCategory = Resources.SharedResources.category_changed;
public string AssessedSameCategory = Resources.SharedResources.category_not_changed;
public string AssessedChangedCategoryFilter = Resources.SharedResources.change_in_category;
public string AxBDescription = Resources.SharedResources.A_B_highest_score;
public string AxB = Resources.SharedResources.A_B;
public string InvasionPotential = Resources.SharedResources.invasion_potential;
public string EcologicalEffect = Resources.SharedResources.ecological_effect;
public string DecisiveCriteria = Resources.SharedResources.decisive_criteria;
public string Lifestyle = Resources.SharedResources.lifestyle;
public string GeographicVariationNotEqual = Resources.SharedResources.geographic_var_unequal;
public string GeographicVariationEqual = Resources.SharedResources.geographic_var_equal;
public string GeographicVariation = Resources.SharedResources.geographic_var;
public string ClimateInvasionPotentialAffected = Resources.SharedResources.invasion_potential_climate_affected;
public string ClimateEcologicalEffectAffected = Resources.SharedResources.ecological_effect_climate_affected;
public string ClimateInvasionPotentialNotAffected = Resources.SharedResources.invasion_potential_climate_not_affected;
public string ClimateEcologicalEffectNotAffected = Resources.SharedResources.ecological_effect_climate_not_affected;
public string ClimateAffected = Resources.SharedResources.climate_affected;
public string ClimateNotAffected = Resources.SharedResources.climate_not_affected;
public string ClimateImpact = Resources.SharedResources.climate_impact;
public string OccurrenceStronglyAlteredNature = Resources.SharedResources.aoo_strongly_altered_nature;
public string OccurrenceThreatenedEcosystem = Resources.SharedResources.aoo_threatened_ecosystems;
public string Ecosystems = Resources.SharedResources.ecosystems;
public string Importation = Resources.SharedResources.import;
public string Introduction = Resources.SharedResources.introduction;
public string Spread = Resources.SharedResources.spread;
public string Pathways = Resources.SharedResources.pathways;
public string ExcludeRegionallyAlien = Resources.SharedResources.regionally_alien_exclude;
public string OnlyRegionallyAlien = Resources.SharedResources.regionally_alien_only;
public string RegionOccurrence = Resources.SharedResources.regionally_distribution;
public string WaterRegions = Resources.SharedResources.water_regions;
public string RegionallyAlien = Resources.SharedResources.regionally_alien;
public string Taxonomy = Resources.SharedResources.taxonomy;
public string SpeciesGroups = Resources.SharedResources.species_groups;
public string RegionsOccurrenceExpected = Resources.SharedResources.regions_expected_occurrence;
public string RegionsOceans = Resources.SharedResources.regions_oceans;
public string IsProductionSpecies = Resources.SharedResources.is_production_species;
public string NotProductionSpecies = Resources.SharedResources.not_production_species;
public string ProductionSpecies = Resources.SharedResources.production_species;
public string DoorKnockers = Resources.SharedResources.doorknockers;
public string EstablishmentCategory = Resources.SharedResources.establishment_category;
public string NotRiskAssessedSpecies = Resources.SharedResources.not_assessed_species;
public string ChooseAll = Resources.SharedResources.choose_all;

}

public const string AlienSpecies2023PageMenuAssessmentAreaText = "områder der arten er regionalt fremmed i Norge (uten Svalbard)";

public const string AlienSpecies2023FirstPublished = "11.08.2023";
Expand Down
Loading

0 comments on commit cb25dbc

Please sign in to comment.