Skip to content

Commit 623b025

Browse files
authored
Merge pull request #2095 from BEXIS2/master
update demo to v4.0.1
2 parents b235143 + bba8993 commit 623b025

File tree

28 files changed

+675
-404
lines changed

28 files changed

+675
-404
lines changed

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: 🐞 Bug Report
22
description: You discovered something that does not work as desired/expected? Please report that bug!
3-
labels: 'Type: Bug Report'
3+
type: 'Bug'
44
projects: [BEXIS2/8]
55
assignees:
66
- sventhiel

Components/IO/BExIS.Io.Transform.Validation/ValueCheck/DataTypeCheck.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public DecimalCharacter GetDecimalCharacter
7676
/// <param name="value"></param>
7777
/// <param name="row"></param>
7878
/// <returns></returns>
79-
public object Execute(string value, int row)
79+
public object Execute(string value, int row=0)
8080
{
8181
if (!String.IsNullOrEmpty(value))
8282
{

Components/Utils/BExIS.Utils.Data/Helpers/ShellSeedDataGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public void GenerateSeedData()
4040

4141
var o12 = operationManager.Find("Shell", "Settings", "*") ?? operationManager.Create("Shell", "Settings", "*", settings);
4242

43-
if (!versionManager.Exists("Shell", "4.0.0"))
43+
if (!versionManager.Exists("Shell", "4.0.1"))
4444
{
45-
versionManager.Create("Shell", "4.0.0");
45+
versionManager.Create("Shell", "4.0.1");
4646
}
4747
}
4848
}

Components/XML/BExIS.Xml.Helpers/BExIS.Xml.Helpers.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@
101101
<Project>{c4ca0a99-0af3-4372-a9b7-b9073599bd8b}</Project>
102102
<Name>BExIS.Dlm.Services</Name>
103103
</ProjectReference>
104+
<ProjectReference Include="..\..\IO\BExIS.IO.Transform.Validation\BExIS.IO.Transform.Validation.csproj">
105+
<Project>{C8A05313-B960-406E-92EC-C1E5B3F47FCD}</Project>
106+
<Name>BExIS.IO.Transform.Validation</Name>
107+
</ProjectReference>
104108
<ProjectReference Include="..\..\IO\BExIS.IO\BExIS.IO.csproj">
105109
<Project>{e4795f06-20c2-4c4c-a720-9a79896384df}</Project>
106110
<Name>BExIS.IO</Name>

Components/XML/BExIS.Xml.Helpers/XmlMetadataConverter.cs

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using BExIS.Dlm.Entities.Common;
2+
using BExIS.Dlm.Entities.DataStructure;
23
using BExIS.Dlm.Entities.MetadataStructure;
34
using BExIS.Dlm.Services.MetadataStructure;
5+
using BExIS.IO.Transform.Validation.Exceptions;
6+
using BExIS.IO.Transform.Validation.ValueCheck;
47
using Newtonsoft.Json;
58
using Newtonsoft.Json.Linq;
69
using System;
@@ -179,7 +182,7 @@ private JToken _convertElementUsage(XmlNode node, BaseUsage usage, bool includeE
179182
XmlNode type = element.FirstChild; // has also reference
180183
//JProperty p = new JProperty(usage.Label, type.InnerText);
181184
if (!string.IsNullOrEmpty(type.InnerText) || includeEmpty)
182-
return addSimple(usage.Label, type.InnerText, (XmlElement)type, includeEmpty);
185+
return addSimple(usage, type.InnerText, (XmlElement)type, includeEmpty);
183186
else
184187
return null;
185188
}
@@ -189,7 +192,7 @@ private JToken _convertElementUsage(XmlNode node, BaseUsage usage, bool includeE
189192
{
190193
if (!string.IsNullOrEmpty(type.InnerText) || includeEmpty)
191194
// check if
192-
array.Add(addSimple(usage.Label, type.InnerText, (XmlElement)type, includeEmpty));
195+
array.Add(addSimple(usage, type.InnerText, (XmlElement)type, includeEmpty));
193196
}
194197

195198
if (array.Count == 0) return null;
@@ -304,11 +307,24 @@ private bool isSimple(XmlNode type)
304307
return false;
305308
}
306309

