Skip to content

Commit b00dbfe

Browse files
committed
#2187 fix issue with choice elements in package
1 parent 75f6457 commit b00dbfe

File tree

7 files changed

+52
-13
lines changed

7 files changed

+52
-13
lines changed

Components/DLM/BExIS.Dlm.Services/MetadataStructure/MetadataPackageManager.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.Diagnostics.Contracts;
55
using System.Linq;
6+
using System.Xml;
67
using Vaiona.Persistence.Api;
78

89
namespace BExIS.Dlm.Services.MetadataStructure
@@ -128,7 +129,7 @@ public MetadataPackage Update(MetadataPackage entity)
128129

129130
#region Associations
130131

131-
public MetadataAttributeUsage AddMetadataAtributeUsage(MetadataPackage package, MetadataAttribute attribute, string label, string description, int minCardinality, int maxCardinality, string defaultValue, string fixedValue)
132+
public MetadataAttributeUsage AddMetadataAtributeUsage(MetadataPackage package, MetadataAttribute attribute, string label, string description, int minCardinality, int maxCardinality, string defaultValue, string fixedValue, XmlDocument extra = null )
132133
{
133134
Contract.Requires(package != null && package.Id >= 0);
134135
Contract.Requires(attribute != null && attribute.Id >= 0);
@@ -166,6 +167,10 @@ select v
166167
DefaultValue = defaultValue,
167168
FixedValue = fixedValue
168169
};
170+
171+
if (extra != null && !string.IsNullOrEmpty(extra.OuterXml))
172+
usage.Extra = extra;
173+
169174
package.MetadataAttributeUsages.Add(usage);
170175
attribute.UsedIn.Add(usage);
171176

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,12 +1218,38 @@ private void addUsageFromMetadataCompoundAttributeToPackage(MetadataPackage pack
12181218
*
12191219
*/
12201220

1221+
//if element is a choise
1222+
XmlDocument extra = null;
1223+
//check if element is a choice
12211224
if (XmlSchemaUtility.IsChoiceType(element))
12221225
{
12231226
min = 0;
1227+
Dictionary<string, string> additionalAttributes = new Dictionary<string, string>();
1228+
1229+
XmlSchemaComplexType ct = element.ElementSchemaType as XmlSchemaComplexType;
1230+
1231+
if (ct != null)
1232+
{
1233+
#region choice
1234+
1235+
// check if it is e choice
1236+
XmlSchemaChoice choice = ct.ContentTypeParticle as XmlSchemaChoice;
1237+
if (choice != null)
1238+
{
1239+
additionalAttributes.Add("min", choice.MinOccurs.ToString());
1240+
if (choice.MaxOccurs > 10)
1241+
additionalAttributes.Add("max", "10");
1242+
else
1243+
additionalAttributes.Add("max", choice.MaxOccurs.ToString());
1244+
}
1245+
1246+
#endregion choice
1247+
}
1248+
1249+
extra = xmlDatasetHelper.AddReferenceToXml(new XmlDocument(), "choice", "true", "elementType", @"extra/type", additionalAttributes);
12241250
}
12251251

1226-
metadataPackageManager.AddMetadataAtributeUsage(package, compoundAttribute, element.Name, GetDescription(element.Annotation), min, max, element.DefaultValue, element.FixedValue);
1252+
metadataPackageManager.AddMetadataAtributeUsage(package, compoundAttribute, element.Name, GetDescription(element.Annotation), min, max, element.DefaultValue, element.FixedValue, extra);
12271253
}
12281254
}
12291255
finally

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,9 @@ public void GenerateSeedData()
285285
if (!metadataStructureManager.Repo.Get().Any(m => m.Name.Equals("Basic ABCD")))
286286
{
287287
string titleXPath =
288-
"Metadata/Metadata/MetadataType/Description/DescriptionType/Representation/MetadataDescriptionRepr/Title/TitleType";
288+
"Metadata/Metadata/ContentMetadata/Description/DescriptionXmlSchemaComplexType/Representation/MetadataDescriptionRepr/Title/String255";
289289
string descriptionXpath =
290-
"Metadata/Metadata/MetadataType/Description/DescriptionType/Representation/MetadataDescriptionRepr/Details/DetailsType";
290+
"Metadata/Metadata/ContentMetadata/Description/DescriptionXmlSchemaComplexType/Representation/MetadataDescriptionRepr/Details/String";
291291

292292
ImportSchema("Basic ABCD", "ABCD_2.06.XSD", "DataSet", entity.Name, entity.EntityType.FullName,
293293
titleXPath, descriptionXpath);
@@ -297,17 +297,17 @@ public void GenerateSeedData()
297297

298298
if (!metadataStructureManager.Repo.Get().Any(m => m.Name.Equals("GBIF")))
299299
{
300-
string titleXPath = "Metadata/Basic/BasicType/title/titleType";
301-
string descriptionXpath = "Metadata/abstract/abstractType/para/paraType";
300+
string titleXPath = "Metadata/Basic/BasicType/title/i18nString";
301+
string descriptionXpath = "Metadata/abstract/abstractXmlSchemaComplexType/para/paraDatatype_string";
302302

303303
ImportSchema("GBIF", "eml.xsd", "Dataset", entity.Name, entity.EntityType.FullName, titleXPath,
304304
descriptionXpath);
305305
}
306306

307307
if (!metadataStructureManager.Repo.Get().Any(m => m.Name.Equals("Publication")))
308308
{
309-
string titleXPath = "Metadata/publication/publicationType/Title/TitleType";
310-
string descriptionXpath = "Metadata/publication/publicationType/Abstract/AbstractType";
309+
string titleXPath = "Metadata/publication/publication/Title/TitleDatatype_string";
310+
string descriptionXpath = "Metadata/publication/publication/Abstract/AbstractXmlSchemaSimpleType";
311311

312312
ImportSchema("Publication", "BEXIS2-Publication-Schema-draft.xsd", "Metadata", publication.Name, publication.EntityType.FullName, titleXPath, descriptionXpath);
313313
}

Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI.Svelte/src/routes/search/+page.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@
1616
contentLayoutType={pageContentLayoutType.full}
1717
{links}
1818
>
19-
<h1>eric is cool</h1>
2019
<Search {controller} />
2120
</Page>

Modules/DIM/BExIS.Dim.NH.ORM/Mappings/Default/Mappings/LinkElement.hbm.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
<column name="Name" />
2424
</property>
2525

26-
<property name="XPath" type="string">
27-
<column name="XPath" />
26+
<property name="XPath" type="StringClob">
27+
<column name="XPath" sql-type="text" />
2828
</property>
2929

3030
<property name="IsSequence" type="boolean">

database update scripts/4.0.2-4.1.0.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ Set
1919
where type in (5,6) and complexity = 1 and xpath !='';
2020
*/
2121

22-
BEGIN TRANSACTION;
23-
2422
-- TEXT - string
2523
update datatypes
2624
set
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
BEGIN TRANSACTION;
2+
3+
ALTER TABLE public.dim_linkelements
4+
ALTER COLUMN xpath TYPE text COLLATE pg_catalog."default";
5+
6+
-- BEXIS2 Version Update
7+
INSERT INTO public.versions(
8+
versionno, extra, module, value, date)
9+
VALUES (1, null, 'Shell', '4.2.0',NOW());
10+
11+
commit;

0 commit comments

Comments
 (0)