public DatasetView CreateDataView(string name, string contentSelectionCriterion, string containerSelectionCriterion, BExIS.Dlm.Entities.DataStructure.DataStructure dataStructure) { Contract.Requires(!string.IsNullOrWhiteSpace(name)); Contract.Requires(!string.IsNullOrWhiteSpace(contentSelectionCriterion) || !string.IsNullOrWhiteSpace(containerSelectionCriterion)); Contract.Requires(dataStructure != null); Contract.Ensures(Contract.Result <DatasetView>() != null); DatasetView e = new DatasetView() { Name = name, ContentSelectionCriterion = contentSelectionCriterion, ContainerSelectionCriterion = containerSelectionCriterion, Dataset = null, }; dataStructure.Views.Add(e); e.DataStructures.Add(dataStructure); using (IUnitOfWork uow = this.GetUnitOfWork()) { // maybe there is a need for persisting the data structure also! IRepository <DatasetView> repo = uow.GetRepository <DatasetView>(); repo.Put(e); uow.Commit(); } return(e); }
//Create for dataset, create for datastrcuture, promote for data strcuture // create takes a nullable Dataset as parameter public DatasetView CreateDataView(string name, string contentSelectionCriterion, string containerSelectionCriterion, Dataset dataset) { Contract.Requires(!string.IsNullOrWhiteSpace(name)); Contract.Requires(!string.IsNullOrWhiteSpace(contentSelectionCriterion) || !string.IsNullOrWhiteSpace(containerSelectionCriterion)); Contract.Requires(dataset != null); Contract.Ensures(Contract.Result <DatasetView>() != null); DatasetView e = new DatasetView() { Name = name, ContentSelectionCriterion = contentSelectionCriterion, ContainerSelectionCriterion = containerSelectionCriterion, Dataset = dataset, }; e.Dataset.Views.Add(e); using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository <DatasetView> repo = uow.GetRepository <DatasetView>(); repo.Put(e); uow.Commit(); } return(e); }
public void Initialize(int columnNumber, DatasetView view) { this.columnNumber = columnNumber; this.view = view; this.active = true; this.attributeText.color = Color.black; this.minmaxText.text = "Min-Max"; this.minmaxText.color = Color.black; this.zscoreText.text = "ZScore"; this.zscoreText.color = Color.black; this.removeText.text = "Remove"; this.removeText.color = Color.black; }
/// <summary> /// The Test. /// </summary> /// <param name="testWindow">The testWindow<see cref="Window"/>.</param> protected override void Test(MetroWindow testWindow) { var globalData = new GlobalData { MainWindow = testWindow }; var viewModel = new DatasetViewModel(globalData) { CsvFilePath = TestData.CountryTestCsv }; var view = new DatasetView { DataContext = viewModel }; WindowFactory.CreateAndShow(view, testWindow); }
public DatasetView UpdateDataView(DatasetView entity) { Contract.Requires(entity != null, "provided entity can not be null"); Contract.Requires(entity.Id >= 0, "provided entity must have a permant ID"); Contract.Ensures(Contract.Result <DatasetView>() != null && Contract.Result <DatasetView>().Id >= 0, "No entity is persisted!"); using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository <DatasetView> repo = uow.GetRepository <DatasetView>(); repo.Merge(entity); var merged = repo.Get(entity.Id); repo.Put(merged); uow.Commit(); } return(entity); }
public bool DeleteDataView(DatasetView entity) { Contract.Requires(entity != null); Contract.Requires(entity.Id >= 0); using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository <DatasetView> repo = uow.GetRepository <DatasetView>(); entity = repo.Reload(entity); entity.Dataset = null; entity.DataStructures.Clear(); repo.Delete(entity); uow.Commit(); } return(true); }
/// <summary> /// Removes the relationship between the structured data structure and the view, neither the data structure nor the view. /// </summary> /// <param name="dataStructure">The data structure to be release from the relationship.</param> /// <param name="view">The view to be release from the relationship.</param> public void RemoveDataView(BExIS.Dlm.Entities.DataStructure.UnStructuredDataStructure dataStructure, DatasetView view) { Contract.Requires(dataStructure != null && dataStructure.Id >= 0); Contract.Requires(view != null && view.Id >= 0); Contract.Requires(view.Dataset == null); //Contract.Ensures(Contract.Result<UnStructuredDataStructure>() != null && Contract.Result<UnStructuredDataStructure>().Id >= 0); using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository <UnStructuredDataStructure> repo = uow.GetRepository <UnStructuredDataStructure>(); repo.Reload(dataStructure); repo.LoadIfNot(dataStructure.Views); int count = (from v in dataStructure.Views where v.Id.Equals(view.Id) select v ) .Count(); if (count <= 0) { throw new Exception(string.Format("There is no connection between data structure {0} and view {1}", dataStructure.Id, view.Id)); } dataStructure.Views.Remove(view); view.DataStructures.Remove(dataStructure); repo.Put(dataStructure); uow.Commit(); } //throw new NotImplementedException(); }
/// <summary> /// Adds a spanning view to the passed unstructured data structure. Spanning views are available and applicable to all datasets associated with the data structure. /// </summary> /// <param name="dataStructure">The unstructured data structure to add the data view to.</param> /// <param name="view">The data view to be linked to the data structure as a spanning view.</param> public void AddDataView(BExIS.Dlm.Entities.DataStructure.UnStructuredDataStructure dataStructure, DatasetView view) { // view should not be connected to a Dataset. if so throw an exception and the caller must remove the relationship to that dataset and then add to a data structure Contract.Requires(dataStructure != null && dataStructure.Id >= 0); Contract.Requires(view != null && view.Id >= 0); Contract.Requires(view.Dataset == null); //Contract.Ensures(Contract.Result<UnStructuredDataStructure>() != null && Contract.Result<UnStructuredDataStructure>().Id >= 0); using (IUnitOfWork uow = this.GetUnitOfWork()) { IRepository <UnStructuredDataStructure> repo = uow.GetRepository <UnStructuredDataStructure>(); repo.Reload(dataStructure); repo.LoadIfNot(dataStructure.Views); int count = (from v in dataStructure.Views where v.Id.Equals(view.Id) select v ) .Count(); if (count > 0) { throw new Exception(string.Format("There is a connection between data structure {0} and view {1}", dataStructure.Id, view.Id)); } dataStructure.Views.Add(view); view.DataStructures.Add(dataStructure); repo.Put(dataStructure); uow.Commit(); } }