public List <Dictionary <ViewTableField, string> > GetTableResult( CoordinateSystemId coordinateSystemId, SpeciesObservationTableColumnsSetId speciesObservationTableColumnsSetId) { SpeciesObservationsData speciesObservationsData = GetSpeciesObservations(coordinateSystemId); var viewManager = new SpeciesObservationTableViewManager(UserContext, MySettings); ViewTableViewModel viewModel = viewManager.CreateViewTableViewModel(speciesObservationTableColumnsSetId); var speciesObservationDataManager = new SpeciesObservationDataManager(UserContext, MySettings); List <Dictionary <ViewTableField, string> > dicResult = speciesObservationDataManager.GetObservationsListDictionary(speciesObservationsData.SpeciesObservationViewModels, viewModel.TableFields); return(dicResult); }
public List <Dictionary <string, string> > GetTablePagedResult(int start, int pageSize) { SpeciesObservationFieldDescriptionViewManager fieldDescriptionViewManager = new SpeciesObservationFieldDescriptionViewManager(UserContext, MySettings); SpeciesObservationFieldDescriptionsViewModel fieldDescriptionsViewModel = fieldDescriptionViewManager.CreateSpeciesObservationFieldDescriptionsViewModel(); SpeciesObservationList speciesObservationList = GetPagedSpeciesObservationList(start, pageSize, null, null); SpeciesObservationsData speciesObservationsData = new SpeciesObservationsData(speciesObservationList, fieldDescriptionsViewModel); var viewManager = new SpeciesObservationTableViewManager(UserContext, MySettings); ViewTableViewModel viewModel = viewManager.CreateViewTableViewModel(); var speciesObservationDataManager = new SpeciesObservationDataManager(UserContext, MySettings); List <Dictionary <string, string> > dicResult = speciesObservationDataManager.GetObservationsDataList(speciesObservationsData.SpeciesObservationViewModels, viewModel.TableFields); return(dicResult); }
/// <summary> /// Returns the view model of the table data. /// </summary> /// <returns></returns> public ViewTableViewModel GetViewTableViewModel() { ViewTableViewModel model = new ViewTableViewModel(); List <ISpeciesObservationFieldDescription> fields = PresentationTableSetting.SpeciesObservationTable.GetTableFields(UserContext); var tableFields = new List <ViewTableField>(); foreach (ISpeciesObservationFieldDescription field in fields) { ViewTableField viewTableField = new ViewTableField(field.Label, field.Name); tableFields.Add(viewTableField); } model.TableFields = tableFields; return(model); }
public List <Dictionary <string, string> > GetTablePagedResultInBbox(int start, int pageSize, double bottom, double left, double right, double top) { Polygon bbox = GetPolygon(bottom, left, right, top); SpeciesObservationList speciesObservationList = GetPagedSpeciesObservationList(start, pageSize, null, bbox); var fieldDescriptionViewManager = new SpeciesObservationFieldDescriptionViewManager(UserContext, MySettings); var fieldDescriptionsViewModel = fieldDescriptionViewManager.CreateSpeciesObservationFieldDescriptionsViewModel(); SpeciesObservationsData speciesObservationsData = new SpeciesObservationsData(speciesObservationList, fieldDescriptionsViewModel); var viewManager = new SpeciesObservationTableViewManager(UserContext, MySettings); ViewTableViewModel viewModel = viewManager.CreateViewTableViewModel(); var speciesObservationDataManager = new SpeciesObservationDataManager(UserContext, MySettings); List <Dictionary <string, string> > dicResult = speciesObservationDataManager.GetObservationsDataList(speciesObservationsData.SpeciesObservationViewModels, viewModel.TableFields); return(dicResult); }
private Dictionary <string, string> GetObservationData( SpeciesObservationViewModel speciesObservationViewModel) { if (speciesObservationViewModel == null) { return(null); } var viewManager = new SpeciesObservationTableViewManager(userContext, mySettings); ViewTableViewModel viewModel = viewManager.CreateViewTableViewModel(); bool useLabelAsKey = mySettings.Presentation.Table.SpeciesObservationTable.UseLabelAsColumnHeader; Dictionary <string, string> dicResult = GetObservationsKeyValueDictionary(speciesObservationViewModel, viewModel.TableFields, useLabelAsKey); return(dicResult); }
public ViewTableViewModel CreateViewTableViewModel() { ViewTableViewModel model = new ViewTableViewModel(); PagedSpeciesObservationResultCalculator resultCalculator = new PagedSpeciesObservationResultCalculator(UserContext, MySettings); model.ComplexityEstimate = resultCalculator.GetQueryComplexityEstimate(); List <ISpeciesObservationFieldDescription> fields = PresentationTableSetting.SpeciesObservationTable.GetTableFields(UserContext); var tableFields = new List <ViewTableField>(); foreach (ISpeciesObservationFieldDescription field in fields) { ViewTableField viewTableField = new ViewTableField(field.Label, field.Name.FirstLetterToUpper()); tableFields.Add(viewTableField); } model.TableFields = tableFields; return(model); }
public Dictionary <string, string> GetObservationData(int observationId, int?importance, bool?showDwcTitle, bool?hideEmptyFields) { SpeciesObservationViewModel speciesObservationViewModel = GetSpeciesObservationViewModel(observationId); if (speciesObservationViewModel != null) { var viewManager = new SpeciesObservationTableViewManager(userContext, mySettings); ViewTableViewModel viewModel = viewManager.CreateViewTableViewModelByImportance(importance); bool useLabelAsKey = mySettings.Presentation.Table.SpeciesObservationTable.UseLabelAsColumnHeader; if (showDwcTitle.HasValue) { useLabelAsKey = !showDwcTitle.Value; } Dictionary <string, string> dicResult = GetObservationsKeyValueDictionary(speciesObservationViewModel, viewModel.TableFields, useLabelAsKey, !hideEmptyFields.GetValueOrDefault(false)); return(dicResult); //return GetObservationData(speciesObservationViewModel); } return(null); }
public ViewTableViewModel CreateViewTableViewModelByImportance(int?importance) { ViewTableViewModel model = new ViewTableViewModel(); List <ISpeciesObservationFieldDescription> fields; if (importance.HasValue) { fields = PresentationTableSetting.SpeciesObservationTable.GetTableFieldsByImportance(UserContext, importance.Value); } else { fields = PresentationTableSetting.SpeciesObservationTable.GetTableFields(UserContext); } var tableFields = new List <ViewTableField>(); foreach (ISpeciesObservationFieldDescription field in fields) { ViewTableField viewTableField = new ViewTableField(field.Label, field.Name.FirstLetterToUpper()); tableFields.Add(viewTableField); } model.TableFields = tableFields; return(model); }
public void GetObservationsListDictionary_WhenOneProjectParameter_ThenProjectAndProjectParameterArePairedTogether() { // Constants const string projectName = "My project"; const int observationId = 150; const string projectParameterName1 = "Degrees"; const string projectParameterValue1 = "25"; //Arrange LoginApplicationUser(); SpeciesObservationDataManager speciesObservationDataManager = new SpeciesObservationDataManager( SessionHandler.UserContext, SessionHandler.MySettings); List <SpeciesObservationViewModel> obsResultList = new List <SpeciesObservationViewModel>(); IEnumerable <ViewTableField> tableFields = null; // Arrange - Mock CoreData.SpeciesObservationManager.DataSource = new StubISpeciesObservationDataSource() { GetSpeciesObservationsIUserContextListOfInt64ICoordinateSystemISpeciesObservationSpecification = (userContext, speciesObservationIds, coordinateSystem, speciesObservationSpecification) => { SpeciesObservationList speciesObservationList = new SpeciesObservationList(); ISpeciesObservation speciesObservation = new ArtDatabanken.Data.SpeciesObservation(); speciesObservation.Id = observationId; speciesObservation.Project = new SpeciesObservationProject { ProjectName = projectName, ProjectParameters = new SpeciesObservationProjectParameterList { new SpeciesObservationProjectParameter { ProjectName = projectName, Property = projectParameterName1, Value = projectParameterValue1 } } }; speciesObservationList.Add(speciesObservation); return(speciesObservationList); } }; var viewManager = new SpeciesObservationTableViewManager( SessionHandler.UserContext, SessionHandler.MySettings); ViewTableViewModel viewModel = viewManager.CreateViewTableViewModel( SessionHandler.MySettings.Presentation.Table.SpeciesObservationTable.SpeciesObservationTableColumnsSetId); tableFields = viewModel.TableFields; obsResultList.Add(new SpeciesObservationViewModel { Id = observationId.ToString(), Projects = new List <ProjectViewModel> { new ProjectViewModel() { Name = projectName, ProjectParameters = new Dictionary <string, ProjectParameterObservationDetailFieldViewModel> { { projectParameterIdentifer1, new ProjectParameterObservationDetailFieldViewModel() { PropertyIdentifier = projectParameterIdentifer1, Name = projectParameterName1, Label = projectParameterName1, Value = projectParameterValue1, } } } } } }); //Act List <Dictionary <ViewTableField, string> > result = speciesObservationDataManager.GetObservationsListDictionary( obsResultList, tableFields); //Assert bool foundProjectParameter = false; foreach (KeyValuePair <ViewTableField, string> pair in result.First()) { string headerTitle = string.Format("[{0}].[{1}]", projectName, projectParameterName1); if (pair.Key.Title == headerTitle && pair.Key.DataField == headerTitle && pair.Value == projectParameterValue1) { foundProjectParameter = true; } } Assert.IsTrue(foundProjectParameter, "Project parameter not found"); }