Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into Common.Locale
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoTheissen committed Dec 6, 2021
2 parents 05b0a4c + 614e574 commit b4d1ff5
Show file tree
Hide file tree
Showing 5 changed files with 1,624 additions and 509 deletions.
3 changes: 2 additions & 1 deletion examples/DynamicProperties-sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
"Property": "Country"
},
{
"DynamicProperty": "@Analytics.AggregatedProperty#sum"
"DynamicProperty": "@Analytics.AggregatedProperty#sum",
"Descending": true
},
{
"DynamicProperty": "/self.Container/me/[email protected]#WeightedAverage"
Expand Down
48 changes: 24 additions & 24 deletions examples/DynamicProperties-sample.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@

<EntityType Name="Sales">
<Key>
<PropertyRef Name="Order"/>
<PropertyRef Name="Order" />
</Key>
<Property Name="Order" Type="Edm.String" Nullable="false"/>
<Property Name="Country" Type="Edm.String" Nullable="false"/>
<Property Name="NumberOfItems" Type="Edm.Int16" Nullable="false"/>
<Property Name="Amount" Type="Edm.Decimal"/>
<Property Name="Order" Type="Edm.String" Nullable="false" />
<Property Name="Country" Type="Edm.String" Nullable="false" />
<Property Name="NumberOfItems" Type="Edm.Int16" Nullable="false" />
<Property Name="Amount" Type="Edm.Decimal" />
<Annotation Term="Analytics.AggregatedProperty" Qualifier="sum">
<Record>
<PropertyValue Property="Name" String="Total"/>
<PropertyValue Property="AggregationMethod" String="sum"/>
<PropertyValue Property="AggregatableProperty" PropertyPath="Amount"/>
<PropertyValue Property="Name" String="Total" />
<PropertyValue Property="AggregationMethod" String="sum" />
<PropertyValue Property="AggregatableProperty" PropertyPath="Amount" />
</Record>
</Annotation>
<Annotation Term="Analytics.AggregatedProperty" Qualifier="max">
<Record>
<PropertyValue Property="Name" String="Maximum"/>
<PropertyValue Property="AggregationMethod" String="max"/>
<PropertyValue Property="AggregatableProperty" PropertyPath="Amount"/>
<PropertyValue Property="Name" String="Maximum" />
<PropertyValue Property="AggregationMethod" String="max" />
<PropertyValue Property="AggregatableProperty" PropertyPath="Amount" />
</Record>
</Annotation>
<Annotation Term="UI.Chart">
<Record>
<PropertyValue Property="ChartType" EnumMember="UI.ChartType/Bubble"/>
<PropertyValue Property="ChartType" EnumMember="UI.ChartType/Bubble" />
<PropertyValue Property="Dimensions">
<Collection>
<PropertyPath>Country</PropertyPath>
Expand All @@ -63,13 +63,13 @@
<PropertyValue Property="SelectOptions">
<Collection>
<Record>
<PropertyValue Property="DynamicPropertyName" AnnotationPath="@Analytics.AggregatedProperty#sum"/>
<PropertyValue Property="DynamicPropertyName" AnnotationPath="@Analytics.AggregatedProperty#sum" />
<PropertyValue Property="Ranges">
<Collection>
<Record>
<PropertyValue Property="Sign" EnumMember="UI.SelectionRangeSignType/I"/>
<PropertyValue Property="Option" EnumMember="UI.SelectionRangeSignType/LE"/>
<PropertyValue Property="Low" Decimal="1000"/>
<PropertyValue Property="Sign" EnumMember="UI.SelectionRangeSignType/I" />
<PropertyValue Property="Option" EnumMember="UI.SelectionRangeSignType/LE" />
<PropertyValue Property="Low" Decimal="1000" />
</Record>
</Collection>
</PropertyValue>
Expand All @@ -83,30 +83,30 @@
<PropertyValue Property="SortOrder">
<Collection>
<Record>
<PropertyValue Property="Property" PropertyPath="Country"/>
<PropertyValue Property="Property" PropertyPath="Country" />
</Record>
<Record>
<PropertyValue Property="DynamicProperty" AnnotationPath="@Analytics.AggregatedProperty#sum"/>
<PropertyValue Property="Descending" Boolean="true"/>
<PropertyValue Property="DynamicProperty" AnnotationPath="@Analytics.AggregatedProperty#sum" />
<PropertyValue Property="Descending" Bool="true" />
</Record>
<Record>
<PropertyValue Property="DynamicProperty" AnnotationPath="/self.Container/me/[email protected]#WeightedAverage"/>
<PropertyValue Property="DynamicProperty" AnnotationPath="/self.Container/me/[email protected]#WeightedAverage" />
</Record>
</Collection>
</PropertyValue>
</Record>
</Annotation>
</EntityType>
<EntityType Name="meType">
<NavigationProperty Name="SalesOrders" Type="Collection(DynamicProperties.examples.Sales)" ContainsTarget="true"/>
<NavigationProperty Name="SalesOrders" Type="Collection(DynamicProperties.examples.Sales)" ContainsTarget="true" />
</EntityType>
<EntityContainer Name="Container">
<Singleton Name="me" Type="DynamicProperties.examples.meType"/>
<Singleton Name="me" Type="DynamicProperties.examples.meType" />
</EntityContainer>
<Annotations Target="self.Container/me/SalesOrders">
<Annotation Term="Aggregation.CustomAggregate" Qualifier="WeightedAverage" String="Edm.Decimal"/>
<Annotation Term="Aggregation.CustomAggregate" Qualifier="WeightedAverage" String="Edm.Decimal" />
</Annotations>

</Schema>
</edmx:DataServices>
</edmx:Edmx>
</edmx:Edmx>
33 changes: 30 additions & 3 deletions lib/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const csdl = require("odata-csdl");
const lib = require("odata-vocabularies");
const fs = require("fs");
const colors = require("colors/safe");

const vocabFolder = "./vocabularies/";
const exampleFolder = "./examples/";
Expand All @@ -15,8 +16,20 @@ fs.readdirSync(vocabFolder)
console.log(xmlfile);

const xml = fs.readFileSync(vocabFolder + xmlfile, "utf8");

const json = csdl.xml2json(xml, true);
let json;
try {
json = csdl.xml2json(xml, true);
} catch (e) {
console.error(
colors.red(
`${vocabFolder + xmlfile}:${e.parser.line}:${e.parser.column}: ${
e.message
}`
)
);
process.exitCode = 1;
return;
}

// swap URLs of latest-version and alternate links
const namespace = Object.keys(json).find((item) =>
Expand Down Expand Up @@ -47,7 +60,21 @@ fs.readdirSync(exampleFolder)
console.log(example + ".json");

const xml = fs.readFileSync(exampleFolder + xmlfile, "utf8");
const json = csdl.xml2json(xml, false);
let json;
try {
json = csdl.xml2json(xml, false);
} catch (e) {
console.error(
colors.red(
`${exampleFolder + xmlfile}:${e.parser.line}:${e.parser.column}: ${
e.message
}`
)
);
process.exitCode = 1;
return;
}

fs.writeFileSync(
exampleFolder + example + ".json",
JSON.stringify(json, null, 4)
Expand Down
Loading

0 comments on commit b4d1ff5

Please sign in to comment.