Search for both LeafInput and LeafInputData

This commit is contained in:
2023-02-02 09:35:22 -05:00
parent 8e16510ad9
commit 680f139aa5
24 changed files with 808 additions and 281 deletions
-7
View File
@@ -5,14 +5,7 @@ namespace LeafWeb.WebCms.Models
public class ChartViewModel
{
public int LeafInputId { get; set; }
public string CurveId { get; set; }
public IEnumerable<string> AvailableCurveId { get; set; }
public string LeafInputIdentifier { get; set; }
}
public class ChartQueryViewModel
{
public int LeafInputId { get; set; }
public string CurveId { get; set; }
}
}
+18 -5
View File
@@ -5,7 +5,11 @@ namespace LeafWeb.WebCms.Models
{
public class LeafDataQuery
{
private const string FloatingPointRegex = @"^([-+]?[0-9]*\.[0-9]+|[0-9]+)$";
// https://3widgets.com/
private const string NumberRange_0_to_2000_Regex = @"^(\d|[1-9]\d{1,2}|1\d{3}|2000)(\.[0-9]+)?$";
private const string NumberRange_0_to_3000_Regex = @"^(\d|[1-9]\d{1,2}|[12]\d{3}|3000)(\.[0-9]+)?$";
private const string NumberRange_Neg20_to_50_Regex = @"^(-[1-9]|-1\d|-20|\d|[1-4]\d|50)(\.[0-9]+)?$";
private const string NumberRange_0_to_1_Regex = @"^(0?\.[0-9]+)|(0|1)?$";
/// <summary>Query</summary>
[Display(Name = "Search", Description = "General query")]
@@ -39,22 +43,22 @@ namespace LeafWeb.WebCms.Models
/// <summary>Sample CO2 concentration</summary>
[Display(Name = "CO2 response curves (CO2S)")]
[RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")]
[RegularExpression(NumberRange_0_to_2000_Regex, ErrorMessage = "Must be numeric, 0 to 2000")]
public string co2s { get; set; }
/// <summary> PAR measured by the in-chamber quantum sensor</summary>
[Display(Name = "Light response curves (PARi)")]
[RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")]
[RegularExpression(NumberRange_0_to_3000_Regex, ErrorMessage = "Must be numeric, 0 to 3000")]
public string pari { get; set; }
/// <summary> temperature of leaf thermocouple</summary>
[Display(Name = "Temperature response curves (Tleaf)")]
[RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")]
[RegularExpression(NumberRange_Neg20_to_50_Regex, ErrorMessage = "Must be numeric, -20 to 50")]
public string tleaf { get; set; }
/// <summary> DeltaF/Fm, the fraction of absorbed PSII photons that are used in photochemistry</summary>
[Display(Name = "Fluorometry measurements (PhiPS2)")]
[RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")]
[RegularExpression(NumberRange_0_to_1_Regex, ErrorMessage = "Must be numeric, 0 to 1")]
public string phips2 { get; set; }
[Display(Name = "Show Only Successfully Completed")]
@@ -75,6 +79,15 @@ namespace LeafWeb.WebCms.Models
public bool OnlyUserData => !string.IsNullOrEmpty(usr);
[Display(Name = "Result Type")]
//[UIHint("Radio")]
public string dsp { get; set; }
public const string LeafInputDataSearchParam = "data";
public bool ShowLeafInputData => dsp == LeafInputDataSearchParam;
public const string LeafInputSearchParam = "set";
public bool ShowLeafInput => dsp == LeafInputSearchParam;
public bool HasExtendedParameters =>
!(
+44
View File
@@ -0,0 +1,44 @@
using System.ComponentModel.DataAnnotations;
using AutoMapper;
using LeafWeb.Core.Entities;
namespace LeafWeb.WebCms.Models
{
public class LeafDataResultViewModel
{
[Display(Name = "Site ID", Description = "The site's name/Fluxnet ID, if known")]
public string SiteId { get; set; }
[Display(Name = "Species Name")]
public string SpeciesSampled { get; set; }
/// <summary>Site latitude, northern hemisphere positive</summary>
[Display(Name = "Latitude")]
public double? Latitude { get; set; }
/// <summary>Site longitude, east positive</summary>
[Display(Name = "Longitude")]
public double? Longitude { get; set; }
/// <summary>Sample CO2 concentration</summary>
[Display(Name = "CO2 response curves (CO2S)")]
public double? CO2S { get; set; }
/// <summary> PAR measured by the in-chamber quantum sensor</summary>
[Display(Name = "Light response curves (PARi)")]
public double? PARi { get; set; }
/// <summary> temperature of leaf thermocouple</summary>
[Display(Name = "Temperature response curves (Tleaf)")]
public double? Tleaf { get; set; }
/// <summary> DeltaF/Fm, the fraction of absorbed PSII photons that are used in photochemistry</summary>
[Display(Name = "Fluorometry measurements (PhiPS2)")]
public double? PhiPS2 { get; set; }
public LeafDataResultViewModel(LeafInputData inputData)
{
Mapper.Map(inputData, this);
}
}
}
@@ -18,9 +18,40 @@ namespace LeafWeb.WebCms.Models
public double? PhiPS2 { get; set; }
public LeafInputDataCurveViewModel() {}
static LeafInputDataCurveViewModel()
{
Mapper.CreateMap<LeafInputData, LeafInputDataCurveViewModel>()
.ForMember(m => m.CO2S,
conf =>
conf.MapFrom(d =>
LeafInputData.Range(d.Data, c => c.CO2S)))
.ForMember(m => m.PARi,
conf =>
conf.MapFrom(d =>
LeafInputData.Range(d.Data, c => c.PARi)))
.ForMember(m => m.Tleaf,
conf =>
conf.MapFrom(d =>
LeafInputData.Range(d.Data, c => c.Tleaf)))
.ForMember(m => m.PhiPS2,
conf =>
conf.MapFrom(d =>
LeafInputData.Range(d.Data, c => c.PhiPS2)))
;
}
public LeafInputDataCurveViewModel(LeafInputDataCurve leafInputDataCurve)
{
Mapper.Map(leafInputDataCurve, this);
}
public LeafInputDataCurveViewModel(LeafInputData leafInputData)
{
Mapper.Map(leafInputData, this);
//CO2S = LeafInputData.Range(dataCurves, c => c.CO2S);
//PARi = LeafInputData.Range(dataCurves, c => c.PARi);
//Tleaf = LeafInputData.Range(dataCurves, c => c.Tleaf);
//PhiPS2 = LeafInputData.Range(dataCurves, c => c.PhiPS2);
}
}
}
@@ -1,11 +1,12 @@
using System.Collections.Generic;
using System.Linq;
using LeafWeb.Core.Entities;
namespace LeafWeb.WebCms.Models
{
public class SearchViewModel
public class SearchLeafInputDataViewModel
{
public IEnumerable<LeafInput> Items { get; set; }
public IQueryable<LeafInputData> Results { get; set; }
public LeafDataQuery Q { get; set; }
}
}
+11
View File
@@ -0,0 +1,11 @@
using System.Linq;
using LeafWeb.Core.Entities;
namespace LeafWeb.WebCms.Models
{
public class SearchLeafInputViewModel
{
public IQueryable<LeafInput> Results { get; set; }
public LeafDataQuery Q { get; set; }
}
}