|
@@ -212,10 +212,8 @@ String function cmd_attr_name(write : Boolean, model : Element, element_name : S
|
|
|
Element attrs
|
|
|
attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
|
|
|
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))
|
|
@@ -227,7 +225,6 @@ String function cmd_attr_name(write : Boolean, model : Element, element_name : S
|
|
|
return "Attribute already defined: " + new_attr_name!
|
|
|
else:
|
|
|
return "Attribute not defined: " + attr_name!
|
|
|
- return "Success"!
|
|
|
else:
|
|
|
return "Attribute not found: " + attr_name!
|
|
|
else:
|
|
@@ -241,9 +238,7 @@ String function cmd_attr_type(write : Boolean, model : Element, element_name : S
|
|
|
Element attrs
|
|
|
attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
|
|
|
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))
|
|
@@ -253,7 +248,6 @@ String function cmd_attr_type(write : Boolean, model : Element, element_name : S
|
|
|
return "Success"!
|
|
|
else:
|
|
|
return "Attribute not defined: " + attr_name!
|
|
|
- return "Success"!
|
|
|
else:
|
|
|
return "Attribute not found: " + attr_name!
|
|
|
else:
|
|
@@ -267,9 +261,7 @@ String function cmd_attr_optional(write : Boolean, model : Element, element_name
|
|
|
Element attrs
|
|
|
attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
|
|
|
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))
|
|
|
log("Was optional: " + cast_v2s(read_attribute(model, attr_edge, "optional")))
|
|
@@ -282,7 +274,25 @@ String function cmd_attr_optional(write : Boolean, model : Element, element_name
|
|
|
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_undefine_attribute(write : Boolean, model : Element, element_name : String, attr_name : String):
|
|
|
+ if (write):
|
|
|
+ if (dict_in(model["model"], element_name)):
|
|
|
+ Element attrs
|
|
|
+ attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ model_undefine_attribute(model, element_name, attr_name)
|
|
|
+ log("REMOVE OK")
|
|
|
+ return "Success"!
|
|
|
+ else:
|
|
|
+ return "Attribute not defined: " + attr_name!
|
|
|
else:
|
|
|
return "Attribute not found: " + attr_name!
|
|
|
else:
|
|
@@ -551,6 +561,8 @@ Element function modify(model : Element, write : Boolean):
|
|
|
output(cmd_all_instances(model, single_input("Type?")))
|
|
|
elif (cmd == "define_attribute"):
|
|
|
output(cmd_define_attribute(write, model, single_input("On which element?"), single_input("Attribute name?"), single_input("Type?")))
|
|
|
+ elif (cmd == "undefine_attribute"):
|
|
|
+ output(cmd_undefine_attribute(write, model, single_input("On which element?"), single_input("Attribute name?")))
|
|
|
else:
|
|
|
output("Unknown command while modelling: " + cmd)
|
|
|
output("Use command 'help' to get a list of available commands")
|