Commit 1ce1b943 authored by Andrei Popescu's avatar Andrei Popescu
Browse files

fixed enum (now both enum and oneOf).

parent b86ba1ac
Pipeline #55688 passed with stage
in 25 seconds
......@@ -19,6 +19,7 @@
rdfs:comment "Describes ad-hoc changes to the system."@en;
vann:preferredNamespaceUri "https://w3id.org/sdm/terms/alerts#".
<https://w3id.org/sdm/terms/> dcterms:creator <https://pietercolpaert.be/#me>, <https://www.linkedin.com/in/andrei-popescu/>.
gbfs:type owl:oneOf (<SYSTEM_CLOSURE> <STATION_CLOSURE> <STATION_MOVE> <OTHER>).
gbfs:times rdf:type rdf:Property;
rdfs:range gbfs:Times.
gbfs:Times rdf:type rdfs:Class.
......
......@@ -20,9 +20,11 @@
vann:preferredNamespaceUri "https://w3id.org/sdm/terms/vehicle_types#".
<https://w3id.org/sdm/terms/> dcterms:creator <https://pietercolpaert.be/#me>, <https://www.linkedin.com/in/andrei-popescu/>.
gbfs:form_factor rdfs:range xsd:string;
rdfs:label "The vehicle's general form factor."@en.
rdfs:label "The vehicle's general form factor."@en;
owl:oneOf (vso:bicycle schema:car <moped> <other> <scooter>).
gbfs:propulsion_type rdfs:range xsd:string;
rdfs:label "The primary propulsion type of the vehicle."@en.
rdfs:label "The primary propulsion type of the vehicle."@en;
owl:oneOf (<human> <electric_assist> <electric> <combustion>).
gbfs:max_range_meters rdfs:range xsd:integer;
rdfs:label "The furthest distance in meters that the vehicle can travel without recharging or refueling when it has the maximum amount of energy potential."@en.
gbfs:default_reserve_time rdfs:range xsd:integer;
......
......@@ -20,4 +20,5 @@
vann:preferredNamespaceUri "https://w3id.org/sdm/terms/versions#".
<https://w3id.org/sdm/terms/> dcterms:creator <https://pietercolpaert.be/#me>, <https://www.linkedin.com/in/andrei-popescu/>.
gbfs:version rdfs:range xsd:string;
rdfs:label "The semantic version of the feed in the form X.Y"@en.
rdfs:label "The semantic version of the feed in the form X.Y"@en;
owl:oneOf (<1.1> <2.0> <2.1> <2.2> <2.3-RC>).
......@@ -198,6 +198,12 @@ var JsonProcessor = /** @class */ (function () {
this.shaclFileText = this.shaclFileText + shaclTools_1.ShaclTools.getShaclTypedProperty(prop, rdfTools_1.RDFTools.getXsdType(propType)) + '\n';
}
}
// There might be an enum
if (directEnum != undefined) {
console.log("directENum", directEnum);
var quad_1 = JsonProcessor.getEnumerationQuad(directEnum, prop);
this.writer.addQuad(quad_1);
}
return;
}
if (propType == 'boolean') {
......@@ -251,19 +257,8 @@ var JsonProcessor = /** @class */ (function () {
this.writer.addQuad(rdfTools_1.RDFTools.node_node_literal(this.prefix + ':' + prop, 'rdfs:label', propDescription.toString()));
}
if (directEnum != undefined) {
var oneOfValues = [];
for (var _a = 0, directEnum_1 = directEnum; _a < directEnum_1.length; _a++) {
var value = directEnum_1[_a];
//We get the values from the mapping, else we create new terms
if (this.termMap.get(value) != undefined) {
oneOfValues.push(namedNode(this.termMap.get(value)));
}
else {
oneOfValues.push(namedNode(value));
}
}
var subPropQuad = rdfTools_1.RDFTools.node_node_list(this.prefix + ':' + newClassName, 'owl:oneOf', oneOfValues);
this.writer.addQuad(subPropQuad);
var quad_2 = JsonProcessor.getEnumerationQuad(directEnum, newClassName);
this.writer.addQuad(quad_2);
}
// Shacl shape text
if (JsonProcessor.isRequired(prop)) {
......@@ -291,6 +286,22 @@ var JsonProcessor = /** @class */ (function () {
}
return;
};
// Auxiliary Methods
JsonProcessor.getEnumerationQuad = function (directEnum, name) {
var oneOfValues = [];
for (var _i = 0, directEnum_1 = directEnum; _i < directEnum_1.length; _i++) {
var value = directEnum_1[_i];
//We get the values from the mapping, else we create new terms
if (this.termMap.get(value) != undefined) {
oneOfValues.push(namedNode(this.termMap.get(value)));
}
else {
oneOfValues.push(namedNode(value));
}
}
var subPropQuad = rdfTools_1.RDFTools.node_node_list(this.prefix + ':' + name, 'owl:oneOf', this.writer.list(oneOfValues));
return subPropQuad;
};
JsonProcessor.getJsonObject = function (mainObject) {
for (var _i = 0, _a = Array.from(this.rdf_json_objects.entries()); _i < _a.length; _i++) {
var entry = _a[_i];
......
......@@ -239,6 +239,14 @@ export class JsonProcessor {
this.shaclFileText = this.shaclFileText+ShaclTools.getShaclTypedProperty(prop, RDFTools.getXsdType(propType))+'\n';
}
}
// There might be an enum
if (directEnum != undefined){
console.log("directENum", directEnum);
let quad = JsonProcessor.getEnumerationQuad(directEnum, prop);
this.writer.addQuad(quad);
}
return;
}
......@@ -302,20 +310,11 @@ export class JsonProcessor {
this.writer.addQuad(RDFTools.node_node_literal(this.prefix+':'+prop, 'rdfs:label', propDescription.toString()));
}
if (directEnum != undefined){
let oneOfValues:NamedNode[] = [];
for (const value of directEnum){
//We get the values from the mapping, else we create new terms
if (this.termMap.get(value)!= undefined) {
oneOfValues.push(namedNode(this.termMap.get(value)));
}
else{
oneOfValues.push(namedNode(value));
}
}
let subPropQuad = RDFTools.node_node_list(this.prefix+':'+newClassName, 'owl:oneOf', oneOfValues);
this.writer.addQuad(subPropQuad);
let quad = JsonProcessor.getEnumerationQuad(directEnum, newClassName);
this.writer.addQuad(quad);
}
// Shacl shape text
if (JsonProcessor.isRequired(prop)){
this.shaclFileText = this.shaclFileText+ShaclTools.getShaclRequiredProperty(prop)+'\n';
......@@ -346,6 +345,26 @@ export class JsonProcessor {
}
return;
}
// Auxiliary Methods
static getEnumerationQuad(directEnum, name){
let oneOfValues:NamedNode[] = [];
for (const value of directEnum){
//We get the values from the mapping, else we create new terms
if (this.termMap.get(value)!= undefined) {
oneOfValues.push(namedNode(this.termMap.get(value)));
}
else{
oneOfValues.push(namedNode(value));
}
}
let subPropQuad = RDFTools.node_node_list(this.prefix+':'+name, 'owl:oneOf', this.writer.list(oneOfValues));
return subPropQuad;
}
static getJsonObject(mainObject: string){
for(let entry of Array.from(this.rdf_json_objects.entries())){
const key = entry[0];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment