/// <summary> /// Provides searching strategies. /// </summary> public PhysicalAddressQueryProvider() { ForProperties( x => x.Id) .AsType(SearchDataTypes.String) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { return(CommonQueryStrategies.IdQuery(token.SearchParameter.Key.GetPropertyName(), token.SearchParameter.Value)); }); ForProperties( x => x.Address, x => x.City, x => x.State, x => x.ZipCode, x => x.Country) .AsType(SearchDataTypes.String) .CanBeUsedIn(QueryTypes.Advanced, QueryTypes.Simple) .UsingStrategy(token => { return(CommonQueryStrategies.StringQuery(token.SearchParameter.Key.GetPropertyName(), token.SearchParameter.Value)); }); ForProperties( x => x.IsHomeAddress) .AsType(SearchDataTypes.Boolean) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { return(CommonQueryStrategies.BooleanQuery(token.SearchParameter.Key.GetPropertyName(), token.SearchParameter.Value)); }); }
/// <summary> /// Provides searching strategies for the watch assignment object. /// </summary> public WatchAssignmentQueryProvider() { ForProperties( x => x.Id) .AsType(SearchDataTypes.String) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { return(CommonQueryStrategies.IdQuery(token.SearchParameter.Key.GetPropertyName(), token.SearchParameter.Value)); }); ForProperties( x => x.CurrentState) .AsType(SearchDataTypes.String) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { return(CommonQueryStrategies.ReferenceListValueQuery(token.SearchParameter.Key, token.SearchParameter.Value)); }); ForProperties( x => x.PersonAssigned, x => x.AssignedBy, x => x.AcknowledgedBy) .AsType(SearchDataTypes.String) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { return(Subqueries.PropertyIn(token.SearchParameter.Key.GetPropertyName(), new Person.PersonQueryProvider().CreateQuery(QueryTypes.Simple, token.SearchParameter.Value).DetachedCriteria.SetProjection(Projections.Id()))); }); ForProperties( x => x.IsAcknowledged) .AsType(SearchDataTypes.Boolean) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { return(CommonQueryStrategies.BooleanQuery(token.SearchParameter.Key.GetPropertyName(), token.SearchParameter.Value)); }); ForProperties( x => x.DateAssigned, x => x.DateAcknowledged) .AsType(SearchDataTypes.DateTime) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { return(CommonQueryStrategies.DateTimeQuery(token.SearchParameter.Key.GetPropertyName(), token.SearchParameter.Value)); }); }
/// <summary> /// Provides searching strategies for the person object. /// </summary> public PersonQueryProvider() { ForProperties( x => x.Id) .AsType(SearchDataTypes.String) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { return(CommonQueryStrategies.IdQuery(token.SearchParameter.Key.GetPropertyName(), token.SearchParameter.Value)); }); ForProperties( x => x.SSN, x => x.Suffix, x => x.Remarks, x => x.Supervisor, x => x.WorkCenter, x => x.WorkRoom, x => x.Shift, x => x.WorkRemarks, x => x.JobTitle, x => x.EmergencyContactInstructions, x => x.ContactRemarks, x => x.DoDId) .AsType(SearchDataTypes.String) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { return(CommonQueryStrategies.StringQuery(token.SearchParameter.Key.GetPropertyName(), token.SearchParameter.Value)); }); ForProperties( x => x.LastName, x => x.FirstName, x => x.MiddleName) .AsType(SearchDataTypes.String) .CanBeUsedIn(QueryTypes.Advanced, QueryTypes.Simple) .UsingStrategy(token => { return(CommonQueryStrategies.StringQuery(token.SearchParameter.Key.GetPropertyName(), token.SearchParameter.Value)); }); ForProperties( x => x.HasCompletedAWARE) .AsType(SearchDataTypes.Boolean) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { return(CommonQueryStrategies.BooleanQuery(token.SearchParameter.Key.GetPropertyName(), token.SearchParameter.Value)); }); ForProperties( x => x.DateOfBirth, x => x.GTCTrainingDate, x => x.ADAMSTrainingDate, x => x.DateOfArrival, x => x.EAOS, x => x.DateOfDeparture, x => x.PRD) .AsType(SearchDataTypes.DateTime) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { return(CommonQueryStrategies.DateTimeQuery(token.SearchParameter.Key.GetPropertyName(), token.SearchParameter.Value)); }); ForProperties( x => x.Sex, x => x.BilletAssignment, x => x.Ethnicity, x => x.ReligiousPreference, x => x.DutyStatus) .AsType(SearchDataTypes.String) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { return(CommonQueryStrategies.ReferenceListValueQuery(token.SearchParameter.Key, token.SearchParameter.Value)); }); ForProperties( x => x.Paygrade, x => x.Designation, x => x.Division, x => x.Department, x => x.Command, x => x.UIC, x => x.PrimaryNEC) .AsType(SearchDataTypes.String) .CanBeUsedIn(QueryTypes.Advanced, QueryTypes.Simple) .UsingStrategy(token => { return(CommonQueryStrategies.ReferenceListValueQuery(token.SearchParameter.Key, token.SearchParameter.Value)); }); ForProperties( x => x.SecondaryNECs) .AsType(SearchDataTypes.String) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { NEC necAlias = null; token.Query = token.Query.JoinAlias(x => x.SecondaryNECs, () => necAlias); //First we need to get what the client gave us into a list of Guids. if (token.SearchParameter.Value == null) { throw new CommandCentralException("You search value must not be null.", ErrorTypes.Validation); } var str = (string)token.SearchParameter.Value; if (String.IsNullOrWhiteSpace(str)) { throw new CommandCentralException("Your search value must be a string of values, delineated by white space, semicolons, or commas.", ErrorTypes.Validation); } List <string> values = new List <string>(); foreach (var value in str.Split(new[] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries)) { if (String.IsNullOrWhiteSpace(value) || String.IsNullOrWhiteSpace(value.Trim())) { throw new CommandCentralException("One of your values was not vallid.", ErrorTypes.Validation); } values.Add(value.Trim()); } var disjunction = new Disjunction(); foreach (var value in values) { disjunction.Add(Restrictions.On(() => necAlias.Value).IsInsensitiveLike(value, MatchMode.Anywhere)); } return(disjunction); }); ForProperties( x => x.WatchQualifications) .AsType(SearchDataTypes.String) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { WatchQualification qualAlias = null; token.Query = token.Query.JoinAlias(x => x.WatchQualifications, () => qualAlias); //First we need to get what the client gave us into a list of Guids. if (token.SearchParameter.Value == null) { throw new CommandCentralException("You search value must not be null.", ErrorTypes.Validation); } var str = (string)token.SearchParameter.Value; if (String.IsNullOrWhiteSpace(str)) { throw new CommandCentralException("Your search value must be a string of values, delineated by white space, semicolons, or commas.", ErrorTypes.Validation); } List <string> values = new List <string>(); foreach (var value in str.Split(new[] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries)) { if (String.IsNullOrWhiteSpace(value) || String.IsNullOrWhiteSpace(value.Trim())) { throw new CommandCentralException("One of your values was not vallid.", ErrorTypes.Validation); } values.Add(value.Trim()); } var disjunction = new Disjunction(); foreach (var value in values) { disjunction.Add(Restrictions.On(() => qualAlias.Value).IsInsensitiveLike(value, MatchMode.Anywhere)); } return(disjunction); }); ForProperties( x => x.EmailAddresses) .AsType(SearchDataTypes.String) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { EmailAddress addressAlias = null; token.Query = token.Query.JoinAlias(x => x.EmailAddresses, () => addressAlias); //First we need to get what the client gave us into a list of Guids. if (token.SearchParameter.Value == null) { throw new CommandCentralException("You search value must not be null.", ErrorTypes.Validation); } var str = (string)token.SearchParameter.Value; if (String.IsNullOrWhiteSpace(str)) { throw new CommandCentralException("Your search value must be a string of values, delineated by white space, semicolons, or commas.", ErrorTypes.Validation); } List <string> values = new List <string>(); foreach (var value in str.Split(new[] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries)) { if (String.IsNullOrWhiteSpace(value) || String.IsNullOrWhiteSpace(value.Trim())) { throw new CommandCentralException("One of your values was not valid.", ErrorTypes.Validation); } values.Add(value.Trim()); } var disjunction = new Disjunction(); foreach (var value in values) { disjunction.Add(Restrictions.On(() => addressAlias.Address).IsInsensitiveLike(value, MatchMode.Anywhere)); } return(disjunction); }); ForProperties( x => x.PhysicalAddresses) .AsType(SearchDataTypes.String) .CanBeUsedIn(QueryTypes.Advanced) .UsingStrategy(token => { PhysicalAddress addressAlias = null; token.Query.JoinAlias(x => x.PhysicalAddresses, () => addressAlias); var query = new PhysicalAddress.PhysicalAddressQueryProvider().CreateQuery(QueryTypes.Simple, token.SearchParameter.Value); using (var session = DataProvider.CurrentSession) { var ids = query.GetExecutableQueryOver(session).Select(x => x.Id).List <Guid>(); return(Restrictions.On(() => addressAlias.Id).IsIn(ids.ToList())); } }); }