Skip to content

Commit

Permalink
user can now reference a json ui schema within the mapping file. Add …
Browse files Browse the repository at this point in the history
…the key 'ui' with a path to the ui file as a value within the array of a xsd. The structure of the mapping file with the reference of the ui is not final and it only supports the read operation for now
  • Loading branch information
LeoDuda committed May 2, 2022
1 parent f68afd6 commit c4bac53
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 117 deletions.
204 changes: 102 additions & 102 deletions src/main/resources/static/jsonSchemas/mappings/kitschema.json
Original file line number Diff line number Diff line change
@@ -1,109 +1,109 @@
{
"$id": "kitxsd.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "This JSON Schema file was generated from kitxsd.xsd on Wed Apr 20 2022 09:28:12 GMT+0200 (Mitteleuropäische Sommerzeit). For more information please see http://www.xsd2jsonschema.org",
"description": "Schema tag attributes: targetNamespace='http://www.example.org/kit' xmlns:kit='http://www.example.org/kit' xmlns:xs='http://www.w3.org/2001/XMLSchema' elementFormDefault='qualified'",
"properties": {
"stringtype": {
"$ref": "#/definitions/stringtype"
},
"employeeidtype": {
"$ref": "#/definitions/employeeidtype"
},
"shorttype": {
"$ref": "#/definitions/shorttype"
},
"departmenttype": {
"$ref": "#/definitions/departmenttype"
},
"employeetype": {
"$ref": "#/definitions/employeetype"
},
"employee": {
"$ref": "#/definitions/employeetype"
}
"$id": "kitxsd.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "This JSON Schema file was generated from kitxsd.xsd on Wed Apr 20 2022 09:28:12 GMT+0200 (Mitteleuropäische Sommerzeit). For more information please see http://www.xsd2jsonschema.org",
"description": "Schema tag attributes: targetNamespace='http://www.example.org/kit' xmlns:kit='http://www.example.org/kit' xmlns:xs='http://www.w3.org/2001/XMLSchema' elementFormDefault='qualified'",
"properties": {
"stringtype": {
"$ref": "#/definitions/stringtype"
},
"type": "object",
"anyOf": [
{
"required": [
"stringtype"
]
},
{
"required": [
"employeeidtype"
]
},
{
"required": [
"shorttype"
]
},
{
"required": [
"departmenttype"
]
},
{
"required": [
"employeetype"
]
},
{
"required": [
"employee"
]
}
],
"definitions": {
"stringtype": {
"type": "string"
},
"employeeidtype": {
"pattern": "[a-z]{2}[0-9]{4}",
"type": "string"
},
"shorttype": {
"pattern": "[A-Z\\-]{3,8}",
"type": "string"
},
"departmenttype": {
"required": [
"departmentname",
"shortname"
],
"properties": {
"departmentname": {
"$ref": "#/definitions/stringtype"
},
"shortname": {
"$ref": "#/definitions/shorttype"
}
"employeeidtype": {
"$ref": "#/definitions/employeeidtype"
},
"shorttype": {
"$ref": "#/definitions/shorttype"
},
"departmenttype": {
"$ref": "#/definitions/departmenttype"
},
"employeetype": {
"$ref": "#/definitions/employeetype"
},
"employee": {
"$ref": "#/definitions/employeetype"
}
},
"type": "object",
"anyOf": [
{
"required": [
"stringtype"
]
},
{
"required": [
"employeeidtype"
]
},
{
"required": [
"shorttype"
]
},
{
"required": [
"departmenttype"
]
},
{
"required": [
"employeetype"
]
},
{
"required": [
"employee"
]
}
],
"definitions": {
"stringtype": {
"type": "string"
},
"employeeidtype": {
"pattern": "[a-z]{2}[0-9]{4}",
"type": "string"
},
"shorttype": {
"pattern": "[A-Z\\-]{3,8}",
"type": "string"
},
"departmenttype": {
"required": [
"departmentname",
"shortname"
],
"properties": {
"departmentname": {
"$ref": "#/definitions/stringtype"
},
"type": "object"
"shortname": {
"$ref": "#/definitions/shorttype"
}
},
"employeetype": {
"required": [
"name",
"department",
"@employeeid"
],
"properties": {
"name": {
"$ref": "#/definitions/stringtype"
},
"department": {
"$ref": "#/definitions/departmenttype"
},
"@employeeid": {
"$ref": "#/definitions/employeeidtype"
}
"type": "object"
},
"employeetype": {
"required": [
"name",
"department",
"@employeeid"
],
"properties": {
"name": {
"$ref": "#/definitions/stringtype"
},
"department": {
"$ref": "#/definitions/departmenttype"
},
"type": "object"
"@employeeid": {
"$ref": "#/definitions/employeeidtype"
}
},
"employee": {
"$ref": "#/definitions/employeetype"
}
"type": "object"
},
"employee": {
"$ref": "#/definitions/employeetype"
}
}
}
}
3 changes: 3 additions & 0 deletions src/main/resources/static/jsonSchemas/mappings/mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
},
{
"v3": "/jsonSchemas/mappings/examplexsd.json"
},
{
"ui": "/jsonSchemas/mappings/ui.json"
}
],
"id_3": [
Expand Down
23 changes: 11 additions & 12 deletions src/main/resources/static/jsonSchemas/mappings/ui.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"firstName": {
"ui:autofocus": true,
"ui:emptyValue": "",
"ui:autocomplete": "family-name"
},
"lastName": {
"ui:emptyValue": "",
"ui:autocomplete": "given-name"
"example:metadata": {
"_attributes":{
"xmlns:example": {
"ui:title": "XMLNS",
"ui:description": "Namespace des XML"
}
},
"telephone": {
"ui:options": {
"inputType": "tel"
"example:title": {
"_text": {
"ui:title": "Titel"
}
}
}
}
}
28 changes: 25 additions & 3 deletions src/main/resources/templates/metadata-management.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,40 @@ <h4>Metadata Record Form</h4>
console.log("im try xml Zeile 183");
var json = convert.xml2json(metadata, { compact: true, spaces: 4 });
console.log(json);
var ui;


$.getJSON(mappingPath, function (mapping) {
console.log(mapping);


console.log("Zeile 192");
var uiReference = mapping[schemaId][mapping[schemaId].length - 1]['ui'];
console.log(uiReference);

try {
$.getJSON(uiReference, function (uiJson) {
console.log(uiJson);
if (uiJson == undefined) {
console.log("undefined");
ui = '*';
} else {
ui = uiJson;
}
});
} catch (e) {
ui = '*'
}

var schemaReference = mapping[schemaId][version - 1]['v' + version];



$.getJSON(schemaReference, function (mappedSchema) {
console.log(ui);
console.log(JSON.stringify(mappedSchema, null, 2));
options = { operation: "READ", dataModel: mappedSchema, uiForm: "*", resource: JSON.parse(json) };
//Achtung, ui für id_1 passt nicht


options = { operation: "READ", dataModel: mappedSchema, uiForm: ui, resource: JSON.parse(json) };
$('form').metadataeditorForm(options, function onSubmitValid(value) {
});
});
Expand Down

0 comments on commit c4bac53

Please sign in to comment.