Example #1
0
 public static EntityInstanceGridRowModel Convert(EntityStoreItem item, bool isPublic)
 {
     return(new EntityInstanceGridRowModel()
     {
         Id = item.Id,
         Title = item.Title,
         IsPublic = isPublic
     });
 }
Example #2
0
        public List <EntityStoreItem> GetEntities(int skip, int take)
        {
            bool withPaging = (take > 0);


            using (var uow = this.GetUnitOfWork())
                using (DatasetManager dm = new DatasetManager())
                    using (MetadataStructureManager metadataStructureManager = new MetadataStructureManager())
                    {
                        XmlDatasetHelper xmlDatasetHelper = new XmlDatasetHelper();
                        var entities = new List <EntityStoreItem>();

                        try
                        {
                            List <long> metadataStructureIds = metadataStructureManager.Repo.Query().Select(m => m.Id).ToList();

                            List <long> metadataSturctureIdsForDatasets = new List <long>();
                            metadataSturctureIdsForDatasets = metadataStructureIds.Where(m => xmlDatasetHelper.HasEntity(m, _entityName)).ToList();

                            foreach (var msid in metadataSturctureIdsForDatasets)
                            {
                                var datasetIds = new List <long>();
                                // get all datasets based on metadata data structure id
                                if (withPaging)
                                {
                                    datasetIds = dm.DatasetRepo
                                                 .Query(d => d.MetadataStructure.Id.Equals(msid))
                                                 .Skip(skip)
                                                 .Take(take)
                                                 .Select(d => d.Id).ToList();
                                }
                                else
                                {
                                    datasetIds = dm.DatasetRepo.Query(d => d.MetadataStructure.Id.Equals(msid)).Select(d => d.Id).ToList();
                                }


                                if (!datasetIds.Any())
                                {
                                    continue;
                                }

                                // create tuples based on dataset id list, and get latest version of each dataset

                                List <DatasetVersion> datasetVersions = dm.GetDatasetLatestVersions(datasetIds, false);
                                foreach (var dsv in datasetVersions)
                                {
                                    var e = new EntityStoreItem()
                                    {
                                        Id      = dsv.Dataset.Id,
                                        Title   = dsv.Title,
                                        Version = dm.GetDatasetVersionCount(dsv.Dataset.Id)
                                    };

                                    entities.Add(e);
                                }
                            }

                            return(entities.ToList());
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
        }