Inheritance: BaseEntity
Beispiel #1
0
        /// <summary>
        /// Adds a spanning view to the passed structured data structure. Spanning views are available and applicable to all datasets associated with the data structure.
        /// </summary>
        /// <param name="dataStructure">The structured 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.StructuredDataStructure dataStructure, DataView 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<StructuredDataStructure>() != null && Contract.Result<StructuredDataStructure>().Id >= 0);

            StructuredDataStructureRepo.Reload(dataStructure);
            StructuredDataStructureRepo.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);
            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository<StructuredDataStructure> repo = uow.GetRepository<StructuredDataStructure>();
                repo.Put(dataStructure);
                uow.Commit();
            }
        }
Beispiel #2
0
        public DataView 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<DataView>() != null);

            DataView e = new DataView()
            {
                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<DataView> repo = uow.GetRepository<DataView>();
                repo.Put(e);
                uow.Commit();
            }
            return (e);
        }
Beispiel #3
0
        public bool DeleteDataView(DataView entity)
        {
            Contract.Requires(entity != null);
            Contract.Requires(entity.Id >= 0);

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository<DataView> repo = uow.GetRepository<DataView>();

                entity = repo.Reload(entity);
                entity.Dataset = null;
                entity.DataStructures.Clear();

                repo.Delete(entity);

                uow.Commit();
            }
            return (true);
        }
Beispiel #4
0
        //Create for dataset, create for datastrcuture, promote for data strcuture
        // create takes a nullable Dataset as parameter
        public DataView 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<DataView>() != null);

            DataView e = new DataView()
            {
                Name = name,
                ContentSelectionCriterion = contentSelectionCriterion,
                ContainerSelectionCriterion = containerSelectionCriterion,
                Dataset = dataset,
            };
            e.Dataset.Views.Add(e);

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository<DataView> repo = uow.GetRepository<DataView>();
                repo.Put(e);
                uow.Commit();
            }
            return (e);
        }
Beispiel #5
0
        public DataView UpdateDataView(DataView 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<DataView>() != null && Contract.Result<DataView>().Id >= 0, "No entity is persisted!");

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository<DataView> repo = uow.GetRepository<DataView>();
                repo.Put(entity); // Merge is required here!!!!
                uow.Commit();
            }
            return (entity);
        }
Beispiel #6
0
        /// <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, DataView 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);

            UnStructuredDataStructureRepo.Reload(dataStructure);
            UnStructuredDataStructureRepo.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);
            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository<UnStructuredDataStructure> repo = uow.GetRepository<UnStructuredDataStructure>();
                repo.Put(dataStructure);
                uow.Commit();
            }
            //throw new NotImplementedException();
        }
Beispiel #7
0
        /// <summary>
        /// Detaches the data view from its dataset and deletes the view from the database.
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>True if successful, False otherwise.</returns>
        public bool DeleteDataView(DataView entity)
        {
            Contract.Requires(entity != null);
            Contract.Requires(entity.Id >= 0);

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository<DataView> repo = uow.GetRepository<DataView>();

                entity = repo.Reload(entity);
                repo.Delete(entity);
                uow.Commit();
            }
            // if any problem was detected during the commit, an exception will be thrown!
            return (true);
        }
Beispiel #8
0
        // there is no need for RemoveDataView as it is equal to DeleteDataView. DataView must be associated with a dataset or some data structures but not both
        // if you like to promote a view from a dataset to a data structure, set its Dataset property to null and send it to DataStructureManager.AddDataView
        /// <summary>
        /// Adds a data view to the designated dataset. This method does not execute the view, but only associates it with the dataset so that later its application can be requested.
        /// A data view is the specification of a set of criteria to filter a dataset vertically and horizontally in on demand.
        /// Applying a data view on a dataset version filters its data tuples and variables if the dataset is structured.
        /// For unstructured dataset the data view can be used to pass the filtering criteria to a proper processing tool.
        /// </summary>
        /// <param name="dataset">The dataset the view is linked to</param>
        /// <param name="view">The data view to be associated to the <paramref name="dataset"/>.</param>
        public void AddDataView(Dataset dataset, DataView view)
        {
            Contract.Requires(dataset != null);
            Contract.Requires(view != null && view.Id >= 0);
            Contract.Requires(view.Dataset == null);

            DatasetRepo.Reload(dataset);
            DatasetRepo.LoadIfNot(dataset.Views);
            int count = (from v in dataset.Views
                         where v.Id.Equals(view.Id)
                         select v
                        )
                        .Count();

            if (count > 0)
                throw new Exception(string.Format("There is a connection between dataset {0} and view {1}", dataset.Id, view.Id));

            dataset.Views.Add(view);
            view.Dataset = dataset;
            view.DataStructures.Clear();

            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                // save the relation controller object which is the 1 side in 1:N relationships. in this case: View
                IRepository<DataView> repo = uow.GetRepository<DataView>();
                repo.Put(view);
                uow.Commit();
            }
        }