diff --git a/BExIS++.sln b/BExIS++.sln index c9cb563234..0e2a080257 100644 --- a/BExIS++.sln +++ b/BExIS++.sln @@ -1630,8 +1630,8 @@ Global {C1AE3004-853A-4CCF-9099-AE919C6121C8} = {96384857-88D4-4282-8EFD-FE8FCB0319B7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.0\lib\NET35;packages\Unity.2.1.505.2\lib\NET35 SolutionGuid = {9B6E4921-8EBA-487D-A098-3E473A0EAC64} + EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.0\lib\NET35;packages\Unity.2.1.505.2\lib\NET35 EndGlobalSection GlobalSection(SubversionScc) = preSolution Svn-Managed = True diff --git a/Components/AAA/BExIS.Security.Entities/Objects/EntityReference.cs b/Components/AAA/BExIS.Security.Entities/Objects/EntityReference.cs index 501f7b072b..943a813f8b 100644 --- a/Components/AAA/BExIS.Security.Entities/Objects/EntityReference.cs +++ b/Components/AAA/BExIS.Security.Entities/Objects/EntityReference.cs @@ -27,6 +27,8 @@ public class EntityReference : BaseEntity public virtual int TargetVersion { get; set; } public virtual string Context { get; set; } public virtual string ReferenceType { get; set; } + public virtual string LinkType { get; set; } + public virtual string Category { get; set; } public virtual DateTime CreationDate { get; set; } public EntityReference() @@ -37,9 +39,14 @@ public EntityReference() TargetEntityId = 0; Context = ""; ReferenceType = ""; + CreationDate = DateTime.Now; + LinkType = ""; + Category = ""; + SourceVersion = 0; + TargetVersion = 0; } - public EntityReference(long sourceId, long sourceEntityId, int sourceVersion, long targetId, long targetEntityId, int targetVersion, string context, string type, DateTime creationDate) + public EntityReference(long sourceId, long sourceEntityId, int sourceVersion, long targetId, long targetEntityId, int targetVersion, string context, string type, DateTime creationDate, string linkType , string category) { SourceId = sourceId; SourceEntityId = sourceEntityId; @@ -50,6 +57,8 @@ public EntityReference(long sourceId, long sourceEntityId, int sourceVersion, lo Context = context; ReferenceType = type; CreationDate = creationDate; + Category = category; + LinkType = linkType; } } } \ No newline at end of file diff --git a/Components/AAA/BExIS.Security.Orm.NH/Mappings/Default/Objects/EntityReference.hbm.xml b/Components/AAA/BExIS.Security.Orm.NH/Mappings/Default/Objects/EntityReference.hbm.xml index c27b6415e8..53a3183835 100644 --- a/Components/AAA/BExIS.Security.Orm.NH/Mappings/Default/Objects/EntityReference.hbm.xml +++ b/Components/AAA/BExIS.Security.Orm.NH/Mappings/Default/Objects/EntityReference.hbm.xml @@ -22,6 +22,8 @@ + + \ No newline at end of file diff --git a/Components/AAA/BExIS.Security.Services/Objects/EntityReferenceManager.cs b/Components/AAA/BExIS.Security.Services/Objects/EntityReferenceManager.cs index cda1cad4f5..7677a8aee6 100644 --- a/Components/AAA/BExIS.Security.Services/Objects/EntityReferenceManager.cs +++ b/Components/AAA/BExIS.Security.Services/Objects/EntityReferenceManager.cs @@ -1,5 +1,6 @@ using BExIS.Security.Entities.Objects; using System; +using System.Collections.Generic; using System.Linq; using Vaiona.Persistence.Api; @@ -42,7 +43,9 @@ public bool Exist(EntityReference entityReference, bool includeVersion = false, r.TargetEntityId.Equals(entityReference.TargetEntityId) && r.TargetVersion.Equals(entityReference.TargetVersion) && r.Context.Equals(entityReference.Context) && - r.ReferenceType.Equals(entityReference.ReferenceType) + r.ReferenceType.Equals(entityReference.ReferenceType) && + r.LinkType.Equals(entityReference.LinkType) && + r.Category.Equals(entityReference.Category) ).Count() == 0) return false; } @@ -55,7 +58,10 @@ public bool Exist(EntityReference entityReference, bool includeVersion = false, r.TargetEntityId.Equals(entityReference.TargetEntityId) && r.TargetVersion.Equals(entityReference.TargetVersion) && r.Context.Equals(entityReference.Context) && - r.ReferenceType.Equals(entityReference.ReferenceType) + r.ReferenceType.Equals(entityReference.ReferenceType) && + r.LinkType.Equals(entityReference.LinkType) && + r.Category.Equals(entityReference.Category) + ).Count() == 0) return false; } @@ -67,7 +73,10 @@ public bool Exist(EntityReference entityReference, bool includeVersion = false, r.TargetId.Equals(entityReference.TargetId) && r.TargetEntityId.Equals(entityReference.TargetEntityId) && r.Context.Equals(entityReference.Context) && - r.ReferenceType.Equals(entityReference.ReferenceType) + r.ReferenceType.Equals(entityReference.ReferenceType) && + r.LinkType.Equals(entityReference.LinkType) && + r.Category.Equals(entityReference.Category) + ).Count() == 0) return false; } @@ -85,9 +94,9 @@ public void Create(EntityReference entityReference) } } - public EntityReference Create(long sourceId, long sourceEntityId, int sourceEntityVersion, long targetId, long targetEntityId, int targetEntityVersion, string context, string type) + public EntityReference Create(long sourceId, long sourceEntityId, int sourceEntityVersion, long targetId, long targetEntityId, int targetEntityVersion, string context, string type, string linkType, string category) { - EntityReference entityReference = new EntityReference(sourceId, sourceEntityId, sourceEntityVersion, targetId, targetEntityId, targetEntityVersion, context, type, DateTime.Now); + EntityReference entityReference = new EntityReference(sourceId, sourceEntityId, sourceEntityVersion, targetId, targetEntityId, targetEntityVersion, context, type, DateTime.Now, linkType, category); using (var uow = this.GetUnitOfWork()) { @@ -110,6 +119,17 @@ public void Delete(long id) } } + public void Delete(IEnumerable ids) + { + using (var uow = this.GetUnitOfWork()) + { + var repo = uow.GetRepository(); + var entityReferences = repo.Query(l=> ids.Contains(l.Id)).Select(l=>l.Id).ToList(); + repo.Delete(entityReferences); + uow.Commit(); + } + } + public void Delete(EntityReference entityReference) { using (var uow = this.GetUnitOfWork()) diff --git a/Components/DLM/BExIS.Dlm.Entities/Data/Dataset.cs b/Components/DLM/BExIS.Dlm.Entities/Data/Dataset.cs index c40174b707..459201da8a 100644 --- a/Components/DLM/BExIS.Dlm.Entities/Data/Dataset.cs +++ b/Components/DLM/BExIS.Dlm.Entities/Data/Dataset.cs @@ -9,6 +9,17 @@ /// namespace BExIS.Dlm.Entities.Data { + /// + /// This is a list fo currently used entity types in BExIS. It is used to identify the type of the entity in a generic way. + /// + public enum EntityType + { + Dataset = 1, + Publication = 2, + Sample = 3, + Extension = 4, + } + /// /// /// diff --git a/Components/DLM/BExIS.Dlm.Entities/Data/EntityTemplate.cs b/Components/DLM/BExIS.Dlm.Entities/Data/EntityTemplate.cs index 67f483a53d..e0d0c005e0 100644 --- a/Components/DLM/BExIS.Dlm.Entities/Data/EntityTemplate.cs +++ b/Components/DLM/BExIS.Dlm.Entities/Data/EntityTemplate.cs @@ -62,9 +62,7 @@ public virtual List MetadataFields public virtual bool MetadataInvalidSaveMode { get; set; } /// - /// should the user be able to save the metadata if not alle mandatory are filled correct - /// if true - also not valid metadat will be stored - /// if false - only valid metadata will be stored + /// should the user be able to select a datastructure /// public virtual bool HasDatastructure { get; set; } @@ -84,6 +82,27 @@ public virtual List DatastructureList JsonDatastructureList = JsonConvert.SerializeObject(value); } } + /// + /// should the user be able to select a extension + /// + public virtual bool HasExtension { get; set; } + + /// + /// List of available Extensions + /// + public virtual string JsonExtensionList { get; set; } + + public virtual List ExtensionList + { + get + { + return JsonConvert.DeserializeObject>(JsonExtensionList); + } + set + { + JsonExtensionList = JsonConvert.SerializeObject(value); + } + } /// /// @@ -174,6 +193,8 @@ public EntityTemplate() PermissionGroups = new PermissionsType(); NotificationGroups = new List(); MetadataInvalidSaveMode = true; + ExtensionList = new List(); + Order = 0; JsonAllowedFileTypes = ""; JsonDatastructureList = ""; @@ -181,6 +202,7 @@ public EntityTemplate() JsonMetadataFields = ""; JsonPermissionGroups = ""; JsonNotificationGroups = ""; + JsonExtensionList = ""; } public EntityTemplate(string name, string description, Entity entityType, MetadataStructure.MetadataStructure metadataStructure) @@ -192,6 +214,7 @@ public EntityTemplate(string name, string description, Entity entityType, Metada AllowedFileTypes = new List(); DisabledHooks = new List(); DatastructureList = new List(); + ExtensionList = new List(); MetadataFields = new List(); PermissionGroups = new PermissionsType(); NotificationGroups = new List(); @@ -203,6 +226,7 @@ public EntityTemplate(string name, string description, Entity entityType, Metada JsonMetadataFields = ""; JsonPermissionGroups = ""; JsonNotificationGroups = ""; + JsonExtensionList = ""; } } @@ -221,4 +245,19 @@ public PermissionsType() ViewEdit = new List(); } } + + public class ExtensionType + { + public long TemplateId { get; set; } + public string ReferenceType { get; set; } + public bool Unique { get; set; } + + + public ExtensionType() + { + TemplateId = 0; + ReferenceType = ""; + Unique = true; + } + } } \ No newline at end of file diff --git a/Components/DLM/BExIS.Dlm.Orm.NH/Mappings/Default/Data/EntityTemplate.hbm.xml b/Components/DLM/BExIS.Dlm.Orm.NH/Mappings/Default/Data/EntityTemplate.hbm.xml index 6e4b3ddff9..dd4992d8a5 100644 --- a/Components/DLM/BExIS.Dlm.Orm.NH/Mappings/Default/Data/EntityTemplate.hbm.xml +++ b/Components/DLM/BExIS.Dlm.Orm.NH/Mappings/Default/Data/EntityTemplate.hbm.xml @@ -44,6 +44,14 @@ + + + + + + + + diff --git a/Components/UI/BExIS.UI/BExIS.UI.csproj b/Components/UI/BExIS.UI/BExIS.UI.csproj index 061b5536ab..eb15400b8a 100644 --- a/Components/UI/BExIS.UI/BExIS.UI.csproj +++ b/Components/UI/BExIS.UI/BExIS.UI.csproj @@ -119,6 +119,7 @@ + diff --git a/Components/UI/BExIS.UI/Models/ExtensionItem.cs b/Components/UI/BExIS.UI/Models/ExtensionItem.cs new file mode 100644 index 0000000000..d6e1acd953 --- /dev/null +++ b/Components/UI/BExIS.UI/Models/ExtensionItem.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BExIS.UI.Models +{ + public class ExtensionItem + { + public long Id { get; set; } + public int Version { get; set; } + public string Title { get; set; } + + public string LinkType { get; set; } + public string ReferenceType { get; set; } + } +} diff --git a/Components/UI/BExIS.UI/Models/ReferenceModels.cs b/Components/UI/BExIS.UI/Models/ReferenceModels.cs index 607ead2be2..a7ad83fb44 100644 --- a/Components/UI/BExIS.UI/Models/ReferenceModels.cs +++ b/Components/UI/BExIS.UI/Models/ReferenceModels.cs @@ -40,6 +40,8 @@ public class ReferenceModel public string Context { get; set; } public string ReferenceType { get; set; } + public string LinkType { get; set; } + public string Category { get; set; } public ReferenceModel() { @@ -48,6 +50,8 @@ public ReferenceModel() Source = new ReferenceElementModel(); Context = ""; ReferenceType = ""; + LinkType = ""; + Category = ""; } } @@ -100,6 +104,7 @@ public class CreateSimpleReferenceModel [Required] public String ReferenceType { get; set; } + public CreateSimpleReferenceModel() { Context = ""; @@ -113,4 +118,39 @@ public CreateSimpleReferenceModel(long sourceId, long sourceTypeId, int sourceVe Context = ""; } } + + public class ReferenceConfig + { + public List ReferenceTypes { get; set; } + public List EntityWhiteList { get; set; } + + public ReferenceConfig() + { + ReferenceTypes = new List(); + EntityWhiteList = new List(); + } + } + + public class ReferenceConfigElement + { + /* + "description": "has dwc:Event extension", + "referenceType": "HasEvent", + "linkType": "extension", + "category": "extension" + }, + */ + public string ReferenceType { get; set; } + public string Description { get; set; } + public string LinkType { get; set; } + public string Category { get; set; } + + public ReferenceConfigElement() + { + ReferenceType=""; + Description = ""; + LinkType = ""; + Category = ""; + } + } } \ No newline at end of file diff --git a/Components/Utils/BExIS.Utils.Data/BExIS.Utils.Data.csproj b/Components/Utils/BExIS.Utils.Data/BExIS.Utils.Data.csproj index 7e9cc797ed..b682228625 100644 --- a/Components/Utils/BExIS.Utils.Data/BExIS.Utils.Data.csproj +++ b/Components/Utils/BExIS.Utils.Data/BExIS.Utils.Data.csproj @@ -44,6 +44,9 @@ ..\..\..\packages\Microsoft.Web.Infrastructure.2.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + + ..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + diff --git a/Components/Utils/BExIS.Utils.Data/Helpers/EntityReferenceHelper.cs b/Components/Utils/BExIS.Utils.Data/Helpers/EntityReferenceHelper.cs index 25ac21be5d..a6b1ad1aba 100644 --- a/Components/Utils/BExIS.Utils.Data/Helpers/EntityReferenceHelper.cs +++ b/Components/Utils/BExIS.Utils.Data/Helpers/EntityReferenceHelper.cs @@ -1,6 +1,7 @@ using BExIS.Security.Entities.Objects; using BExIS.Security.Services.Objects; using BExIS.UI.Models.EntityReference; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; @@ -15,9 +16,11 @@ namespace BExIS.Utils.Data.Helpers { public class EntityReferenceHelper { + private ReferenceConfig _config = null; + public EntityReferenceHelper() { - + _config = getReferenceConfig(); } public bool EntityExist(long id, long typeId) @@ -193,21 +196,17 @@ public EntityReference Convert(CreateSimpleReferenceModel model) tmp.ReferenceType = model.ReferenceType; tmp.CreationDate = DateTime.Now; - return tmp; - } + // get additional informations + ReferenceConfigElement config = GetReferenceConfigByType(model.ReferenceType); - //public EntityReference Convert(SimpleReferenceModel model, long sourceId, long sourceTypeId) - //{ - // EntityReference tmp = new EntityReference(); - // tmp.SourceId = sourceId; - // tmp.SourceEntityId = sourceTypeId; - // tmp.TargetId = model.Id; - // tmp.TargetEntityId = model.TypeId; - // tmp.Context = model.Context; - // tmp.ReferenceType = model.ReferenceType; + if (config != null) + { + tmp.LinkType = config.LinkType; + tmp.Category = config.Category; + } - // return tmp; - //} + return tmp; + } public SimpleSourceReferenceModel GetSimpleReferenceModel(long id, long typeId, int version) { @@ -248,6 +247,8 @@ public ReferenceModel Convert(EntityReference entityReference) tmp.Context = entityReference.Context; tmp.ReferenceType = entityReference.ReferenceType; tmp.RefId = entityReference.Id; + tmp.LinkType = entityReference.LinkType; + tmp.Category = entityReference.Category; return tmp; } @@ -346,54 +347,89 @@ public List GetTargetReferences(long id, long typeid, int versio #region Entity Reference Config + private ReferenceConfig getReferenceConfig() + { + string filepath = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DCM"), "EntityReferenceConfig.json"); + string dir = Path.GetDirectoryName(filepath); + + if (Directory.Exists(dir) && File.Exists(filepath)) + { + ReferenceConfig referenceConfig = new ReferenceConfig(); + referenceConfig = JsonConvert.DeserializeObject(File.ReadAllText(filepath)); + + return referenceConfig; + } + else + { + throw new FileNotFoundException("File EntityReferenceConfig.json not found in :" + dir, "EntityReferenceConfig.json"); + } + } + + public ReferenceConfigElement GetReferenceConfigByType(string type) + { + if (_config != null) + { + return _config.ReferenceTypes.Where(e => e.ReferenceType.Equals(type)).FirstOrDefault(); + } + + return null; + } + + /// /// this function return a list of all reference types. This types are listed in the entity reference config.xml in the workspace /// /// public SelectList GetReferencesTypes() { - string filepath = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DCM"), "EntityReferenceConfig.xml"); - string dir = Path.GetDirectoryName(filepath); - - if (Directory.Exists(dir) && File.Exists(filepath)) + + if (_config != null) { - XDocument xdoc = XDocument.Load(filepath); - - var types = xdoc.Root.Descendants("referenceType").Select(e => new SelectListItem() + var types = _config.ReferenceTypes.Select(e => new SelectListItem() { - Text = String.IsNullOrEmpty(e.Attribute("description").Value) ? e.Value : e.Attribute("description").Value, - Value = e.Value + Text = String.IsNullOrEmpty(e.Description) ? e.ReferenceType : e.Description, + Value = e.ReferenceType }).ToList(); return new SelectList(types, "Value", "Text"); } - else - { - throw new FileNotFoundException("File EntityReferenceConfig.xml not found in :" + dir, "EntityReferenceConfig.xml"); - } + + return new SelectList(new List(), "Value", "Text"); } - public SelectList GetReferencesHelpTypes() + public SelectList GetReferencesTypes(string type) { - string filepath = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DCM"), "EntityReferenceConfig.xml"); - string dir = Path.GetDirectoryName(filepath); - if (Directory.Exists(dir) && File.Exists(filepath)) + if (_config != null) { - XDocument xdoc = XDocument.Load(filepath); - - var types = xdoc.Root.Descendants("referenceType").Select(e => new SelectListItem() + var types = _config.ReferenceTypes.Where(e => e.LinkType.Equals(type)).Select(e => new SelectListItem() { - Text = String.IsNullOrEmpty(e.Attribute("description").Value) ? e.Value : e.Attribute("description").Value, - Value = e.Value, + Text = String.IsNullOrEmpty(e.Description) ? e.ReferenceType : e.Description, + Value = e.ReferenceType }).ToList(); return new SelectList(types, "Value", "Text"); } - else + + return new SelectList(new List(), "Value", "Text"); + } + + public List> GetReferencesTypesAsKVP(string type) + { + List> tmp = new List>(); + if (_config != null) { - throw new FileNotFoundException("File EntityReferenceConfig.xml not found in :" + dir, "EntityReferenceConfig.xml"); + tmp = _config.ReferenceTypes.Where(e => e.LinkType.Equals(type)).Select(e => + new KeyValuePair(e.ReferenceType, string.IsNullOrEmpty(e.Description) ? e.ReferenceType : e.Description)).ToList(); + } + + return tmp; + } + + public SelectList GetReferencesHelpTypes() + { + return GetReferencesTypes(); } #endregion Entity Reference Config @@ -406,21 +442,18 @@ public SelectList GetReferencesHelpTypes() /// public SelectList GetEntityTypesWhitlist() { - string filepath = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DCM"), "EntityReferenceConfig.xml"); - string dir = Path.GetDirectoryName(filepath); - - if (Directory.Exists(dir) && File.Exists(filepath)) + if (_config != null) { - XDocument xdoc = XDocument.Load(filepath); - - var types = xdoc.Root.Descendants("entityType").Select(e => new SelectListItem() { Text = e.Attribute("description").Value.ToString(), Value = e.Value }).ToList(); + var types = _config.EntityWhiteList.Select(e => new SelectListItem() + { + Text = e, + Value = e + }).ToList(); - return new SelectList(types, "Text", "Value"); - } - else - { - throw new FileNotFoundException("File EntityReferenceConfig.xml not found in :" + dir, "EntityReferenceConfig.xml"); + return new SelectList(types, "Value", "Text"); } + + return new SelectList(new List(), "Value", "Text"); } #endregion Entity Config diff --git a/Components/Utils/BExIS.Utils.Data/packages.config b/Components/Utils/BExIS.Utils.Data/packages.config index b94c99c2d4..7ea0793d9e 100644 --- a/Components/Utils/BExIS.Utils.Data/packages.config +++ b/Components/Utils/BExIS.Utils.Data/packages.config @@ -5,4 +5,5 @@ + \ No newline at end of file diff --git a/Components/XML/BExIS.Xml.Helpers/BExIS.Xml.Helpers.csproj b/Components/XML/BExIS.Xml.Helpers/BExIS.Xml.Helpers.csproj index bd80f6d530..d892ea3955 100644 --- a/Components/XML/BExIS.Xml.Helpers/BExIS.Xml.Helpers.csproj +++ b/Components/XML/BExIS.Xml.Helpers/BExIS.Xml.Helpers.csproj @@ -74,6 +74,7 @@ + diff --git a/Components/XML/BExIS.Xml.Helpers/ExtensionStore.cs b/Components/XML/BExIS.Xml.Helpers/ExtensionStore.cs new file mode 100644 index 0000000000..8bfd13b929 --- /dev/null +++ b/Components/XML/BExIS.Xml.Helpers/ExtensionStore.cs @@ -0,0 +1,226 @@ +using BExIS.Dlm.Entities.Data; +using BExIS.Dlm.Services.Data; +using BExIS.Dlm.Services.MetadataStructure; +using BExIS.Security.Services.Objects; +using System; +using System.Collections.Generic; +using System.Linq; +using Vaiona.Persistence.Api; + +namespace BExIS.Xml.Helpers +{ + public class ExtensionStore : IEntityStore + { + private const string _entityName = "Extension"; + + public List GetEntities() + { + return GetEntities(0, 0); + } + + public List 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(); + + try + { + List metadataStructureIds = metadataStructureManager.Repo.Query().Select(m => m.Id).ToList(); + + List metadataSturctureIdsForDatasets = new List(); + metadataSturctureIdsForDatasets = metadataStructureIds.Where(m => xmlDatasetHelper.HasEntity(m, _entityName)).ToList(); + + foreach (var msid in metadataSturctureIdsForDatasets) + { + var datasetIds = new List(); + // 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 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; + } + } + } + + public int CountEntities() + { + using (var uow = this.GetUnitOfWork()) + using (DatasetManager dm = new DatasetManager()) + using (MetadataStructureManager metadataStructureManager = new MetadataStructureManager()) + { + XmlDatasetHelper xmlDatasetHelper = new XmlDatasetHelper(); + var entities = new List(); + int count = 0; + + try + { + List metadataStructureIds = metadataStructureManager.Repo.Query().Select(m => m.Id).ToList(); + + List metadataSturctureIdsForDatasets = new List(); + metadataSturctureIdsForDatasets = metadataStructureIds.Where(m => xmlDatasetHelper.HasEntity(m, _entityName)).ToList(); + + foreach (var msid in metadataSturctureIdsForDatasets) + { + var datasetIds = new List(); + // get all datasets based on metadata data structure id + + datasetIds = dm.DatasetRepo.Query(d => d.MetadataStructure.Id.Equals(msid)).Select(d => d.Id).ToList(); + count += datasetIds.Count; + } + + return count; + } + catch (Exception ex) + { + throw ex; + } + finally + { + dm.Dispose(); + } + } + } + + public string GetTitleById(long id) + { + using (var uow = this.GetUnitOfWork()) + { + var dm = new DatasetManager(); + + try + { + var dsv = dm.GetDatasetLatestVersion(id); + + return dsv.Title; + } + catch + { + return String.Empty; + } + finally + { + dm.Dispose(); + } + } + } + + public int CountVersions(long id) + { + DatasetManager dm = new DatasetManager(); + + try + { + var datasetIds = dm.GetDatasetLatestIds(); + var datasetHelper = new XmlDatasetHelper(); + + int version = dm.GetDataset(id).Versions.Count; + + return version; + } + catch (Exception ex) + { + return 0; + } + finally + { + dm.Dispose(); + } + } + + public List GetVersionsById(long id) + { + DatasetManager dm = new DatasetManager(); + List tmp = new List(); + try + { + var datasetIds = dm.GetDatasetLatestIds(); + var datasetHelper = new XmlDatasetHelper(); + var versions = dm.GetDataset(id).Versions.OrderBy(v => v.Timestamp).ToList(); + + foreach (var v in versions) + { + tmp.Add(new EntityStoreItem() + { + Id = v.Id, + Title = v.Title, + Version = versions.IndexOf(v) + 1, + CommitComment = "(" + v.Timestamp.ToString("dd.MM.yyyy HH:mm") + "): " + v.ChangeDescription + }); + } + + return tmp; + } + catch (Exception ex) + { + return tmp; + } + finally + { + dm.Dispose(); + } + } + + public bool HasVersions() + { + return true; + } + + public bool Exist(long id) + { + DatasetManager dm = new DatasetManager(); + Dataset dataset = null; + + try + { + dataset = dm.GetDataset(id); + return dataset != null ? true : false; + } + catch (Exception ex) + { + return false; + } + finally + { + dm.Dispose(); + } + } + } +} \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/App_Data/BExIS.Modules.Dim.UI.xml b/Console/BExIS.Web.Shell/App_Data/BExIS.Modules.Dim.UI.xml index f6f5bf1d5b..d284c51611 100644 --- a/Console/BExIS.Web.Shell/App_Data/BExIS.Modules.Dim.UI.xml +++ b/Console/BExIS.Web.Shell/App_Data/BExIS.Modules.Dim.UI.xml @@ -610,7 +610,7 @@ - + Get a list of unique metadata values, count and list of occurrence for a given XPath. @@ -899,6 +899,14 @@ + + + Entrypoint for Publish Hook + + + + + ToDo Refactor submission Commented by Javad due to modularity issues. @@ -980,61 +988,6 @@ - - - Return model of Dataset API - - - - - Return model of Data Statistic API - - - - - Return model of Metadata Statistic API - - - - - Xpath e.g. Metadata/methods/methodsType/measurements/measurementsType/sampleAnalysis/ - - - - - List of Dataset version IDs to include instead of dataset id (latests versions) - - - - - List of Dataset IDs to include - - - - - List of Dataset IDs to exclude - - - - - List of Metdata structure IDs to include - - - - - List of Metdata structure IDs to exclude - - - - - Regex to define text to include - - - - - Regex to define text to exclude - - It is only a wrapper around the DataTable class to provide a specific name for Result formatting in MVC pipeline. diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/app.html b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/app.html index 615d4bfa2e..0867e7504e 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/app.html +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/app.html @@ -8,10 +8,10 @@
-
+
-
+
%sveltekit.body%
diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/DefaultViewHook.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/DefaultViewHook.svelte new file mode 100644 index 0000000000..5dc692d47b --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/DefaultViewHook.svelte @@ -0,0 +1,69 @@ + + + + +{#if isEnabled} +
+ +
+ + + +{/if} diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/entitytemplates/EntryContainer.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/EntryContainer.svelte similarity index 100% rename from Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/entitytemplates/EntryContainer.svelte rename to Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/EntryContainer.svelte diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/ExtensionEntries.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/ExtensionEntries.svelte new file mode 100644 index 0000000000..040030b681 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/ExtensionEntries.svelte @@ -0,0 +1,55 @@ + +{#if selectedExtensions && selectedExtensions.length > 0} +
+ +
+ +
+
Extension Template
+
Reference Type
+
+
+ {#each selectedExtensions as extension, i} +
+
+ +
+
+ +
+
+ {/each} + + +
+{/if} +
+ +
diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/ExtensionEntry.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/ExtensionEntry.svelte new file mode 100644 index 0000000000..75fa145270 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/ExtensionEntry.svelte @@ -0,0 +1,52 @@ + + +
+ +
+ + +
+ +
+ + onChangeFn(e)} + /> +
+
+ Unique +
+ + +
diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/Hook.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/Hook.svelte index 0db7172105..7e76dd54ba 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/Hook.svelte +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/Hook.svelte @@ -8,9 +8,17 @@ --> {#if isEnabled}
- {displayName.toUpperCase()} +
-{/if} - + + +{/if} diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/View.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/View.svelte index 8c4aa2b360..7db0100a02 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/View.svelte +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/View.svelte @@ -16,6 +16,7 @@ onMount(async () => { //load javascript from server const urlscript = host + start + '?id=' + id + '&&version=' + version; + console.log("🚀 ~ urlscript:", urlscript) import(urlscript).then((resp) => { ExtComponent = resp.default; diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/customComponents/DateRangePicker_0.1/component.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/customComponents/DateRangePicker_0.1/component.svelte index 16ae33fe85..5086c338d7 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/customComponents/DateRangePicker_0.1/component.svelte +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/customComponents/DateRangePicker_0.1/component.svelte @@ -5,7 +5,7 @@ import SveltyPicker, { } from 'svelty-picker'; //import { en, de } from 'svelty-picker/dist/i18n'; - let componentName: string = 'DateRangePicker_0.1'; + let componentName: string = 'date_range_picker_v1.0.0'; export let label: string; export let anchor: string; diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/customComponents/componentCatalog.ts b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/customComponents/componentCatalog.ts index 177ca245d8..6f05599ff4 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/customComponents/componentCatalog.ts +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/customComponents/componentCatalog.ts @@ -3,7 +3,7 @@ import terminologyService from './TerminologyService_0.1/component.svelte'; import TextField from './TextField_0.1/component.svelte'; export const customComponentsCatalog: any = { - 'DateRangePicker_0.1': { + 'date_range_picker_v1.0.0': { component: dateRangepicker}, 'terminology_v2.2.26': { component: terminologyService}, diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/datadescription/Show.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/datadescription/Show.svelte index 1154428e07..33703142e8 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/datadescription/Show.svelte +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/datadescription/Show.svelte @@ -3,7 +3,6 @@ import Header from './ShowHeader.svelte'; import { Table } from '@bexis2/bexis2-core-ui'; import type { TableConfig } from '@bexis2/bexis2-core-ui'; - import { dataset_dev } from 'svelte/internal'; import { writable } from 'svelte/store'; import NameTableCol from './NameTableCol.svelte'; diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/create/Form.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/entityTemplate/Form.svelte similarity index 100% rename from Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/create/Form.svelte rename to Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/entityTemplate/Form.svelte diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/create/InputEntry.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/entityTemplate/InputEntry.svelte similarity index 100% rename from Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/create/InputEntry.svelte rename to Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/entityTemplate/InputEntry.svelte diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/create/List.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/entityTemplate/List.svelte similarity index 85% rename from Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/create/List.svelte rename to Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/entityTemplate/List.svelte index b5579674d0..ccb7435faa 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/create/List.svelte +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/components/entityTemplate/List.svelte @@ -1,5 +1,5 @@ + +
+
+ +
+
\ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/hooks/Permission.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/hooks/Permission.svelte new file mode 100644 index 0000000000..6de4babd56 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/hooks/Permission.svelte @@ -0,0 +1,26 @@ + + +
+
+ +
+
\ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/hooks/Publish.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/hooks/Publish.svelte new file mode 100644 index 0000000000..6de4babd56 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/hooks/Publish.svelte @@ -0,0 +1,26 @@ + + +
+
+ +
+
\ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/hooks/Validation.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/hooks/Validation.svelte index 4240ddaa83..30fc28c976 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/hooks/Validation.svelte +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/lib/hooks/Validation.svelte @@ -29,8 +29,7 @@ let model: ValidationModel | null; $: model; - onMount(async () => { - latestFileUploadDate.subscribe((s) => { + latestFileUploadDate.subscribe((s) => { if (s > 0) { console.log( '🚀 ~ file: Validation.svelte:37 ~ onMount ~ latestFileUploadDate:', @@ -39,6 +38,7 @@ reload('latestFileUploadDate'); } }); + latestDataDescriptionDate.subscribe((s) => { if (s > 0) { console.log( @@ -48,6 +48,7 @@ reload('latestDataDescriptionDate'); } }); + latestFileReaderDate.subscribe((s) => { if (s > 0) { console.log( @@ -57,22 +58,26 @@ reload('latestFileReaderDate'); } }); + latestSubmitDate.subscribe((s) => { if (s > 0) { - console.log( - '🚀 ~ file: Validation.svelte:49 ~ onMount ~ latestSubmitDate:', - $latestSubmitDate - ); + // console.log( + // '🚀 ~ file: Validation.svelte:49 ~ onMount ~ latestSubmitDate:', + // $latestSubmitDate + // ); //reload('latestSubmitDate'); } }); + + onMount(async () => { + }); async function reload(type) { model = null; model = await getHookStart(start, id, version); console.log('validation end', model); - latestValidationDate.set(Date.now()); + //latestValidationDate.set(Date.now()); } diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/models/EntityTemplate.ts b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/models/EntityTemplate.ts index a66fb7e2fd..c02e092d2e 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/models/EntityTemplate.ts +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/models/EntityTemplate.ts @@ -11,6 +11,8 @@ export interface EntityTemplateModel { metadataInvalidSaveMode: boolean; hasDatastructure: boolean; datastructureList: number[]; + hasExtension: boolean; + extensionList: extensionType[]; allowedFileTypes: string[]; disabledHooks: string[]; notificationGroups: number[]; @@ -26,3 +28,19 @@ export interface permissionsType { viewEdit: number[]; view: number[]; } + +export class extensionType { + templateId: number; + referenceType: string; + unique: boolean; + + public constructor() { + this.templateId = -1; + this.referenceType = ''; + this.unique = false; + } +} + + + + diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/models/Hook.ts b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/models/Hook.ts new file mode 100644 index 0000000000..8cdfa85684 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/models/Hook.ts @@ -0,0 +1,25 @@ +export interface HookModel { + name: string; + displayName: string; + status: HookStatus; + mode: HookMode; + entity: string; + module: string; + place: string; + start: string; + description: string; +} + +export enum HookStatus { + Disabled = 0, + AccessDenied = 1, + Open = 2, + Ready = 3, + Exist = 4, + Inactive = 5 +} + +export enum HookMode { + view = 0, + edit = 1 +} diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/models/View.ts b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/models/View.ts index 79132d2f41..351b20317e 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/models/View.ts +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/models/View.ts @@ -1,33 +1,157 @@ -export interface ViewModel { + +import type { HookModel } from "./Hook"; + +export interface ViewModel extends ApiDatasetModel { + settings: ViewSettings; + hasData: boolean; + count: number; + isValid: boolean; + downloadAccess: boolean; + requestExist: boolean; + requestAble: boolean; + hasRequestRight: boolean; + labels: { [key: string]: string; }; +} + +export interface ViewSettings { + useTags: boolean; + useMinor: boolean; + dataAggrement: string; + hooks: HookModel[]; +} + +export interface ApiDatasetModel { + id: number; + version: number; + versionId: number; + title: string; + description: string; + dataStructureId: number; + metadataStructureId: number; + entityTemplateId: number; + isPublic: boolean; + publicationDate: string; + additionalInformations: { [key: string]: string; }; + parties: { [key: string]: { [key: string]: string; }; }; + versionDate: string; + names: any; + links: LinksOverview; +} + +export interface LinksOverview { + from: ReferenceModel[]; + to: ReferenceModel[]; +} + +export interface ApiDatasetAttachmentsModel { + datasetId: number; + attachments: ApiSimpleAttachmentModel[]; +} + +export interface Citator { + firstName: string; + lastName: string; +} + +export interface ApiSimpleAttachmentModel { + id: number; + name: string; + mimeType: string; +} + +export interface ReferenceModel { + refId: number; + target: ReferenceElementModel; + source: ReferenceElementModel; + context: string; + referenceType: string; + linkType: string; + category: string; +} + +export interface ReferenceElementModel { + id: number; + version: number; + typeId: number; + type: string; + title: string; + latestVersion: boolean; +} + + + +export interface ApiDatasetModel { id: number; - versionId: number; version: number; + versionId: number; title: string; - hooks: Hook[]; -} - -export interface Hook { - name: string; - displayName: string; - status: HookStatus; - mode: HookMode; - entity: string; - module: string; - place: string; - start: string; description: string; + dataStructureId: number; + metadataStructureId: number; + isPublic: boolean; + publicationDate: string; + additionalInformations: { [key: string]: string; }; + parties: { [key: string]: { [key: string]: string; }; }; + versionDate: string; + names: any; + links: LinksOverview; +} + +export interface LinksOverview { + from: ReferenceModel[]; + to: ReferenceModel[]; +} + +export interface ReferenceModel { + refId: number; + target: ReferenceElementModel; + source: ReferenceElementModel; + context: string; + referenceType: string; + linkType: string; + category: string; +} + +export interface ReferenceElementModel { + id: number; + version: number; + typeId: number; + type: string; + title: string; + latestVersion: boolean; +} + + +export enum ReadCitationFormat { + APA, + Text, + Default +} + +export interface CitationModel { + format: ReadCitationFormat; + data: CitationDataModel; } -export enum HookStatus { - Disabled = 0, - AccessDenied = 1, - Open = 2, - Ready = 3, - Exist = 4, - Inactive = 5 +export enum CitationFormat { + APA, + RIS, + Text, + Bibtex } -export enum HookMode { - view = 0, - edit = 1 +export interface CitationDataModel { + title: string; + version: string; + tag: string; + projects: string[]; + year: string; + dOI: string; + uRL: string; + authors: string[]; + entryType: string; + entityName: string; + publisher: string; + keyword: string; + note: string; } diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/create/+page.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/create/+page.svelte index bc459e6c58..f2f1586433 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/create/+page.svelte +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/create/+page.svelte @@ -1,6 +1,6 @@ - -
- {#await load()} - - {:then a} - {#if model && model.hooks && datasethooks && addtionalhooks && hookStatusList} - - -
+ {#if entityTemplate} +
+ + {#if entityTemplate.hasExtension} + - - {:else} - - {/if} - {:catch error} - - {/await} - + {:else} + + {/if} + + {/if} + - + \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/AdvancedEntity.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/AdvancedEntity.svelte new file mode 100644 index 0000000000..980aa3d143 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/AdvancedEntity.svelte @@ -0,0 +1,101 @@ + + + + + {entity} {title} + + + + {#each extensions as ext (ext.id)} + + {ext.title} + + + + {/each} + + + + + + + + + {#if tabSet === 0} + + {:else if tabSet === 100} + + {/if} + + {#each extensions as ext (ext.id)} + + {#if tabSet === ext.id} +
+ +
+ + + + {/if} + {/each} +
+
diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/Entity.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/Entity.svelte new file mode 100644 index 0000000000..7dc6bb51fa --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/Entity.svelte @@ -0,0 +1,251 @@ + + {#await load()} + + {:then a} + {#if model && model.hooks && datasethooks && addtionalhooks && hookStatusList} + + + +
+ + + {:else} + + {/if} + {:catch error} + + {/await} + + + diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/ExtensionCreation.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/ExtensionCreation.svelte new file mode 100644 index 0000000000..cba9cc7ea5 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/ExtensionCreation.svelte @@ -0,0 +1,83 @@ + + + +
+ {#await load()} +
+ +
+ {:then result} +
+ + + {#if selected && isOpen} +
(isOpen = false)} + on:save={(e) => onSaveHandler(e)} + /> + {/if} +
+ {:catch error} + + {/await} +
+ diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/Header.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/Header.svelte index 19112dceeb..ff6014f9bc 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/Header.svelte +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/Header.svelte @@ -28,5 +28,12 @@ View +
diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/Hooks.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/Hooks.svelte index 82c1e0b819..3717b62635 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/Hooks.svelte +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/edit/Hooks.svelte @@ -1,11 +1,12 @@ {#if entityTemplate} @@ -258,6 +287,7 @@
+

Data Structure

@@ -293,6 +323,40 @@
+ {#if !isExtensions} +

Extension

+
+ +
+ + Allow to use extensions + +
+
+ {#if entityTemplate.hasExtension} + + + {/if} +
+ +
+ + +

Administration

Set permissions per default to the following groups

@@ -364,9 +428,11 @@ />
- +{/if }

Dataset Settings

+
+ {#if !isExtensions} - + {/if} - import { onMount } from 'svelte'; - import { getView } from './services'; - import { getViewStart } from '../../services/HookCaller'; - import { setApiConfig, Spinner } from '@bexis2/bexis2-core-ui'; + import { getApiDataset, getView } from './services'; + import { ErrorMessage, type linkType, Page, pageContentLayoutType, positionType, setApiConfig, Spinner } from '@bexis2/bexis2-core-ui'; import Header from './Header.svelte'; - import TabContent from './Tab.svelte'; - import Debug from '../../lib/components/Debug.svelte'; - import { TabGroup, Tab } from '@skeletonlabs/skeleton'; + //types - import type { ViewModel, Hook } from '../../models/View'; + import type { ViewModel, Hook, ApiDatasetModel } from '../../models/View'; + import { fade } from 'svelte/transition'; + import Hooks from './Hooks.svelte'; + import Links from './Links.svelte'; + import Authors from './Authors.svelte'; + import Versions from './Versions.svelte'; + import Keywords from './Keywords.svelte'; + import Funding from './Funding.svelte'; let title = ''; @@ -20,18 +23,20 @@ let version: number = 0; let model: ViewModel; - // tabs - let activeTab = 'metadata'; - let tabSet = 0; + let hookList: Hook[]; $: hooks = hookList; - // for test ui - $: testPage = ''; + const links: linkType[] = [ + { + label: 'Manual', + url: '/home/docs/Datasets#dataset-view-page' + } + ]; - onMount(async () => { + async function load () { // get data from parent container = document.getElementById('view'); id = container?.getAttribute('dataset'); @@ -44,56 +49,67 @@ // load data from server model = await getView(id); - console.log('onmount', model); - - hooks = model.hooks; + hooks = model.settings.hooks; title = model.title; version = model.version; id = model.id; - console.log(model); + console.log('model',model); console.log('hooks', hooks); - //test ui as html - // const resTestPage = await fetch('dcm/view/test'); - // testPage = await resTestPage.text(); - }); - async function loadTab(action, id, version) { - let test = await getViewStart(action, id, version); - return test; } - -
- -
+ + + +
+ + {#await load()} +
+ +
+ {:then result} + +
+ + + +
+
+ {model.description} +
+
+ + + +
+
- {#if hooks} - - - {#each hooks as hook, i} - {#if hook.status == 2} - {hook.name} - {/if} - {/each} +
Additional Information Overview
+
+ +
+
License : {model.additionalInformations['license'] ? model.additionalInformations['license'] : 'n/a'}
- - - - {#each hooks as hook, i} - {#if hook.status == 2} - - {/if} + {#if model.additionalInformations} + {#each Object.entries(model.additionalInformations) as info} +
{info[0]}:{info[1]}
{/each} -
- - {:else} -
- + {/if} +
- {/if} - + + + + + {:catch error} + + {/await} +
+ + + diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Authors.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Authors.svelte new file mode 100644 index 0000000000..e1f2bb958d --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Authors.svelte @@ -0,0 +1,14 @@ + + + +
+ {#if author && author != ' '} +
{author}
+ {:else} +
n/a
+ {/if} +
diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Citation.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Citation.svelte new file mode 100644 index 0000000000..91520567c3 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Citation.svelte @@ -0,0 +1,39 @@ + + +{#key citationComponent} + +{/key} + diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Funding.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Funding.svelte new file mode 100644 index 0000000000..4873094b1e --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Funding.svelte @@ -0,0 +1,3 @@ +
+ Funding +
\ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Header.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Header.svelte index 2829231543..01bc13fe0f 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Header.svelte +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Header.svelte @@ -1,11 +1,27 @@ - -

{title}

-Dataset Id: {id} -Version: {version} -version selection -download +
+
+ +
+
+ + {#if labelKeys && labelKeys.length > 0} + {#each labelKeys as key} + {key} + {/each} + {/if} + +
+
diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Hooks.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Hooks.svelte new file mode 100644 index 0000000000..f68ba59e6a --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Hooks.svelte @@ -0,0 +1,25 @@ + + +
+ +{#if hooks && hooks.length > 0} +
more details
+
+ {#each hooks as hook} +
+ +
+ {/each} +
+{:else} +

No hooks available.

+{/if} +
diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Keywords.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Keywords.svelte new file mode 100644 index 0000000000..1c1d870d65 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Keywords.svelte @@ -0,0 +1,3 @@ +
+ Subject keywords +
\ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Links.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Links.svelte new file mode 100644 index 0000000000..844b7bb3d7 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Links.svelte @@ -0,0 +1,27 @@ + + + +{#if types} +

Related Work

+
+ {#each types as type} + +
+

{type.toUpperCase()}

+
+ {#each links.filter(link => link.linkType === type) as link} +
{link.referenceType}{link.target.title}
+ {/each} +
+
+ {/each} +
+{/if} diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Versions.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Versions.svelte new file mode 100644 index 0000000000..717289e121 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/Versions.svelte @@ -0,0 +1,3 @@ +
+ Versions +
\ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/citation/APA.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/citation/APA.svelte new file mode 100644 index 0000000000..eb9ad068f7 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/citation/APA.svelte @@ -0,0 +1,9 @@ + + +
APA
\ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/citation/Default.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/citation/Default.svelte new file mode 100644 index 0000000000..91a998b9c2 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/citation/Default.svelte @@ -0,0 +1,14 @@ + + +{#if model} +

{model.title}

+{:else} +

Title is not available.

+{/if} \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/citation/Text.svelte b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/citation/Text.svelte new file mode 100644 index 0000000000..e3aca345d4 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/citation/Text.svelte @@ -0,0 +1,54 @@ + + + +
Citation: +
+ {model.authors} + ({model.year}): + {model.title}. + Version {model.version}. + {model.publisher}. + {model.entityName}. + {model.uRL} + +
+ +
+ + \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/services.js b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/services.js index 82789f69c9..61724150e5 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/services.js +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/services.js @@ -8,3 +8,29 @@ export const getView = async (id) => { console.error(error); } }; + +export const getApiDataset = async (id, version ) => { + try { + if(version === undefined || version <= 0){ + const response = await Api.get('/api/dataset/'+id); + return response.data; + } + else{ + const response = await Api.get('/api/dataset/'+id+'/version_number/'+version); + return response.data; + } + + + } catch (error) { + console.error(error); + } +}; + +export const getCitation = async (id, version) => { + try { + const response = await Api.get('/dcm/view/getcitation?id=' + id+'&version=' + version); + return response.data; + } catch (error) { + console.error(error); + } +}; diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/types.ts b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/types.ts new file mode 100644 index 0000000000..c4be970cc5 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/routes/view/types.ts @@ -0,0 +1,78 @@ +import type { HookModel } from "../edit/types"; + +export interface ViewModel extends ApiDatasetModel { + settings: ViewSettings; + hasData: boolean; + count: number; + isValid: boolean; + downloadAccess: boolean; + requestExist: boolean; + requestAble: boolean; + hasRequestRight: boolean; + labels: { [key: string]: string; }; +} + +export interface ViewSettings { + useTags: boolean; + useMinor: boolean; + dataAggrement: string; + hooks: HookModel[]; +} + +export interface ApiDatasetModel { + id: number; + version: number; + versionId: number; + title: string; + description: string; + dataStructureId: number; + metadataStructureId: number; + entityTemplateId: number; + isPublic: boolean; + publicationDate: string; + additionalInformations: { [key: string]: string; }; + parties: { [key: string]: { [key: string]: string; }; }; + versionDate: string; + names: any; + links: LinksOverview; +} + +export interface LinksOverview { + from: ReferenceModel[]; + to: ReferenceModel[]; +} + +export interface ApiDatasetAttachmentsModel { + datasetId: number; + attachments: ApiSimpleAttachmentModel[]; +} + +export interface Citator { + firstName: string; + lastName: string; +} + +export interface ApiSimpleAttachmentModel { + id: number; + name: string; + mimeType: string; +} + +export interface ReferenceModel { + refId: number; + target: ReferenceElementModel; + source: ReferenceElementModel; + context: string; + referenceType: string; + linkType: string; + category: string; +} + +export interface ReferenceElementModel { + id: number; + version: number; + typeId: number; + type: string; + title: string; + latestVersion: boolean; +} \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/services/EntityTemplateCaller.ts b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/services/EntityTemplateCaller.ts index 76de6a462a..c86592435c 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/services/EntityTemplateCaller.ts +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/src/services/EntityTemplateCaller.ts @@ -11,6 +11,16 @@ export const getEntityTemplate = async (id: number) => { } }; +export const getEntityTemplateByObject = async (id: number) => { + try { + const response = await Api.get('/dcm/entitytemplates/GetByObject?id=' + id); + return response.data; + } catch (error) { + console.error(error); + throw error; + } +}; + export const getEntityTemplateList = async () => { try { const response = await Api.get('/dcm/entitytemplates/Load'); @@ -61,6 +71,27 @@ export const getDataStructures = async () => { } }; +export const getExtensions = async () => { + try { + const response = await Api.get('/dcm/entitytemplates/Extensions'); + return response.data; + } catch (error) { + console.error(error); + throw error; + } +}; + +export const getReferenceTypes = async () => { + try { + const response = await Api.get('/dcm/entitytemplates/ReferenceTypes'); + console.log("🚀 ~ getReferenceTypes ~ response:", response.data) + return response.data; + } catch (error) { + console.error(error); + throw error; + } +}; + export const getHooks = async () => { try { const response = await Api.get('/dcm/entitytemplates/Hooks'); diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/vite.config.ts.timestamp-1782117629941-7c8845186878.mjs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/vite.config.ts.timestamp-1782117629941-7c8845186878.mjs new file mode 100644 index 0000000000..2d4afe43b1 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI.Svelte/vite.config.ts.timestamp-1782117629941-7c8845186878.mjs @@ -0,0 +1,16 @@ +// vite.config.ts +import { sveltekit } from "file:///C:/Users/David%20Sch%C3%B6ne/source/repos/BEXIS2/BEXIS2-DEV/Core/node_modules/.pnpm/@sveltejs+kit@2.63.0_patch__973f09f10404d661120ee3d506acfc20/node_modules/@sveltejs/kit/src/exports/vite/index.js"; +import { defineConfig } from "file:///C:/Users/David%20Sch%C3%B6ne/source/repos/BEXIS2/BEXIS2-DEV/Core/node_modules/.pnpm/vitest@2.0.5_@types+node@22.0.2/node_modules/vitest/dist/config.js"; +var vite_config_default = defineConfig({ + plugins: [sveltekit()], + test: { + include: ["src/**/*.{test,spec}.{js,ts}"] + }, + ssr: { + noExternal: ["@skeletonlabs/skeleton"] + } +}); +export { + vite_config_default as default +}; +//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCJDOlxcXFxVc2Vyc1xcXFxEYXZpZCBTY2hcdTAwRjZuZVxcXFxzb3VyY2VcXFxccmVwb3NcXFxcQkVYSVMyXFxcXEJFWElTMi1ERVZcXFxcQ29yZVxcXFxDb25zb2xlXFxcXEJFeElTLldlYi5TaGVsbFxcXFxBcmVhc1xcXFxEQ01cXFxcQkV4SVMuTW9kdWxlcy5EY20uVUkuU3ZlbHRlXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ZpbGVuYW1lID0gXCJDOlxcXFxVc2Vyc1xcXFxEYXZpZCBTY2hcdTAwRjZuZVxcXFxzb3VyY2VcXFxccmVwb3NcXFxcQkVYSVMyXFxcXEJFWElTMi1ERVZcXFxcQ29yZVxcXFxDb25zb2xlXFxcXEJFeElTLldlYi5TaGVsbFxcXFxBcmVhc1xcXFxEQ01cXFxcQkV4SVMuTW9kdWxlcy5EY20uVUkuU3ZlbHRlXFxcXHZpdGUuY29uZmlnLnRzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9tZXRhX3VybCA9IFwiZmlsZTovLy9DOi9Vc2Vycy9EYXZpZCUyMFNjaCVDMyVCNm5lL3NvdXJjZS9yZXBvcy9CRVhJUzIvQkVYSVMyLURFVi9Db3JlL0NvbnNvbGUvQkV4SVMuV2ViLlNoZWxsL0FyZWFzL0RDTS9CRXhJUy5Nb2R1bGVzLkRjbS5VSS5TdmVsdGUvdml0ZS5jb25maWcudHNcIjtpbXBvcnQgeyBzdmVsdGVraXQgfSBmcm9tICdAc3ZlbHRlanMva2l0L3ZpdGUnO1xyXG5pbXBvcnQgeyBkZWZpbmVDb25maWcgfSBmcm9tICd2aXRlc3QvY29uZmlnJztcclxuXHJcbmV4cG9ydCBkZWZhdWx0IGRlZmluZUNvbmZpZyh7XHJcblx0cGx1Z2luczogW3N2ZWx0ZWtpdCgpXSxcclxuXHR0ZXN0OiB7XHJcblx0XHRpbmNsdWRlOiBbJ3NyYy8qKi8qLnt0ZXN0LHNwZWN9Lntqcyx0c30nXVxyXG5cdH0sXHJcblx0c3NyOiB7XHJcbiAgICBub0V4dGVybmFsOiBbJ0Bza2VsZXRvbmxhYnMvc2tlbGV0b24nXVxyXG4gIH1cclxufSk7XHJcbiJdLAogICJtYXBwaW5ncyI6ICI7QUFBd2pCLFNBQVMsaUJBQWlCO0FBQ2xsQixTQUFTLG9CQUFvQjtBQUU3QixJQUFPLHNCQUFRLGFBQWE7QUFBQSxFQUMzQixTQUFTLENBQUMsVUFBVSxDQUFDO0FBQUEsRUFDckIsTUFBTTtBQUFBLElBQ0wsU0FBUyxDQUFDLDhCQUE4QjtBQUFBLEVBQ3pDO0FBQUEsRUFDQSxLQUFLO0FBQUEsSUFDRixZQUFZLENBQUMsd0JBQXdCO0FBQUEsRUFDdkM7QUFDRixDQUFDOyIsCiAgIm5hbWVzIjogW10KfQo= diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/BExIS.Modules.Dcm.UI.csproj b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/BExIS.Modules.Dcm.UI.csproj index ec40b640a8..3605b6fb24 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/BExIS.Modules.Dcm.UI.csproj +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/BExIS.Modules.Dcm.UI.csproj @@ -83,6 +83,7 @@ + @@ -91,7 +92,9 @@ + + @@ -152,6 +155,7 @@ + @@ -367,6 +371,7 @@ PreserveNewest + @@ -526,6 +531,9 @@ True True + + ..\..\..\..\..\packages\NameParserSharp.1.5.0\lib\net45\NameParser.dll + ..\..\..\..\..\packages\Newtonsoft.Json.13.0.4\lib\net45\Newtonsoft.Json.dll @@ -795,6 +803,10 @@ {a7fbcc13-7e29-4710-82a1-bd6d6f811fda} BExIS.Utils.Data + + {0F1EC13E-D685-4F4D-A438-52797B0E53A0} + BExIS.Utils.NH + {782b71c1-707f-4ab1-80e9-90d2880635b4} BExIS.Utils @@ -875,6 +887,10 @@ {cac933a2-6849-4c61-82b4-cbf4052210cc} BExIS.Dim.Services + + {9BFFFD11-03C6-47DF-9CC9-F458A9A49377} + BExIS.Modules.Dim.UI + diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/CreateController.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/CreateController.cs index b671917ab6..6a4fbc526b 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/CreateController.cs +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/CreateController.cs @@ -469,7 +469,9 @@ public JsonResult GetEntityTemplateList() List entityTemplateModels = new List(); using (var entityTemplateManager = new EntityTemplateManager()) { - foreach (var e in entityTemplateManager.Repo.Query(e=>e.Activated).OrderBy(e=>e.Order).ToList()) + // get entity templates without extension + string extensionName = Convert.ToString(EntityType.Extension); + foreach (var e in entityTemplateManager.Repo.Query(e=>e.Activated && !e.EntityType.Name.ToLower().Equals(extensionName.ToLower())).ToList()) { entityTemplateModels.Add(EntityTemplateHelper.ConvertTo(e, false)); } diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/EditController.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/EditController.cs index 38b76c17e7..c8e829d7ef 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/EditController.cs +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/EditController.cs @@ -2,12 +2,22 @@ using BExIS.App.Bootstrap.Helpers; using BExIS.Dlm.Entities.Data; using BExIS.Dlm.Services.Data; +using BExIS.Modules.Dcm.UI.Helpers; using BExIS.Modules.Dcm.UI.Models.Edit; +using BExIS.Modules.Dcm.UI.Models.EntityTemplate; using BExIS.Security.Entities.Authorization; +using BExIS.Security.Entities.Objects; +using BExIS.Security.Services.Objects; using BExIS.UI.Helpers; using BExIS.UI.Hooks; +using BExIS.UI.Models; +using BExIS.Utils.Data.Helpers; +using DocumentFormat.OpenXml.Drawing.Diagrams; using System; using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; using System.Web.Mvc; using System.Web.SessionState; @@ -124,5 +134,187 @@ public JsonResult Hooks(long id, int version = 0) return Json(Hooks, JsonRequestBehavior.AllowGet); } } + + #region extension + [JsonNetFilter] + public JsonResult GetExtensions(long id) + { + List tmp = new List(); + + using (var datasetManager = new DatasetManager()) + using (var entityReferenceManager = new EntityReferenceManager()) + { + var dataset = datasetManager.GetDataset(id); + var entity = dataset.EntityTemplate.EntityType; + + var entityreferences = entityReferenceManager.ReferenceRepository.Query(e => + e.LinkType.Equals("extension") && + e.SourceId.Equals(id) && + e.SourceEntityId.Equals(entity.Id)).ToList(); + + foreach (var x in entityreferences) + { + string title = ""; + if (x.TargetVersion == 0) // latest + title = datasetManager.GetDatasetLatestVersion(x.TargetId).Title; + else + title = datasetManager.GetDatasetVersion(x.TargetId, x.TargetVersion).Title; + + tmp.Add(new ExtensionItem() + { + Id = x.TargetId, + Version = x.TargetVersion, + Title = title, + LinkType = x.LinkType, + ReferenceType = x.ReferenceType + }); + } + } + return Json(tmp, JsonRequestBehavior.AllowGet); + } + + [JsonNetFilter] + [HttpGet] + public JsonResult GetExtensionEntityTemplateList(long id) + { + if(id==0) throw new Exception("id is missing"); + + List entityTemplateModels = new List(); + + using (var datasetManager = new DatasetManager()) + using (var entityTemplateManager = new EntityTemplateManager()) + { + + var dataset = datasetManager.GetDataset(id); + var template = dataset.EntityTemplate; + var extensions = template.ExtensionList.Select(e=>e.TemplateId); + + foreach (var e in entityTemplateManager.Repo.Query(e => e.Activated && extensions.Contains(e.Id)).ToList()) + { + entityTemplateModels.Add(EntityTemplateHelper.ConvertTo(e, false)); + } + + } + + return Json(entityTemplateModels, JsonRequestBehavior.AllowGet); + + } + + [JsonNetFilter] + [HttpPost] + public JsonResult CreateExtensionLink(long id, long extensionId) + { + using (var datasetmanager = new DatasetManager()) + using (var entityReferenceManager = new EntityReferenceManager()) + { + try + { + + if (id == 0) throw new Exception("id is missing"); + if (extensionId == 0) throw new Exception("extensionId is missing"); + + + // get object + var dataset = datasetmanager.GetDataset(id); + var extension = datasetmanager.GetDataset(extensionId); + + // get templates + var datasetTemplate = dataset.EntityTemplate; + var extensionTemplate = extension.EntityTemplate; + + var extensionType = datasetTemplate.ExtensionList.Where(e => e.TemplateId.Equals(extensionTemplate.Id)).FirstOrDefault(); + + // check if extension is allowed + if (datasetTemplate.ExtensionList == null || extensionType == null) + throw new Exception("This extension is not allowed for this subject."); + + // check if extension is unique and allready exists + if (datasetTemplate.ExtensionList.Any(e => e.TemplateId.Equals(extensionTemplate.Id) && e.Unique)) + { + var existingLinks = entityReferenceManager.ReferenceRepository.Query(e => + e.LinkType.Equals("extension") && + e.SourceId.Equals(id) && + e.SourceEntityId.Equals(dataset.EntityTemplate.EntityType.Id) && + e.TargetEntityId.Equals(extension.EntityTemplate.EntityType.Id)).ToList(); + + if (existingLinks.Count > 0) + throw new Exception("This extension is unique and allready exists."); + } + + // create link + EntityReferenceHelper entityReferenceHelper = new EntityReferenceHelper(); + var extensionRef = entityReferenceHelper.GetReferenceConfigByType(extensionType.ReferenceType); + + + + EntityReference entitreference = new EntityReference(); + entitreference.SourceId = id; + entitreference.SourceEntityId = dataset.EntityTemplate.EntityType.Id; + entitreference.SourceVersion = 0; // not used + entitreference.TargetId = extensionId; + entitreference.TargetEntityId = extension.EntityTemplate.EntityType.Id; + entitreference.TargetVersion = 0; + entitreference.LinkType = extensionRef.LinkType; + entitreference.ReferenceType = extensionRef.ReferenceType; + //entitreference.Context = "added"; + entitreference.Category = extensionRef.Category; + + entityReferenceManager.Create(entitreference); + + + + } + catch (Exception ex) + { + datasetmanager.PurgeDataset(extensionId); + + throw new Exception(ex.Message); + } + } + + return Json(true); + } + + [JsonNetFilter] + [HttpPost] + public JsonResult DeleteExtension(long extensionId) + { + + + using (var datasetmanager = new DatasetManager()) + using (var entityReferenceManager = new EntityReferenceManager()) + { + try + { + if (extensionId == 0) throw new Exception("extensionId is missing"); + + // remove all existing links + + var linkIds = entityReferenceManager.ReferenceRepository.Query(e => + e.TargetId.Equals(extensionId) && + e.LinkType.Equals("extension")).Select(l=>l.Id); + + entityReferenceManager.Delete(linkIds.ToList()); + + + // purge dataset + datasetmanager.PurgeDataset(extensionId); + + + } + catch (Exception ex) + { + + throw new Exception(ex.Message); + } + } + + Response.StatusCode = (int)HttpStatusCode.OK; + + return Json( new { Success = true, Message = "Extension successful deleted" }); + + } + + #endregion } } \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/EntityTemplatesController.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/EntityTemplatesController.cs index 455f32313a..a7d0f1f0d6 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/EntityTemplatesController.cs +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/EntityTemplatesController.cs @@ -13,6 +13,7 @@ using BExIS.UI.Helpers; using BExIS.UI.Hooks; using BExIS.UI.Models; +using BExIS.Utils.Data.Helpers; using BExIS.Xml.Helpers; using System; using System.Collections.Generic; @@ -77,6 +78,23 @@ public JsonResult Get(long id) } } + + [JsonNetFilter] + [HttpGet] + public JsonResult GetByObject(long id) + { + if (id == 0) return Json(new EntityTemplateModel(), JsonRequestBehavior.AllowGet); + + using (var datasetManager = new DatasetManager()) + using (var entityTemplateManager = new EntityTemplateManager()) + { + var obj = datasetManager.GetDataset(id); + var entityTemplate = entityTemplateManager.Repo.Get(obj.EntityTemplate.Id); + return Json(EntityTemplateHelper.ConvertTo(entityTemplate), JsonRequestBehavior.AllowGet); + } + } + + [JsonNetFilter] [HttpDelete] public JsonResult Delete(long id) @@ -201,6 +219,30 @@ public JsonResult DataStructures() return Json(tmp, JsonRequestBehavior.AllowGet); } + [JsonNetFilter] + [HttpGet] + public JsonResult Extensions() + { + List tmp = new List(); + using (var entityTemplateManager = new EntityTemplateManager()) + using (var entityManager = new EntityManager()) + { + var extensionEntity = entityManager.EntityRepository.Get().Where(e => e.Name.Equals("Extension")).FirstOrDefault(); + tmp = entityTemplateManager.Repo.Query(t=>t.EntityType.Id.Equals(extensionEntity.Id) && t.Activated) + .Select(e => new ListItem(e.Id, e.Name,"")).ToList(); + } + + return Json(tmp, JsonRequestBehavior.AllowGet); + } + + [JsonNetFilter] + [HttpGet] + public JsonResult ReferenceTypes() + { + EntityReferenceHelper helper = new EntityReferenceHelper(); + return Json(helper.GetReferencesTypesAsKVP("extension"), JsonRequestBehavior.AllowGet); + } + [JsonNetFilter] [HttpGet] public JsonResult Hooks() diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/Hooks/EntityReferenceController.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/Hooks/EntityReferenceController.cs index e1308e08a6..ea04f7940d 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/Hooks/EntityReferenceController.cs +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/Hooks/EntityReferenceController.cs @@ -9,6 +9,7 @@ using BExIS.UI.Models.EntityReference; using BExIS.Utils.Data.Helpers; using BExIS.Xml.Helpers; +using DocumentFormat.OpenXml.EMMA; using NHibernate.Util; using System; using System.Collections.Generic; @@ -68,7 +69,7 @@ public ActionResult Start(long id, int version) using (EntityManager entityManager = new EntityManager()) { var entity = entityManager.Entities.Where(e => e.Name.Equals(entityName)).FirstOrDefault(); - return RedirectToAction("Show", "EntityReference", new { sourceId = id, sourceTypeId = entity.Id, sourceVersion = version }); + return RedirectToAction("Show2", "EntityReference", new { sourceId = id, sourceTypeId = entity.Id, sourceVersion = version }); } } } @@ -91,7 +92,7 @@ public ActionResult StartView(long id, int version) using (EntityManager entityManager = new EntityManager()) { var entity = entityManager.Entities.Where(e => e.Name.Equals(entityName)).FirstOrDefault(); - return RedirectToAction("Show", "EntityReference", new { sourceId = id, sourceTypeId = entity.Id, sourceVersion = version }); + return RedirectToAction("Show2", "EntityReference", new { sourceId = id, sourceTypeId = entity.Id, sourceVersion = version }); } } } diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/Legacy/CreateDatasetController.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/Legacy/CreateDatasetController.cs index 0d0a0b553d..5755736c0f 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/Legacy/CreateDatasetController.cs +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/Legacy/CreateDatasetController.cs @@ -823,7 +823,9 @@ private List getAllMetadataReferences(DatasetVersion datasetVer xVersion, xpath, DefaultEntitiyReferenceType.MetadataLink.GetDisplayName(), - DateTime.Now + DateTime.Now, + "", + "" )); } } diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/ViewController.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/ViewController.cs index b7e354b632..8b235b8f70 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/ViewController.cs +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/ViewController.cs @@ -1,17 +1,61 @@ using BExIS.App.Bootstrap.Attributes; +using BExIS.Dim.Entities.Export; +using BExIS.Dim.Entities.Mappings; +using BExIS.Dim.Helpers.BIOSCHEMA; +using BExIS.Dim.Helpers.Mappings; +using BExIS.Dim.Helpers.Models; +using BExIS.Dim.Services; +using BExIS.Dim.Services.Mappings; using BExIS.Dlm.Entities.Data; +using BExIS.Dlm.Entities.DataStructure; +using BExIS.Dlm.Entities.Party; using BExIS.Dlm.Services.Data; +using BExIS.Dlm.Services.Party; +using BExIS.Modules.Dcm.UI.Helpers; +using BExIS.Modules.Dcm.UI.Helpers.View; using BExIS.Modules.Dcm.UI.Models.View; +using BExIS.Modules.Dim.UI.Helpers; using BExIS.Security.Entities.Authorization; +using BExIS.Security.Entities.Subjects; +using BExIS.Security.Services.Authorization; +using BExIS.Security.Services.Objects; +using BExIS.Security.Services.Requests; +using BExIS.Security.Services.Subjects; using BExIS.UI.Helpers; using BExIS.UI.Hooks; +using BExIS.UI.Models; +using BExIS.Utils.Data; +using BExIS.Utils.Data.Upload; +using DocumentFormat.OpenXml.Office2013.Excel; +using Microsoft.AspNet.Identity; +using NHibernate.Engine; using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Threading.Tasks; using System.Web.Mvc; +using System.Web.SessionState; +using Vaiona.Logging; +using Vaiona.Persistence.Api; +using Vaiona.Web.Mvc.Modularity; namespace BExIS.Modules.Dcm.UI.Controllers { + [SessionState(SessionStateBehavior.ReadOnly)] public class ViewController : Controller { + + private readonly UserManager _userManager; + + public ViewController(UserManager userManager) + { + _userManager = userManager; + } + + + #region about View + // GET: View /// /// this action loads the main view page of the dataset. @@ -20,21 +64,36 @@ public class ViewController : Controller /// /// /// - public ActionResult Index(long id, int version = 0) + public ActionResult Index(long id, int version = 0, double tag = 0) { - string pageId = "view"; string module = "DCM"; - ViewData["PageId"] = pageId; - ViewData["PageScript"] = SvelteHelper.GetPageScript(module, pageId); - ViewData["PageCss"] = SvelteHelper.GetPageCss(module, pageId); - ViewData["id"] = id; ViewData["version"] = version; + ViewData["app"] = SvelteHelper.GetApp(module); + ViewData["start"] = SvelteHelper.GetStart(module); + + // load settings from ddm + var moduleSettings = ModuleManager.GetModuleSettings("Ddm"); + ViewData["use_tags"] = moduleSettings.GetValueByKey("use_tags"); + bool useTags = (bool)ViewData["use_tags"]; + ViewData["use_minor"] = moduleSettings.GetValueByKey("use_minor"); + ViewData["has_data"] = false; + ViewData["data_aggreement"] = moduleSettings.GetValueByKey("data_aggreement"); + + if (version > 0) + { + // load BioSchema Description if exist + string bioschemadescription = getBioSchema(id, version); + if (!string.IsNullOrEmpty(bioschemadescription)) + ViewData["bioSchema"] = bioschemadescription; + } - ViewData["LayoutScript"] = SvelteHelper.GetLayoutScript(module); - ViewData["LayoutCss"] = SvelteHelper.GetLayoutCss(module); - ViewData["LayoutSvelteScript"] = SvelteHelper.GetLayoutSvelteScript(module); + //ToDo + // add bioschema to view data + // has data + // data_aggreement + // check_public_metadata return View(); } @@ -48,46 +107,407 @@ public ActionResult Index(long id, int version = 0) /// [BExISEntityAuthorize(typeof(Dataset), "id", RightType.Read)] [JsonNetFilter] - public JsonResult Load(long id, int version = 0) + public JsonResult Load(long id, int version = 0, double tag = 0) { + + EntityPermissionManager entityPermissionManager = new EntityPermissionManager(); + ApiDatasetHelper apiDatasetHelper = new ApiDatasetHelper(); + ViewModel model = new ViewModel(); model.Id = id; - model.Version = version; + + long versionId = 0; + bool latestVersion = false; + long latestVersionId = 0; + long latestVersionNr = 0; + bool useTags = false; + + // load dataset version + // if version number = 0 load latest version + DatasetVersion datasetVersion = null; + string dataStructureType = DataStructureType.Structured.ToString(); using (var datasetManager = new DatasetManager()) + using (EntityManager entityManager = new EntityManager()) { - // load dataset version - // if version number = 0 load latest version - DatasetVersion datasetVersion = null; - if (version == 0) // get latest + // Retrieve data for active and hidden (marked as deleted) datasets + if (datasetManager.IsDatasetCheckedIn(id) || datasetManager.IsDatasetDeleted(id)) { - datasetVersion = datasetManager.GetDatasetLatestVersion(id); - model.Version = datasetManager.GetDatasetVersionCount(id); // get number of the latest version + // check is public + long? entityTypeId = entityManager.FindByName(typeof(Dataset).Name)?.Id; + entityTypeId = entityTypeId.HasValue ? entityTypeId.Value : -1; + + List datasetVersions = datasetManager.GetDatasetVersions(id); + List datasetVersionsAllowed = new List(); + + if (!datasetManager.IsDatasetDeleted(id)) // dataset should not be in delete state + { + // Get version id based on public or internal access. Version name has a higher priority as version. + // Public access has higher priority as major/minor versions + versionId = getVersionId(id, version, "", tag).Result; + + if (useTags) + { + // compare the current version with the latest version id also based on tags + var x = datasetManager.GetLatestTag(id); + if (x != null) + { + latestVersionId = datasetManager.GetLatestVersionIdByTagNr(id, x.Nr); + latestVersion = (versionId >= latestVersionId); + } + else + { + latestVersionId = datasetManager.GetDatasetLatestVersionId(id); + latestVersion = (versionId >= latestVersionId); + } + + } + else + { + // Set if the latest version is selected. Compare current version id against unfiltered max id + + latestVersionId = datasetVersions.OrderByDescending(d => d.Timestamp).Select(d => d.Id).FirstOrDefault(); + latestVersionNr = datasetManager.GetDatasetVersionNr(latestVersionId); + latestVersion = (versionId == latestVersionId); + + } + // Get version number based on version id + if (versionId >= 0) + { + version = datasetManager.GetDatasetVersionNr(versionId); + } + + // Throw error if no version id was found. + if (versionId <= 0) + { + + ModelState.AddModelError("", string.Format("The requested version (release tag or version ID: {0}{1}) could not be found or you don’t have permission to access it.", version, "")); + } + else + { + datasetVersion = datasetManager.DatasetVersionRepo.Get(versionId); // this is needed to allow dsv to access to an open session that is available via the repo + var dataset = datasetVersion.Dataset; + ApiDatasetModel datasetModel = apiDatasetHelper.GetContent(datasetVersion, id, version, dataset.MetadataStructure.Id, dataset.DataStructure.Id, dataset.EntityTemplate.Id); + + model = ViewModel.Map(datasetModel); + + if (datasetVersion != null && datasetVersion.StateInfo != null) + { + model.IsValid = DatasetStateInfo.Valid.ToString().Equals(datasetVersion.StateInfo.State) ; + } + + model.MetadataStructureId = datasetVersion.Dataset.MetadataStructure.Id; + + //MetadataStructureManager msm = new MetadataStructureManager(); + //dsv.Dataset.MetadataStructure = msm.Repo.Get(dsv.Dataset.MetadataStructure.Id); + + model.Title = datasetVersion.Title; // this function only needs metadata and extra fields, there is no need to pass the version to it. + model.Labels = getLabels(id, versionId, tag, datasetVersion.Dataset.EntityTemplate.Name); + + if (datasetVersion.Dataset.DataStructure != null) + model.DataStructureId = datasetVersion.Dataset.DataStructure.Id; + + + // check if the user has download rights + model.DownloadAccess = entityPermissionManager.HasEffectiveRightsAsync(HttpContext.User.Identity.Name, typeof(Dataset), id, RightType.Read).Result; + + model.IsPublic = entityPermissionManager.ExistsAsync(entityTypeId.Value, id).Result; + // if the dataset is public, user or even no user has download rights + if (model.IsPublic) model.DownloadAccess = model.IsPublic; + + // check if a reuqest of this dataset exist + if (!model.DownloadAccess) + { + model.RequestExist = hasOpenRequest(id); + + if (UserExist() && hasRequestMapping(id)) + { + model.RequestAble = true; + model.HasRequestRight = hasUserRequestRight(); + } + } + + // get data structure type + if (datasetVersion.Dataset.DataStructure != null && datasetVersion.Dataset.DataStructure.Self.GetType().Equals(typeof(StructuredDataStructure))) + { + dataStructureType = DataStructureType.Structured.ToString(); + long c = datasetManager.RowCount(datasetVersion.Dataset.Id, null); + ViewData["gridTotal"] = c; + if (c > 0) model.HasData = true; + } + else + { + dataStructureType = DataStructureType.Unstructured.ToString(); + if (datasetVersion.ContentDescriptors.Where(c => c.Name.Equals("unstructuredData")).Any()) + { + model.HasData = true; + } + } + } + + #region settings + // load settings from ddm + var moduleSettings = ModuleManager.GetModuleSettings("Ddm"); + model.Settings.UseTags = Convert.ToBoolean(moduleSettings.GetValueByKey("use_tags")); + model.Settings.UseMinor = Convert.ToBoolean(moduleSettings.GetValueByKey("use_minor")); + model.Settings.DataAggrement = moduleSettings.GetValueByKey("data_aggreement").ToString(); + + // load all hooks for the edit view + HookManager hooksManager = new HookManager(); + model.Settings.Hooks = hooksManager.GetHooksFor("dataset", "details", HookMode.view); + + // run all checks + string userName = ""; + if (HttpContext.User.Identity.IsAuthenticated) + userName = HttpContext.User.Identity.Name; + + model.Settings.Hooks.ForEach(h => h.Check(id, userName)); + + #endregion + } + } - else // get specific + + if (version > 0) { - model.VersionId = datasetManager.GetDatasetVersionId(id, version); // get version id - datasetVersion = datasetManager.GetDatasetVersion(model.VersionId); // load datasetversion by id + // load BioSchema Description if exist + string bioschemadescription = getBioSchema(id, version); + if (!string.IsNullOrEmpty(bioschemadescription)) + ViewData["bioSchema"] = bioschemadescription; } - // get title - model.Title = datasetVersion.Title; - // load all hooks for the edit view - HookManager hooksManager = new HookManager(); - model.Hooks = hooksManager.GetHooksFor("dataset", "details", HookMode.view); + return Json(model, JsonRequestBehavior.AllowGet); + } + } + + // load bioschema + public JsonResult GetBioSchema(long id, int version) + { + string bioschema = getBioSchema(id, version); + return Json(bioschema, JsonRequestBehavior.AllowGet); + } + + [JsonNetFilter] + private string getBioSchema(long id, int version) + { + if (id <= 0) throw new ArgumentException("id is not valid"); + ViewData["Id"] = id; + + var helper = new BioSchemaHelper(); + string json = helper.GetBioSchemaForDataset(id, version, HttpContext.Request.Url.ToString()); + + return json; // Replace "_PartialViewName" with your actual name + + } + + [JsonNetFilter] + public JsonResult GetCitation(long id, int version) + { + // default setup for citation model if something goes wrong + CitaionModelJson model = new CitaionModelJson() + { + Format = ReadCitationFormat.Default, + Data = new CitationDataModel() + { + Title = "Title is not available." + } + }; + + try + { + using (var datasetManager = new DatasetManager()) + using (var conceptManager = new ConceptManager()) + { + var dataset = datasetManager.GetDataset(id); + DatasetVersion datasetVersion = null; - // run all checks - string userName = ""; - if (HttpContext.User.Identity.IsAuthenticated) - userName = HttpContext.User.Identity.Name; + long datasetVersionId = 0; + if(version>0) + datasetVersionId = datasetManager.GetDatasetVersionId(id, version); + else + datasetVersionId = datasetManager.GetDatasetLatestVersionId(id); - model.Hooks.ForEach(h => h.Check(id, userName)); + if (dataset.Status == DatasetStatus.Deleted) + { + datasetVersion = datasetManager.GetDeletedDatasetLatestVersion(id); + } + else + { + datasetVersion = datasetManager.GetDatasetVersion(datasetVersionId); + } + if (datasetVersion == null) + { + return Json(model, JsonRequestBehavior.AllowGet); + } + + var settingsHelper = new DDMSettingsHelper(); + var citationSettings = settingsHelper.GetCitationSettings(); + + var errors = new List(); + string conceptName = "Citation_" + citationSettings.ReadCitationFormat; + var concept = conceptManager.FindByName(conceptName); + + model.Data = CitationsHelper.CreateCitationDataModel(datasetVersion); + + if (model.Data == null) + { + model.Data = new CitationDataModel() + { + Title = datasetVersion.Title + }; + } + + if (citationSettings == null || !citationSettings.ShowCitation || concept == null || !MappingUtils.IsMapped(datasetVersion.Dataset.MetadataStructure.Id, LinkElementType.MetadataStructure, concept.Id, LinkElementType.MappingConcept, out errors)) + { + return Json(model, JsonRequestBehavior.AllowGet); + } + + if (!CitationsHelper.IsCitationDataModelValid(model.Data)) + { + + return Json(model, JsonRequestBehavior.AllowGet); + } + + + model.Format = citationSettings.ReadCitationFormat; + + return Json(model, JsonRequestBehavior.AllowGet); + + } + } + catch (Exception ex) + { return Json(model, JsonRequestBehavior.AllowGet); } + + } + + public PartialViewResult Tags(long id, int version) + { + if (id <= 0) throw new ArgumentException("id is not valid"); + + ViewData["Id"] = id; + List tags = new List(); + bool hasEditRights = hasUserRights(id, RightType.Write); + + if (version == 0) return PartialView("_tagsView", tags); // return empty list + + + + using (DatasetManager datasetmanager = new DatasetManager()) + { + TagInfoHelper _helper = new TagInfoHelper(); + var versions = datasetmanager.GetDatasetVersions(id); + + var currentVersion = datasetmanager.GetDatasetVersion(id, version); + ViewData["Tag"] = currentVersion.Tag?.Nr; + + if (versions != null) + { + tags = _helper.GetViews(versions, datasetmanager, !hasEditRights); + } + } + + return PartialView("_tagsView", tags); // Replace "_PartialViewName" with your actual name + + } + + private async Task getVersionId(long datasetId, int versionNr = 0, string versionName = "", double tagNr = 0) + { + + var moduleSettings = ModuleManager.GetModuleSettings("Ddm"); + bool useTags = false; + bool.TryParse(moduleSettings.GetValueByKey("use_tags").ToString(), out useTags); + + return await DatasetVersionHelper.GetVersionId(datasetId, GetUsernameOrDefault(), versionNr, useTags, tagNr); + + } + + // requests + private bool hasOpenRequest(long datasetId) + { + using (RequestManager requestManager = new RequestManager()) + using (DecisionManager decisionManager = new DecisionManager()) + using (SubjectManager subjectManager = new SubjectManager()) + using (EntityManager entityManager = new EntityManager()) + { + if (HttpContext.User != null && HttpContext.User.Identity != null && !string.IsNullOrEmpty(HttpContext.User.Identity.Name)) + { + long userId = subjectManager.Subjects.Where(s => s.Name.Equals(HttpContext.User.Identity.Name)).Select(s => s.Id).First(); + long entityId = entityManager.Entities.Where(e => e.Name.ToLower().Equals("dataset")).First().Id; + + var request = requestManager.Requests.Where(r => + r.Applicant.Id.Equals(userId) && + r.Entity.Id.Equals(entityId) && + r.Key.Equals(datasetId) && + r.Status == Security.Entities.Requests.RequestStatus.Open).FirstOrDefault(); + + if (request != null) return true; + } + + return false; + } } + private bool hasRequestMapping(long datasetId) + { + using (EntityManager entityManager = new EntityManager()) + using (PartyManager partyManager = new PartyManager()) + using (PartyTypeManager partyTypeManager = new PartyTypeManager()) + using (PartyRelationshipTypeManager partyRelationshipTypeManager = new PartyRelationshipTypeManager()) + { + try + { + var datasetPartyType = partyTypeManager.PartyTypes.Where(pt => pt.DisplayName.ToLower().Equals("dataset")).FirstOrDefault(); + + long partyId = partyManager.Parties.Where(p => p.PartyType.Id.Equals(datasetPartyType.Id) && p.Name.Equals(datasetId.ToString())).FirstOrDefault().Id; + + var ownerPartyRelationshipType = partyRelationshipTypeManager.PartyRelationshipTypes.Where(pt => pt.Title.Equals(ModuleManager.GetModuleSettings("bam").GetValueByKey("OwnerPartyRelationshipType").ToString())).FirstOrDefault(); + if (ownerPartyRelationshipType == null) return false; + + var ownerRelationships = partyManager.PartyRelationships.Where(p => + p.TargetParty.Id.Equals(partyId) && + p.PartyRelationshipType.Id.Equals(ownerPartyRelationshipType.Id)); + + if (ownerRelationships == null) return false; + + var exist = ownerRelationships.Count() > 0 ? true : false; + return exist; + } + catch (Exception ex) + { + LoggerFactory.LogCustom(ex.Message); + return false; + } + } + } + + private bool hasUserRequestRight() + { + using (var featurePermissionManager = new FeaturePermissionManager()) + using (var operationManager = new OperationManager()) + { + var operation = operationManager.Find("DDM", "RequestsSend", "*"); + if (operation != null) + { + var feature = operation.Feature; + + if (feature != null) + { + var result = _userManager.FindByNameAsync(GetUsernameOrDefault()); + + if (featurePermissionManager.HasAccessAsync(result.Result?.Id, feature.Id).Result) return true; + } + } + } + + return false; + } + + #endregion about view + /// /// Start from Metadata Hook - view /// @@ -144,9 +564,98 @@ public ActionResult StartDataStructure(long id, int version) return RedirectToAction("ShowPreviewDataStructure", "Data", new { area = "DDM", datasetID = id }); } + + public ActionResult Test() { return PartialView("_test"); } + + #region Helpers + + public bool UserExist() + { + if (HttpContext.User != null && HttpContext.User.Identity != null && !string.IsNullOrEmpty(HttpContext.User.Identity.Name)) return true; + + return false; + } + + public string GetUsernameOrDefault() + { + var username = string.Empty; + try + { + username = HttpContext.User.Identity.Name; + } + catch { } + + return !string.IsNullOrWhiteSpace(username) ? username : "DEFAULT"; + } + + private string getPartyNameOrDefault() + { + var userName = string.Empty; + try + { + userName = HttpContext.User.Identity.Name; + } + catch { } + + if (userName != null) + { + using (var uow = this.GetUnitOfWork()) + using (var partyManager = new PartyManager()) + { + var userRepository = uow.GetReadOnlyRepository(); + var user = userRepository.Query(s => s.Name.ToUpperInvariant() == userName.ToUpperInvariant()).FirstOrDefault(); + + if (user != null) + { + Party party = partyManager.GetPartyByUser(user.Id); + if (party != null) + { + return party.Name; + } + } + } + } + return !string.IsNullOrWhiteSpace(userName) ? userName : "DEFAULT"; + } + + private bool hasUserRights(long entityId, RightType rightType) + { + #region security permissions and authorizations check + + EntityPermissionManager entityPermissionManager = new EntityPermissionManager(); + + return entityPermissionManager.HasEffectiveRightsAsync(GetUsernameOrDefault(), typeof(Dataset), entityId, rightType).Result; + + + #endregion security permissions and authorizations check + } + + public Dictionary getLabels(long id, long versionId, double tag, string template) + { + using (var publicationManager = new PublicationManager()) + { + Dictionary keyValuePairs = new Dictionary(); + + var publications = publicationManager.PublicationRepo.Query(p => p.Dataset.Id == id && p.DatasetVersion.Id == versionId && p.ExternalLink != ""); + if (publications != null && publications.Any()) + { + + foreach (var item in publications) + { + keyValuePairs.Add(item.ExternalLink, item.ExternalLinkType); + } + } + + keyValuePairs.Add(template, "template"); + + return keyValuePairs; + } + } + + #endregion } } \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Dcm.Manifest.xml b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Dcm.Manifest.xml index d161057190..4b7635abac 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Dcm.Manifest.xml +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Dcm.Manifest.xml @@ -73,6 +73,7 @@ + + - + type="BExIS.Modules.Dcm.UI.Hooks.LinkEditHook, BExIS.Modules.DCM.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> e.Name.ToUpperInvariant() == "Extension".ToUpperInvariant()).FirstOrDefault(); + + if (extension == null) + { + extension = new Entity(); + extension.Name = "Extension"; + extension.EntityType = typeof(Dataset); + extension.EntityStoreType = typeof(Xml.Helpers.ExtensionStore); + extension.UseMetadata = true; + extension.Securable = true; + + //add to Extra + + XmlDocument xmlDoc = new XmlDocument(); + XmlDatasetHelper xmlDatasetHelper = new XmlDatasetHelper(); + xmlDatasetHelper.AddReferenceToXml(xmlDoc, AttributeNames.name.ToString(), "ddm", AttributeType.parameter.ToString(), "extra/modules/module"); + + extension.Extra = xmlDoc; + + entityManager.Create(extension); + } + else + { + XmlDocument xmlDoc = new XmlDocument(); + + if (extension.Extra != null) + if (extension.Extra is XmlDocument) xmlDoc = extension.Extra as XmlDocument; + else xmlDoc.AppendChild(extension.Extra); + + //update to Extra + XmlDatasetHelper xmlDatasetHelper = new XmlDatasetHelper(); + xmlDatasetHelper.AddReferenceToXml(xmlDoc, AttributeNames.name.ToString(), "ddm", AttributeType.parameter.ToString(), "extra/modules/module"); + + extension.Extra = xmlDoc; + + entityManager.Update(extension); + } + #endregion create entities #region SECURITY @@ -321,6 +360,14 @@ public void GenerateSeedData() ImportSchema("Publication", "BEXIS2-Publication-Schema-draft.xsd", "Metadata", publication.Name, publication.EntityType.FullName, titleXPath, descriptionXpath); } + if (!metadataStructureManager.Repo.Get().Any(m => m.Name.Equals("Extension"))) + { + string titleXPath = "Metadata/metadata/metadata/title/titleXmlSchemaComplexType"; + string descriptionXpath = "Metadata/metadata/metadata/description/descriptionXmlSchemaComplexType\r\n "; + + ImportSchema("Extension", "BEXIS2-Extension.xsd", "", extension.Name, extension.EntityType.FullName, titleXPath, descriptionXpath); + } + #endregion Add Metadata #region create default entitytemplate diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Helpers/EntityTemplateHelper.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Helpers/EntityTemplateHelper.cs index 4081d2fc7a..f644a64bf9 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Helpers/EntityTemplateHelper.cs +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Helpers/EntityTemplateHelper.cs @@ -23,6 +23,8 @@ public static EntityTemplate ConvertTo(EntityTemplateModel model) entityTemplate.HasDatastructure = model.HasDatastructure; entityTemplate.DisabledHooks = model.DisabledHooks; entityTemplate.DatastructureList = model.DatastructureList; + entityTemplate.HasExtension = model.HasExtension; + entityTemplate.ExtensionList = model.ExtensionList; entityTemplate.AllowedFileTypes = model.AllowedFileTypes; entityTemplate.PermissionGroups = model.PermissionGroups; entityTemplate.NotificationGroups = model.NotificationGroups; @@ -62,8 +64,10 @@ public static EntityTemplate Merge(EntityTemplateModel model) entityTemplate.Description = model.Description; entityTemplate.MetadataInvalidSaveMode = model.MetadataInvalidSaveMode; entityTemplate.HasDatastructure = model.HasDatastructure; + entityTemplate.HasExtension = model.HasExtension; entityTemplate.DisabledHooks = model.DisabledHooks; entityTemplate.DatastructureList = model.DatastructureList; + entityTemplate.ExtensionList = model.ExtensionList; entityTemplate.AllowedFileTypes = model.AllowedFileTypes; entityTemplate.PermissionGroups = model.PermissionGroups; entityTemplate.NotificationGroups = model.NotificationGroups; @@ -93,8 +97,10 @@ public static EntityTemplateModel ConvertTo(EntityTemplate entityTemplate, bool model.Description = entityTemplate.Description; model.MetadataInvalidSaveMode = entityTemplate.MetadataInvalidSaveMode; model.HasDatastructure = entityTemplate.HasDatastructure; + model.HasExtension = entityTemplate.HasExtension; model.DisabledHooks = entityTemplate.DisabledHooks != null ? entityTemplate.DisabledHooks : new List(); ; model.DatastructureList = entityTemplate.DatastructureList != null ? entityTemplate.DatastructureList : new List(); + model.ExtensionList = entityTemplate.ExtensionList != null ? entityTemplate.ExtensionList : new List(); model.AllowedFileTypes = entityTemplate.AllowedFileTypes != null ? entityTemplate.AllowedFileTypes : new List(); model.PermissionGroups = entityTemplate.PermissionGroups != null ? entityTemplate.PermissionGroups : new PermissionsType(); model.NotificationGroups = entityTemplate.NotificationGroups != null ? entityTemplate.NotificationGroups : new List(); diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Helpers/TagInfoHelper.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Helpers/TagInfoHelper.cs new file mode 100644 index 0000000000..d8c724484d --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Helpers/TagInfoHelper.cs @@ -0,0 +1,104 @@ +using BExIS.Dlm.Entities.Data; +using BExIS.Dlm.Services.Data; +using BExIS.Modules.Dcm.UI.Models.View; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace BExIS.Modules.Dcm.UI.Helpers +{ + public class TagInfoHelper + { + public Tag Update(TagInfoEditModel model, Tag tag) + { + if (model != null && tag != null) + { + tag.Nr = model.TagNr; + tag.ReleaseDate = model.ReleaseDate; + tag.Final = model.Publish; + + if (tag.Final && model.ReleaseDate == new DateTime()) + { + tag.ReleaseDate = DateTime.Now; + } + } + + return tag; + } + + public List ConvertTo(List versions, DatasetManager datasetManager) + { + List models = new List(); + + foreach (var version in versions) + { + models.Add(ConvertTo(version, datasetManager.GetDatasetVersionNr(version))); + } + + return models; + } + + public TagInfoEditModel ConvertTo(DatasetVersion dsv, int versionNr) + { + TagInfoEditModel model = new TagInfoEditModel(); + + if (dsv != null) + { + model.VersionId = dsv.Id; + model.VersionNr = versionNr; + model.ReleaseNote = dsv.ChangeDescription; + + if(dsv.ModificationInfo != null && !string.IsNullOrEmpty(dsv.ModificationInfo.Comment)) + model.SystemDescription = dsv.ModificationInfo.Comment; + + if (dsv.ModificationInfo != null && !string.IsNullOrEmpty(dsv.ModificationInfo.Performer)) + model.SystemAuthor = dsv.ModificationInfo.Performer; + + model.Show = dsv.Show; + + if(dsv.ModificationInfo?.Timestamp != null) + model.SystemDate = (DateTime)dsv.ModificationInfo?.Timestamp; + + + if (dsv.Tag != null) + { + model.TagId = dsv.Tag.Id; + model.TagNr = dsv.Tag.Nr; + model.ReleaseDate = dsv.Tag.ReleaseDate; + model.Publish = dsv.Tag.Final; + } + } + + return model; + } + + + + public List GetViews(List versions, DatasetManager datasetManager,bool released=false) + { + List models = new List(); + + List tags = versions.Where(v=>v.Tag!=null).Select(v => v.Tag.Nr).Distinct().ToList(); + + foreach (var nr in tags) + { + var tagVersions = versions.OrderByDescending(o=>o.Id).Where(v => v.Tag !=null && v.Show && v.Tag.Nr.Equals(nr)).ToList(); + if (released) + tagVersions = tagVersions.Where(v => v.Show && v.Tag.Final).ToList(); + + if (tagVersions.Any()) + { + models.Add(new TagInfoViewModel() + { + Version = nr, + ReleaseDate = tagVersions.FirstOrDefault().Tag.ReleaseDate, + ReleaseNotes = tagVersions.Select(v => v.ChangeDescription).ToList() + }); + } + + } + + return models; + } + } +} \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Helpers/View/CitationsHelper.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Helpers/View/CitationsHelper.cs new file mode 100644 index 0000000000..9adf5ad4c8 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Helpers/View/CitationsHelper.cs @@ -0,0 +1,350 @@ +using BExIS.Dim.Helpers.Mappings; +using BExIS.Dim.Services; +using BExIS.Dim.Services.Mappings; +using BExIS.Dlm.Entities.Data; +using BExIS.Dlm.Services.Data; +using BExIS.Modules.Dcm.UI.Models.View; +using BExIS.Security.Services.Authorization; +using BExIS.Security.Services.Objects; +using NameParser; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Web; +using System.Xml; +using System.Xml.Serialization; +using Vaiona.Web.Mvc.Modularity; + +namespace BExIS.Modules.Dcm.UI.Helpers.View +{ + public class CitationsHelper + { + public static CitationDataModel CreateCitationDataModel(DatasetVersion datasetVersion, CitationFormat format = 0) + { + try + { + using (var datasetManager = new DatasetManager()) + using (var conceptManager = new ConceptManager()) + using (var entityManager = new EntityManager()) + { + var entityPermissionManager = new EntityPermissionManager(); + var metadata = datasetVersion.Metadata; + + var concept = conceptManager.MappingConceptRepository.Query(c => c.Name.ToLower() == "citation_" + format.ToString().ToLower()).FirstOrDefault(); + + if (concept == null) + return null; + + var conceptOutput = MappingUtils.GetConceptOutput(datasetVersion.Dataset.MetadataStructure.Id, concept.Id, metadata); + + var model = new CitationDataModel(); + XmlSerializer serializer = new XmlSerializer(typeof(CitationDataModel), new XmlRootAttribute("data")); + using (XmlReader reader = new XmlNodeReader(conceptOutput)) + { + model = (CitationDataModel)serializer.Deserialize(reader); + } + + if (model == null) + return null; + + var settingsHelper = new DDMSettingsHelper(); + + var moduleSettings = ModuleManager.GetModuleSettings("Ddm"); + var useTags = Convert.ToBoolean(moduleSettings.GetValueByKey("use_tags")); + var citationSettings = settingsHelper.GetCitationSettings(); + + // Authors + if (citationSettings.NumberOfAuthors > 0 && model.Authors.Count > citationSettings.NumberOfAuthors) + { + model.Authors = new List() { model.Authors.Take(citationSettings.NumberOfAuthors) + " et al." }; + } + + //create authorname in the correct format + List authors = new List(); + foreach (string author in model.Authors) + { + HumanName name = new HumanName(author); + if (String.IsNullOrEmpty(name.Middle)) + authors.Add(name.Last + ", " + name.First); + else + authors.Add(name.Last + ", " + name.Middle + " " + name.First); + } + + model.Authors = authors; + + // Version + if (model.Version == null || string.IsNullOrEmpty(model.Version)) + { + model.Version = datasetManager.GetDatasetVersionNr(datasetVersion.Id).ToString(); + } + + //Tag + if (useTags) + { + if (datasetVersion.Tag != null) + model.Tag = datasetVersion.Tag.Nr.ToString(); + } + + var isPublic = entityPermissionManager.IsPublicAsync(datasetVersion.Dataset.EntityTemplate.EntityType.Id, datasetVersion.Dataset.Id).Result; + + // Entity Type + if (String.IsNullOrEmpty(model.EntityName)) + { + model.EntityName = datasetVersion.Dataset.EntityTemplate.EntityType.Name; + } + + // Publication Year + if (model.Year == null || String.IsNullOrEmpty(model.Year)) + { + if(useTags) + model.Year = datasetVersion.Tag != null ? datasetVersion.Tag.ReleaseDate.Date.ToString("yyyy") : datasetVersion.Timestamp.Date.ToString("yyyy"); + else + model.Year = datasetVersion.Timestamp.Date.ToString("yyyy"); + } + + // URL + if (String.IsNullOrEmpty(model.URL)) + { + model.URL = HttpContext.Current.Request.Url.Host; + } + + using (var publicationManager = new PublicationManager()) + { + var pub = publicationManager.GetPublication(datasetVersion.Dataset.Id); + if (pub != null) + { + if (!String.IsNullOrEmpty(pub.Doi)) + model.DOI = pub.Doi; + //else if (!String.IsNullOrEmpty(pub.ExternalLink)) + // model.URL = pub.ExternalLink; + } + } + + return model; + } + } + catch (Exception ex) + { + return null; + } + } + + public static bool IsCitationDataModelValid(CitationDataModel model) + { + try + { + var validationResults = new List(); + var context = new ValidationContext(model, serviceProvider: null, items: null); + return Validator.TryValidateObject(model, context, validationResults, true); + } + catch (Exception ex) + { + return false; + } + } + + public static string GetCitationString(CitationDataModel model, CitationFormat format, bool isPublic, long entityId, bool useTags) + { + try + { + switch (format) + { + case CitationFormat.Bibtex: + return GenerateBibtex(entityId, model, isPublic, useTags); + case CitationFormat.RIS: + return GenerateRis(entityId, model, isPublic, useTags); + case CitationFormat.Text: + return GenerateText(entityId, model, isPublic, useTags); + case CitationFormat.APA: + return GetApaFromCitationDataModel(model); + default: + return ""; + } + } + catch (Exception ex) + { + // Log the exception or handle it as needed + return string.Empty; + } + } + + public static string GetApaFromCitationDataModel(CitationDataModel model) + { + if (model == null) + { + return string.Empty; + } + var citation = new StringBuilder(); + citation.AppendLine($"{string.Join(", ", model.Authors)} ({model.Year}). {model.Title}. Version {model.Version}."); + if (!string.IsNullOrEmpty(model.DOI)) + { + citation.AppendLine($"https://doi.org/{model.DOI}"); + } + if (model.Projects != null && model.Projects.Count > 0) + { + citation.AppendLine($"Projects: {string.Join(", ", model.Projects)}"); + } + return citation.ToString(); + } + + public static string GenerateBibtex(long entityId,CitationDataModel model, bool isPublic, bool useTags) + { + if (model == null) + { + return string.Empty; + } + + string bibtex = "@misc{" + model.Keyword + "\n"; + bibtex += "title ={" + model.Title + "},\n"; + bibtex += "author ={"; + var lastAuthor = model.Authors.Last(); + foreach (string author in model.Authors) + { + if (author == lastAuthor) + bibtex += author + ""; + else + bibtex += author + " and "; + } + bibtex += "},\n"; + + if (useTags && !String.IsNullOrEmpty(model.Tag)) + bibtex += "version ={" + model.Tag + "},\n"; + else + bibtex += "version ={" + model.Version + "},\n"; + + bibtex += "year ={" + model.Year + "},\n"; + bibtex += "publisher ={" + model.Publisher + "},\n"; + + string url = model.URL; + if (isPublic) + { + if (useTags && !String.IsNullOrEmpty(model.Tag)) + url += "/ddm/data/Showdata/" + entityId + "?tag=" + model.Tag + ""; + else + url += "/ddm/data/Showdata/" + entityId + "?version=" + model.Version + ""; + + bibtex += "url ={" + url + "},\n"; + } + else + bibtex += "url ={" + url + "},\n"; + + if (!String.IsNullOrEmpty(model.DOI)) + bibtex += "doi ={" + model.DOI + "},\n"; + + if (!String.IsNullOrEmpty(model.EntityName)) + { + if (isPublic) + bibtex += "type ={" + model.EntityName + ". Published.},\n"; + else + bibtex += "type ={" + model.EntityName + ". Unpublished.},\n"; + } + if(String.IsNullOrEmpty(model.Note)) + bibtex += "note ={" + model.EntityName + " ID: " + entityId + "},\n"; + else + bibtex += "note ={"+ model.Note + "},\n"; + + bibtex += "}"; + + return bibtex; + } + + public static string GenerateRis(long entityId, CitationDataModel model, bool isPublic, bool useTags) + { + if (model == null) + { + return string.Empty; + } + string ris = "TY - " + model.EntryType + " \n"; + ris += "T1 - " + model.Title + "\n"; + + foreach (string author in model.Authors) + { + ris += "AU - " + author + "\n"; + } + ris += "PY - " + model.Year + " \n"; + + if (useTags && !String.IsNullOrEmpty(model.Tag)) + ris += "ET - " + model.Tag + " \n"; + else + ris += "ET - " + model.Version + " \n"; + + ris += "PB - " + model.Publisher + " \n"; + + if (!String.IsNullOrEmpty(model.DOI)) + ris += "DO - " + model.DOI + "\n"; + + string url = model.URL; + if (isPublic) + { + if (useTags && !String.IsNullOrEmpty(model.Tag)) + url += "/ddm/data/Showdata/" + entityId + "?tag=" + model.Tag + ""; + else + url += "/ddm/data/Showdata/" + entityId + "?version=" + model.Version + ""; + + ris += "UR - " + url + "\n"; + } + else + ris += "UR - " + url + "\n"; + + if (isPublic) + ris += "N1 - " + model.EntityName +" ID: " + entityId + ", Published. \n"; + else + ris += "N1 - " + model.EntityName + " ID: " + entityId + ", Unpublished. \n"; + ris += "ER -"; + + return ris; + } + + public static string GenerateText(long entityId,CitationDataModel model, bool isPublic, bool useTags) + { + string text = ""; + var lastAuthor = model.Authors.Last(); + foreach (string author in model.Authors) + { + if (author.Equals(lastAuthor)) + text += author; + else + text += author + "; "; + } + text += " (" + model.Year + "): "; + text += model.Title + ". "; + + if (useTags && !String.IsNullOrEmpty(model.Tag)) + text += "Version " + model.Tag + ". "; + else + text += "Version " + model.Version + ". "; + + text += model.Publisher + ". "; + text += model.EntityName + ". "; + + if (!String.IsNullOrEmpty(model.DOI)) + { + text += model.DOI; + } + else + { + string url = model.URL; + if (isPublic) + { + if (useTags && !String.IsNullOrEmpty(model.Tag)) + url += "/ddm/data/Showdata/" + entityId + "?tag=" + model.Tag + ""; + else + url += "/ddm/data/Showdata/" + entityId + "?version=" + model.Version + ""; + + text += url + ". "; + } + else + text += url + ". "; + + if(String.IsNullOrEmpty(model.Note)) + text += model.EntityName + " ID= " + entityId; + else + text += model.Note; + } + + return text; + } + } +} \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Helpers/View/DDMSettingsHelper.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Helpers/View/DDMSettingsHelper.cs new file mode 100644 index 0000000000..d94d3fd0de --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Helpers/View/DDMSettingsHelper.cs @@ -0,0 +1,68 @@ +using BExIS.Xml.Helpers; +using System.Collections.Generic; +using System; +using System.IO; +using System.Xml.Linq; +using Vaiona.Utils.Cfg; +using Vaiona.Web.Mvc.Modularity; +using BExIS.Modules.Dcm.UI.Models.View; + +namespace BExIS.Modules.Dcm.UI.Helpers +{ + public class DDMSettingsHelper + { + private ModuleSettings _settings; + private string filePath = ""; + + public DDMSettingsHelper() + { + _settings = ModuleManager.GetModuleSettings("ddm"); + } + + public bool KeyExist(string key) + { + XDocument settings = XDocument.Load(filePath); + XElement element = XmlUtility.GetXElementByAttribute("entry", "key", key.ToLower(), settings); + + return element != null ? true : false; + } + + //public string GetValue(string key) + //{ + // XDocument settings = XDocument.Load(filePath); + // XElement element = XmlUtility.GetXElementByAttribute("entry", "key", key.ToLower(), settings); + + // string value = ""; + // if (element != null) + // { + // value = element.Attribute("value")?.Value; + // } + + // return value; + //} + + public T GetValue(string key) where T : class + { + try + { + return _settings.GetValueByKey(key); + } + catch (Exception ex) + { + return null; + } + } + + public CitationSettings GetCitationSettings() + { + try + { + return _settings.GetValueByKey("citationSettings"); + } + catch (Exception ex) + { + return new CitationSettings(); + } + } + } +} \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/AttachmentEditHook.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/AttachmentEditHook.cs index c5781dcc94..3ac06f06ac 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/AttachmentEditHook.cs +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/AttachmentEditHook.cs @@ -1,5 +1,6 @@ using BExIS.Dlm.Services.Data; using BExIS.Security.Entities.Authorization; +using BExIS.Security.Services.Objects; using BExIS.UI.Hooks; namespace BExIS.Modules.Dcm.UI.Hooks @@ -13,12 +14,16 @@ public AttachmentEditHook() public override void Check(long id, string username) { + // check status checkStatus(id, username); // check if subject is checked in // only check if status is open checkAvailablity(id); + + // disable for extension entity + checkEntity(id); } private void checkStatus(long id, string username) @@ -42,5 +47,18 @@ private void checkAvailablity(long id) using (var datasetManager = new DatasetManager()) Status = datasetManager.IsDatasetCheckedIn(id) == true ? HookStatus.Open : HookStatus.Waiting; } + + private void checkEntity(long id) + { + using (var datasetManager = new DatasetManager()) + using (var entityManager = new EntityManager()) + { + var entity = entityManager.FindByName("extension"); // get entity + if (entity != null) + { + Status = datasetManager.GetDataset(id).EntityTemplate.EntityType.Id.Equals(entity.Id) ? HookStatus.Disabled: Status; // disable if entity type matches + } + } + } } } \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/AttachmentViewHook.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/AttachmentViewHook.cs index e2b0c852e3..15f72fad05 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/AttachmentViewHook.cs +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/AttachmentViewHook.cs @@ -1,5 +1,6 @@ using BExIS.Dlm.Services.Data; using BExIS.Security.Entities.Authorization; +using BExIS.Security.Services.Objects; using BExIS.UI.Hooks; namespace BExIS.Modules.Dcm.UI.Hooks @@ -15,6 +16,9 @@ public override void Check(long id, string username) { // check status checkStatus(id, username); + + // disable for extension entity + checkEntity(id); } private void checkStatus(long id, string username) @@ -35,5 +39,18 @@ private void checkStatus(long id, string username) if (dataset.Status != Dlm.Entities.Data.DatasetStatus.CheckedIn) Status = HookStatus.Disabled; } } + + private void checkEntity(long id) + { + using (var datasetManager = new DatasetManager()) + using (var entityManager = new EntityManager()) + { + var entity = entityManager.FindByName("extension"); // get entity + if (entity != null) + { + Status = datasetManager.GetDataset(id).EntityTemplate.EntityType.Id.Equals(entity.Id) ? HookStatus.Disabled : Status; // disable if entity type matches + } + } + } } } \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/LinkEditHook.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/LinkEditHook.cs index 352c3eb360..c995ca7f20 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/LinkEditHook.cs +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/LinkEditHook.cs @@ -1,5 +1,6 @@ using BExIS.Dlm.Services.Data; using BExIS.Security.Entities.Authorization; +using BExIS.Security.Services.Objects; using BExIS.UI.Hooks; namespace BExIS.Modules.Dcm.UI.Hooks @@ -13,12 +14,17 @@ public LinkEditHook() public override void Check(long id, string username) { + + // check status checkStatus(id, username); // check if subject is checked in // only check if status is open checkAvailablity(id); + + // disable for extension entity + checkEntity(id); } private void checkStatus(long id, string username) @@ -42,5 +48,18 @@ private void checkAvailablity(long id) using (var datasetManager = new DatasetManager()) Status = datasetManager.IsDatasetCheckedIn(id) == true ? HookStatus.Open : HookStatus.Waiting; } + + private void checkEntity(long id) + { + using (var datasetManager = new DatasetManager()) + using (var entityManager = new EntityManager()) + { + var entity = entityManager.FindByName("extension"); // get entity + if (entity != null) + { + Status = datasetManager.GetDataset(id).EntityTemplate.EntityType.Id.Equals(entity.Id) ? HookStatus.Disabled : Status; // disable if entity type matches + } + } + } } } \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/LinkViewHook.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/LinkViewHook.cs index 983cc3f36e..7e348751f1 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/LinkViewHook.cs +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Hooks/LinkViewHook.cs @@ -1,4 +1,6 @@ -using BExIS.Security.Entities.Authorization; +using BExIS.Dlm.Services.Data; +using BExIS.Security.Entities.Authorization; +using BExIS.Security.Services.Objects; using BExIS.UI.Hooks; namespace BExIS.Modules.Dcm.UI.Hooks @@ -12,8 +14,16 @@ public LinkViewHook() public override void Check(long id, string username) { - // check status - checkStatus(id, username); + // disable for extension entity + checkEntity(id); + + if (Status != HookStatus.Disabled) + { + + // check status + checkStatus(id, username); + + } } private void checkStatus(long id, string username) @@ -22,5 +32,18 @@ private void checkStatus(long id, string username) Status = HookStatus.Open; } + + private void checkEntity(long id) + { + using (var datasetManager = new DatasetManager()) + using (var entityManager = new EntityManager()) + { + var entity = entityManager.FindByName("extension"); // get entity + if (entity != null) + { + Status = datasetManager.GetDataset(id).EntityTemplate.EntityType.Id.Equals(entity.Id) ? HookStatus.Disabled : Status; // disable if entity type matches + } + } + } } } \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/LICENSE.txt b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/LICENSE.txt new file mode 100644 index 0000000000..8db6358335 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright Adam Shirey +https://github.com/aeshirey/NameParserSharp + +Derived from nameparser 0.36 (https://pypi.python.org/pypi/nameparser), copyright Derek Gulbranson . +http://derekgulbranson.com/ + +Which in turn is based on PHP nameParser.php by G. Miernicki +http://code.google.com/p/nameparser/ + +----- + +LGPL +http://www.opensource.org/licenses/lgpl-license.html + +This library is free software; you can redistribute it and/or modify it under the +terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2.1 of the License, or (at your option) any later +version. + +This library is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Models/EntityTemplates/EntityTemplateModels.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Models/EntityTemplates/EntityTemplateModels.cs index a8cd964b8f..acce99e4c7 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Models/EntityTemplates/EntityTemplateModels.cs +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Models/EntityTemplates/EntityTemplateModels.cs @@ -50,6 +50,11 @@ public class EntityTemplateModel /// public virtual bool HasDatastructure { get; set; } + /// + /// If this flag is true, the entity will have a extensions + /// + public virtual bool HasExtension { get; set; } + /// /// If this flag is true, user can use this tempate to create a entity /// @@ -60,6 +65,11 @@ public class EntityTemplateModel ///
public virtual List DatastructureList { get; set; } + /// + /// List of available extensions + /// + public virtual List ExtensionList { get; set; } + public List AllowedFileTypes { get; set; } /// diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Models/View/CitationModels.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Models/View/CitationModels.cs new file mode 100644 index 0000000000..3989bf0fed --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Models/View/CitationModels.cs @@ -0,0 +1,156 @@ +using BExIS.App.Bootstrap.Attributes; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Xml.Serialization; + +namespace BExIS.Modules.Dcm.UI.Models.View +{ + public class CitationModel + { + public string CitationString { get; set; } + } + + public class ReadCitationModel + { + public string Title { get; set; } + public string Version { get; set; } + } + + public enum ReadCitationFormat + { + APA, + Text, + Default + } + + public enum CitationFormat + { + APA, + RIS, + Text, + Bibtex + } + + public class CitaionModelJson + { + public ReadCitationFormat Format { get; set; } + public CitationDataModel Data { get; set; } + } + + + [XmlRoot("data")] + public class CitationDataModel + { + [XmlElement("title")] + [Required(ErrorMessage = "Title is required")] + [MinLength(1, ErrorMessage = "Title cannot be empty")] + public string Title { get; set; } + + [XmlElement("version")] + public string Version { get; set; } + public string Tag { get; set; } + + [XmlArray("projects")] + [XmlArrayItem("project")] + public List Projects { get; set; } + + [XmlElement("year")] + [Required(ErrorMessage = "Year is required")] + [MinLength(1, ErrorMessage = "Year cannot be empty")] + public string Year { get; set; } + + [XmlElement("doi")] + public string DOI { get; set; } + + [XmlElement("url")] + [Required(ErrorMessage = "URL is required")] + [MinLength(1, ErrorMessage = "URL cannot be empty")] + public string URL { get; set; } + + [XmlArray("authorNames")] + [XmlArrayItem("authorName")] + [MinCapacity(1), NoNullOrEmptyItems] + public List Authors { get; set; } + + //[XmlElement("entityType")] + //[Required(ErrorMessage = "Entity Type is required")] + //[MinLength(1, ErrorMessage = "Entity Type cannot be empty")] + //public string EntityType { get; set; } + + [XmlElement("entryType")] + public string EntryType { get; set; } + + [XmlElement("entityName")] + public string EntityName { get; set; } + + [XmlElement("publisher")] + [Required(ErrorMessage = "Publisher is required")] + [MinLength(1, ErrorMessage = "Publisher cannot be empty")] + public string Publisher { get; set; } + + [XmlElement("keyword")] + public string Keyword { get; set; } + + [XmlElement("note")] + public string Note { get; set; } + + public CitationDataModel() + { + Authors = new List(); + Projects = new List(); + } + } + + public class CitationDatasetIds + { + public string[] DatasetIds { get; set; } + } + + public class DatasetCitationEntry + { + public DatasetCitationEntry() + { + Projects = new List(); + } + + public string URL { get; set; } + public string Publisher { get; set; } + public string Year { get; set; } + public List Authors { get; set; } + public string Title { get; set; } + public List Projects { get; set; } + public string DatasetId { get; set; } + public string Version { get; set; } + public bool IsPublic { get; set; } + public string DOI { get; set; } + public string CitationStringTxt { get; set; } + } + public class Project + { + public string Name { get; set; } + public long Id { get; set; } + } + + public class CitationSettings + { + public string Instance { get; set; } + public string Publisher { get; set; } + public bool ShowCitation { get; set; } + public int NumberOfAuthors { get; set; } + public ReadCitationFormat ReadCitationFormat { get; set; } + + public List DownloadCitationFormats { get; set; } + + public CitationSettings() + { + Instance = "BEXIS2"; + Publisher = "BEXIS2"; + ShowCitation = false; + NumberOfAuthors = 1; + ReadCitationFormat = ReadCitationFormat.Text; + DownloadCitationFormats = new List() { }; + } + } + +} \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Models/View/ViewModel.cs b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Models/View/ViewModel.cs index 73fd8f2dc3..c3eb3a8791 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Models/View/ViewModel.cs +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Models/View/ViewModel.cs @@ -1,15 +1,26 @@ -using BExIS.UI.Hooks; +using BExIS.Dim.Helpers.Models; +using BExIS.Modules.Dim.UI.Models.Download; +using BExIS.UI.Hooks; +using Newtonsoft.Json; +using System; using System.Collections.Generic; +using System.Reflection; namespace BExIS.Modules.Dcm.UI.Models.View { - public class ViewModel + public class ViewModel:ApiDatasetModel { - public long Id { get; set; } - public long VersionId { get; set; } - public int Version { get; set; } - public string Title { get; set; } - public List Hooks { get; set; } + public ViewSettings Settings { get; set; } + public bool HasData { get; set; } + public int Count { get; set; } + public bool IsValid { get; set; } + public bool DownloadAccess { get; set; } + public bool RequestExist { get; set; } + public bool RequestAble { get; set; } + public bool HasRequestRight { get; set; } + + + public Dictionary Labels { get; set; } public ViewModel() { @@ -17,7 +28,134 @@ public ViewModel() Version = 0; VersionId = 0; Title = ""; + HasData = false; + Labels = new Dictionary(); + Settings = new ViewSettings(); + } + + public static ViewModel Map(ApiDatasetModel source) + { + ViewModel target = new ViewModel(); + + // 1. Hole alle öffentlichen Instanz-Eigenschaften des Quell-Typs + PropertyInfo[] sourceProperties = typeof(ApiDatasetModel).GetProperties(BindingFlags.Public | BindingFlags.Instance); + + // 2. Durchlaufe die Eigenschaften in einer Schleife + foreach (PropertyInfo sourceProperty in sourceProperties) + { + // 3. Suche die entsprechende Eigenschaft im Ziel-Typ + PropertyInfo targetProperty = typeof(GeneralMetadataModel).GetProperty(sourceProperty.Name); + + // 4. Überprüfe, ob die Eigenschaft existiert und gesetzt werden kann + if (targetProperty != null && targetProperty.CanWrite) + { + // 5. Überprüfe, ob die Typen übereinstimmen (empfohlen) + if (targetProperty.PropertyType == sourceProperty.PropertyType) + { + // 6. Lese den Wert aus der Quelle + object value = sourceProperty.GetValue(source); + + // 7. Setze den Wert im Ziel + targetProperty.SetValue(target, value); + } + } + } + + return target; + } + } + + public class ViewSettings + { + public bool UseTags { get; set; } // use tags, e.g., 1.0, 2.0, 3.0 + public bool UseMinor { get; set; } // use minor tags, e.g., 1.1, 1.2, 1.3 + public string DataAggrement { get; set; } + + public List Hooks { get; set; } + + public ViewSettings() + { + UseTags = false; + UseMinor = false; Hooks = new List(); } } + + public class TagInfoViewModel + { + [JsonProperty("version")] + public double Version { get; set; } + [JsonProperty("releaseNotes")] + public List ReleaseNotes { get; set; } + [JsonProperty("releaseDate")] + public DateTime ReleaseDate { get; set; } + + public TagInfoViewModel() + { + Version = 0; + ReleaseNotes = new List(); + } + + } + + public class TagInfoEditModel + { + [JsonProperty("versionId")] + public long VersionId { get; set; } + + [JsonProperty("versionNr")] + public long VersionNr { get; set; } + + + [JsonProperty("releaseNote")] + public string ReleaseNote { get; set; } + [JsonProperty("show")] + public bool Show { get; set; } + + [JsonProperty("tagId")] + public long TagId { get; set; } + + [JsonProperty("tagNr")] + public double TagNr { get; set; } + + [JsonProperty("publish")] + public bool Publish { get; set; } + + [JsonProperty("releaseDate")] + public DateTime ReleaseDate { get; set; } + [JsonProperty("systemDescription")] + public string SystemDescription { get; set; } + [JsonProperty("systemAuthor")] + public string SystemAuthor { get; set; } + [JsonProperty("systemDate")] + public DateTime SystemDate { get; set; } + + [JsonProperty("link")] + public string Link { get; set; } + + public TagInfoEditModel() + { + VersionId = 0; + VersionNr = 0; + TagId = 0; + TagNr = 0; + ReleaseNote = ""; + SystemDescription = ""; + SystemAuthor = ""; + Link = ""; + } + + public TagInfoEditModel(long versionId, long versionNr, double tagNr, string releaseNote, DateTime releaseDate, string systemDescription, string systemAuthor, DateTime systemDate, string link) + { + VersionId = versionId; + VersionNr = versionNr; + TagNr = tagNr; + ReleaseNote = releaseNote; + ReleaseDate = releaseDate; + if (!string.IsNullOrEmpty(systemAuthor)) SystemAuthor = systemAuthor; + if (!string.IsNullOrEmpty(systemDescription)) SystemAuthor = systemDescription; + SystemDate = systemDate; + Link = link; + } + } } \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Views/EntityReference/Show.cshtml b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Views/EntityReference/Show.cshtml index 34876683f4..5a279c85fc 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Views/EntityReference/Show.cshtml +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Views/EntityReference/Show.cshtml @@ -2,7 +2,7 @@ @model BExIS.UI.Models.EntityReference.ReferencesModel @{ - ViewBag.Title = " ... "; + ViewBag.Title = "Links for "+ Model.Selected.Title; string debugPath = ""; @@ -12,17 +12,28 @@ } } - - - +@section scripts +{ + + + + + + +} \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Views/View/Index.cshtml b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Views/View/Index.cshtml index 3c6c584a7a..39bdae9946 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Views/View/Index.cshtml +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Views/View/Index.cshtml @@ -1,38 +1,27 @@ @{ - ViewBag.Title = "Test"; + ViewBag.Title = "View"; Layout = "~/Themes/Default/Layouts/_svelteLayout.cshtml"; - string page = ViewData["PageScript"].ToString(); - string pagecss = ViewData["PageCss"].ToString(); - string pageId = ViewData["PageId"].ToString(); + long id = 0; + long version = -1; - //string skeletoncss = "../../../Content/skeleton/themes/theme-modern.css"; + if (ViewData["id"] != null) { id = Convert.ToInt64(ViewData["id"]); } - string layoutcss = ""; - if (ViewData["LayoutCss"] != null) + if (ViewData["version"] != null) { version = Convert.ToInt64(ViewData["version"]); } + + string bioSchemaInfos = ""; + if (ViewData["bioSchema"] != null) { - layoutcss = ViewData["LayoutCss"].ToString(); + bioSchemaInfos = ViewData["bioSchema"].ToString(); } - string layoutScript = ViewData["LayoutScript"].ToString(); - - string layoutSvelteScript = ViewData["LayoutSvelteScript"].ToString(); - - long id = Convert.ToInt64(ViewData["id"]); - long version = Convert.ToInt64(ViewData["version"]); - } - - - - - - - import page from '@page' +
- const app = new page({ - target: document.querySelector('[data-sveltekit-hydrate="view"]').parentNode - }); - \ No newline at end of file + @Html.Partial("_sveltePage") +
\ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/packages.config b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/packages.config index ba8366ced3..ae6382ddb2 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/packages.config +++ b/Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/packages.config @@ -22,6 +22,7 @@ + diff --git a/Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI.Svelte/vite.config.ts.timestamp-1782117629957-9809f624b91ce.mjs b/Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI.Svelte/vite.config.ts.timestamp-1782117629957-9809f624b91ce.mjs new file mode 100644 index 0000000000..19e4da128e --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI.Svelte/vite.config.ts.timestamp-1782117629957-9809f624b91ce.mjs @@ -0,0 +1,16 @@ +// vite.config.ts +import { sveltekit } from "file:///C:/Users/David%20Sch%C3%B6ne/source/repos/BEXIS2/BEXIS2-DEV/Core/node_modules/.pnpm/@sveltejs+kit@2.63.0_patch__973f09f10404d661120ee3d506acfc20/node_modules/@sveltejs/kit/src/exports/vite/index.js"; +import { defineConfig } from "file:///C:/Users/David%20Sch%C3%B6ne/source/repos/BEXIS2/BEXIS2-DEV/Core/node_modules/.pnpm/vitest@2.0.5_@types+node@22.0.2/node_modules/vitest/dist/config.js"; +var vite_config_default = defineConfig({ + plugins: [sveltekit()], + test: { + include: ["src/**/*.{test,spec}.{js,ts}"] + }, + ssr: { + noExternal: ["@skeletonlabs/skeleton"] + } +}); +export { + vite_config_default as default +}; +//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCJDOlxcXFxVc2Vyc1xcXFxEYXZpZCBTY2hcdTAwRjZuZVxcXFxzb3VyY2VcXFxccmVwb3NcXFxcQkVYSVMyXFxcXEJFWElTMi1ERVZcXFxcQ29yZVxcXFxDb25zb2xlXFxcXEJFeElTLldlYi5TaGVsbFxcXFxBcmVhc1xcXFxERE1cXFxcQkV4SVMuTW9kdWxlcy5EZG0uVUkuU3ZlbHRlXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ZpbGVuYW1lID0gXCJDOlxcXFxVc2Vyc1xcXFxEYXZpZCBTY2hcdTAwRjZuZVxcXFxzb3VyY2VcXFxccmVwb3NcXFxcQkVYSVMyXFxcXEJFWElTMi1ERVZcXFxcQ29yZVxcXFxDb25zb2xlXFxcXEJFeElTLldlYi5TaGVsbFxcXFxBcmVhc1xcXFxERE1cXFxcQkV4SVMuTW9kdWxlcy5EZG0uVUkuU3ZlbHRlXFxcXHZpdGUuY29uZmlnLnRzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9tZXRhX3VybCA9IFwiZmlsZTovLy9DOi9Vc2Vycy9EYXZpZCUyMFNjaCVDMyVCNm5lL3NvdXJjZS9yZXBvcy9CRVhJUzIvQkVYSVMyLURFVi9Db3JlL0NvbnNvbGUvQkV4SVMuV2ViLlNoZWxsL0FyZWFzL0RETS9CRXhJUy5Nb2R1bGVzLkRkbS5VSS5TdmVsdGUvdml0ZS5jb25maWcudHNcIjtpbXBvcnQgeyBzdmVsdGVraXQgfSBmcm9tICdAc3ZlbHRlanMva2l0L3ZpdGUnO1xyXG5pbXBvcnQgeyBkZWZpbmVDb25maWcgfSBmcm9tICd2aXRlc3QvY29uZmlnJztcclxuXHJcbmV4cG9ydCBkZWZhdWx0IGRlZmluZUNvbmZpZyh7XHJcblx0cGx1Z2luczogW3N2ZWx0ZWtpdCgpXSxcclxuXHR0ZXN0OiB7XHJcblx0XHRpbmNsdWRlOiBbJ3NyYy8qKi8qLnt0ZXN0LHNwZWN9Lntqcyx0c30nXVxyXG5cdH0sXHJcblx0c3NyOiB7XHJcblx0XHRub0V4dGVybmFsOiBbJ0Bza2VsZXRvbmxhYnMvc2tlbGV0b24nXVxyXG5cdH1cclxufSk7XHJcbiJdLAogICJtYXBwaW5ncyI6ICI7QUFBd2pCLFNBQVMsaUJBQWlCO0FBQ2xsQixTQUFTLG9CQUFvQjtBQUU3QixJQUFPLHNCQUFRLGFBQWE7QUFBQSxFQUMzQixTQUFTLENBQUMsVUFBVSxDQUFDO0FBQUEsRUFDckIsTUFBTTtBQUFBLElBQ0wsU0FBUyxDQUFDLDhCQUE4QjtBQUFBLEVBQ3pDO0FBQUEsRUFDQSxLQUFLO0FBQUEsSUFDSixZQUFZLENBQUMsd0JBQXdCO0FBQUEsRUFDdEM7QUFDRCxDQUFDOyIsCiAgIm5hbWVzIjogW10KfQo= diff --git a/Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI/BExIS.Modules.Ddm.UI.csproj b/Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI/BExIS.Modules.Ddm.UI.csproj index 88511846c0..03c28b812e 100644 --- a/Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI/BExIS.Modules.Ddm.UI.csproj +++ b/Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI/BExIS.Modules.Ddm.UI.csproj @@ -407,7 +407,7 @@ BExIS.Ddm.Api - {FBE3101A-791A-4EAB-9B8F-F6E071F8DBDC} + {fbe3101a-791a-4eab-9b8f-f6e071f8dbdc} BExIS.Ddm.Providers.LuceneProvider diff --git a/Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI/Controllers/DataController.cs b/Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI/Controllers/DataController.cs index c111386b81..f805d8d8a6 100644 --- a/Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI/Controllers/DataController.cs +++ b/Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI/Controllers/DataController.cs @@ -2277,8 +2277,6 @@ public Dictionary getLabels(long id, long versionId, double tag, { Dictionary keyValuePairs = new Dictionary(); - - var publications = publicationManager.PublicationRepo.Query(p => p.Dataset.Id == id && p.DatasetVersion.Id == versionId && p.ExternalLink != ""); if (publications != null && publications.Any()) { diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI.Svelte/vite.config.ts.timestamp-1782117629967-db0307906de94.mjs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI.Svelte/vite.config.ts.timestamp-1782117629967-db0307906de94.mjs new file mode 100644 index 0000000000..257303b2bb --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI.Svelte/vite.config.ts.timestamp-1782117629967-db0307906de94.mjs @@ -0,0 +1,16 @@ +// vite.config.ts +import { sveltekit } from "file:///C:/Users/David%20Sch%C3%B6ne/source/repos/BEXIS2/BEXIS2-DEV/Core/node_modules/.pnpm/@sveltejs+kit@2.63.0_patch__973f09f10404d661120ee3d506acfc20/node_modules/@sveltejs/kit/src/exports/vite/index.js"; +import { defineConfig } from "file:///C:/Users/David%20Sch%C3%B6ne/source/repos/BEXIS2/BEXIS2-DEV/Core/node_modules/.pnpm/vitest@2.0.5_@types+node@22.0.2/node_modules/vitest/dist/config.js"; +var vite_config_default = defineConfig({ + plugins: [sveltekit()], + test: { + include: ["src/**/*.{test,spec}.{js,ts}"] + }, + ssr: { + noExternal: ["@skeletonlabs/skeleton"] + } +}); +export { + vite_config_default as default +}; +//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCJDOlxcXFxVc2Vyc1xcXFxEYXZpZCBTY2hcdTAwRjZuZVxcXFxzb3VyY2VcXFxccmVwb3NcXFxcQkVYSVMyXFxcXEJFWElTMi1ERVZcXFxcQ29yZVxcXFxDb25zb2xlXFxcXEJFeElTLldlYi5TaGVsbFxcXFxBcmVhc1xcXFxESU1cXFxcQkV4SVMuTW9kdWxlcy5EaW0uVUkuU3ZlbHRlXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ZpbGVuYW1lID0gXCJDOlxcXFxVc2Vyc1xcXFxEYXZpZCBTY2hcdTAwRjZuZVxcXFxzb3VyY2VcXFxccmVwb3NcXFxcQkVYSVMyXFxcXEJFWElTMi1ERVZcXFxcQ29yZVxcXFxDb25zb2xlXFxcXEJFeElTLldlYi5TaGVsbFxcXFxBcmVhc1xcXFxESU1cXFxcQkV4SVMuTW9kdWxlcy5EaW0uVUkuU3ZlbHRlXFxcXHZpdGUuY29uZmlnLnRzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9tZXRhX3VybCA9IFwiZmlsZTovLy9DOi9Vc2Vycy9EYXZpZCUyMFNjaCVDMyVCNm5lL3NvdXJjZS9yZXBvcy9CRVhJUzIvQkVYSVMyLURFVi9Db3JlL0NvbnNvbGUvQkV4SVMuV2ViLlNoZWxsL0FyZWFzL0RJTS9CRXhJUy5Nb2R1bGVzLkRpbS5VSS5TdmVsdGUvdml0ZS5jb25maWcudHNcIjtpbXBvcnQgeyBzdmVsdGVraXQgfSBmcm9tICdAc3ZlbHRlanMva2l0L3ZpdGUnO1xyXG5pbXBvcnQgeyBkZWZpbmVDb25maWcgfSBmcm9tICd2aXRlc3QvY29uZmlnJztcclxuXHJcbmV4cG9ydCBkZWZhdWx0IGRlZmluZUNvbmZpZyh7XHJcblx0cGx1Z2luczogW3N2ZWx0ZWtpdCgpXSxcclxuXHR0ZXN0OiB7XHJcblx0XHRpbmNsdWRlOiBbJ3NyYy8qKi8qLnt0ZXN0LHNwZWN9Lntqcyx0c30nXVxyXG5cdH0sXHJcblx0c3NyOiB7XHJcbiAgICBub0V4dGVybmFsOiBbJ0Bza2VsZXRvbmxhYnMvc2tlbGV0b24nXVxyXG4gIH1cclxufSk7XHJcbiJdLAogICJtYXBwaW5ncyI6ICI7QUFBd2pCLFNBQVMsaUJBQWlCO0FBQ2xsQixTQUFTLG9CQUFvQjtBQUU3QixJQUFPLHNCQUFRLGFBQWE7QUFBQSxFQUMzQixTQUFTLENBQUMsVUFBVSxDQUFDO0FBQUEsRUFDckIsTUFBTTtBQUFBLElBQ0wsU0FBUyxDQUFDLDhCQUE4QjtBQUFBLEVBQ3pDO0FBQUEsRUFDQSxLQUFLO0FBQUEsSUFDRixZQUFZLENBQUMsd0JBQXdCO0FBQUEsRUFDdkM7QUFDRixDQUFDOyIsCiAgIm5hbWVzIjogW10KfQo= diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/BExIS.Modules.Dim.UI.csproj b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/BExIS.Modules.Dim.UI.csproj index 6b0707ef4d..87e15a68d7 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/BExIS.Modules.Dim.UI.csproj +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/BExIS.Modules.Dim.UI.csproj @@ -511,9 +511,9 @@ - + + - diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/AttachmentOutController.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/AttachmentOutController.cs index d98e03c5ee..706bd62775 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/AttachmentOutController.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/AttachmentOutController.cs @@ -1,7 +1,7 @@ using BExIS.App.Bootstrap.Attributes; +using BExIS.Dim.Helpers.Models; using BExIS.Dlm.Entities.Data; using BExIS.Dlm.Services.Data; -using BExIS.Modules.Dim.UI.Models.Api; using BExIS.Security.Entities.Authorization; using BExIS.Security.Entities.Subjects; using BExIS.Security.Services.Authorization; diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/DataQualityOutController.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/DataQualityOutController.cs index 9031d8c04c..b619df2ca1 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/DataQualityOutController.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/DataQualityOutController.cs @@ -1,16 +1,15 @@ using BExIS.App.Bootstrap.Attributes; +using BExIS.Dim.Helpers.Models; using BExIS.Dlm.Entities.Data; using BExIS.Dlm.Entities.DataStructure; using BExIS.Dlm.Services.Data; using BExIS.Dlm.Services.DataStructure; using BExIS.IO.Transform.Output; using BExIS.Modules.Dim.UI.Models; -using BExIS.Modules.Dim.UI.Models.Api; using BExIS.Security.Entities.Authorization; using BExIS.Security.Entities.Subjects; using BExIS.Security.Services.Authorization; using BExIS.Security.Services.Objects; -using BExIS.Security.Services.Subjects; using BExIS.Utils.Route; using BExIS.Xml.Helpers; using Newtonsoft.Json; diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/DataStatisticOutController.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/DataStatisticOutController.cs index fb7eb45ef3..98582c7e40 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/DataStatisticOutController.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/DataStatisticOutController.cs @@ -1,4 +1,5 @@ using BExIS.App.Bootstrap.Attributes; +using BExIS.Dim.Helpers.Models; using BExIS.Dlm.Entities.Data; using BExIS.Dlm.Entities.DataStructure; using BExIS.Dlm.Services.Data; @@ -6,7 +7,6 @@ using BExIS.IO.DataType.DisplayPattern; using BExIS.IO.Transform.Output; using BExIS.Modules.Dim.UI.Models; -using BExIS.Modules.Dim.UI.Models.Api; using BExIS.Security.Entities.Authorization; using BExIS.Security.Entities.Subjects; using BExIS.Security.Services.Authorization; diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/DatasetOutController.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/DatasetOutController.cs index a938ec66e9..bb2c0c6005 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/DatasetOutController.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/DatasetOutController.cs @@ -1,11 +1,11 @@ using BExIS.App.Bootstrap.Attributes; using BExIS.Dim.Entities.Mappings; using BExIS.Dim.Helpers.Mappings; +using BExIS.Dim.Helpers.Models; using BExIS.Dlm.Entities.Data; using BExIS.Dlm.Services.Data; using BExIS.Dlm.Services.Party; using BExIS.Modules.Dim.UI.Helpers; -using BExIS.Modules.Dim.UI.Models.Api; using BExIS.Security.Services.Authorization; using BExIS.Security.Services.Objects; using BExIS.Utils.Data.Helpers; diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/MetadataStatisticOutController.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/MetadataStatisticOutController.cs index 78ff459b63..d4826e45ff 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/MetadataStatisticOutController.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/API/MetadataStatisticOutController.cs @@ -1,7 +1,6 @@ using BExIS.App.Bootstrap.Attributes; -using BExIS.Modules.Dim.UI.Models.Api; +using BExIS.Dim.Helpers.Models; using BExIS.Security.Entities.Subjects; -using BExIS.Security.Services.Subjects; using BExIS.Utils.Route; using Newtonsoft.Json; using System; diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/ExportController.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/ExportController.cs index 5344a3f303..39214b35c8 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/ExportController.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/ExportController.cs @@ -2,6 +2,7 @@ using BExIS.Dim.Entities.Publications; using BExIS.Dim.Helpers; using BExIS.Dim.Helpers.Export; +using BExIS.Dim.Helpers.Models; using BExIS.Dim.Services; using BExIS.Dlm.Entities.Data; using BExIS.Dlm.Entities.DataStructure; @@ -12,8 +13,6 @@ using BExIS.Dlm.Services.Party; using BExIS.IO; using BExIS.IO.Transform.Output; -using BExIS.Modules.Dim.UI.Helpers; -using BExIS.Modules.Dim.UI.Models.Api; using BExIS.Modules.Dim.UI.Models.Download; using BExIS.Modules.Dim.UI.Models.Export; using BExIS.Security.Entities.Subjects; diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/PublishController.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/PublishController.cs index 443d296dd7..b6d59a4139 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/PublishController.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/PublishController.cs @@ -21,6 +21,19 @@ public ActionResult Index() /// [BExISEntityAuthorize(typeof(Dataset), "id", RightType.Read)] public ActionResult Start(long id, int version = 0) + { + // not implemented yet + return RedirectToAction("getPublishDataView", "Submission", new { datasetId = id, versionId = version }); + } + + /// + /// Entrypoint for Publish Hook + /// + /// + /// + /// + [BExISEntityAuthorize(typeof(Dataset), "id", RightType.Read)] + public ActionResult StartView(long id, int version = 0) { return RedirectToAction("getPublishDataPartialView", "Submission", new { datasetId = id, versionId = version }); } diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/SubmissionController.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/SubmissionController.cs index 3379ee6a53..4ea20cf99a 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/SubmissionController.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/SubmissionController.cs @@ -148,6 +148,15 @@ public ActionResult getPublishDataPartialView(long datasetId, long datasetVersio return PartialView("_showPublishDataView", model); } + [BExISEntityAuthorize(typeof(Dataset), "datasetId", RightType.Read)] + public ActionResult getPublishDataView(long datasetId, long datasetVersionId = -1) + { + setViewData(datasetId); + ShowPublishDataModel model = getShowPublishDataModel(datasetId, datasetVersionId); + + return View("_showPublishDataView", model); + } + public async Task LoadRequirementView(long brokerId, long datasetId, int versionNr = 0, double tagNr = 0) { setViewData(datasetId); @@ -435,6 +444,8 @@ private ShowPublishDataModel getShowPublishDataModel(long datasetId, long datase try { Dataset dataset = datasetManager.GetDataset(datasetId); + var latestVersion = datasetManager.GetDatasetLatestVersion(datasetId); + model.Title = latestVersion != null ? latestVersion.Title : "No title available"; List Brokers = GetBrokers(dataset.MetadataStructure.Id, publicationManager); @@ -501,9 +512,9 @@ private ShowPublishDataModel getShowPublishDataModel(long datasetId, long datase Status = pub.Status, DatasetVersionNr = versionNr, Tag = pub.DatasetVersion.Tag != null ? pub.DatasetVersion.Tag.Nr : 0, + }); } - return model; } finally @@ -914,7 +925,8 @@ private void setViewData(long datasetId) ViewData["VersionNrs"] = versionNumbers; ViewData["Tags"] = tags; - + ViewData["Title"] = tags; + } } } diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Dim.Manifest.xml b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Dim.Manifest.xml index e8ad11a5e7..d6baad3326 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Dim.Manifest.xml +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Dim.Manifest.xml @@ -57,12 +57,22 @@ + type="BExIS.Modules.Dim.UI.Hooks.PublishViewHook, BExIS.Modules.DIM.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> + + + \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/ApiDatasetHelper.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/ApiDatasetHelper.cs index ade820e09b..daf5230cfc 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/ApiDatasetHelper.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/ApiDatasetHelper.cs @@ -1,9 +1,9 @@ using BExIS.Dim.Entities.Mappings; using BExIS.Dim.Helpers.Mappings; +using BExIS.Dim.Helpers.Models; using BExIS.Dlm.Entities.Data; using BExIS.Dlm.Entities.Party; using BExIS.Dlm.Services.Party; -using BExIS.Modules.Dim.UI.Models.Api; using BExIS.Security.Services.Authorization; using BExIS.Security.Services.Objects; using BExIS.Utils.Data.Helpers; diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/DimSeedDataGenerator.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/DimSeedDataGenerator.cs index 1171309618..0678798577 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/DimSeedDataGenerator.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/DimSeedDataGenerator.cs @@ -9,7 +9,6 @@ using BExIS.Dlm.Services.Meanings; using BExIS.Dlm.Services.MetadataStructure; using BExIS.Modules.Dim.UI.Helper; -using BExIS.Modules.Dim.UI.Models.Api; using BExIS.Security.Entities.Objects; using BExIS.Security.Services.Authorization; using BExIS.Security.Services.Objects; @@ -1769,6 +1768,44 @@ private void createSystemKeyMappings() } #endregion mapping GBIF to System Keys + + #region extension to system keys + + if (metadataStructures.Any(m => m.Name.ToLower().Equals("extension"))) + { + MetadataStructure metadataStructure = + metadataStructures.FirstOrDefault(m => m.Name.ToLower().Equals("extension")); + + XDocument metadataRef = xmlMetadataWriter.CreateMetadataXml(metadataStructure.Id); + + //create root mapping + LinkElement extensionRoot = createLinkELementIfNotExist(mappingManager, metadataAttributeManager, metadataStructure.Id, metadataStructure.Name, LinkElementType.MetadataStructure, LinkElementComplexity.None, ""); + + //create system mapping + LinkElement system = createLinkELementIfNotExist(mappingManager, metadataAttributeManager, 0, "System", LinkElementType.System, LinkElementComplexity.None, ""); + + #region mapping GBIF to System Keys + + Mapping rootTo = mappingManager.CreateMapping(extensionRoot, system, 0, null, null); + Mapping rootFrom = mappingManager.CreateMapping(system, extensionRoot, 0, null, null); + + if (Exist("title", LinkElementType.MetadataAttributeUsage, uow)) + { + createToKeyMapping("title", LinkElementType.MetadataAttributeUsage, "title", LinkElementType.MetadataAttributeUsage, Key.Title, rootTo, metadataRef, mappingManager, metadataAttributeManager); + createFromKeyMapping("title", LinkElementType.MetadataAttributeUsage, "title", LinkElementType.MetadataAttributeUsage, Key.Title, rootFrom, metadataRef, mappingManager, metadataAttributeManager); + } + + if (Exist("description", LinkElementType.MetadataAttributeUsage, uow)) + { + createToKeyMapping("description", LinkElementType.MetadataAttributeUsage, "description", LinkElementType.MetadataAttributeUsage, Key.Description, rootTo, metadataRef, mappingManager, metadataAttributeManager); + createFromKeyMapping("description", LinkElementType.MetadataAttributeUsage, "description", LinkElementType.MetadataAttributeUsage, Key.Description, rootFrom, metadataRef, mappingManager, metadataAttributeManager); + } + + + #endregion mapping GBIF to System Keys + } + + #endregion } } diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Hooks/PublishHook.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Hooks/PublishEditHook.cs similarity index 61% rename from Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Hooks/PublishHook.cs rename to Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Hooks/PublishEditHook.cs index 6daa37d4c5..1b64a19318 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Hooks/PublishHook.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Hooks/PublishEditHook.cs @@ -1,12 +1,13 @@ using BExIS.Dlm.Services.Data; using BExIS.Security.Entities.Authorization; +using BExIS.Security.Services.Objects; using BExIS.UI.Hooks; namespace BExIS.Modules.Dim.UI.Hooks { - public class PublishHook : Hook + public class PublishEditHook : Hook { - public PublishHook() + public PublishEditHook() { Start = "/dim/publish/start"; } @@ -15,6 +16,9 @@ public override void Check(long id, string username) { // check status checkStatus(id, username); + + // disable for extension entity + checkEntity(id); } private void checkStatus(long id, string username) @@ -36,5 +40,17 @@ private void checkStatus(long id, string username) if (dataset.Status != Dlm.Entities.Data.DatasetStatus.CheckedIn) Status = HookStatus.Disabled; } } + private void checkEntity(long id) + { + using (var datasetManager = new DatasetManager()) + using (var entityManager = new EntityManager()) + { + var entity = entityManager.FindByName("extension"); // get entity + if (entity != null) + { + Status = datasetManager.GetDataset(id).EntityTemplate.EntityType.Id.Equals(entity.Id) ? HookStatus.Disabled : Status; // disable if entity type matches + } + } + } } } \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Hooks/PublishViewHook.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Hooks/PublishViewHook.cs new file mode 100644 index 0000000000..60735377db --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Hooks/PublishViewHook.cs @@ -0,0 +1,57 @@ +using BExIS.Dlm.Services.Data; +using BExIS.Security.Entities.Authorization; +using BExIS.Security.Services.Objects; +using BExIS.UI.Hooks; + +namespace BExIS.Modules.Dim.UI.Hooks +{ + public class PublishViewHook : Hook + { + public PublishViewHook() + { + Start = "/dim/publish/startView"; + } + + public override void Check(long id, string username) + { + // check status + checkStatus(id, username); + + // disable for extension entity + checkEntity(id); + } + + private void checkStatus(long id, string username) + { + Status = HookStatus.Open; + + // check if the user has access rights to the entrypoint - set in Start + bool hasAccess = hasUserAccessRights(username); + + // user rights to the dataset + bool hasRights = hasUserEntityRights(id, username, RightType.Write); + + // if one fail then access is denied + if (hasAccess == false || hasRights == false) Status = HookStatus.AccessDenied; + + using (var datasetManager = new DatasetManager()) + { + var dataset = datasetManager.GetDataset(id); + if (dataset.Status != Dlm.Entities.Data.DatasetStatus.CheckedIn) Status = HookStatus.Disabled; + } + } + + private void checkEntity(long id) + { + using (var datasetManager = new DatasetManager()) + using (var entityManager = new EntityManager()) + { + var entity = entityManager.FindByName("extension"); // get entity + if (entity != null) + { + Status = datasetManager.GetDataset(id).EntityTemplate.EntityType.Id.Equals(entity.Id) ? HookStatus.Disabled : Status; // disable if entity type matches + } + } + } + } +} \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Models/Download/GeneralMetadataModel.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Models/Download/GeneralMetadataModel.cs index 3e4b710b74..76e8cdb678 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Models/Download/GeneralMetadataModel.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Models/Download/GeneralMetadataModel.cs @@ -1,9 +1,5 @@ -using BExIS.Modules.Dim.UI.Models.Api; -using System; -using System.Collections.Generic; -using System.Linq; +using BExIS.Dim.Helpers.Models; using System.Reflection; -using System.Web; namespace BExIS.Modules.Dim.UI.Models.Download { diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Models/ShowPublishDataModel.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Models/ShowPublishDataModel.cs index 80e1c2ee19..730639ee3e 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Models/ShowPublishDataModel.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Models/ShowPublishDataModel.cs @@ -8,6 +8,7 @@ public class ShowPublishDataModel { public List Brokers; public long DatasetId; + public string Title; public bool EditRights; public bool DownloadRights; public bool MetadataIsValid; @@ -22,7 +23,8 @@ public ShowPublishDataModel() EditRights = false; DownloadRights = false; MetadataIsValid = false; - } + Title = "No title available"; + } } public class PublicationModel diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Views/Submission/_showPublishDataView.cshtml b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Views/Submission/_showPublishDataView.cshtml index e53c3bb283..d2ed9a31fa 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Views/Submission/_showPublishDataView.cshtml +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Views/Submission/_showPublishDataView.cshtml @@ -4,6 +4,7 @@ @model BExIS.Modules.Dim.UI.Models.ShowPublishDataModel @{ + ViewBag.Title = "Preparation for "+Model.Title; List datarepolist = Model.Brokers; List versionNrs = new List(); List tags = new List(); @@ -60,7 +61,7 @@ $("#preloader").preloader(14, "Please wait..."); - + jQuery.ajax({ type: "POST", url: "@Url.Action("CheckExportPossibility", "Submission")", @@ -268,9 +269,25 @@ }); }); } + + function backFn() { + + window.location.href = '/dcm/edit/?id=@Model.DatasetId'; + } + + +
+ +
+
+ +
+ +
+
@@ -417,5 +434,11 @@ .t-state-active { line-height: 14pt } + + .publishContentContainer-header { + display: flex; + gap: 3px; + align-items: center; + }
\ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/BExIS.Modules.Sam.UI.csproj b/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/BExIS.Modules.Sam.UI.csproj index a919af2843..8b03b2165e 100644 --- a/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/BExIS.Modules.Sam.UI.csproj +++ b/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/BExIS.Modules.Sam.UI.csproj @@ -145,7 +145,8 @@ - + + diff --git a/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Controllers/UserPermissionsController.cs b/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Controllers/UserPermissionsController.cs index 228ea65dcf..6551884479 100644 --- a/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Controllers/UserPermissionsController.cs +++ b/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Controllers/UserPermissionsController.cs @@ -20,7 +20,16 @@ public ActionResult Start(long id, int version = 0) { using (var entityManager = new EntityManager()) { - return RedirectToAction("Subjects", "UserPermissions", new { EntityId = entityManager.FindByName("Dataset").Id, InstanceId = id }); + return RedirectToAction("SubjectsView", "UserPermissions", new { EntityId = entityManager.FindByName("Dataset").Id, InstanceId = id }); + } + } + + [BExISEntityAuthorize(typeof(Dataset), "id", RightType.Grant)] + public ActionResult StartView(long id, int version = 0) + { + using (var entityManager = new EntityManager()) + { + return RedirectToAction("SubjectsPartialView", "UserPermissions", new { EntityId = entityManager.FindByName("Dataset").Id, InstanceId = id }); } } @@ -60,11 +69,16 @@ public async Task RemoveRightFromEntityPermission(long subjectId, long entityId, } } - public ActionResult Subjects(long entityId, long instanceId) + public ActionResult SubjectsPartialView(long entityId, long instanceId) { return PartialView("_Subjects", new EntityInstanceModel() { EntityId = entityId, InstanceId = instanceId }); } + public ActionResult SubjectsView(long entityId, long instanceId) + { + return View("_Subjects", new EntityInstanceModel() { EntityId = entityId, InstanceId = instanceId}); + } + [GridAction] public ActionResult Subjects_Select(long entityId, long instanceId) { diff --git a/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Hooks/UserPermissionsHook.cs b/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Hooks/UserPermissionsEditHook.cs similarity index 64% rename from Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Hooks/UserPermissionsHook.cs rename to Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Hooks/UserPermissionsEditHook.cs index e12112baa2..898084a053 100644 --- a/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Hooks/UserPermissionsHook.cs +++ b/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Hooks/UserPermissionsEditHook.cs @@ -1,5 +1,6 @@ using BExIS.Dlm.Services.Data; using BExIS.Security.Entities.Authorization; +using BExIS.Security.Services.Objects; using BExIS.UI.Hooks; using System; using System.Collections.Generic; @@ -8,9 +9,9 @@ namespace BExIS.Modules.Sam.UI.Hooks { - public class UserPermissionsHook : Hook + public class UserPermissionsEditHook : Hook { - public UserPermissionsHook() + public UserPermissionsEditHook() { Start = "/sam/UserPermissions/start"; } @@ -20,6 +21,9 @@ public override void Check(long id, string username) // check status checkStatus(id, username); + // disable for extension entity + checkEntity(id); + } private void checkStatus(long id, string username) @@ -48,5 +52,18 @@ private void checkStatus(long id, string username) } + private void checkEntity(long id) + { + using (var datasetManager = new DatasetManager()) + using (var entityManager = new EntityManager()) + { + var entity = entityManager.FindByName("extension"); // get entity + if (entity != null) + { + Status = datasetManager.GetDataset(id).EntityTemplate.EntityType.Id.Equals(entity.Id) ? HookStatus.Disabled : Status; // disable if entity type matches + } + } + } + } } \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Hooks/UserPermissionsViewHook.cs b/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Hooks/UserPermissionsViewHook.cs new file mode 100644 index 0000000000..449ff0d236 --- /dev/null +++ b/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Hooks/UserPermissionsViewHook.cs @@ -0,0 +1,63 @@ +using BExIS.Dlm.Services.Data; +using BExIS.Security.Entities.Authorization; +using BExIS.Security.Services.Objects; +using BExIS.UI.Hooks; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace BExIS.Modules.Sam.UI.Hooks +{ + public class UserPermissionsViewHook : Hook + { + public UserPermissionsViewHook() + { + Start = "/sam/UserPermissions/startView"; + } + + public override void Check(long id, string username) + { + // check status + checkStatus(id, username); + + // disable for extension entity + checkEntity(id); + + } + + private void checkStatus(long id, string username) + { + // check if the user has access rights to the entrypoint - set in Start + bool hasAccess = hasUserAccessRights(username); + + // user rights to the dataset + bool hasRights = hasUserEntityRights(id, username,RightType.Grant); + + // if one fail then access is denied + if (hasAccess == false || hasRights == false) + { + Status = HookStatus.AccessDenied; + } + else + { + Status = HookStatus.Open; + } + + } + + private void checkEntity(long id) + { + using (var datasetManager = new DatasetManager()) + using (var entityManager = new EntityManager()) + { + var entity = entityManager.FindByName("extension"); // get entity + if (entity != null) + { + Status = datasetManager.GetDataset(id).EntityTemplate.EntityType.Id.Equals(entity.Id) ? HookStatus.Disabled : Status; // disable if entity type matches + } + } + } + + } +} \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Sam.Manifest.xml b/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Sam.Manifest.xml index fb30f940d0..5c4255c74e 100644 --- a/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Sam.Manifest.xml +++ b/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Sam.Manifest.xml @@ -103,21 +103,21 @@ + type="BExIS.Modules.Sam.UI.Hooks.UserPermissionsViewHook, BExIS.Modules.SAM.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> - + type="BExIS.Modules.Sam.UI.Hooks.UserPermissionsEditHook, BExIS.Modules.SAM.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Views/UserPermissions/_Subjects.cshtml b/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Views/UserPermissions/_Subjects.cshtml index a12fce9d4d..7c08f3f683 100644 --- a/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Views/UserPermissions/_Subjects.cshtml +++ b/Console/BExIS.Web.Shell/Areas/SAM/BExIS.Modules.Sam.UI/Views/UserPermissions/_Subjects.cshtml @@ -3,12 +3,31 @@ @using Telerik.Web.Mvc.UI @model EntityInstanceModel +@{ + ViewBag.Title = "Permissions for "+Model.InstanceId; +} + + + +
+
+ +
+ @*
+

Permissions for

+
*@ +
@(Html.Telerik().Grid() .Name("grid_subjects") diff --git a/Console/Workspace b/Console/Workspace index 664b8f5321..cd0a18705c 160000 --- a/Console/Workspace +++ b/Console/Workspace @@ -1 +1 @@ -Subproject commit 664b8f53211ba4808fd3cc579b7f7ff8fa23857c +Subproject commit cd0a18705c2f64ba87d663f82f1f86f4b992f3d1 diff --git a/Modules/DDM/BExIS.Ddm.Providers.LuceneProvider/Indexer/BexisIndexer.cs b/Modules/DDM/BExIS.Ddm.Providers.LuceneProvider/Indexer/BexisIndexer.cs index f35c6c9a71..c1560d6eee 100644 --- a/Modules/DDM/BExIS.Ddm.Providers.LuceneProvider/Indexer/BexisIndexer.cs +++ b/Modules/DDM/BExIS.Ddm.Providers.LuceneProvider/Indexer/BexisIndexer.cs @@ -408,6 +408,7 @@ private void writeBexisIndex(long id, bool onlyReleasedTags, DatasetManager dm) string doi = ""; string date = ""; string entityTemplate = ""; + string entityName = ""; DatasetVersion version = null; XmlDocument metadata = null; @@ -426,14 +427,18 @@ private void writeBexisIndex(long id, bool onlyReleasedTags, DatasetManager dm) metadata = dm.GetDatasetLatestMetadataVersion(id); } - if (version != null) - { - // doi - entityTemplate = version.Dataset.EntityTemplate.Name; - date = version.ModificationInfo?.Timestamp?.ToString("yyyy-MM-dd"); - if (date == null) version.CreationInfo?.Timestamp?.ToString("yyyy-MM-dd"); - if (date == null) date = ""; + if (version != null) + { + // doi + entityTemplate = version.Dataset.EntityTemplate.Name; + entityName = version.Dataset.EntityTemplate.EntityType.Name; + date = version.ModificationInfo?.Timestamp?.ToString("yyyy-MM-dd"); + if(date == null) version.CreationInfo?.Timestamp?.ToString("yyyy-MM-dd"); + if (date == null) date = ""; + } + // stop indexing if entity is an extension + if(entityName.ToLowerInvariant().Equals(Convert.ToString(EntityType.Extension).ToLowerInvariant())) return; var dataset = new Document(); List facetNodes = facetXmlNodeList; @@ -445,7 +450,7 @@ private void writeBexisIndex(long id, bool onlyReleasedTags, DatasetManager dm) dataset.Add(new Field("gen_isPublic", entityPermissionManager.ExistsAsync(entityTypeId.Value, id).Result ? "TRUE" : "FALSE", Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NOT_ANALYZED)); XmlDatasetHelper xmlDatasetHelper = new XmlDatasetHelper(); - var entityName = xmlDatasetHelper.GetEntityName(id); + //var entityName = xmlDatasetHelper.GetEntityName(id); dataset.Add(new Field("gen_entity_name", entityName, Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NOT_ANALYZED)); dataset.Add(new Field("gen_doi", doi, Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NOT_ANALYZED)); dataset.Add(new Field("gen_modifieddate", date, Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NOT_ANALYZED)); @@ -657,7 +662,7 @@ private void writeBexisIndex(long id, bool onlyReleasedTags, DatasetManager dm) } indexWriter.AddDocument(dataset); - } + } diff --git a/Modules/DIM/BExIS.Dim.Helper/Api/ApiDatasetHelper.cs b/Modules/DIM/BExIS.Dim.Helper/Api/ApiDatasetHelper.cs new file mode 100644 index 0000000000..bd281bd062 --- /dev/null +++ b/Modules/DIM/BExIS.Dim.Helper/Api/ApiDatasetHelper.cs @@ -0,0 +1,207 @@ +using BExIS.Dim.Entities.Mappings; +using BExIS.Dim.Helpers.Mappings; +using BExIS.Dim.Helpers.Models; +using BExIS.Dlm.Entities.Data; +using BExIS.Dlm.Entities.Party; +using BExIS.Dlm.Services.Party; +using BExIS.Security.Services.Authorization; +using BExIS.Security.Services.Objects; +using BExIS.Utils.Data.Helpers; +using BExIS.Xml.Helpers; +using NameParser; +using System; +using System.Collections.Generic; +using System.Data; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace BExIS.Dim.Helpers +{ + public class ApiDatasetHelper + { + public ApiDatasetModel GetContent(DatasetVersion datasetVersion, long id, int versionNumber, long metadataStructureId, long dataStructureId, long entityTemplateId) + { + ApiDatasetModel datasetModel = new ApiDatasetModel() + { + Id = id, + Version = versionNumber, + VersionId = datasetVersion.Id, + VersionDate = datasetVersion.Timestamp.ToString(new CultureInfo("en-US")), + Title = datasetVersion.Title, + Description = datasetVersion.Description, + DataStructureId = dataStructureId, + MetadataStructureId = metadataStructureId, + EntityTemplateId = entityTemplateId + }; + + Dictionary> objects = new Dictionary>(); + + // add additional Information / mapped system keys + foreach (Key k in Enum.GetValues(typeof(Key))) + { + var tmp = MappingUtils.GetValuesFromMetadata(Convert.ToInt64(k), LinkElementType.Key, + metadataStructureId, XmlUtility.ToXDocument(datasetVersion.Metadata)); + + if (tmp != null) + { + string value = string.Join(",", tmp.Distinct()); + if (!string.IsNullOrEmpty(value)) + { + datasetModel.AdditionalInformations.Add(k.ToString(), value); + } + // collect all results for each system key + objects.Add(k.ToString(), MappingUtils.GetXObjectFromMetadata(Convert.ToInt64(k), LinkElementType.Key, + datasetVersion.Dataset.MetadataStructure.Id, XmlUtility.ToXDocument(datasetVersion.Metadata))); + } + } + + // get isMain parts for all found parties if exists (e.g. first and last name) + datasetModel.Parties = getPartyIsMainAttributesForParties(objects); + + // set up person key list + var personKeyList = new List(); + // setup dic with values of the persons + var personKeyDic = new Dictionary>(); + + // add keys here + personKeyList.Add(Key.Author.ToString()); + + foreach (var key in personKeyList) + { + // check if key exists in alle mapped elements + if (objects.ContainsKey(key)) + personKeyDic.Add(key, objects[key]); + } + + datasetModel.Names = getSplitedNames(personKeyDic); + + var publicAndDate = getPublicAndDate(id); + // check is public + datasetModel.IsPublic = publicAndDate.Item1; + + // check for publication date + datasetModel.PublicationDate = publicAndDate.Item2.ToString(new CultureInfo("en-US")); + + // get links + EntityReferenceHelper entityReferenceHelper = new EntityReferenceHelper(); + datasetModel.Links.From = entityReferenceHelper.GetSourceReferences(id, datasetVersion.Dataset.EntityTemplate.EntityType.Id, versionNumber); + datasetModel.Links.To = entityReferenceHelper.GetTargetReferences(id, datasetVersion.Dataset.EntityTemplate.EntityType.Id, versionNumber); + + + return datasetModel; + } + + // Search if the XML element contains a partyid and return it + private long getPartyId(XElement e) + { + if (e.Attributes().Any(x => x.Name.LocalName.Equals("partyid"))) + { + return Convert.ToInt64(e.Attribute("partyid").Value); + } + if (e.Parent != null) return getPartyId(e.Parent); + + return 0; + } + + private Dictionary> getPartyIsMainAttributesForParties(Dictionary> elements) + { + Dictionary> dict = new Dictionary>(); + using (PartyManager partyManager = new PartyManager()) + { + foreach (var key in elements) + { + foreach (XObject o in key.Value) + { + if (o is XElement) + { + string value = ""; + + XElement element = (XElement)o; + value = element.Value; + + long partyid = getPartyId(element); + Dictionary dict2 = new Dictionary(); + + + // id direct + if (partyid > 0) + { + var party = partyManager.GetParty(partyid); + + if (party != null) + { + var attrs = party.CustomAttributeValues.Where(a => a.CustomAttribute.IsMain == true).ToArray(); + + foreach (var attr in attrs) + { + dict2.Add(attr.CustomAttribute.Name, attr.Value); + } + } + if (!dict.ContainsKey(value)) + { + dict.Add(value, dict2); + } + } + } + } + } + } + + return dict; + } + + private Dictionary> getSplitedNames(Dictionary> elements) + { + Dictionary> dict = new Dictionary>(); + using (PartyManager partyManager = new PartyManager()) + { + foreach (var key in elements) + { + foreach (XObject o in key.Value) + { + if (o is XElement) + { + XElement element = (XElement)o; + + long partyid = getPartyId(element); + Dictionary dict2 = new Dictionary(); + // id direct + Console.WriteLine(partyid); + if (partyid > 0) { } + else + { + var person = new HumanName(element.Value); + var GivenName = (person.Middle.Length > 0) ? $"{person.First} {person.Middle}" : $"{person.First}"; + var FamilyName = person.Last; + dict2.Add("GivenName", GivenName); + dict2.Add("FamilyName", FamilyName); + + if (!dict.ContainsKey(element.Value)) + { + dict.Add(element.Value, dict2); + } + } + } + } + } + } + return dict; + } + + // @TODO: move to dataset manager? + private static Tuple getPublicAndDate(long id) + { + using (EntityManager entityManager = new EntityManager()) + { + var entityPermissionManager = new EntityPermissionManager(); + long? entityTypeId = entityManager.FindByName(typeof(Dataset).Name)?.Id; + entityTypeId = entityTypeId.HasValue ? entityTypeId.Value : -1; + return entityPermissionManager.GetPublicAndDate(entityTypeId.Value, id); + } + } + + } +} diff --git a/Modules/DIM/BExIS.Dim.Helper/BExIS.Dim.Helpers.csproj b/Modules/DIM/BExIS.Dim.Helper/BExIS.Dim.Helpers.csproj index 743f736ce1..11c4dc6e30 100644 --- a/Modules/DIM/BExIS.Dim.Helper/BExIS.Dim.Helpers.csproj +++ b/Modules/DIM/BExIS.Dim.Helper/BExIS.Dim.Helpers.csproj @@ -158,6 +158,7 @@ + @@ -172,6 +173,7 @@ + @@ -210,6 +212,14 @@ {C4D68AC5-84FA-4A97-9E64-9F11623DADC9} BEXIS.JSON.Helpers + + {de0ad99c-c559-422f-8132-cc4d7c46ff83} + BExIS.UI + + + {a7fbcc13-7e29-4710-82a1-bd6d6f811fda} + BExIS.Utils.Data + {782b71c1-707f-4ab1-80e9-90d2880635b4} BExIS.Utils diff --git a/Modules/DIM/BExIS.Dim.Helper/Models/ApiModels.cs b/Modules/DIM/BExIS.Dim.Helper/Models/ApiModels.cs new file mode 100644 index 0000000000..fdc30a67dd --- /dev/null +++ b/Modules/DIM/BExIS.Dim.Helper/Models/ApiModels.cs @@ -0,0 +1,169 @@ +using BExIS.UI.Models.EntityReference; +using System.Collections.Generic; +using System.Data; + +namespace BExIS.Dim.Helpers.Models +{ + public class ApiSimpleDatasetModel + { + public long Id { get; set; } + public string Title { get; set; } + public List Versions { get; set; } + + public ApiSimpleDatasetModel() + { + Versions = new List(); + } + } + + public class ApiSimpleDatasetVersionModel + { + public long Id { get; set; } + public long Number { get; set; } + public double Tag { get; set; } + public string ChangeDescription { get; set; } + } + + /// + /// Return model of Dataset API + /// + public class ApiDatasetModel + { + public long Id { get; set; } + public long Version { get; set; } + public long VersionId { get; set; } + public string Title { get; set; } + public string Description { get; set; } + public long DataStructureId { get; set; } + public long MetadataStructureId { get; set; } + public long EntityTemplateId { get; set; } + public bool IsPublic { get; set; } + public string PublicationDate { get; set; } + //public string VersionName { get; set; } + //public bool VersionPublicAccess { get; set; } + //public string VersionPublicAccessDate { get; set; } + public Dictionary AdditionalInformations { get; set; } + public Dictionary> Parties { get; set; } + public string VersionDate { get; set; } + public object Names { get; set; } + + public LinksOverview Links { get; set; } + + public ApiDatasetModel() + { + AdditionalInformations = new Dictionary(); + Parties = new Dictionary>(); + Links = new LinksOverview(); + } + } + + public class LinksOverview + { + public List From { get; set; } + public List To { get; set; } + + public LinksOverview() + { + From = new List(); + To = new List(); + } + } + + public class ApiDatasetAttachmentsModel + { + public long DatasetId { get; set; } + public List Attachments { get; set; } + + public ApiDatasetAttachmentsModel() + { + DatasetId = 0; + Attachments = new List(); + } + } + + public class Citator + { + public string FirstName { get; set; } + public string LastName { get; set; } + + public Citator() + { + FirstName = ""; + LastName = ""; + } + } + + public class ApiSimpleAttachmentModel + { + public long Id { get; set; } + public string Name { get; set; } + public string MimeType { get; set; } + } + + /// + /// Return model of Data Statistic API + /// + public class ApiDataStatisticModel + { + public long VariableId { get; set; } + public string VariableName { get; set; } + public string VariableDescription { get; set; } + public string DataTypeName { get; set; } + public string DataTypeSystemType { get; set; } + public string DataTypeDisplayPattern { get; set; } + public string Unit { get; set; } + public DataTable uniqueValues { get; set; } + public string count { get; set; } + public string max { get; set; } + public string min { get; set; } + public string maxLength { get; set; } + public string minLength { get; set; } + public DataTable missingValues { get; set; } + } + + /// + /// Return model of Metadata Statistic API + /// + public class PostApiMetadataStatisticModel + { + /// + /// Xpath e.g. Metadata/methods/methodsType/measurements/measurementsType/sampleAnalysis/ + /// + public string Xpath { get; set; } + + /// + /// List of Dataset version IDs to include instead of dataset id (latests versions) + /// + public string[] DatasetVersionIdsInclude { get; set; } + + /// + /// List of Dataset IDs to include + /// + public string[] DatasetIdsInclude { get; set; } + + /// + /// List of Dataset IDs to exclude + /// + public string[] DatasetIdsExclude { get; set; } + + /// + /// List of Metdata structure IDs to include + /// + public string[] MetadatastructureIdsInclude { get; set; } + + /// + /// List of Metdata structure IDs to exclude + /// + public string[] MetadatastructureIdsExclude { get; set; } + + /// + /// Regex to define text to include + /// + public string RegexInclude { get; set; } + + /// + /// Regex to define text to exclude + /// + public string RegexExclude { get; set; } + } +} \ No newline at end of file diff --git a/database update scripts/4.0.2-4.1.0.sql b/database update scripts/4.0.2-4.1.0.sql index 472efa95fb..3a0f80114c 100644 --- a/database update scripts/4.0.2-4.1.0.sql +++ b/database update scripts/4.0.2-4.1.0.sql @@ -134,12 +134,12 @@ order by id limit 1); --- update all variables with Floating Point Number +-- update all variables with Date Time update variables set datatyperef = (select id from datatypes where name = 'Date and Time') where datatyperef in (select id from datatypes where SystemType = 'DateTime'); --- update datacontainers with Floating Point Number +-- update datacontainers with Date Time update datacontainers set datatyperef = (select id from datatypes where name = 'Date and Time') where datatyperef in (select id from datatypes where SystemType = 'DateTime'); @@ -155,12 +155,12 @@ where id = (select id systemtype from datatypes where systemtype = 'Boolean' order by id limit 1); --- update all variables with Floating Point Number +-- update all variables with Boolean update variables set datatyperef = (select id from datatypes where name = 'Boolean') where datatyperef in (select id from datatypes where SystemType = 'Boolean'); --- update datacontainers with Floating Point Number +-- update datacontainers with Boolean update datacontainers set datatyperef = (select id from datatypes where name = 'Boolean') where datatyperef in (select id from datatypes where SystemType = 'Boolean'); diff --git a/database update scripts/4.1.0.-4.2.0.sql b/database update scripts/4.1.0.-4.2.0.sql new file mode 100644 index 0000000000..f4a9c148f9 --- /dev/null +++ b/database update scripts/4.1.0.-4.2.0.sql @@ -0,0 +1,41 @@ +BEGIN TRANSACTION; + +-- entities - extension +INSERT INTO public.entities ( + versionno, + extra, + entitystoretype, + entitytype, + name, + securable, + usemetadata, + parentref + ) +SELECT + 1, + '', + 'BExIS.Xml.Helpers.ExtensionStore, BExIS.Xml.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null', + 'BExIS.Dlm.Entities.Data.Dataset, BExIS.Dlm.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null', + 'Extension', + true, + true, + null + +WHERE NOT EXISTS (SELECT * FROM public.entities WHERE name='Extension'); + +-- update entity template +--- add columns +--- update existing entity templates + +-- update entity references +--- add link type, category + + + + +-- BEXIS2 Version Update +INSERT INTO public.versions( + versionno, extra, module, value, date) + VALUES (1, null, 'Shell', '4.2.0',NOW()); + +commit;