|
@@ -206,6 +206,86 @@ String function cmd_attr_del(write : Boolean, model : Element, element_name : St
|
|
|
else:
|
|
|
return "Permission denied to write"!
|
|
|
|
|
|
+String function cmd_attr_name(write : Boolean, model : Element, element_name : String, attr_name : String, new_attr_name : String):
|
|
|
+ if (write):
|
|
|
+ if (dict_in(model["model"], element_name)):
|
|
|
+ Element attrs
|
|
|
+ attrs = getAttributeList(model, element_name)
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ //TODO this can be more interesting if we keep the IDs in the model, thereby preventing problems with language evolution
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ if (bool_not(set_in(dict_keys(attrs), new_attr_name))):
|
|
|
+ // TODO use a cleaner way of deleting the attribute
|
|
|
+ Boolean optional
|
|
|
+ String attr_edge
|
|
|
+ attr_edge = reverseKeyLookup(model["model"], dict_read_edge(model["model"][element_name], attr_name))
|
|
|
+ optional = read_attribute(model, attr_edge, "optional")
|
|
|
+ model_undefine_attribute(model, element_name, attr_name)
|
|
|
+ model_define_attribute_ID(model, element_name, attr_name, optional, attrs[attr_name], attr_edge)
|
|
|
+ return "Success"!
|
|
|
+ else:
|
|
|
+ return "Attribute already defined: " + new_attr_name!
|
|
|
+ else:
|
|
|
+ return "Attribute not defined: " + attr_name!
|
|
|
+ return "Success"!
|
|
|
+ else:
|
|
|
+ return "Attribute not found: " + attr_name!
|
|
|
+ else:
|
|
|
+ return "Element not found: " + element_name!
|
|
|
+ else:
|
|
|
+ return "Permission denied to write"!
|
|
|
+
|
|
|
+String function cmd_attr_type(write : Boolean, model : Element, element_name : String, attr_name : String, new_attr_type : String):
|
|
|
+ if (write):
|
|
|
+ if (dict_in(model["model"], element_name)):
|
|
|
+ Element attrs
|
|
|
+ attrs = getAttributeList(model, element_name)
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ //TODO this can be more interesting if we keep the IDs in the model, thereby preventing problems with language evolution
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ // TODO use a cleaner way of deleting the attribute
|
|
|
+ Boolean optional
|
|
|
+ String attr_edge
|
|
|
+ attr_edge = reverseKeyLookup(model["model"], dict_read_edge(model["model"][element_name], attr_name))
|
|
|
+ optional = read_attribute(model, attr_edge, "optional")
|
|
|
+ model_undefine_attribute(model, element_name, attr_name)
|
|
|
+ model_define_attribute_ID(model, element_name, attr_name, optional, new_attr_type, attr_edge)
|
|
|
+ return "Success"!
|
|
|
+ else:
|
|
|
+ return "Attribute not defined: " + attr_name!
|
|
|
+ return "Success"!
|
|
|
+ else:
|
|
|
+ return "Attribute not found: " + attr_name!
|
|
|
+ else:
|
|
|
+ return "Element not found: " + element_name!
|
|
|
+ else:
|
|
|
+ return "Permission denied to write"!
|
|
|
+
|
|
|
+String function cmd_attr_optional(write : Boolean, model : Element, element_name : String, attr_name : String, optional : Boolean):
|
|
|
+ if (write):
|
|
|
+ if (dict_in(model["model"], element_name)):
|
|
|
+ Element attrs
|
|
|
+ attrs = getAttributeList(model, element_name)
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ //TODO this can be more interesting if we keep the IDs in the model, thereby preventing problems with language evolution
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ // TODO use a cleaner way of deleting the attribute
|
|
|
+ String attr_edge
|
|
|
+ attr_edge = reverseKeyLookup(model["model"], dict_read_edge(model["model"][element_name], attr_name))
|
|
|
+ optional = read_attribute(model, attr_edge, "optional")
|
|
|
+ model_undefine_attribute(model, element_name, attr_name)
|
|
|
+ model_define_attribute_ID(model, element_name, attr_name, optional, attrs[attr_name], attr_edge)
|
|
|
+ return "Success"!
|
|
|
+ else:
|
|
|
+ return "Attribute not defined: " + attr_name!
|
|
|
+ return "Success"!
|
|
|
+ else:
|
|
|
+ return "Attribute not found: " + attr_name!
|
|
|
+ else:
|
|
|
+ return "Element not found: " + element_name!
|
|
|
+ else:
|
|
|
+ return "Permission denied to write"!
|
|
|
+
|
|
|
String function cmd_delete(write : Boolean, model : Element, element_name : String):
|
|
|
if (write):
|
|
|
if (dict_in(model["model"], element_name)):
|
|
@@ -426,7 +506,13 @@ Element function modify(model : Element, write : Boolean):
|
|
|
elif (cmd == "attr_add_code"):
|
|
|
output(cmd_attr_add_code(write, model, single_input("Name?"), single_input("Attribute name?")))
|
|
|
elif (cmd == "attr_del"):
|
|
|
- output(cmd_attr_del(write, model, single_input("Name?"), single_input("Attribute_name?")))
|
|
|
+ output(cmd_attr_del(write, model, single_input("Name?"), single_input("Attribute name?")))
|
|
|
+ elif (cmd == "attr_name"):
|
|
|
+ output(cmd_attr_name(write, model, single_input("Name?"), single_input("Attribute name?"), single_input("New name?")))
|
|
|
+ elif (cmd == "attr_type"):
|
|
|
+ output(cmd_attr_type(write, model, single_input("Name?"), single_input("Attribute name?"), single_input("Type name?")))
|
|
|
+ elif (cmd == "attr_optional"):
|
|
|
+ output(cmd_attr_optional(write, model, single_input("Name?"), single_input("Attribute name?"), cast_s2b(single_input("Optional?"))))
|
|
|
elif (cmd == "delete"):
|
|
|
output(cmd_delete(write, model, single_input("Name?")))
|
|
|
elif (cmd == "nice_list"):
|