Skip to content
Snippets Groups Projects
Commit 1446a804 authored by Rolf Niepraschk's avatar Rolf Niepraschk
Browse files

view+list zugefügt u.a.

parent eebad6f4
No related branches found
No related tags found
No related merge requests found
......@@ -23,16 +23,7 @@
"Class": {
"type": "string",
"propertyOrder": 12,
"enum": [
"",
"CDG",
"SRG",
"TLA",
"TLV",
"IG",
"PT100",
"DMM"
]
"enum": "{{000_DEVICETYPES@ENUM}}"
},
"Owner": {
"required": [
......@@ -46,7 +37,7 @@
}
}
},
"{{Setup}}": {},
"Setup":"{{000_SUBSCHEMAS-cob@SSCH@Setup}}",
"Device": {
"required": [
"Producer",
......
{
"_id": "000_SCHEMA-cus",
"Content":{
"Customer": {
"required": [
"Address",
"Contact",
"Lang",
"Name",
"Sign",
"Type"
],
"type": "object",
"options": {
"disable_properties": false,
"display_required_only": false
},
"defaultProperties": [
"Address",
"Contact",
"Lang",
"Name",
"Sign",
"Type"
],
"properties": {
"Name": {
"type": "string",
"propertyOrder": 5
"Content": {
"Customer": {
"required": [
"Address",
"Contact",
"Lang",
"Name",
"Sign",
"Type"
],
"type": "object",
"options": {
"disable_properties": false,
"display_required_only": false
},
"Lang": {
"type": "string",
"propertyOrder": 20,
"enum": [
"",
"en",
"de"
]
},
"Type": {
"type": "string",
"propertyOrder": 15,
"enum": [
"",
"Firma",
"NMI",
"NMI/DI",
"DAkkS",
"PTB",
"Sonstige"
]
},
"Shipping": {
"type": "object",
"options": {
"collapsed": false
"defaultProperties": [
"Address",
"Contact",
"Lang",
"Name",
"Sign",
"Type"
],
"properties": {
"Name": {
"type": "string",
"propertyOrder": 5
},
"propertyOrder": 99,
"properties": {
"Town": {
"type": "string"
},
"Gender": {
"type": "string",
"enum": [
"",
"male",
"female"
]
},
"Land": {
"type": "string",
"enum": [
"",
"AU",
"BY",
"CH",
"CN",
"CO",
"CZ",
"DE",
"DK",
"ES",
"FI",
"FR",
"HU",
"IL",
"IT",
"LI",
"NL",
"PH",
"PL",
"SG",
"SI",
"TH",
"TW",
"UK",
"US",
"ZA"
]
"Lang": {
"type": "string",
"propertyOrder": 20,
"enum": [
"",
"en",
"de"
]
},
"Type": {
"type": "string",
"propertyOrder": 15,
"enum": "{{000_CUSTOMERTYPES@ENUM}}"
},
"Shipping": {
"type": "object",
"options": {
"collapsed": false
},
"Name": {
"type": "string"
"propertyOrder": 99,
"properties": {
"Town": {
"type": "string"
},
"Gender": {
"type": "string",
"enum": [
"",
"male",
"female"
]
},
"Land": {
"type": "string",
"enum": "{{000_COUNTRIES@ENUM}}"
},
"Name": {
"type": "string"
}
}
}
},
"Sign": {
"type": "string",
"propertyOrder": 10,
"minLength": 3,
"maxLength": 10,
"format": "uppercase"
},
"Contact": {
"required": [
"Email",
"Gender",
"Name",
"Phone"
],
"type": "object",
"propertyOrder": 25,
"properties": {
"Phone": {
"type": "string"
},
"Fax": {
"type": "string"
},
"Name": {
"type": "string"
},
"Email": {
"type": "string",
"format": "email"
},
"Gender": {
"type": "string",
"enum": [
"",
"male",
"female"
]
},
"Sign": {
"type": "string",
"propertyOrder": 10,
"minLength": 3,
"maxLength": 10,
"format": "uppercase"
},
"Contact": {
"required": [
"Email",
"Gender",
"Name",
"Phone"
],
"type": "object",
"propertyOrder": 25,
"properties": {
"Phone": {
"type": "string"
},
"Fax": {
"type": "string"
},
"Name": {
"type": "string"
},
"Email": {
"type": "string",
"format": "email"
},
"Gender": {
"type": "string",
"enum": [
"",
"male",
"female"
]
}
}
}
},
"Address": {
"required": [
"Street",
"Town",
"Land",
"Category"
],
"type": "object",
"propertyOrder": 30,
"properties": {
"Town": {
"type": "string"
},
"Street": {
"type": "string"
},
"Land": {
"type": "string",
"enum": [
"",
"AU",
"BY",
"CH",
"CN",
"CO",
"CZ",
"DE",
"DK",
"ES",
"FI",
"FR",
"HU",
"IL",
"IT",
"LI",
"NL",
"PH",
"PL",
"SG",
"SI",
"TH",
"TW",
"UK",
"US",
"ZA"
],
"default": "DE"
},
"Zipcode": {
"type": "string"
},
"District": {
"type": "string"
},
"Category": {
"type": "string",
"enum": [
"",
"Inland",
"EU-Ausland",
"Ausland"
]
},
"Address": {
"required": [
"Street",
"Town",
"Land",
"Category"
],
"type": "object",
"propertyOrder": 30,
"properties": {
"Town": {
"type": "string"
},
"Street": {
"type": "string"
},
"Land": {
"type": "string",
"enum": "{{000_COUNTRIES@ENUM}}",
"default": "DE"
},
"Zipcode": {
"type": "string"
},
"District": {
"type": "string"
},
"Category": {
"type": "string",
"enum": [
"",
"Inland",
"EU-Ausland",
"Ausland"
]
}
}
}
}
}
} }
}
}
......@@ -36,33 +36,12 @@
},
"Standard": {
"type": "string",
"enum": [
"",
"SE2",
"SE1",
"CE3",
"FM1",
"TL2",
"FRS5",
"DKM_PPC4",
"FS250",
"MKT50",
"SE3"
],
"enum": "{{000_STANDARDS@ENUM}}",
"propertyOrder": 10
},
"Gas": {
"type": "string",
"enum": [
"",
"N2",
"Ar",
"He",
"H2",
"D2",
"Kr",
"Xe"
],
"enum": "{{000_GASES@ENUM}}",
"propertyOrder": 15
},
"Repeat": {
......@@ -79,16 +58,7 @@
},
"Type": {
"type": "string",
"enum": [
"",
"error",
"srg_error",
"sigma",
"flow",
"cf",
"conductanceflow",
"corr"
],
"enum": "{{000_TODOTYPES@ENUM}}",
"propertyOrder": 25
},
"Comment": {
......@@ -121,12 +91,7 @@
},
"Unit": {
"type": "string",
"enum": [
"",
"mbar",
"Pa",
"Torr"
]
"enum": "{{000_UNITS@ENUM@Pressure}}"
}
}
},
......@@ -149,11 +114,7 @@
},
"Unit": {
"type": "string",
"enum": [
"",
"C",
"K"
]
"enum": "{{000_UNITS@ENUM@Temperature}}"
}
}
}
......
# Rolf Niepraschk, 2017-09-17, Rolf.Niepraschk@ptb.de
local :
putdoc deploy http://localhost:5984/vl_db
server :
putdoc deploy http://a73434.berlin.ptb.de:5984/vl_db
.PHONY : deploy
# curl http://localhost:5984/vl_db/_design/editor-schema/_list/getSchema/all000?sel=000_SCHEMA-cob
# curl http://localhost:5984/vl_db/_design/editor-schema/_view/all000
_design/az/schema-jsoneditor
_design/editor-schema
// Rolf Niepraschk, 2017-09-25, Rolf.Niepraschk@ptb.de
function(head, req) {
var mainDocName = req.query.sel, mainDoc, docs = {}, key = '', row;
function sendError(s) {
var err = { error:'list_error', reason:s };
send(JSON.stringify(err) + '\n');
}
function getBracedVariable(s) {// "{{ foo }}" --> "foo", "bar" --> false
var re = /{{\s?([^}]*)\s?}}/,
x = typeof s == 'string' ? s.match(re) : false;
return x ? x[1] : x;
}
function getReplacement(doc, type, p1) {
// Liefert Datenstruktur je nach doc, type und ggf. subtype
var obj = docs[doc], ret = false, src;
///send(doc + ' *** ' + type + ' *** ' + p1 + '\n');
///send(JSON.stringify(obj) + '\n');
if (obj) {
switch (type) {
case 'ENUM':
ret = [];
switch (doc) {
case '000_COUNTRIES': // TODO: Dokument erneuern
ret = Object.keys(obj.Countries);
break
case '000_DEVICETYPES':
src = obj.DeviceTypes;
for (var i=0; i<src.length; i++) {
ret.push(src[i].Type);
}
break;
case '000_TODOTYPES':
src = obj.ToDoTypes;
for (var i=0; i<src.length; i++) {
ret.push(src[i].Type);
}
break;
case '000_CUSTOMERTYPES':
src = obj.CustomerTypes;
for (var i=0; i<src.length; i++) {
ret.push(src[i].Type);
}
break;
case '000_STANDARDS':
src = obj.Standards;
for (var i=0; i<src.length; i++) {
ret.push(src[i].Name);
}
break;
case '000_GASES':
src = obj.Gases;
for (var i=0; i<src.length; i++) {
ret.push(src[i]);
}
break;
case '000_UNITS':
src = obj.Units[p1];
for (var i=0; i<src.length; i++) {
ret.push(src[i]);
}
break; ;
}
break;
}
return ret;
} else false;
}
//https://stackoverflow.com/questions/2549320/looping-through-an-object-tree-recursively
//https://stackoverflow.com/questions/15502629/regex-for-mustache-style-double-braces
function eachRecursive(obj) {
var val = '', a, rep;
for (var k in obj) {
if (typeof obj[k] == 'object' && obj[k] !== null)
eachRecursive(obj[k]);
else {
val = getBracedVariable(obj[k]);
if (val) {// Ersetzen nötig?
a = val.split('@');
rep = getReplacement(a[0], a[1], a[2]);
if (rep) {
///send('rep:' + JSON.stringify(rep) + '\n');
obj[k] = rep;
}
}
}
}
}
start({"headers":{"Content-Type":"application/json"}});
while(row = getRow()) {// Speichern aller von View gelieferten Dokumente
docs[row.value._id] = row.value;
}
mainDoc = docs[mainDocName];
if (!mainDoc) {
sendError('Wrong or none main schema.');
return;
}
eachRecursive(mainDoc);
send(JSON.stringify(mainDoc) + '\n');
send('\n');
}
function(doc) {
if (doc._id.indexOf('000_') == 0) {
emit(null, doc);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment