diff --git a/Components/AAA/BExIS.Security.Services/Requests/DecisionManager.cs b/Components/AAA/BExIS.Security.Services/Requests/DecisionManager.cs index ca9450bd8e..f341457950 100644 --- a/Components/AAA/BExIS.Security.Services/Requests/DecisionManager.cs +++ b/Components/AAA/BExIS.Security.Services/Requests/DecisionManager.cs @@ -147,7 +147,7 @@ public void Reject(long decisionId, string reason) var mergedDecision = decisionRepository.Get(decision.Id); decisionRepository.Put(mergedDecision); - if (decisionRepository.Query(m => m.Request.Id == decision.Request.Id) + if (decisionRepository.Query(m => m.Request.Id == decision.Request.Id).ToList() .All(m => m.Status != DecisionStatus.Open)) { var request = requestRepository.Get(decision.Request.Id); diff --git a/Components/AAA/BExIS.Security.Services/Utilities/MessageHelper.cs b/Components/AAA/BExIS.Security.Services/Utilities/MessageHelper.cs index 041cc269cc..34f65857cd 100644 --- a/Components/AAA/BExIS.Security.Services/Utilities/MessageHelper.cs +++ b/Components/AAA/BExIS.Security.Services/Utilities/MessageHelper.cs @@ -34,6 +34,27 @@ public static string GetDeleteDatasetMessage(long datasetid, string userName) return message + "."; } + public static string GetTryToDeleteDatasetHeader() + { + return $"Someone tried to delete a dataset"; + } + + public static string GetTryToDeleteDatasetMessage(long datasetid, string userName) + { + string message = $"An unsuccessful attempt was made to delete a Dataset with id ({datasetid})"; + + if (!string.IsNullOrEmpty(userName)) + + return message += $" by {userName}"; + + return message + "."; + } + + public static string GetPurgeDatasetHeader() + { + return $"Dataset was purged"; + } + public static string GetPurgeDatasetMessage(long datasetid, string userName) { string message = $"Dataset with id ({datasetid}) was purged"; @@ -45,6 +66,22 @@ public static string GetPurgeDatasetMessage(long datasetid, string userName) return message + "."; } + public static string GetTryToPurgeDatasetHeader() + { + return $"Someone tried to purge a dataset"; + } + + public static string GetTryToPurgeDatasetMessage(long datasetid, string userName) + { + string message = $"An unsuccessful attempt was made to purge a Dataset with id ({datasetid})"; + + if (!string.IsNullOrEmpty(userName)) + + return message += $" by {userName}"; + + return message + "."; + } + public static string GetDownloadDatasetHeader() { return $"Dataset was downloaded"; @@ -78,12 +115,12 @@ public static string GetRegisterUserMessage(long userId, string userName, string public static string GetSendRequestHeader(long datasetid) { - return $"Request to dataset width id {datasetid}"; + return $"Request to dataset with id {datasetid}"; } public static string GetSendRequestMessage(long datasetid, string title, string requester) { - return $"User \"{requester}\" send a request for Dataset \"{title}\" with id ({datasetid})"; + return $"User \"{requester}\" sent a request for Dataset \"{title}\" with id ({datasetid})"; } public static string GetTryToRegisterUserHeader() diff --git a/Components/DLM/BExIS.Dlm.Orm.NH/Mappings/Default/DataStructure/DataContainer.hbm.xml b/Components/DLM/BExIS.Dlm.Orm.NH/Mappings/Default/DataStructure/DataContainer.hbm.xml index 0d831f0efe..237eb3d9a7 100644 --- a/Components/DLM/BExIS.Dlm.Orm.NH/Mappings/Default/DataStructure/DataContainer.hbm.xml +++ b/Components/DLM/BExIS.Dlm.Orm.NH/Mappings/Default/DataStructure/DataContainer.hbm.xml @@ -71,8 +71,8 @@ - - + + diff --git a/Components/IO/BExIS.Io.Transform.Output/OutputDataManager.cs b/Components/IO/BExIS.Io.Transform.Output/OutputDataManager.cs index f0379a8a52..fee4d7a2c8 100644 --- a/Components/IO/BExIS.Io.Transform.Output/OutputDataManager.cs +++ b/Components/IO/BExIS.Io.Transform.Output/OutputDataManager.cs @@ -346,6 +346,7 @@ private string createDownloadFile(string ns, long datastructureId, string title, // text based files case ".csv": case ".txt": + case ".tsv": AsciiWriter asciiwriter = (AsciiWriter)writer; return asciiwriter.CreateFile(ns, title, ext); diff --git a/Components/XML/BExIS.Xml.Helpers/XmlMetadataWriter.cs b/Components/XML/BExIS.Xml.Helpers/XmlMetadataWriter.cs index 587ad98627..5c9c8d6e14 100644 --- a/Components/XML/BExIS.Xml.Helpers/XmlMetadataWriter.cs +++ b/Components/XML/BExIS.Xml.Helpers/XmlMetadataWriter.cs @@ -92,35 +92,36 @@ public XDocument CreateMetadataXml(long metadataStructureId, XDocument importXml package.SetAttributeValue("number", "1"); role.Add(package); + setChildren(package, mpu, importXml); - attributes = mpu.MetadataPackage.MetadataAttributeUsages.ToList(); + //attributes = mpu.MetadataPackage.MetadataAttributeUsages.ToList(); - foreach (MetadataAttributeUsage mau in attributes) - { - XElement attribute; + //foreach (MetadataAttributeUsage mau in attributes) + //{ + // XElement attribute; - XElement attributeRole = CreateXElement(mau.Label, XmlNodeType.MetadataAttributeUsage); - if (_mode.Equals(XmlNodeMode.xPath)) - { - attributeRole.SetAttributeValue("name", mau.Label); - attributeRole.SetAttributeValue("id", mau.Id.ToString()); - } - package.Add(attributeRole); + // XElement attributeRole = CreateXElement(mau.Label, XmlNodeType.MetadataAttributeUsage); + // if (_mode.Equals(XmlNodeMode.xPath)) + // { + // attributeRole.SetAttributeValue("name", mau.Label); + // attributeRole.SetAttributeValue("id", mau.Id.ToString()); + // } + // package.Add(attributeRole); - attribute = CreateXElement(mau.MetadataAttribute.Name, XmlNodeType.MetadataAttribute); - if (_mode.Equals(XmlNodeMode.xPath)) attribute.SetAttributeValue("name", mau.MetadataAttribute.Name); + // attribute = CreateXElement(mau.MetadataAttribute.Name, XmlNodeType.MetadataAttribute); + // if (_mode.Equals(XmlNodeMode.xPath)) attribute.SetAttributeValue("name", mau.MetadataAttribute.Name); - attribute.SetAttributeValue("roleId", mau.Id.ToString()); - attribute.SetAttributeValue("id", mau.MetadataAttribute.Id.ToString()); - attribute.SetAttributeValue("number", "1"); + // attribute.SetAttributeValue("roleId", mau.Id.ToString()); + // attribute.SetAttributeValue("id", mau.MetadataAttribute.Id.ToString()); + // attribute.SetAttributeValue("number", "1"); - string xpath = attributeRole.GetAbsoluteXPath() + attribute.GetAbsoluteXPath(); + // string xpath = attributeRole.GetAbsoluteXPath() + attribute.GetAbsoluteXPath(); - attributeRole.Add(attribute); + // attributeRole.Add(attribute); - setChildren(attribute, mau, importXml); + // setChildren(attribute, mau, importXml); - } + //} } return doc; @@ -129,7 +130,8 @@ public XDocument CreateMetadataXml(long metadataStructureId, XDocument importXml private XElement setChildren(XElement element, BaseUsage usage, XDocument importDocument = null) { - MetadataAttribute metadataAttribute; + MetadataAttribute metadataAttribute = null; + MetadataPackage metadataPackage = null; if (usage is MetadataAttributeUsage) { @@ -137,31 +139,32 @@ private XElement setChildren(XElement element, BaseUsage usage, XDocument import metadataAttribute = metadataAttributeUsage.MetadataAttribute; } - else + else if (usage is MetadataNestedAttributeUsage) { MetadataNestedAttributeUsage mnau = (MetadataNestedAttributeUsage)usage; metadataAttribute = mnau.Member; + } + else + { + MetadataPackageUsage mpu = (MetadataPackageUsage)usage; + metadataPackage = mpu.MetadataPackage; + } - if (metadataAttribute.Self is MetadataCompoundAttribute) + if (metadataAttribute != null && metadataAttribute.Self is MetadataCompoundAttribute) { - //MetadataCompoundAttribute mca = (MetadataCompoundAttribute)metadataAttribute.Self; MetadataCompoundAttribute mca = this.GetUnitOfWork().GetReadOnlyRepository().Get(metadataAttribute.Self.Id); foreach (MetadataNestedAttributeUsage nestedUsage in mca.MetadataNestedAttributeUsages) { - //Debug.WriteLine("MetadataCompoundAttribute: " + element.Name); - //Debug.WriteLine("*************************: " + element.Name); - //XElement x = element.Descendants().Where(e => e.Name.Equals(nestedUsage.Member.Name)).First(); if (importDocument != null) { string parentPath = element.GetAbsoluteXPathWithIndex(); string usagePath = parentPath + "/" + nestedUsage.Label; - //+"/"+ nestedUsage.Member.Name; XElement usageElement = importDocument.XPathSelectElement(usagePath); List typeList = new List(); @@ -169,13 +172,10 @@ private XElement setChildren(XElement element, BaseUsage usage, XDocument import if (usageElement != null && usageElement.HasElements) { int num = usageElement.Elements().Count(); - //importDocument.XPathSelectElements(childPath).Count(); - //num = XmlUtility.ToXmlDocument(importDocument).SelectNodes(childPath).Count; if (num == 0) { typeList = AddAndReturnAttribute(element, nestedUsage, 1, 1); - //x = setChildren(x, nestedUsage, importDocument); } else { @@ -207,6 +207,63 @@ private XElement setChildren(XElement element, BaseUsage usage, XDocument import } } + else + { + if (metadataPackage != null) + { + + foreach (MetadataAttributeUsage attrUsage in metadataPackage.MetadataAttributeUsages) + { + + if (importDocument != null) + { + string parentPath = element.GetAbsoluteXPathWithIndex(); + + string usagePath = parentPath + "/" + attrUsage.Label; + + + XElement usageElement = importDocument.XPathSelectElement(usagePath); + List typeList = new List(); + + if (usageElement != null && usageElement.HasElements) + { + int num = usageElement.Elements().Count(); + + if (num == 0) + { + typeList = AddAndReturnAttribute(element, attrUsage, 1, 1); + } + else + { + typeList = AddAndReturnAttribute(element, attrUsage, 1, num); + } + + + } + else + { + Debug.WriteLine("NULL OR EMPTY:------> " + usagePath); + + typeList = AddAndReturnAttribute(element, attrUsage, 1, 1); + } + + foreach (var type in typeList) + { + setChildren(type, attrUsage, importDocument); + } + + } + else + { + List typeList = new List(); + + typeList = AddAndReturnAttribute(element, attrUsage, 1, 1); + setChildren(typeList.FirstOrDefault(), attrUsage, importDocument); + } + + } + } + } return element; } diff --git a/Console/BExIS.Web.Shell/Areas/DCM/Content/bexis-metadata.css b/Console/BExIS.Web.Shell/Areas/DCM/Content/bexis-metadata.css index 636b669627..a32689c4bb 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/Content/bexis-metadata.css +++ b/Console/BExIS.Web.Shell/Areas/DCM/Content/bexis-metadata.css @@ -218,4 +218,34 @@ input:disabled, textarea:disabled, .bx-input.bx-disabled, .bx-textarea.bx-disabl .bx-info { cursor:help !important; +} + + + +/****HELP*****/ +#help_container { + position: relative +} + +#help_nested { + position: absolute; + top: -4px; + left: -2px; + font-size: 200%; + color: rgba(217, 83, 79, 0.7); +} + +#show_help_all, #hide_help_all { + float: right; + margin-top: 10px; + margin-right: 20px; + cursor: help !important; +} + +#hide_help_all { + display: none; +} + +#show_help_all .fa-info, #hide_help_all .fa-ban { + cursor: pointer !important; } \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/Controllers/FormController.cs b/Console/BExIS.Web.Shell/Areas/DCM/Controllers/FormController.cs index 6382f5e559..0286fa3d44 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/Controllers/FormController.cs +++ b/Console/BExIS.Web.Shell/Areas/DCM/Controllers/FormController.cs @@ -10,6 +10,7 @@ using BExIS.Dlm.Services.MetadataStructure; using BExIS.Dlm.Services.TypeSystem; using BExIS.IO; +using BExIS.IO.Transform.Output; using BExIS.IO.Transform.Validation.Exceptions; using BExIS.Modules.Dcm.UI.Helpers; using BExIS.Modules.Dcm.UI.Models.CreateDataset; @@ -24,8 +25,10 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; using System.Web; using System.Web.Mvc; +using System.Web.Routing; using System.Xml; using System.Xml.Linq; using Vaiona.Persistence.Api; @@ -33,6 +36,7 @@ using Vaiona.Web.Extensions; using Vaiona.Web.Mvc; using Vaiona.Web.Mvc.Models; +using Vaiona.Web.Mvc.Modularity; namespace BExIS.Modules.Dcm.UI.Controllers { @@ -252,7 +256,7 @@ public ActionResult LoadMetadataFromExternal(long entityId, string title, long m if (datastructureId != -1) TaskManager.AddToBus(CreateTaskmanager.DATASTRUCTURE_ID, datastructureId); if (metadata != null && metadata.DocumentElement != null) - TaskManager.AddToBus(CreateTaskmanager.METADATA_XML, XmlUtility.ToXDocument(metadata)); + TaskManager.AddToBus(CreateTaskmanager.METADATA_XML, convertMetadata(metadata)); TaskManager.AddToBus(CreateTaskmanager.ENTITY_TITLE, title); @@ -290,7 +294,7 @@ public ActionResult LoadMetadataFromExternal(long entityId, string title, long m if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_XML)) { - var xMetadata = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var xMetadata = getMetadata(); if (String.IsNullOrEmpty(title)) title = "No Title available."; @@ -449,7 +453,7 @@ public ActionResult LoadMetadataOfflineVersion(long entityId, string title, long if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_XML)) { - var xMetadata = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var xMetadata = getMetadata(); if (String.IsNullOrEmpty(title)) title = "No Title available."; @@ -989,7 +993,7 @@ public ActionResult AddComplexUsage(int parentStepId, int number) } //// load InstanzB for parentmodel - parentStepModelHelper.Model.ConvertInstance((XDocument)(TaskManager.Bus[CreateTaskmanager.METADATA_XML]), parentStepModelHelper.XPath); + parentStepModelHelper.Model.ConvertInstance(getMetadata(), parentStepModelHelper.XPath); return PartialView("_metadataCompoundAttributeView", parentStepModelHelper); @@ -1023,7 +1027,7 @@ public ActionResult AddMetadataAttributeUsage(int id, int parentid, int number, //addtoxml AddAttributeToXml(parentUsage, parentModelNumber, metadataAttributeUsage, number, stepModelHelperParent.XPath); - model.ConvertInstance((XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML], stepModelHelperParent.XPath + "//" + metadataAttributeUsage.Label.Replace(" ", string.Empty)); + model.ConvertInstance(getMetadata(), stepModelHelperParent.XPath + "//" + metadataAttributeUsage.Label.Replace(" ", string.Empty)); if (model != null) { @@ -1086,7 +1090,7 @@ public ActionResult DownComplexUsage(int parentStepId, int number) si.title = (i + 1).ToString(); } - stepModelHelper.Model.ConvertInstance((XDocument)(TaskManager.Bus[CreateTaskmanager.METADATA_XML]), stepModelHelper.XPath); + stepModelHelper.Model.ConvertInstance(getMetadata(), stepModelHelper.XPath); } @@ -1223,7 +1227,7 @@ public ActionResult UpComplexUsage(int parentStepId, int number) si.title = (i + 1).ToString(); } - stepModelHelper.Model.ConvertInstance((XDocument)(TaskManager.Bus[CreateTaskmanager.METADATA_XML]), stepModelHelper.XPath); + stepModelHelper.Model.ConvertInstance(getMetadata(), stepModelHelper.XPath); } return PartialView("_metadataCompoundAttributeView", stepModelHelper); @@ -1342,7 +1346,7 @@ private StepInfo AddStepsBasedOnUsage(BaseUsage usage, StepInfo current, string if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_XML)) { - var xMetadata = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var xMetadata = getMetadata(); var x = new XElement("null"); var elements = new List(); @@ -1691,7 +1695,7 @@ private StepInfo LoadStepsBasedOnUsage(BaseUsage usage, StepInfo current, string if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_XML)) { - var xMetadata = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var xMetadata = getMetadata(); //var x = new XElement("null"); var parentXElement = new XElement("tmp"); @@ -1808,7 +1812,7 @@ private List UpdateStepsBasedOnUsage(BaseUsage usage, StepInfo current if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_XML)) { - var xMetadata = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var xMetadata = getMetadata(); var x = XmlUtility.GetXElementByXPath(parentXpath, xMetadata); @@ -2218,6 +2222,63 @@ private void SetXml(XDocument metadataXml) } + private string storeGeneratedFilePathToContentDiscriptor(long datasetId, DatasetVersion datasetVersion, + string title, string ext) + { + + string name = ""; + string mimeType = ""; + + if (ext.Contains("csv")) + { + name = "datastructure"; + mimeType = "text/comma-separated-values"; + } + + if (ext.Contains("html")) + { + name = title; + mimeType = "application/html"; + } + + + // create the generated FileStream and determine its location + string dynamicPath = OutputDatasetManager.GetDynamicDatasetStorePath(datasetId, datasetVersion.Id, title, + ext); + //Register the generated data FileStream as a resource of the current dataset version + //ContentDescriptor generatedDescriptor = new ContentDescriptor() + //{ + // OrderNo = 1, + // Name = name, + // MimeType = mimeType, + // URI = dynamicPath, + // DatasetVersion = datasetVersion, + //}; + + DatasetManager dm = new DatasetManager(); + if (datasetVersion.ContentDescriptors.Count(p => p.Name.Equals(name)) > 0) + { + // remove the one contentdesciptor + foreach (ContentDescriptor cd in datasetVersion.ContentDescriptors) + { + if (cd.Name == name) + { + cd.URI = dynamicPath; + dm.UpdateContentDescriptor(cd); + } + } + } + else + { + // add current contentdesciptor to list + //datasetVersion.ContentDescriptors.Add(generatedDescriptor); + dm.CreateContentDescriptor(name, mimeType, dynamicPath, 1, datasetVersion); + } + + //dm.EditDatasetVersion(datasetVersion, null, null, null); + return dynamicPath; + } + #endregion Helper #region Attribute @@ -2377,7 +2438,7 @@ private void AddAttributeToXml(BaseUsage parentUsage, int parentNumber, BaseUsag { TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; - var metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var metadataXml = getMetadata(); var xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath); metadataXml = xmlMetadataWriter.AddAttribute(metadataXml, attribute, number, metadataStructureUsageHelper.GetNameOfType(attribute), metadataStructureUsageHelper.GetIdOfType(attribute).ToString(), parentXPath); @@ -2393,7 +2454,7 @@ private void AddCompoundAttributeToXml(BaseUsage usage, int number, string xpath { TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; - var metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var metadataXml = getMetadata(); var xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath); @@ -2406,7 +2467,7 @@ private void AddPackageToXml(BaseUsage usage, int number, string xpath) { TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; - var metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var metadataXml = getMetadata(); var xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath); @@ -2427,7 +2488,7 @@ private void AddPackageToXml(BaseUsage usage, int number, string xpath) private void ChangeInXml(string selectedXPath, string destinationXPath) { TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; - var metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var metadataXml = getMetadata(); var xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath); metadataXml = xmlMetadataWriter.Change(metadataXml, selectedXPath, destinationXPath); @@ -2441,7 +2502,7 @@ private void ChangeInXml(string selectedXPath, string destinationXPath) private void RemoveAttributeToXml(int packageNumber, BaseUsage attribute, int number, string metadataAttributeName, string parentXPath) { TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; - var metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var metadataXml = getMetadata(); var xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath); metadataXml = xmlMetadataWriter.RemoveAttribute(metadataXml, attribute, number, metadataAttributeName, parentXPath); @@ -2456,7 +2517,7 @@ private void RemoveCompoundAttributeToXml(BaseUsage usage, int number) { TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; - var metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var metadataXml = getMetadata(); var xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath); metadataXml = xmlMetadataWriter.RemovePackage(metadataXml, usage, number, metadataStructureUsageHelper.GetNameOfType(usage)); @@ -2468,7 +2529,7 @@ private void RemoveFromXml(string xpath) { TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; - var metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var metadataXml = getMetadata(); var xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath); metadataXml = xmlMetadataWriter.Remove(metadataXml, xpath); @@ -2480,7 +2541,7 @@ private void ClearXml(string xpath) { TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; - var metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var metadataXml = getMetadata(); var xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath); metadataXml = xmlMetadataWriter.Clean(metadataXml, xpath); @@ -2491,7 +2552,7 @@ private void ClearXml(string xpath) private void UpdateAttribute(BaseUsage parentUsage, int packageNumber, BaseUsage attribute, int number, object value, string parentXpath) { TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; - var metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var metadataXml = getMetadata(); var xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath); metadataXml = xmlMetadataWriter.Update(metadataXml, attribute, number, value, metadataStructureUsageHelper.GetNameOfType(attribute), parentXpath); @@ -2506,7 +2567,7 @@ private void UpdateAttribute(BaseUsage parentUsage, int packageNumber, BaseUsage private void AddXmlAttribute(string xpath, string attrName, string attrValue) { TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; - XDocument metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + XDocument metadataXml = getMetadata(); XmlDocument xmlDocument = XmlUtility.ToXmlDocument(metadataXml); @@ -2530,7 +2591,7 @@ private void UpdateCompoundAttributeToXml(BaseUsage usage, int number, string xp { TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; - var metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var metadataXml = getMetadata(); var xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath); @@ -2546,6 +2607,68 @@ private void UpdateCompoundAttributeToXml(BaseUsage usage, int number, string xp #endregion Xml Add / Remove / Update + #region Xml Helper + + private XDocument getMetadata() + { + try + { + + if (TaskManager == null) TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; + + + if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_XML)) + { + var metadata = TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + + if (metadata is XDocument) return (XDocument)metadata; + else + { + if (metadata is XmlDocument) + { + return XmlUtility.ToXDocument((XmlDocument)metadata); + } + + + } + + } + + + + return new XDocument(); + } + catch + { + return new XDocument(); + } + } + + private XDocument convertMetadata(object metadata) + { + try + { + if (metadata is XDocument) return (XDocument)metadata; + else + { + if (metadata is XmlDocument) + { + return XmlUtility.ToXDocument((XmlDocument)metadata); + } + } + + + return new XDocument(); + } + catch + { + return new XDocument(); + } + } + + + #endregion + #endregion Xml #region Validation @@ -2813,7 +2936,7 @@ private MetadataCompoundAttributeModel createCompoundModel(int stepId, bool vali //get Instance if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_XML)) { - var xMetadata = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var xMetadata = getMetadata(); model.ConvertInstance(xMetadata, stepModelHelper.XPath); } } @@ -2866,7 +2989,7 @@ private MetadataPackageModel createPackageModel(int stepId, bool validateIt) //get Instance if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_XML)) { - var xMetadata = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var xMetadata = getMetadata(); model.ConvertInstance(xMetadata, stepModelHelper.XPath); } } @@ -2901,7 +3024,7 @@ private MetadataPackageModel createPackageModel(int stepId, bool validateIt) private AbstractMetadataStepModel LoadSimpleAttributesForModelFromXml(StepModelHelper stepModelHelper) { TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; - var metadata = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; + var metadata = getMetadata(); var complexElement = XmlUtility.GetXElementByXPath(stepModelHelper.XPath, metadata); var additionalyMetadataAttributeModel = new List(); @@ -3141,5 +3264,74 @@ public ActionResult Reset() } #endregion overrideable Action + + #region download + + public ActionResult DownloadAsHtml() + { + + if (TaskManager == null) TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; + + if (TaskManager != null) + { + DatasetManager datasetManager = new DatasetManager(); + + XmlDatasetHelper xmlDatasetHelper = new XmlDatasetHelper(); + long entityId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.ENTITY_ID]); + long datastructureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.DATASTRUCTURE_ID]); + long researchplanId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.RESEARCHPLAN_ID]); + long metadatastructureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]); + + string title = xmlDatasetHelper.GetInformation(entityId, NameAttributeValues.title); + + // get the offline version of the metadata + var view = this.Render("DCM", "Form", "LoadMetadataOfflineVersion", new RouteValueDictionary() + { + { "entityId", entityId }, + { "title", title }, + { "metadatastructureId", metadatastructureId }, + { "datastructureId", datastructureId }, + { "researchplanId", researchplanId }, + { "sessionKeyForMetadata", null }, + { "resetTaskManager", false } + }); + + + + // prepare view to write it to the file + byte[] content = Encoding.ASCII.GetBytes(view.ToString()); + + return File(content, "application/xhtml+xml", "metadata.htm"); + } + + return Content("no metadata html file is loaded."); + } + + public ActionResult DownloadAsXml() + { + + try + { + if (TaskManager == null) TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; + + if (TaskManager != null) + { + long entityId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.ENTITY_ID]); + string path = OutputMetadataManager.CreateConvertedMetadata(entityId, TransmissionType.mappingFileExport); + + path = Path.Combine(AppConfiguration.DataPath, path); + + return File(path, "application/xml", Path.GetFileName(path)); + } + } + catch (Exception ex) + { + return Content(ex.Message); + } + + return Content("no metadata xml file is loaded."); + } + + #endregion } } \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/Scripts/Form.js b/Console/BExIS.Web.Shell/Areas/DCM/Scripts/Form.js index 6fcf2f31af..289ec26783 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/Scripts/Form.js +++ b/Console/BExIS.Web.Shell/Areas/DCM/Scripts/Form.js @@ -683,6 +683,8 @@ function OnClose(e) { /****************************************** ********* Component************************ ******************************************/ + + function UpdateWithParty(componentId, number, partyid) { console.log("update with party"); @@ -840,7 +842,7 @@ function showHideClick(e) { function TryParseInt(str, defaultValue) { var retValue = defaultValue; - if (str !== null && str != undefined) { + if (str !== null && str !== undefined) { if (str.length > 0) { if (!isNaN(str)) { retValue = parseInt(str); @@ -848,4 +850,26 @@ function TryParseInt(str, defaultValue) { } } return retValue; +} + + + +/****************************************** + ********* HELP *************************** + ******************************************/ + +function showHelp(id) { + $("#" + id).toggle(); +} + +function showHelpAll() { + $(".help").show(); + $("#show_help_all").hide(); + $("#hide_help_all").show(); +} + +function hideHelpAll() { + $(".help").hide(); + $("#show_help_all").show(); + $("#hide_help_all").hide(); } \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/DCM/Views/Form/MetadataEditor.cshtml b/Console/BExIS.Web.Shell/Areas/DCM/Views/Form/MetadataEditor.cshtml index 64e88362c0..7db8106b52 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/Views/Form/MetadataEditor.cshtml +++ b/Console/BExIS.Web.Shell/Areas/DCM/Views/Form/MetadataEditor.cshtml @@ -100,49 +100,64 @@ @if (locked) { - - @if (Model.EditRight && Model.EditAccessRight) - { - - if (copy.IsComplete()) - { - @Html.ActionLink("Copy", copy.ActionName, copy.ControllerName, new { area = copy.AreaName, id = @Model.DatasetId, type = "DatasetId" }, new { @class = "bx-button function", @id = @Model.DatasetId }) - } + + + + + + + + + @if (Model.EditRight && Model.EditAccessRight) + { + + + if (copy.IsComplete()) + { + @Html.ActionLink("Copy", copy.ActionName, copy.ControllerName, new { area = copy.AreaName, id = @Model.DatasetId, type = "DatasetId" }, new { @class = "bx-button function", @id = @Model.DatasetId }) } - else + } + else + { + string tooltip = ""; + + if (!Model.EditRight) { - string tooltip = ""; + tooltip += " You do not have permission to edit or copy this dataset."; + } - if (!Model.EditRight) - { - tooltip += " You do not have permission to edit or copy this dataset."; - } + if (!Model.EditAccessRight) + { + tooltip += " You do not have permission for this function."; + } - if (!Model.EditAccessRight) - { - tooltip += " You do not have permission for this function."; - } + if ((!Model.EditAccessRight && !Model.EditRight) == false) + { + - if ((!Model.EditAccessRight && !Model.EditRight) == false) + if (copy.IsComplete()) { - - - if (copy.IsComplete()) - { - - } + } } + } - @Html.CheckBox("showAll", @showOptional, new { OnChange = "switchVisibilityOfOptionalElements()", Name = "showAll", Id = "showAll" }) + @Html.CheckBox("showAll", @showOptional, new { OnChange = "switchVisibilityOfOptionalElements()", Name = "showAll", Id = "showAll" }) - show all fields + show all fields + } @@ -150,17 +165,17 @@ { @(Html.Telerik().Upload() - .Name("SelectFileUploader") - .Multiple(false) - .ShowFileList(false) - .HtmlAttributes(new { title = "Import from xml", accept = ".xml" }) - .ClientEvents(events => events - .OnSuccess("OnSuccess") - .OnSelect("SelectFileProcess_OnSelect") - .OnLoad("SelectFileUploader_OnLoad")) - .Async(async => async - .Save("SelectFileProcess", "Form") - .AutoUpload(true)) + .Name("SelectFileUploader") + .Multiple(false) + .ShowFileList(false) + .HtmlAttributes(new { title = "Import from xml", accept = ".xml" }) + .ClientEvents(events => events + .OnSuccess("OnSuccess") + .OnSelect("SelectFileProcess_OnSelect") + .OnLoad("SelectFileUploader_OnLoad")) + .Async(async => async + .Save("SelectFileProcess", "Form") + .AutoUpload(true)) ) @@ -172,9 +187,16 @@
+
+
+ + + + + @if (Model.Created && Model.DatasetId != -1 && !@Model.FromEditMode) { @@ -193,6 +215,8 @@ } } } + + @@ -237,7 +261,7 @@ - diff --git a/Console/BExIS.Web.Shell/Areas/DCM/Views/Form/MetadataEditorOffline.cshtml b/Console/BExIS.Web.Shell/Areas/DCM/Views/Form/MetadataEditorOffline.cshtml index 8564dcba88..3d975b6e60 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/Views/Form/MetadataEditorOffline.cshtml +++ b/Console/BExIS.Web.Shell/Areas/DCM/Views/Form/MetadataEditorOffline.cshtml @@ -61,12 +61,15 @@ } - - @* -
- -
*@ - + + @* +
+ +
*@ + +
+
+ @if (Model.Created && Model.DatasetId != -1 && !@Model.FromEditMode) diff --git a/Console/BExIS.Web.Shell/Areas/DCM/Views/Form/_metadataAttributeView.cshtml b/Console/BExIS.Web.Shell/Areas/DCM/Views/Form/_metadataAttributeView.cshtml index 84a0ad06ed..fa482c0a5a 100644 --- a/Console/BExIS.Web.Shell/Areas/DCM/Views/Form/_metadataAttributeView.cshtml +++ b/Console/BExIS.Web.Shell/Areas/DCM/Views/Form/_metadataAttributeView.cshtml @@ -92,267 +92,268 @@ @if (@Model != null && !(!showOptional && Model.IsEmpty && (Model.MinCardinality == 0) && locked)) { - - - - + +
- @if (Model.MinCardinality > 0) -{ - * - } - - @displayName - - @*Empty = @Model.IsEmpty.ToString();*@ - - @if (Model.SystemType.Equals(TypeCode.String.ToString())) + + + + + + +
+ @if (Model.MinCardinality > 0) + { + * + } + + @displayName + + @*Empty = @Model.IsEmpty.ToString();*@ + + @if (Model.SystemType.Equals(TypeCode.String.ToString())) + { + + if (Model.DataType.ToLower().Equals("text") || + (Model.DataType.ToLower().Equals("string") && + Model.Value != null && Model.Value.ToString().Length >= 60)) { - - if (Model.DataType.ToLower().Equals("text") || - (Model.DataType.ToLower().Equals("string") && - Model.Value!= null && Model.Value.ToString().Length>=60)) + if (!locked) { - if (!locked) + if (Model.DomainList.Count == 0) { - if (Model.DomainList.Count == 0) - { - @Html.TextAreaFor(m => m.Value, - new { OnChange = "OnChange(this)", - Name = @displayName, - Id = @idInput, - PackageId = @Model.Parent.Id, - Title = @errorMessage, - @class = "bx-input bx-metadataFormTextInput " + @errorClass, - onkeyup = "OnKeyUpTextArea(this)", - OnLoad = "OnKeyUpTextInput(this)" - }) - } - else - { - @(Html.Telerik().DropDownList() - .Placeholder("Select, please") - .Name(@idInput) - .HtmlAttributes(new { PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-dropdown" + @errorClass }) - .ClientEvents(events => events.OnChange("OnChangeDropDown")) - .BindTo(new SelectList(Model.DomainList, Model.Value))) - } + @Html.TextAreaFor(m => m.Value, + new { OnChange = "OnChange(this)", + Name = @displayName, + Id = @idInput, + PackageId = @Model.Parent.Id, + Title = @errorMessage, + @class = "bx-input bx-metadataFormTextInput " + @errorClass, + onkeyup = "OnKeyUpTextArea(this)", + OnLoad = "OnKeyUpTextInput(this)" + }) } else { - - //@Html.TextAreaFor(m => m.Value, new { disabled = "disabled", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-input bx-metadataFormTextInput " + @errorClass + " " + lockedClass }) -
- @if (Model.Value != null) - { - @Html.DisplayWithLinksFor(m => m.Value) - } -
+ @(Html.Telerik().DropDownList() + .Placeholder("Select, please") + .Name(@idInput) + .HtmlAttributes(new { PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-dropdown" + @errorClass }) + .ClientEvents(events => events.OnChange("OnChangeDropDown")) + .BindTo(new SelectList(Model.DomainList, Model.Value))) } + } + else + { + //@Html.TextAreaFor(m => m.Value, new { disabled = "disabled", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-input bx-metadataFormTextInput " + @errorClass + " " + lockedClass }) +
+ @if (Model.Value != null) + { + @Html.DisplayWithLinksFor(m => m.Value) + } +
+ } - } - if (Model.DataType.ToLower().Equals("string") && - ((Model.Value != null && Model.Value.ToString().Length < 60) || - Model.Value == null)) - { - if (!locked) - { + } - if (Model.DomainList.Count == 0) - { - string value = ""; - if (@Model.Value != null) - { - value = @Model.Value.ToString(); - } - - @*@Html.TextBoxFor(m => m.Value, new { OnChange = "OnChange(this)", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-input " + @errorClass })*@ - - @(Html.Telerik().AutoComplete() - .Name(@idInput) - .Encode(false) - .Value(value) - .HtmlAttributes(new {@class = "bx-metadataFormTextInput " + @errorClass, title = @errorMessage, onKeyUp = "OnKeyUpTextInput(this)", test = Model.Id }) - .ClientEvents(events => events - .OnChange("OnChangeTextInput") - .OnClose("OnClose")) - - .DataBinding(dataBinding => dataBinding - .Ajax().Select("_AutoCompleteAjaxLoading", "Form", new {id = Model.Id, type = Model.Source.GetType().Name}) - .Cache(false) - - ) - - .Filterable(filtering => - { - filtering.FilterMode(AutoCompleteFilterMode.Contains); - filtering.MinimumChars(1); - - }) - ) + if (Model.DataType.ToLower().Equals("string") && + ((Model.Value != null && Model.Value.ToString().Length < 60) || + Model.Value == null)) + { + if (!locked) + { - } - else + if (Model.DomainList.Count == 0) + { + string value = ""; + if (@Model.Value != null) { - @(Html.Telerik().DropDownList() - .Name(@idInput) - .Placeholder("Select, please") - .HtmlAttributes(new {PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-dropdown " + @errorClass}) - .ClientEvents(events => events.OnChange("OnChangeDropDown")) - .BindTo(new SelectList(Model.DomainList, Model.Value))) + value = @Model.Value.ToString(); } + + @*@Html.TextBoxFor(m => m.Value, new { OnChange = "OnChange(this)", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-input " + @errorClass })*@ + + @(Html.Telerik().AutoComplete() + .Name(@idInput) + .Encode(false) + .Value(value) + .HtmlAttributes(new { @class = "bx-metadataFormTextInput " + @errorClass, title = @errorMessage, onKeyUp = "OnKeyUpTextInput(this)", test = Model.Id }) + .ClientEvents(events => events + .OnChange("OnChangeTextInput") + .OnClose("OnClose")) + + .DataBinding(dataBinding => dataBinding + .Ajax().Select("_AutoCompleteAjaxLoading", "Form", new { id = Model.Id, type = Model.Source.GetType().Name }) + .Cache(false) + + ) + + .Filterable(filtering => + { + filtering.FilterMode(AutoCompleteFilterMode.Contains); + filtering.MinimumChars(1); + + }) + ) + } else { - //@Html.TextBoxFor(m => m.Value, new {disabled = "disabled", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-input bx-metadataFormTextInput " + @errorClass + " " + lockedClass}) - -
- @if (Model.Value != null) - { + @(Html.Telerik().DropDownList() + .Name(@idInput) + .Placeholder("Select, please") + .HtmlAttributes(new { PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-dropdown " + @errorClass }) + .ClientEvents(events => events.OnChange("OnChangeDropDown")) + .BindTo(new SelectList(Model.DomainList, Model.Value))) + } + } + else + { + //@Html.TextBoxFor(m => m.Value, new {disabled = "disabled", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-input bx-metadataFormTextInput " + @errorClass + " " + lockedClass}) - @Html.DisplayWithLinksFor(m => m.Value) - } -
+
+ @if (Model.Value != null) + { - } + @Html.DisplayWithLinksFor(m => m.Value) + } +
} } - @if (Model.SystemType.Equals(TypeCode.Boolean.ToString())) - { + } - bool value = false;//(bool?)Model.Value ?? false; - try - { - value = Convert.ToBoolean(Model.Value); - } - catch - { - value = false; - } + @if (Model.SystemType.Equals(TypeCode.Boolean.ToString())) + { - if (!locked) - { - @Html.CheckBox(Model.DisplayName, value, new { OnClick = "OnChangeCheckBox(this)", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage }) - } - else - { - @Html.CheckBox(Model.DisplayName, value, new { OnClick = "OnChangeCheckBox(this)", disabled = "disabled", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage }) - } + bool value = false;//(bool?)Model.Value ?? false; + try + { + value = Convert.ToBoolean(Model.Value); + } + catch + { + value = false; + } + if (!locked) + { + @Html.CheckBox(Model.DisplayName, value, new { OnClick = "OnChangeCheckBox(this)", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage }) + } + else + { + @Html.CheckBox(Model.DisplayName, value, new { OnClick = "OnChangeCheckBox(this)", disabled = "disabled", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage }) } - @if (Model.SystemType.Equals(TypeCode.Int32.ToString()) || - Model.SystemType.Equals(TypeCode.Int64.ToString()) || - Model.SystemType.Equals(TypeCode.Int16.ToString()) || - Model.SystemType.Equals(TypeCode.UInt16.ToString()) || - Model.SystemType.Equals(TypeCode.UInt32.ToString()) || - Model.SystemType.Equals(TypeCode.UInt64.ToString()) - - ) + } + + @if (Model.SystemType.Equals(TypeCode.Int32.ToString()) || + Model.SystemType.Equals(TypeCode.Int64.ToString()) || + Model.SystemType.Equals(TypeCode.Int16.ToString()) || + Model.SystemType.Equals(TypeCode.UInt16.ToString()) || + Model.SystemType.Equals(TypeCode.UInt32.ToString()) || + Model.SystemType.Equals(TypeCode.UInt64.ToString()) + + ) + { + if (!locked) { - if (!locked) - { - int value = 0; - value = Convert.ToInt32(Model.Value); - - @(Html.Telerik().IntegerTextBox() - .Name(idInput) - .MinValue(0) - .MaxValue(Int32.MaxValue) - .Value(value) - .ClientEvents(events => events - .OnChange("OnChangeNumbers")) - .InputHtmlAttributes(new { PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-input bx-metadataFormTextInput " + @errorClass }) - ) - } - else - { + int value = 0; + value = Convert.ToInt32(Model.Value); + + @(Html.Telerik().IntegerTextBox() + .Name(idInput) + .MinValue(0) + .MaxValue(Int32.MaxValue) + .Value(value) + .ClientEvents(events => events + .OnChange("OnChangeNumbers")) + .InputHtmlAttributes(new { PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-input bx-metadataFormTextInput " + @errorClass }) + ) + } + else + { - @Html.TextBoxFor(m => m.Value, new { disabled = "disabled", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-input bx-metadataFormTextInput " + @errorClass + " " + lockedClass }) - } + @Html.TextBoxFor(m => m.Value, new { disabled = "disabled", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-input bx-metadataFormTextInput " + @errorClass + " " + lockedClass }) } + } + + @if (Model.SystemType.Equals(TypeCode.Decimal.ToString()) || + Model.SystemType.Equals(TypeCode.Double.ToString()) || + Model.SystemType.Equals(TypeCode.Single.ToString()) + ) + { + if (!locked) + { + @Html.TextBoxFor(m => m.Value, new { OnChange = "OnChange(this)", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-input bx-metadataFormTextInput " + @errorClass }) + } + else + { + @Html.TextBoxFor(m => m.Value, new { OnChange = "OnChange(this)", disabled = "disabled", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-input bx-metadataFormTextInput " + @errorClass }) + } + } + - @if (Model.SystemType.Equals(TypeCode.Decimal.ToString()) || - Model.SystemType.Equals(TypeCode.Double.ToString()) || - Model.SystemType.Equals(TypeCode.Single.ToString()) - ) + @if (Model.SystemType.Equals(TypeCode.DateTime.ToString())) + { + if (!locked) { - if (!locked) + string value = ""; + if (Model.Value != null) { - @Html.TextBoxFor(m => m.Value, new { OnChange = "OnChange(this)", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-input bx-metadataFormTextInput " + @errorClass }) + value = Model.Value.ToString(); } else { - @Html.TextBoxFor(m => m.Value, new { OnChange = "OnChange(this)", disabled = "disabled", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, Title = @errorMessage, @class = "bx-input bx-metadataFormTextInput " + @errorClass }) + value = "";//@defaultDate.ToString(); } - } + string format = Model.DisplayPattern; + if (string.IsNullOrEmpty(format)) + { + format = "yyyy-MM-dd"; + } - @if (Model.SystemType.Equals(TypeCode.DateTime.ToString())) + @(Html.Telerik().DatePicker() + .Name(@idInput) + .ShowButton(true) + .TodayButton("d") + .OpenOnFocus(true) + .Format(format) + .Value(value) + .ClientEvents(events => events + .OnChange("OnChangeDatePicker")) + .InputHtmlAttributes(new { Title = @errorMessage, @class = @errorClass }) + ) + } + else { - if (!locked) - { - string value = ""; - if (Model.Value != null) - { - value = Model.Value.ToString(); - } - else + @Html.TextBoxFor(m => m.Value, new { disabled = "disabled", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, @class = "bx-input bx-metadataFormTextInput " + lockedClass }) + } + } +
+ + + + - @(Html.Telerik().DatePicker() - .Name(@idInput) - .ShowButton(true) - .TodayButton("d") - .OpenOnFocus(true) - .Format(format) - .Value(value) - .ClientEvents(events => events - .OnChange("OnChangeDatePicker")) - .InputHtmlAttributes(new { Title = @errorMessage, @class = @errorClass }) - ) - } - else + + @Html.ValidationMessageFor(m => m.Value) + @if (Model.MaxCardinality > 1 && !locked) { - @Html.TextBoxFor(m => m.Value, new { disabled = "disabled", Name = @displayName, Id = @idInput, PackageId = @Model.Parent.Id, @class = "bx-input bx-metadataFormTextInput " + lockedClass }) - } - } - - - -
+ @if (!string.IsNullOrEmpty(Model.Discription)) { - value = "";//@defaultDate.ToString(); + } - string format = Model.DisplayPattern; - if (string.IsNullOrEmpty(format)) - { - format = "yyyy-MM-dd"; - } + - - + + - - - @Html.ValidationMessageFor(m => m.Value) - @if (Model.MaxCardinality > 1 && !locked) - { - - - - - + + - } - -
- @if (!string.IsNullOrEmpty(Model.Discription)) - { - - } - - - @if (!Model.last) + @if (!Model.last) { } @@ -361,25 +362,25 @@ } - + @if (!Model.first) { } else { - + } -
-
+ } +
+
} diff --git a/Console/BExIS.Web.Shell/Areas/DDM/Controllers/DataController.cs b/Console/BExIS.Web.Shell/Areas/DDM/Controllers/DataController.cs index c48a625a79..c266b1c48f 100644 --- a/Console/BExIS.Web.Shell/Areas/DDM/Controllers/DataController.cs +++ b/Console/BExIS.Web.Shell/Areas/DDM/Controllers/DataController.cs @@ -141,7 +141,9 @@ public ActionResult ShowData(long id, int version = 0) if (!downloadAccess) { requestExist = HasRequest(id); - requestAble = HasRequestMapping(id); + + if (UserExist() && HasRequestMapping(id)) requestAble = true; + } if (dsv.Dataset.DataStructure.Self.GetType().Equals(typeof(StructuredDataStructure))) @@ -1263,6 +1265,7 @@ public JsonResult SendRequest(long id) if (string.IsNullOrEmpty(title)) title = "No Title available."; string emailDescionMaker = request.Decisions.FirstOrDefault().DecisionMaker.Email; + //ToDo send emails to owner & requester var es = new EmailService(); es.Send(MessageHelper.GetSendRequestHeader(id), @@ -1348,6 +1351,13 @@ public string GetUsernameOrDefault() return !string.IsNullOrWhiteSpace(username) ? username : "DEFAULT"; } + public bool UserExist() + { + if (HttpContext.User != null && HttpContext.User.Identity != null && !string.IsNullOrEmpty(HttpContext.User.Identity.Name)) return true; + + return false; + } + private static string storeGeneratedFilePathToContentDiscriptor(long datasetId, DatasetVersion datasetVersion, string title, string ext) { string name = ""; diff --git a/Console/BExIS.Web.Shell/Areas/DDM/Views/Dashboard/Index.cshtml b/Console/BExIS.Web.Shell/Areas/DDM/Views/Dashboard/Index.cshtml index 81c4643a27..dcbb706eb2 100644 --- a/Console/BExIS.Web.Shell/Areas/DDM/Views/Dashboard/Index.cshtml +++ b/Console/BExIS.Web.Shell/Areas/DDM/Views/Dashboard/Index.cshtml @@ -67,7 +67,7 @@ var result = confirm('Are you sure you want to reject this request (Id:' + $(this).attr("value") + ')?'); if (result) { - $.post('/sam/request/reject', { DecisionId: $(this).attr("value") }, function (e) { + $.post('/sam/requests/reject', { RequestId: $(this).attr("value") }, function (e) { $("#grid_decisions .t-refresh").trigger('click'); }); } diff --git a/Console/BExIS.Web.Shell/Areas/SAM/Controllers/DatasetsController.cs b/Console/BExIS.Web.Shell/Areas/SAM/Controllers/DatasetsController.cs index bf13129981..abcf2c6bc8 100644 --- a/Console/BExIS.Web.Shell/Areas/SAM/Controllers/DatasetsController.cs +++ b/Console/BExIS.Web.Shell/Areas/SAM/Controllers/DatasetsController.cs @@ -3,6 +3,8 @@ using BExIS.Dlm.Services.Data; using BExIS.Modules.Sam.UI.Models; using BExIS.Security.Services.Authorization; +using BExIS.Security.Services.Objects; +using BExIS.Security.Services.Subjects; using BExIS.Security.Services.Utilities; using System; using System.Collections.Generic; @@ -46,28 +48,63 @@ public ActionResult Delete(long id) { var datasetManager = new DatasetManager(); var entityPermissionManager = new EntityPermissionManager(); + var entityManager = new EntityManager(); + var subjectManager = new SubjectManager(); + var userManager = new UserManager(); try { - if (datasetManager.DeleteDataset(id, ControllerContext.HttpContext.User.Identity.Name, true)) + var userName = GetUsernameOrDefault(); + var user = userManager.Users.Where(u => u.Name.Equals(userName)).FirstOrDefault(); + + // check if a user is logged in + if (user != null) { + // is the user allowed to delete this dataset + if (entityPermissionManager.HasEffectiveRight(user, entityManager.FindByName("Dataset"), id, Security.Entities.Authorization.RightType.Delete)) + { + //try delete the dataset + if (datasetManager.DeleteDataset(id, ControllerContext.HttpContext.User.Identity.Name, true)) + { - //send email - var es = new EmailService(); - es.Send(MessageHelper.GetUpdateDatasetHeader(), - MessageHelper.GetDeleteDatasetMessage(id, ControllerContext.HttpContext.User.Identity.Name), - ConfigurationManager.AppSettings["SystemEmail"] - ); + //send email + var es = new EmailService(); + es.Send(MessageHelper.GetDeleteDatasetHeader(), + MessageHelper.GetDeleteDatasetMessage(id, user.Name), + ConfigurationManager.AppSettings["SystemEmail"] + ); - //entityPermissionManager.Delete(typeof(Dataset), id); // This is not needed here. + //entityPermissionManager.Delete(typeof(Dataset), id); // This is not needed here. - if (this.IsAccessible("DDM", "SearchIndex", "ReIndexUpdateSingle")) + if (this.IsAccessible("DDM", "SearchIndex", "ReIndexUpdateSingle")) + { + var x = this.Run("DDM", "SearchIndex", "ReIndexUpdateSingle", new RouteValueDictionary() { { "id", id }, { "actionType", "DELETE" } }); + } + } + } + else // user is not allowed { - var x = this.Run("DDM", "SearchIndex", "ReIndexUpdateSingle", new RouteValueDictionary() { { "id", id }, { "actionType", "DELETE" } }); + ViewData.ModelState.AddModelError("", $@"You do not have the permission to delete the record."); + + var es = new EmailService(); + es.Send(MessageHelper.GetTryToDeleteDatasetHeader(), + MessageHelper.GetTryToDeleteDatasetMessage(id, GetUsernameOrDefault()), + ConfigurationManager.AppSettings["SystemEmail"] + ); } } + else // no user exist + { + ViewData.ModelState.AddModelError("", $@"This function can only be executed with a logged-in user."); + + var es = new EmailService(); + es.Send(MessageHelper.GetTryToDeleteDatasetHeader(), + MessageHelper.GetTryToDeleteDatasetMessage(id, userName), + ConfigurationManager.AppSettings["SystemEmail"] + ); + } } - catch (Exception e) + catch (Exception e) //for technical reasons the dataset cannot be deleted { ViewData.ModelState.AddModelError("", $@"Dataset {id} could not be deleted."); } @@ -173,25 +210,59 @@ public ActionResult Purge(long id) DatasetManager dm = new DatasetManager(); var entityPermissionManager = new EntityPermissionManager(); + var datasetManager = new DatasetManager(); + var entityManager = new EntityManager(); + var userManager = new UserManager(); try { - if (dm.PurgeDataset(id)) + var userName = GetUsernameOrDefault(); + var user = userManager.Users.Where(u => u.Name.Equals(userName)).FirstOrDefault(); + + // check if a user is logged in + if (user != null) { - entityPermissionManager.Delete(typeof(Dataset), id); + // is the user allowed to delete this dataset + if (entityPermissionManager.HasEffectiveRight(user, entityManager.FindByName("Dataset"), id, Security.Entities.Authorization.RightType.Delete)) + { + if (dm.PurgeDataset(id)) + { + entityPermissionManager.Delete(typeof(Dataset), id); - var es = new EmailService(); - es.Send(MessageHelper.GetUpdateDatasetHeader(), - MessageHelper.GetPurgeDatasetMessage(id, ControllerContext.HttpContext.User.Identity.Name), - ConfigurationManager.AppSettings["SystemEmail"] - ); + var es = new EmailService(); + es.Send(MessageHelper.GetPurgeDatasetHeader(), + MessageHelper.GetPurgeDatasetMessage(id, user.Name), + ConfigurationManager.AppSettings["SystemEmail"] + ); - if (this.IsAccessible("DDM", "SearchIndex", "ReIndexUpdateSingle")) + if (this.IsAccessible("DDM", "SearchIndex", "ReIndexUpdateSingle")) + { + var x = this.Run("DDM", "SearchIndex", "ReIndexUpdateSingle", new RouteValueDictionary() { { "id", id }, { "actionType", "DELETE" } }); + } + } + + } + else // user is not allowed { - var x = this.Run("DDM", "SearchIndex", "ReIndexUpdateSingle", new RouteValueDictionary() { { "id", id }, { "actionType", "DELETE" } }); + ViewData.ModelState.AddModelError("", $@"You do not have the permission to purge the record."); + + var es = new EmailService(); + es.Send(MessageHelper.GetTryToPurgeDatasetHeader(), + MessageHelper.GetTryToPurgeDatasetMessage(id, user.Name), + ConfigurationManager.AppSettings["SystemEmail"] + ); } } + else // no user exist + { + ViewData.ModelState.AddModelError("", $@"This function can only be executed with a logged-in user."); + var es = new EmailService(); + es.Send(MessageHelper.GetTryToPurgeDatasetHeader(), + MessageHelper.GetTryToPurgeDatasetMessage(id, userName), + ConfigurationManager.AppSettings["SystemEmail"] + ); + } } catch (Exception e) { @@ -330,7 +401,17 @@ private string flip(string dateTime, out bool needUpdate) } + public string GetUsernameOrDefault() + { + var username = string.Empty; + try + { + username = HttpContext.User.Identity.Name; + } + catch { } + return !string.IsNullOrWhiteSpace(username) ? username : "DEFAULT"; + } } } \ No newline at end of file diff --git a/Console/BExIS.Web.Shell/Areas/SAM/Controllers/RequestsController.cs b/Console/BExIS.Web.Shell/Areas/SAM/Controllers/RequestsController.cs index 7d7de02481..df90dcef09 100644 --- a/Console/BExIS.Web.Shell/Areas/SAM/Controllers/RequestsController.cs +++ b/Console/BExIS.Web.Shell/Areas/SAM/Controllers/RequestsController.cs @@ -1,5 +1,4 @@ using BExIS.Modules.Sam.UI.Models; -using BExIS.Security.Entities.Requests; using BExIS.Security.Services.Objects; using BExIS.Security.Services.Requests; using System; @@ -132,7 +131,7 @@ public ActionResult Requests_Select(long entityId, GridCommand command) // Source + Transformation - Data var requests = requestManager.Requests.Where(r => r.Entity.Id == entityId && r.Applicant.Name == HttpContext.User.Identity.Name); - + var results = requests.Select( m => new RequestGridRowModel() { Id = m.Key, InstanceId = m.Key, Title = entityStore.GetTitleById(m.Key), Rights = m.Rights, RequestStatus = m.Status }); diff --git a/Console/BExIS.Web.Shell/Areas/SAM/Views/Requests/Index.cshtml b/Console/BExIS.Web.Shell/Areas/SAM/Views/Requests/Index.cshtml index dde2a595ef..72f6eb42a5 100644 --- a/Console/BExIS.Web.Shell/Areas/SAM/Views/Requests/Index.cshtml +++ b/Console/BExIS.Web.Shell/Areas/SAM/Views/Requests/Index.cshtml @@ -56,10 +56,13 @@ }); $('.bx-delete').click(function () { + + var result = confirm('Are you sure you want to reject this request (Id:' + $(this).attr("value") + ')?'); if (result) { - $.post('@Url.Action("Reject", "Requests")', { DecisionId: $(this).attr("value") }, function (e) { + $.post('@Url.Action("Reject", "Requests")', { requestId: $(this).attr("value") }, function (e) { + console.log("reject"); $("#grid_decisions .t-refresh").trigger('click'); }); } diff --git a/Console/BExIS.Web.Shell/Areas/SAM/Views/Requests/_Decisions.cshtml b/Console/BExIS.Web.Shell/Areas/SAM/Views/Requests/_Decisions.cshtml index 9db99330ba..b230068ac5 100644 --- a/Console/BExIS.Web.Shell/Areas/SAM/Views/Requests/_Decisions.cshtml +++ b/Console/BExIS.Web.Shell/Areas/SAM/Views/Requests/_Decisions.cshtml @@ -1,8 +1,6 @@ @using BExIS.Modules.Sam.UI.Models -@using BExIS.Security.Entities.Requests; @using Telerik.Web.Mvc.UI -@model long @(Html.Telerik().Grid() .Name("grid_decisions") diff --git a/Console/BExIS.Web.Shell/Controllers/ErrorController.cs b/Console/BExIS.Web.Shell/Controllers/ErrorController.cs index bda8fad60e..80910757d9 100644 --- a/Console/BExIS.Web.Shell/Controllers/ErrorController.cs +++ b/Console/BExIS.Web.Shell/Controllers/ErrorController.cs @@ -4,6 +4,14 @@ namespace BExIS.Web.Shell.Controllers { public class ErrorController : Controller { + + // GET: Error + public ActionResult Index() + { + + return View("Error"); + } + // GET: Error public ActionResult AccessDenied() { diff --git a/Console/BExIS.Web.Shell/Global.asax.cs b/Console/BExIS.Web.Shell/Global.asax.cs index 9728e483bc..ae64744dda 100644 --- a/Console/BExIS.Web.Shell/Global.asax.cs +++ b/Console/BExIS.Web.Shell/Global.asax.cs @@ -108,16 +108,21 @@ protected void Application_Error(object sender, EventArgs e) bool sendExceptions = false; bool.TryParse(ConfigurationManager.AppSettings["SendExceptions"], out sendExceptions); + var error = Server.GetLastError(); var code = (error is HttpException) ? (error as HttpException).GetHttpCode() : 500; - if (sendExceptions && code != 404) + + if ( + sendExceptions && + code != 404 && // not existing action is called + !(error is InvalidOperationException) && !error.Message.StartsWith("Multiple types were found that match the controller named") // same controller name in multpily controller, and no correct action call + ) { HttpUnhandledException httpUnhandledException = new HttpUnhandledException(error.Message, error); - //SendEmailWithErrors(httpUnhandledException.GetHtmlErrorMessage()); ErrorHelper.SendEmailWithErrors( httpUnhandledException.GetHtmlErrorMessage() diff --git a/Console/BExIS.Web.Shell/web.config b/Console/BExIS.Web.Shell/web.config index 899fe68dc4..b76f0b9e3e 100644 --- a/Console/BExIS.Web.Shell/web.config +++ b/Console/BExIS.Web.Shell/web.config @@ -21,8 +21,8 @@ - - + + diff --git a/Libraries/Vaiona/Vaiona.Web.Mvc.Modularity.dll b/Libraries/Vaiona/Vaiona.Web.Mvc.Modularity.dll index 51a989fd2c..1b97eedded 100644 Binary files a/Libraries/Vaiona/Vaiona.Web.Mvc.Modularity.dll and b/Libraries/Vaiona/Vaiona.Web.Mvc.Modularity.dll differ diff --git a/Manuals/2.12.3/BEXIS2123_DataCollection_UserGuide.docx b/Manuals/2.12.3/BEXIS2123_DataCollection_UserGuide.docx new file mode 100644 index 0000000000..bf28b9a139 Binary files /dev/null and b/Manuals/2.12.3/BEXIS2123_DataCollection_UserGuide.docx differ diff --git a/Manuals/2.12.3/BEXIS2123_DataDissemination_UserGuide.docx b/Manuals/2.12.3/BEXIS2123_DataDissemination_UserGuide.docx new file mode 100644 index 0000000000..b312f6af9f Binary files /dev/null and b/Manuals/2.12.3/BEXIS2123_DataDissemination_UserGuide.docx differ diff --git a/Manuals/2.12.3/BEXIS2123_DataPlanning_UserGuide.docx b/Manuals/2.12.3/BEXIS2123_DataPlanning_UserGuide.docx new file mode 100644 index 0000000000..5f7c85074f Binary files /dev/null and b/Manuals/2.12.3/BEXIS2123_DataPlanning_UserGuide.docx differ diff --git a/Manuals/2.12.3/BEXIS2123_Installation_Manual.docx b/Manuals/2.12.3/BEXIS2123_Installation_Manual.docx new file mode 100644 index 0000000000..f504593d49 Binary files /dev/null and b/Manuals/2.12.3/BEXIS2123_Installation_Manual.docx differ diff --git a/Manuals/2.12.3/BEXIS2123_PartyPackage_UserGuide.docx b/Manuals/2.12.3/BEXIS2123_PartyPackage_UserGuide.docx new file mode 100644 index 0000000000..e7efa93f82 Binary files /dev/null and b/Manuals/2.12.3/BEXIS2123_PartyPackage_UserGuide.docx differ diff --git a/Manuals/2.12.3/BEXIS2123_SearchUI_UserGuide.docx b/Manuals/2.12.3/BEXIS2123_SearchUI_UserGuide.docx new file mode 100644 index 0000000000..b48abeaf41 Binary files /dev/null and b/Manuals/2.12.3/BEXIS2123_SearchUI_UserGuide.docx differ diff --git a/Manuals/2.12.3/BEXIS2123_SystemAdmin_UserGuide.docx b/Manuals/2.12.3/BEXIS2123_SystemAdmin_UserGuide.docx new file mode 100644 index 0000000000..f4f4656d15 Binary files /dev/null and b/Manuals/2.12.3/BEXIS2123_SystemAdmin_UserGuide.docx differ diff --git a/Manuals/2.12.3/BEXIS2123_UserGuide.docx b/Manuals/2.12.3/BEXIS2123_UserGuide.docx new file mode 100644 index 0000000000..dee0939f22 Binary files /dev/null and b/Manuals/2.12.3/BEXIS2123_UserGuide.docx differ diff --git a/Manuals/2.12.3/BEXIS2123_Visualization_UserGuide.docx b/Manuals/2.12.3/BEXIS2123_Visualization_UserGuide.docx new file mode 100644 index 0000000000..8bdece8eff Binary files /dev/null and b/Manuals/2.12.3/BEXIS2123_Visualization_UserGuide.docx differ diff --git a/Update_Script_2121to2122.txt b/Update_Script_2121to2122.txt new file mode 100644 index 0000000000..5260796d7b --- /dev/null +++ b/Update_Script_2121to2122.txt @@ -0,0 +1 @@ +-- no updates needed \ No newline at end of file diff --git a/Update_Script_2122to2123.txt b/Update_Script_2122to2123.txt new file mode 100644 index 0000000000..9b25a5a3c2 --- /dev/null +++ b/Update_Script_2122to2123.txt @@ -0,0 +1,8 @@ +BEGIN TRANSACTION; + +-- ROLLBACK TRANSACTION; + +ALTER TABLE datacontainers +ALTER COLUMN description TYPE character varying; + +--COMMIT; \ No newline at end of file