|
@@ -15,6 +15,43 @@ Element core = ?
|
|
|
String core_location = "models/CoreFormalism"
|
|
|
String core_model_location = "core"
|
|
|
|
|
|
+String function JSON_print(model : Element):
|
|
|
+ String result
|
|
|
+ Element keys_m
|
|
|
+ String v_m
|
|
|
+ String type
|
|
|
+ String attr_key
|
|
|
+ Element attr_keys
|
|
|
+
|
|
|
+ result = "["
|
|
|
+ keys_m = dict_keys(model["model"])
|
|
|
+
|
|
|
+ while (read_nr_out(keys_m) > 0):
|
|
|
+ v_m = set_pop(keys_m)
|
|
|
+ type = read_type(model["metamodel"], read_type(model, v_m))
|
|
|
+
|
|
|
+ if (bool_or(type == "Class", type == "Association")):
|
|
|
+ result = result + "{"
|
|
|
+ result = (((result + "\"id\": \"") + v_m) + "\"") + ","
|
|
|
+ result = (((result + "\"type\": \"") + read_type(model, v_m)) + "\"") + ","
|
|
|
+ if (type == "Association"):
|
|
|
+ result = ((result + "\"__source\": \"") + reverseKeyLookup(model["model"], read_edge_src(model["model"][v_m]))) + "\","
|
|
|
+ result = ((result + "\"__target\": \"") + reverseKeyLookup(model["model"], read_edge_dst(model["model"][v_m]))) + "\","
|
|
|
+
|
|
|
+ // Has attributes
|
|
|
+ attr_keys = dict_keys(getAttributeList(model, v_m))
|
|
|
+ while (0 < read_nr_out(attr_keys)):
|
|
|
+ attr_key = set_pop(attr_keys)
|
|
|
+ result = ((((result + "\"") + attr_key) + "\": ") + cast_v2s(read_attribute(model, v_m, attr_key))) + ","
|
|
|
+
|
|
|
+ result = result + "}"
|
|
|
+
|
|
|
+ if (read_nr_out(keys_m) > 0):
|
|
|
+ result = result + ","
|
|
|
+ result = result + "]"
|
|
|
+
|
|
|
+ return result!
|
|
|
+
|
|
|
Void function main():
|
|
|
// Initialize the Core Formalism
|
|
|
String core_model
|
|
@@ -904,7 +941,7 @@ Void function user_function_skip_init(user_id : String):
|
|
|
|
|
|
// Also output the resulting model
|
|
|
output("Mapping success")
|
|
|
- output(pretty_print(get_full_model(get_model_id(rendered_name))))
|
|
|
+ output(JSON_print(get_full_model(get_model_id(rendered_name))))
|
|
|
|
|
|
else:
|
|
|
output("Permission denied")
|