|
@@ -96,13 +96,17 @@ String function cmd_define_attribute(write : Boolean, model : Element, element_n
|
|
|
if (write):
|
|
|
if (dict_in(model["model"], element_name)):
|
|
|
if (dict_in(model["model"], type)):
|
|
|
- Element attrs
|
|
|
- attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
|
|
|
- if (bool_not(set_in(dict_keys(attrs), attr_name))):
|
|
|
- model_define_attribute(model, element_name, attr_name, False, type)
|
|
|
- return "Success"!
|
|
|
+ //TODO automatically find name AttributeLink, as this might change with merging...
|
|
|
+ if (dict_in(model["metamodel"]["model"], "AttributeLink")):
|
|
|
+ Element attrs
|
|
|
+ attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
|
|
|
+ if (bool_not(set_in(dict_keys(attrs), attr_name))):
|
|
|
+ model_define_attribute(model, element_name, attr_name, False, type)
|
|
|
+ return "Success"!
|
|
|
+ else:
|
|
|
+ return "Attribute exists: " + attr_name!
|
|
|
else:
|
|
|
- return "Attribute exists: " + attr_name!
|
|
|
+ return "Not a SimpleClassDiagrams model!"!
|
|
|
else:
|
|
|
return "Element not found: " + type!
|
|
|
else:
|
|
@@ -165,26 +169,30 @@ String function cmd_attr_name(write : Boolean, model : Element, element_name : S
|
|
|
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)):
|
|
|
+ // TODO automatically find AttributeLink name
|
|
|
+ if (dict_in(model["metamodel"]["model"], "AttributeLink")):
|
|
|
+ attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
|
|
|
if (set_in(dict_keys(attrs), attr_name)):
|
|
|
- if (bool_not(set_in(dict_keys(attrs), new_attr_name))):
|
|
|
- if (dict_in(model["model"][element_name], attr_name)):
|
|
|
- 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, new_attr_name, optional, attrs[attr_name], attr_edge)
|
|
|
- return "Success"!
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ if (bool_not(set_in(dict_keys(attrs), new_attr_name))):
|
|
|
+ if (dict_in(model["model"][element_name], attr_name)):
|
|
|
+ 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, new_attr_name, optional, attrs[attr_name], attr_edge)
|
|
|
+ return "Success"!
|
|
|
+ else:
|
|
|
+ return "Attribute not defined here: " + new_attr_name!
|
|
|
else:
|
|
|
- return "Attribute not defined here: " + new_attr_name!
|
|
|
+ return "Attribute exists: " + new_attr_name!
|
|
|
else:
|
|
|
- return "Attribute exists: " + new_attr_name!
|
|
|
+ return "Attribute not found: " + attr_name!
|
|
|
else:
|
|
|
return "Attribute not found: " + attr_name!
|
|
|
else:
|
|
|
- return "Attribute not found: " + attr_name!
|
|
|
+ return "Not a SimpleClassDiagrams model!"!
|
|
|
else:
|
|
|
return "Element not found: " + element_name!
|
|
|
else:
|
|
@@ -194,23 +202,27 @@ String function cmd_attr_type(write : Boolean, model : Element, element_name : S
|
|
|
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)):
|
|
|
+ // TODO automatically find AttributeLink name
|
|
|
+ if (dict_in(model["metamodel"]["model"], "AttributeLink")):
|
|
|
+ attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
|
|
|
if (set_in(dict_keys(attrs), attr_name)):
|
|
|
- if (dict_in(model["model"][element_name], attr_name)):
|
|
|
- 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"!
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ if (dict_in(model["model"][element_name], attr_name)):
|
|
|
+ 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 here: " + attr_name!
|
|
|
else:
|
|
|
- return "Attribute not defined here: " + attr_name!
|
|
|
+ return "Attribute not defined: " + attr_name!
|
|
|
else:
|
|
|
- return "Attribute not defined: " + attr_name!
|
|
|
+ return "Attribute not found: " + attr_name!
|
|
|
else:
|
|
|
- return "Attribute not found: " + attr_name!
|
|
|
+ return "Not a SimpleClassDiagrams model!"!
|
|
|
else:
|
|
|
return "Element not found: " + element_name!
|
|
|
else:
|
|
@@ -220,21 +232,25 @@ String function cmd_attr_optional(write : Boolean, model : Element, element_name
|
|
|
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)):
|
|
|
+ // TODO automatically find AttributeLink name
|
|
|
+ if (dict_in(model["metamodel"]["model"], "AttributeLink")):
|
|
|
+ attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
|
|
|
if (set_in(dict_keys(attrs), attr_name)):
|
|
|
- if (dict_in(model["model"][element_name], attr_name)):
|
|
|
- String attr_edge
|
|
|
- attr_edge = reverseKeyLookup(model["model"], dict_read_edge(model["model"][element_name], attr_name))
|
|
|
- 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"!
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ if (dict_in(model["model"][element_name], attr_name)):
|
|
|
+ String attr_edge
|
|
|
+ attr_edge = reverseKeyLookup(model["model"], dict_read_edge(model["model"][element_name], attr_name))
|
|
|
+ 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 here: " + attr_name!
|
|
|
else:
|
|
|
- return "Attribute not defined here: " + attr_name!
|
|
|
+ return "Attribute not defined: " + attr_name!
|
|
|
else:
|
|
|
- return "Attribute not defined: " + attr_name!
|
|
|
+ return "Attribute not found: " + attr_name!
|
|
|
else:
|
|
|
- return "Attribute not found: " + attr_name!
|
|
|
+ return "Not a SimpleClassDiagrams model!"!
|
|
|
else:
|
|
|
return "Element not found: " + element_name!
|
|
|
else:
|
|
@@ -243,19 +259,23 @@ String function cmd_attr_optional(write : Boolean, model : Element, element_name
|
|
|
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)):
|
|
|
+ //TODO automatically find name AttributeLink, as this might change with merging...
|
|
|
+ if (dict_in(model["metamodel"]["model"], "AttributeLink")):
|
|
|
+ Element attrs
|
|
|
+ attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
|
|
|
if (set_in(dict_keys(attrs), attr_name)):
|
|
|
- if (dict_in(model["model"][element_name], attr_name)):
|
|
|
- model_undefine_attribute(model, element_name, attr_name)
|
|
|
- return "Success"!
|
|
|
+ if (set_in(dict_keys(attrs), attr_name)):
|
|
|
+ if (dict_in(model["model"][element_name], attr_name)):
|
|
|
+ model_undefine_attribute(model, element_name, attr_name)
|
|
|
+ return "Success"!
|
|
|
+ else:
|
|
|
+ return "Attribute not defined here: " + attr_name!
|
|
|
else:
|
|
|
- return "Attribute not defined here: " + attr_name!
|
|
|
+ return "Attribute not defined: " + attr_name!
|
|
|
else:
|
|
|
- return "Attribute not defined: " + attr_name!
|
|
|
+ return "Attribute not found: " + attr_name!
|
|
|
else:
|
|
|
- return "Attribute not found: " + attr_name!
|
|
|
+ return "Not a SimpleClassDiagrams model!"!
|
|
|
else:
|
|
|
return "Element not found: " + element_name!
|
|
|
else:
|
|
@@ -387,16 +407,20 @@ String function cmd_read_defined_attrs(model : Element, element_name : String):
|
|
|
|
|
|
result = "Success: "
|
|
|
if (dict_in(model["model"], element_name)):
|
|
|
- attr_list = getInstantiatableAttributes(model, element_name, "AttributeLink")
|
|
|
- optionality = getAttributeOptionality(model, element_name, "AttributeLink")
|
|
|
- attr_keys = dict_keys(attr_list)
|
|
|
- while (0 < set_len(attr_keys)):
|
|
|
- attr_key = set_pop(attr_keys)
|
|
|
- if (optionality[attr_key]):
|
|
|
- result = string_join(result, attr_key) + " ?: " + cast_string(attr_list[attr_key]) + "\n"
|
|
|
- else:
|
|
|
- result = string_join(result, attr_key) + " : " + cast_string(attr_list[attr_key]) + "\n"
|
|
|
- return result!
|
|
|
+ //TODO automatically find name AttributeLink, as this might change with merging...
|
|
|
+ if (dict_in(model["metamodel"]["model"], "AttributeLink")):
|
|
|
+ attr_list = getInstantiatableAttributes(model, element_name, "AttributeLink")
|
|
|
+ optionality = getAttributeOptionality(model, element_name, "AttributeLink")
|
|
|
+ attr_keys = dict_keys(attr_list)
|
|
|
+ while (0 < set_len(attr_keys)):
|
|
|
+ attr_key = set_pop(attr_keys)
|
|
|
+ if (optionality[attr_key]):
|
|
|
+ result = string_join(result, attr_key) + " ?: " + cast_string(attr_list[attr_key]) + "\n"
|
|
|
+ else:
|
|
|
+ result = string_join(result, attr_key) + " : " + cast_string(attr_list[attr_key]) + "\n"
|
|
|
+ return result!
|
|
|
+ else:
|
|
|
+ return "Not a SimpleClassDiagrams model!"!
|
|
|
else:
|
|
|
return "Element not found: " + element_name!
|
|
|
|