Skip to content

Commit 9ecdb35

Browse files
committed
#2189 change the get type name fn by xsd reader
1 parent c25b8cc commit 9ecdb35

File tree

3 files changed

+45
-17
lines changed

3 files changed

+45
-17
lines changed

Components/XML/BExIS.Xml.Helpers/Mapping/XmlSchemaManager.cs

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ public long GenerateMetadataStructure(string nameOfStartNode, string schemaName)
716716
//Debug.Writeline("package : " + element.Name);
717717
//Debug.Writeline("--------------------------");
718718

719-
string typeName = GetTypeOfName(element.Name);
719+
string typeName = GetTypeOfName(element);
720720
string rootName = ((XmlSchemaElement)root).Name;
721721

722722
string xpathInternal = "Metadata/" + element.Name + "/" + typeName;
@@ -965,7 +965,7 @@ private MetadataCompoundAttribute get(XmlSchemaElement element, List<string> par
965965
if (ct.Name != null)
966966
nameOfType = ct.Name;
967967
else
968-
nameOfType = GetTypeOfName(element.Name);
968+
nameOfType = GetTypeOfName(element);
969969

970970
MetadataCompoundAttribute metadataCompountAttr = getExistingMetadataCompoundAttribute(nameOfType);
971971
string currentInternalXPath = internalXPath + "/" + element.Name + "/" + nameOfType;
@@ -1328,9 +1328,9 @@ private MetadataCompoundAttribute addMetadataAttributeToMetadataCompoundAttribut
13281328
MetadataAttribute attribute;
13291329

13301330
if (metadataAttributeManager.MetadataAttributeRepo != null &&
1331-
getExistingMetadataAttribute(GetTypeOfName(element.Name)) != null)
1331+
getExistingMetadataAttribute(GetTypeOfName(element)) != null)
13321332
{
1333-
attribute = getExistingMetadataAttribute(GetTypeOfName(element.Name));
1333+
attribute = getExistingMetadataAttribute(GetTypeOfName(element));
13341334
}
13351335
else
13361336
{
@@ -1443,7 +1443,7 @@ private MetadataAttribute createMetadataAttribute(XmlSchemaElement element, stri
14431443
{
14441444
XmlSchemaSimpleType type = (XmlSchemaSimpleType)element.ElementSchemaType;
14451445

1446-
string name = GetTypeOfName(element.Name);
1446+
string name = GetTypeOfName(element);
14471447
string description = "";
14481448

14491449
if (element.Annotation != null)
@@ -1507,7 +1507,7 @@ private MetadataAttribute createMetadataAttribute(XmlSchemaElement element, stri
15071507
var t = ComplexTypes.FirstOrDefault(c => c.Name.Equals(type.Name));
15081508
if (t != null) type = t;
15091509

1510-
string name = GetTypeOfName(element.Name);
1510+
string name = GetTypeOfName(element);
15111511
string description = "";
15121512

15131513
if (element.Annotation != null)
@@ -1628,7 +1628,8 @@ private MetadataCompoundAttribute createMetadataCompoundAttribute(XmlSchemaEleme
16281628
{
16291629
// create a compoundAttribute
16301630
int i = 0;
1631-
MetadataCompoundAttribute mca = getExistingMetadataCompoundAttribute(element.Name + "Type"); ;// = metadataAttributeManager.MetadataCompoundAttributeRepo.Get(p => p.Name == element.Name+"Type").FirstOrDefault();
1631+
string typeName = GetTypeOfName(element);
1632+
MetadataCompoundAttribute mca = getExistingMetadataCompoundAttribute(typeName); ;// = metadataAttributeManager.MetadataCompoundAttributeRepo.Get(p => p.Name == element.Name+"Type").FirstOrDefault();
16321633
//Debug.WriteLine("createMetadataCompoundAttribute" + i++);
16331634
DataType dt1 = dataTypeManager.Repo.Get(p => p.Name.ToLower().Equals("text")).FirstOrDefault();
16341635
if (dt1 == null)
@@ -1640,8 +1641,8 @@ private MetadataCompoundAttribute createMetadataCompoundAttribute(XmlSchemaEleme
16401641
{
16411642
mca = new MetadataCompoundAttribute
16421643
{
1643-
ShortName = GetTypeOfName(element.Name),
1644-
Name = GetTypeOfName(element.Name),
1644+
ShortName = typeName,
1645+
Name = typeName,
16451646
Description = "",
16461647
DataType = dt1
16471648
};
@@ -1909,9 +1910,9 @@ private void addMetadataAttributeToMappingFile(MetadataCompoundAttribute compoun
19091910
MetadataAttribute attribute;
19101911

19111912
if (metadataAttributeManager.MetadataAttributeRepo != null &&
1912-
metadataAttributeManager.MetadataAttributeRepo.Query().Where(m => m.Name.Equals(GetTypeOfName(element.Name))).Count() > 0)
1913+
metadataAttributeManager.MetadataAttributeRepo.Query().Where(m => m.Name.Equals(GetTypeOfName(element))).Count() > 0)
19131914
{
1914-
attribute = metadataAttributeManager.MetadataAttributeRepo.Query().Where(m => m.Name.Equals(GetTypeOfName(element.Name))).First();
1915+
attribute = metadataAttributeManager.MetadataAttributeRepo.Query().Where(m => m.Name.Equals(GetTypeOfName(element))).First();
19151916
}
19161917
else
19171918
{
@@ -2203,9 +2204,28 @@ private void checkDirectory(string filePath)
22032204
}
22042205
}
22052206

2206-
private string GetTypeOfName(string name)
2207+
private string GetTypeOfName(XmlSchemaElement element)
22072208
{
2208-
return name + "Type";
2209+
string nameOfType = "";
2210+
2211+
// check if type is complex
2212+
XmlSchemaComplexType ct = XmlSchemaUtility.GetComplextType(element);
2213+
2214+
if (ct != null && ct.Name != null)
2215+
{
2216+
return ct.Name;
2217+
}
2218+
2219+
//check if simple type
2220+
XmlSchemaSimpleType st = XmlSchemaUtility.GetSimpleType(element);
2221+
2222+
if(st != null && st.Name != null)
2223+
{
2224+
return st.Name;
2225+
}
2226+
2227+
// nothing found so create a new name + XSDType
2228+
return element.Name + element.ElementType.GetType().Name; // bexis2InternType
22092229
}
22102230

22112231
#endregion helper functions

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,14 @@ public static XmlSchemaComplexType GetComplextType(XmlSchemaElement element)
524524
return null;
525525
}
526526

527+
public static XmlSchemaSimpleType GetSimpleType(XmlSchemaElement element)
528+
{
529+
if (element.ElementSchemaType is XmlSchemaSimpleType)
530+
return element.ElementSchemaType as XmlSchemaSimpleType;
531+
532+
return null;
533+
}
534+
527535
public static List<XmlSchemaElement> GetAllSimpleElements(List<XmlSchemaElement> elements)
528536
{
529537
List<XmlSchemaElement> simpleElementList = new List<XmlSchemaElement>();

Console/BExIS.Web.Shell/Areas/SMM/BExIS.Modules.SMM.UI/SMM.Manifest.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212
<Exports>
1313
<!--add proper menu items-->
1414

15-
<Export tag="settings" id="createDataset" order="1"
15+
<!--<Export tag="settings" id="createDataset" order="1"
1616
title="Manage Parties" description="" icon=""
1717
controller="Party" action="index"
18-
extends="./settingsRoot" />
18+
extends="./settingsRoot" />-->
1919

2020
<!-- INTERNAL-->
2121

22-
<Export tag="internalApi" id="loadFromPartyUserRegisterationForm"
22+
<!--<Export tag="internalApi" id="loadFromPartyUserRegisterationForm"
2323
title="Load From Party User Registration Form" description="Load FromParty User Registration Form" icon=""
2424
controller="PartyService" action="UserRegistration"
2525
extends="" />
2626
<Export tag="internalApi" id="GetPartyTypesForAccount"
2727
title="Get partyTypes for account" description="Get partyTypes for account which are defined in setting.xml" icon=""
2828
controller="PartyService" action="GetPartyTypesForAccount"
29-
extends="" />
29+
extends="" />-->
3030
<Export tag="lunchbar" id="helpSmm" order="2"
3131
title="Account / Parties" description="Parties Help Manual" icon=""
3232
controller="Help" action="index"

0 commit comments

Comments
 (0)