307-
private JObject addSimple(string label, string value, XmlElement reference, bool includeEmpty)
310+
private JObject addSimple(BaseUsage usage, string valueAsString, XmlElement reference, bool includeEmpty)
308311
{
309312
JObject simple = new JObject();
310313

314+
object value = valueAsString;
315+
316+
DataType dataType = getDataType(usage);
317+
318+
if(dataType!=null && !dataType.SystemType.Contains("String")) // if ther is a datatype , try to convert
319+
{
320+
DataTypeCheck dataTypeChecker = new DataTypeCheck("", dataType.SystemType,IO.DecimalCharacter.point);
321+
var result = dataTypeChecker.Execute(valueAsString);
322+
// if value is a error or datytpe is dateteim tehn not replace value
323+
if ((result is ErrorType) == false && !dataType.SystemType.Contains("DateTime")) value = result;
324+
}
325+
311326
setReference(simple, reference, includeEmpty);
327+
312328
simple.Add(new JProperty("#text", value));
313329

314330
return simple;
@@ -646,6 +662,25 @@ private int getMaxCardinality(BaseUsage usage)
646662
return 1; // default
647663
}
648664

665+
private DataType getDataType(BaseUsage usage)
666+
{
667+
if (usage is MetadataAttributeUsage)
668+
{
669+
return ((MetadataAttributeUsage)usage).MetadataAttribute.DataType;
670+
}
671+
672+
if (usage is MetadataNestedAttributeUsage)
673+
{
674+
return ((MetadataNestedAttributeUsage)usage).Member.DataType;
675+
}
676+
677+
if (usage is MetadataParameterUsage)
678+
{
679+
return ((MetadataParameterUsage)usage).Member.DataType;
680+
}
681+
682+
return null;
683+
}
649684

650685
#endregion
651686

Components/XML/BExIS.Xml.Helpers/XmlUtility.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,20 @@ public static XElement GetXElementByXPath(string xpath, XDocument xDoc)
740740
return xDoc.XPathSelectElement(xpath.Replace(" ", string.Empty));
741741
}
742742

743+
/// <summary>
744+
///
745+
/// </summary>
746+
/// <remarks></remarks>
747+
/// <seealso cref=""/>
748+
/// <param name="name"></param>
749+
/// <returns></returns>
750+
public static XAttribute GetXAttributeByXPath(string xpath, XDocument xDoc)
751+
{
752+
var tmp = (IEnumerable<object>)xDoc.XPathEvaluate(xpath.Replace(" ", string.Empty));
753+
var x = tmp.FirstOrDefault();
754+
return x as XAttribute;
755+
}
756+
743757
/// <summary>
744758
///
745759
/// </summary>

Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/BExIS.Modules.Dcm.UI.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@
472472
<Content Include="Views\Form\_number.cshtml" />
473473
<Content Include="Views\Form\_metadataParameterViewOffline.cshtml" />
474474
<Content Include="Web.config" />
475+
<Content Include="Views\Form\_displayname.cshtml" />
475476
<None Include="Web.Debug.config">
476477
<DependentUpon>Web.config</DependentUpon>
477478
</None>

Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Controllers/FormController.cs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ public ActionResult ActivateComplexUsageInAChoice(int parentid, int id, long ent
10191019

10201020
//RemoveFromXml(pStepModelHelper.XPath, entityId);
10211021

1022-
//update stepModel to parentStepModel
1022+
//update stepModel to parentSte5pModel
10231023
for (var i = 0; i < pStepModelHelper.Childrens.Count; i++)
10241024
{
10251025
var c = pStepModelHelper.Childrens.ElementAt(i);
@@ -1030,7 +1030,7 @@ public ActionResult ActivateComplexUsageInAChoice(int parentid, int id, long ent
10301030
cStepModelHelper.Activated = pStepModelHelper.ChoiceMax <= 1? false :true;
10311031

10321032
if(cStepModelHelper.StepId.Equals(id)) cStepModelHelper.Activated = true;
1033-
1033+
10341034

10351035
if (!cStepModelHelper.Activated)
10361036
{
@@ -1062,6 +1062,14 @@ public ActionResult ActivateComplexUsageInAChoice(int parentid, int id, long ent
10621062
cStepModelHelper = getChildModelsHelper(cStepModelHelper, TaskManager);
10631063

10641064
setStepModelActive(cStepModelHelper);
1065+
1066+
// wenn das cStepModelHelper (usage) activiert wird und das objekt required ist, dann muss der type auch aktiviert werden.
1067+
if (cStepModelHelper.Model.MinCardinality > 0 && cStepModelHelper.Childrens.Any())
1068+
{
1069+
var instance = cStepModelHelper.Childrens.FirstOrDefault();
1070+
if (instance != null) instance.Activated = true;
1071+
}
1072+
10651073
}
10661074
}
10671075
}
@@ -1100,13 +1108,22 @@ public ActionResult DeactivateComplexUsageInAChoice(int parentid, int id, long e
11001108

11011109
RemoveFromXml(cStepModelHelper.XPath, entityId);
11021110
cleanMetadataAttributes(cStepModelHelper);
1103-
1111+
11041112

11051113
}
11061114
cStepModelHelper.Activated = false;
1115+
1116+
var stepInfo = cStepModelHelper.Model.StepInfo.Children.FirstOrDefault(s=> s.Id.Equals(id));
1117+
cStepModelHelper.Model.StepInfo.Children = new List<StepInfo>();
1118+
cStepModelHelper.Childrens = new List<StepModelHelper>();
1119+
1120+
//cStepModelHelper.Model = null;
11071121
}
1108-
// if only one choice is possible, reset all active steps before
1109-
cStepModelHelper.Activated = pStepModelHelper.ChoiceMax <= 1 ? true : cStepModelHelper.StepId.Equals(id);
1122+
//else
1123+
//{
1124+
// // if only one choice is possible, reset all active steps before
1125+
// cStepModelHelper.Activated = pStepModelHelper.ChoiceMax <= 1 ? true : cStepModelHelper.StepId.Equals(id);
1126+
//}
11101127

11111128
}
11121129

