|
@@ -27,23 +27,24 @@ Element function modify(model : Element, write : Boolean):
|
|
|
output("Allowed operations:")
|
|
|
if (write):
|
|
|
output(" == READ/WRITE ==")
|
|
|
- output(" instantiate -- Create a new model element")
|
|
|
- output(" delete -- Delete an existing element")
|
|
|
- output(" attr_add -- Add an attribute to an element")
|
|
|
- output(" attr_del -- Delete an attribute of an element")
|
|
|
- output(" attr_modify -- Modify an attribute of an element")
|
|
|
- output(" constrain -- Add a constraint function to the model")
|
|
|
- output(" rename -- Rename an existing element")
|
|
|
- output(" modify -- Modify the attributes of an element")
|
|
|
- output(" retype -- Change the type of an element")
|
|
|
+ output(" instantiate -- Create a new model element")
|
|
|
+ output(" delete -- Delete an existing element")
|
|
|
+ output(" attr_add -- Add an attribute to an element")
|
|
|
+ output(" attr_add_code -- Add a coded attribute to an element")
|
|
|
+ output(" attr_del -- Delete an attribute of an element")
|
|
|
+ output(" attr_modify -- Modify an attribute of an element")
|
|
|
+ output(" constrain -- Add a constraint function to the model")
|
|
|
+ output(" rename -- Rename an existing element")
|
|
|
+ output(" modify -- Modify the attributes of an element")
|
|
|
+ output(" retype -- Change the type of an element")
|
|
|
else:
|
|
|
output(" == READ-ONLY ==")
|
|
|
- output(" list -- Prints the list of elements in the model")
|
|
|
- output(" list_full -- Prints the list of all elements in the model")
|
|
|
- output(" types -- Prints the list of elements that can be instantiated")
|
|
|
- output(" read -- Prints the current state of a model element")
|
|
|
- output(" verify -- Check whether the model conforms to the metamodel")
|
|
|
- output(" exit -- Leave the modification interface")
|
|
|
+ output(" list -- Prints the list of elements in the model")
|
|
|
+ output(" list_full -- Prints the list of all elements in the model")
|
|
|
+ output(" types -- Prints the list of elements that can be instantiated")
|
|
|
+ output(" read -- Prints the current state of a model element")
|
|
|
+ output(" verify -- Check whether the model conforms to the metamodel")
|
|
|
+ output(" exit -- Leave the modification interface")
|
|
|
elif (cmd == "exit"):
|
|
|
return model!
|
|
|
elif (cmd == "instantiate"):
|
|
@@ -82,27 +83,6 @@ Element function modify(model : Element, write : Boolean):
|
|
|
else:
|
|
|
output("Permission denied")
|
|
|
|
|
|
- elif (cmd == "constrain"):
|
|
|
- if (write):
|
|
|
- output("Element to constrain (empty for global)?")
|
|
|
- String model_name
|
|
|
- model_name = input()
|
|
|
-
|
|
|
- if (model_name == ""):
|
|
|
- // Global constraint
|
|
|
- output("Give input to function constructors for GLOBAL constraint!")
|
|
|
- set_model_constraints(model, construct_function())
|
|
|
- elif (dict_in(model["model"], model_name)):
|
|
|
- // Local constraint for this model
|
|
|
- output("Give input to function constructors for LOCAL constraint!")
|
|
|
- add_constraint(model, model_name, construct_function())
|
|
|
- output("Added constraint to model!")
|
|
|
- else:
|
|
|
- // Local constraint, but model not found
|
|
|
- output("Unknown model; aborting")
|
|
|
- else:
|
|
|
- output("Permission denied")
|
|
|
-
|
|
|
elif (cmd == "attr_modify"):
|
|
|
if (write):
|
|
|
String model_name
|
|
@@ -148,6 +128,28 @@ Element function modify(model : Element, write : Boolean):
|
|
|
else:
|
|
|
output("Permission denied")
|
|
|
|
|
|
+ elif (cmd == "attr_add_code"):
|
|
|
+ if (write):
|
|
|
+ String model_name
|
|
|
+ output("Which model do you want to assign a coded attribute to?")
|
|
|
+ model_name = input()
|
|
|
+ if (dict_in(model["model"], model_name)):
|
|
|
+ Element attrs
|
|
|
+ attrs = getAttributeList(model, model_name)
|
|
|
+ String attr_name
|
|
|
+ output("Which attribute do you wish to assign?")
|
|
|
+ attr_name = input()
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ output("Waiting for code constructors...")
|
|
|
+ instantiate_attribute_code(model, model_name, attr_name, input())
|
|
|
+ output("Added attribute!")
|
|
|
+ else:
|
|
|
+ output("No such attribute!")
|
|
|
+ else:
|
|
|
+ output("No such model!")
|
|
|
+ else:
|
|
|
+ output("Permission denied")
|
|
|
+
|
|
|
elif (cmd == "attr_del"):
|
|
|
if (write):
|
|
|
String model_name
|