Files
LeafWeb/WebCms/Models/LeafDataQuery.cs
T

100 lines
4.0 KiB
C#

using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace LeafWeb.WebCms.Models
{
public class LeafDataQuery
{
private const string FloatingPointRegex = @"^([-+]?[0-9]*\.[0-9]+|[0-9]+)$";
/// <summary>Query</summary>
[Display(Name = "Search", Description = "General query")]
public string q { get; set; }
[Display(Name = "Site ID", Description = "The site's name/Fluxnet ID, if known")]
[RegularExpression(@".{3,}", ErrorMessage = "Specify at least three characters")]
public string siteid { get; set; }
[Display(Name = "Species Name")]
[RegularExpression(@".{3,}", ErrorMessage = "Specify at least three characters")]
public string species { get; set; }
/// <summary>Site latitude, northern hemisphere positive</summary>
[Display(Name = "Latitude")]
[RegularExpression(@"^-?([0-9]|[1-8][0-9]|90)$", ErrorMessage = "Site latitude, northern hemisphere positive, -90 &ndash; 90")]
public string lat { get; set; }
[Display(Name = "Range")]
[RegularExpression(@"^([0-9]|[1-8][0-9]|90)$", ErrorMessage = "&plusmn; latitude degrees")]
public string latr { get; set; }
/// <summary>Site longitude, east positive</summary>
[Display(Name = "Longitude")]
[RegularExpression(@"^-?([0-9]|[1-8][0-9]|9[0-9]|1[0-7][0-9]|180)$", ErrorMessage = "Site longitude, east positive, -180 &ndash; 180")]
public string lon { get; set; }
[Display(Name = "Range")]
[RegularExpression(@"^([0-9]|[1-8][0-9]|9[0-9]|1[0-7][0-9]|180)$", ErrorMessage = "&plusmn; longitude degrees")]
public string lonr { get; set; }
/// <summary>Sample CO2 concentration</summary>
[Display(Name = "CO2 response curves (CO2S)")]
[RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")]
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")]
public string pari { get; set; }
/// <summary> temperature of leaf thermocouple</summary>
[Display(Name = "Temperature response curves (Tleaf)")]
[RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")]
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")]
public string phips2 { get; set; }
[Display(Name = "Show Only Successfully Completed")]
[UIHint("Checkbox")]
public string compl { get; set; }
public bool ShowOnlySuccessfullyCompleted => !string.IsNullOrEmpty(compl);
[Display(Name = "Show Only Erred")]
[UIHint("Checkbox")]
public string erred { get; set; }
public bool ShowOnlyErred => !string.IsNullOrEmpty(erred);
[Display(Name = "Only my data")]
[UIHint("Checkbox")]
public string usr { get; set; }
public bool OnlyUserData => !string.IsNullOrEmpty(usr);
public bool HasExtendedParameters =>
!(
string.IsNullOrEmpty(siteid)
&& string.IsNullOrEmpty(species)
&& string.IsNullOrEmpty(lat)
&& string.IsNullOrEmpty(latr)
&& string.IsNullOrEmpty(lon)
&& string.IsNullOrEmpty(lonr)
&& string.IsNullOrEmpty(co2s)
&& string.IsNullOrEmpty(pari)
&& string.IsNullOrEmpty(tleaf)
&& string.IsNullOrEmpty(phips2)
&& string.IsNullOrEmpty(compl)
&& string.IsNullOrEmpty(erred)
);
public bool HasParameters =>
HasExtendedParameters
|| !string.IsNullOrEmpty(q)
|| !string.IsNullOrEmpty(usr);
}
}