|
@@ -146,52 +146,58 @@ Element function petrinet_loaded(model : Element):
|
|
|
output("Type to instantiate?")
|
|
|
mm_type_name = input()
|
|
|
if (dict_in(model["metamodel"]["model"], mm_type_name)):
|
|
|
- metamodel_element_pn = model["metamodel"]["model"][mm_type_name]
|
|
|
String element_name
|
|
|
output("Name of new element?")
|
|
|
element_name = input()
|
|
|
if (dict_in(model["model"], element_name)):
|
|
|
output("Element already exists; aborting")
|
|
|
else:
|
|
|
- Boolean cnt
|
|
|
- cnt = True
|
|
|
- Element additional_opts
|
|
|
- additional_opts = create_node()
|
|
|
if (is_edge(metamodel_element_pn)):
|
|
|
output("Source name?")
|
|
|
String src_name
|
|
|
src_name = input()
|
|
|
if (dict_in(model["model"], src_name)):
|
|
|
- list_append(additional_opts, model["model"][src_name])
|
|
|
output("Destination name?")
|
|
|
String dst_name
|
|
|
dst_name = input()
|
|
|
if (dict_in(model["model"], dst_name)):
|
|
|
- list_append(additional_opts, model["model"][dst_name])
|
|
|
+ instantiate_link(model, mm_type_name, element_name, src_name, dst_name)
|
|
|
+ output("Instantiation successful!")
|
|
|
+ if (dict_in(model["model"], element_name)):
|
|
|
+ output("Instantiation successful!")
|
|
|
+ else:
|
|
|
+ output("Instantiation error!")
|
|
|
else:
|
|
|
output("Unknown destination; aborting")
|
|
|
- cnt = False
|
|
|
else:
|
|
|
output("Unknown source; aborting")
|
|
|
- cnt = False
|
|
|
- if (has_value(metamodel_element_pn)):
|
|
|
- // It is a value
|
|
|
- output("Value?")
|
|
|
- list_append(additional_opts, input())
|
|
|
- if (cnt):
|
|
|
- //attr_list_pn = getAttributeList(model, metamodel_element_pn)
|
|
|
- //attr_keys_pn = dict_keys(attr_list_pn)
|
|
|
- //Element attrs
|
|
|
- //attrs = create_node()
|
|
|
- //while (0 < read_nr_out(attr_keys_pn)):
|
|
|
- // attr_key_pn = set_pop(attr_keys_pn)
|
|
|
- // output(((attr_key_pn + " : ") + cast_e2s(attr_list_pn[attr_key_pn])) + "?")
|
|
|
- // dict_add(attrs, attr_key_pn, input())
|
|
|
- //Element resulting_element
|
|
|
- //resulting_element = instantiate_model_lib(model, metamodel_element_pn, element_name, additional_opts, create_node(), attrs)
|
|
|
- output("Instantiation successful!")
|
|
|
+ else:
|
|
|
+ instantiate_node(model, mm_type_name, element_name)
|
|
|
+ if (dict_in(model["model"], element_name)):
|
|
|
+ output("Instantiation successful!")
|
|
|
+ else:
|
|
|
+ output("Instantiation error!")
|
|
|
else:
|
|
|
output("Unknown type specified; aborting")
|
|
|
+ elif (cmd == "attr_add"):
|
|
|
+ String model_name
|
|
|
+ output("Which model do you want to assign an attribute to?")
|
|
|
+ model_name = input()
|
|
|
+ if (dict_in(model["model"], model_name)):
|
|
|
+ Element attrs
|
|
|
+ attrs = getAttributeList(model, model_name)
|
|
|
+ output(print_dict(attrs))
|
|
|
+ String attr_name
|
|
|
+ output("Which attribute do you wish to assign?")
|
|
|
+ attr_name = input()
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ output("Value of attribute?")
|
|
|
+ instantiate_attribute(model, model_name, attr_name, input())
|
|
|
+ output("Added attribute!")
|
|
|
+ else:
|
|
|
+ output("No such attribute!")
|
|
|
+ else:
|
|
|
+ output("No such model!")
|
|
|
elif (cmd == "delete"):
|
|
|
output("What is the name of the element you want to delete?")
|
|
|
cmd = input()
|
|
@@ -200,31 +206,6 @@ Element function petrinet_loaded(model : Element):
|
|
|
output("Deleted!")
|
|
|
else:
|
|
|
output("No such element; aborting")
|
|
|
- elif (cmd == "modify"):
|
|
|
- output("Element to modify?")
|
|
|
- cmd = input()
|
|
|
- if (dict_in(model["model"], cmd)):
|
|
|
- Element mod
|
|
|
- mod = model["model"][cmd]
|
|
|
- metamodel_element_pn = dict_read_node(model["type_mapping"], mod)
|
|
|
-
|
|
|
- attr_list_pn = getAttributeList(model, metamodel_element_pn)
|
|
|
- attr_keys_pn = dict_keys(attr_list_pn)
|
|
|
- while (0 < read_nr_out(attr_keys_pn)):
|
|
|
- attr_key_pn = set_pop(attr_keys_pn)
|
|
|
- output(((" " + attr_key_pn) + " : ") + cast_e2s(attr_list_pn[attr_key_pn]))
|
|
|
-
|
|
|
- output("Attribute to modify?")
|
|
|
- String attr_name
|
|
|
- attr_name = input()
|
|
|
- if (set_in(dict_keys(getAttributeList(model, metamodel_element_pn)), attr_name)):
|
|
|
- output("New value?")
|
|
|
- //setAttribute(model, mod, attr_name, input())
|
|
|
- output("Modified!")
|
|
|
- else:
|
|
|
- output("Unknown attribute; aborting")
|
|
|
- else:
|
|
|
- output("Element does not exist; aborting")
|
|
|
elif (cmd == "rename"):
|
|
|
output("Old name?")
|
|
|
String old_name_e
|
|
@@ -274,7 +255,7 @@ Element function petrinet_loaded(model : Element):
|
|
|
attr_key_pn = set_pop(attr_keys_pn)
|
|
|
output((((" " + attr_key_pn) + " : ") + cast_e2s(attr_list_pn[attr_key_pn])))
|
|
|
output("Attributes:")
|
|
|
- attr_list_pn = getAttributeList(model, metamodel_element_pn)
|
|
|
+ attr_list_pn = getAttributeList(model, read_elem)
|
|
|
attr_keys_pn = dict_keys(attr_list_pn)
|
|
|
while (0 < read_nr_out(attr_keys_pn)):
|
|
|
attr_key_pn = set_pop(attr_keys_pn)
|