@@ -2504,6 +2521,11 @@ private StepModelHelper getChildModelsHelper(StepModelHelper stepModelHelper, Cr
25042521

25052522
childStepModelHelper = getChildModelsHelper(childStepModelHelper, taskManager);
25062523

2524+
//check if the child step model helper is already in the list and activates
2525+
// if the usage is active and themin cardinality is 1, also activate the types
2526+
if (childStepModelHelper.Model.MinCardinality == 1)
2527+
childStepModelHelper.Childrens.ForEach(c => c.Activated = true);
2528+
25072529
if(!stepModelHelper.Childrens.Any(c=> c.UsageId.Equals(childStepModelHelper.UsageId) && c.Number.Equals(childStepModelHelper.Number)))
25082530
stepModelHelper.Childrens.Add(childStepModelHelper);
25092531
}

Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Helpers/SystemMetadataHelper.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public XmlDocument SetSystemValuesToMetadata(long datasetid, long version, long
1313
foreach (var t in systemKeyList)
1414
{
1515
//get all mappings to automatic system from the metadata structure
16-
var mappings = MappingUtils.GetMappingsWhereSource((int)t, LinkElementType.Key);
16+
var mappings = MappingUtils.GetMappingsWhereSource((int)t, LinkElementType.Key, 2);
1717

1818
if (mappings != null)
1919
{
@@ -69,11 +69,17 @@ private XmlDocument setValue(string xpath, string value, XmlDocument metadata)
6969
{
7070
try
7171
{
72-
var xmlElement = metadata.SelectSingleNode(xpath);
73-
if (xmlElement != null && (XmlElement)xmlElement != null)
72+
var xmlobj = metadata.SelectSingleNode(xpath);
73+
if (xmlobj != null && xmlobj is XmlElement)
7474
{
75-
((XmlElement)xmlElement).InnerText = value;
75+
((XmlElement)xmlobj).InnerText = value;
7676
}
77+
78+
if (xmlobj != null && xmlobj is XmlAttribute)
79+
{
80+
((XmlAttribute)xmlobj).InnerText = value;
81+
}
82+
7783
}
7884
catch (Exception ex)
7985
{

Console/BExIS.Web.Shell/Areas/DCM/BExIS.Modules.Dcm.UI/Models/CreateDataset/StepModelHelper.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public AbstractMetadataStepModel Model
3636
set
3737
{
3838
_model = value;
39+
3940
Activated = SetActiveByPreload();
4041
}
4142
}
@@ -96,6 +97,8 @@ public string GetXPathFromSimpleAttribute(long id, long number)
9697

9798
public bool IsEmpty()
9899
{
100+
if (Model == null) return true;
101+
99102
foreach (MetadataAttributeModel simpleAttr in Model.MetadataAttributeModels)
100103
{
101104
if (simpleAttr.IsEmpty != true) return false;
@@ -109,6 +112,12 @@ public bool IsEmpty()
109112
return true;
110113
}
111114

115+
private bool isChildOfChoiceParent(StepModelHelper parent )
116+
{
117+
if(parent == null) return false;
118+
return parent.Choice;
119+
}
120+
112121
public string DisplayName()
113122
{
114123
string displayName = "";
@@ -147,8 +156,17 @@ public string DisplayName()
147156
/// <returns></returns>
148157
private bool SetActiveByPreload()
149158
{
150-
if (Model != null &&
151-
Model.MinCardinality > 0) Activated = true;
159+
// check if a parent is in a choice object
160+
if (!isChildOfChoiceParent(Parent)) // not, so set active if MinCardinality >0
161+
{
162+
if (Model != null &&
163+
Model.MinCardinality > 0 &&
164+
Model.MaxCardinality == 1)
165+
{
166+
Activated = true;
167+
}
168+
}
169+
152170

153171
return Activated;
154172
}

0 commit comments

Comments
 (0)