浏览代码

better elementselection in hostgraph

tpinna 10 年之前
父节点
当前提交
b03bd125e4
共有 1 个文件被更改,包括 20 次插入 和 16 次删除
  1. 20 16
      integration/code/pn_interface.alc

+ 20 - 16
integration/code/pn_interface.alc

@@ -20,12 +20,23 @@ Element function find_attribute_type_s(model : Element, elem : String, name : St
 	else:
 		return getName(model["metamodel"], read_edge_dst( dict_read_edge(mm_elem, name)))
 
-Element function getTypeName(model:Element, node:Element):
+//given a model and a node, it will return the name of it's type in the metamodel
+String function getTypeName(model:Element, node:Element):
 	return getName(model["metamodel"], dict_read_node(model["type_mapping"], node))
 
-Element function getMetaTypeName(model:Element, node:Element):
+//given a model and a node it will return the name of it's type in the metametamodel
+String function getMetaTypeName(model:Element, node:Element):
 	return getTypeName(model["metamodel"], dict_read_node(model["type_mapping"], node))
 
+Boolean function isAttributeRelated(model:Element, node:Element):
+	if(getMetaTypeName(model, node) == "Type"):
+		return True
+	elif(getMetaTypeName(model, node) == "l5"):
+		if(getMetaTypeName(model, read_edge_dst(node)) == "Type" ):
+			return True
+	return False
+
+
 //function to print information about a node (attributes, type and name)
 Element function printNode(tf_pn_model: Element, tf_pn_node: Element):
 	
@@ -41,8 +52,8 @@ Element function printNode(tf_pn_model: Element, tf_pn_node: Element):
 	String metatype
 	metatype = getMetaTypeName(tf_pn_model, tf_pn_node)
 	log(string_join("metatype: ",  metatype))
-	if (metatype == "l5"):
-		log(string_join("dest_metatype: ",  getMetaTypeName(tf_pn_model, read_edge_dst(tf_pn_node))))
+	if (isAttributeRelated(tf_pn_model, tf_pn_node)):
+		log(">attribute related")
 	
 	
 	//print attributes
@@ -94,18 +105,10 @@ Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Elem
 	Element tf_ma_ramified_node
 	while (integer_lt(0, list_len(tf_ma_pattern_edges))):
 		tf_ma_ramified_node = read_edge_dst(set_pop(tf_ma_pattern_edges))
-		printNode(tf_ma_transformation, tf_ma_ramified_node)
+		//printNode(tf_ma_transformation, tf_ma_ramified_node)
 		set_add(tf_ma_ramified_nodes, tf_ma_ramified_node)
 	
-	//find all nodes in the graph
-	//TODO: solve attributes
-	//	1) allow them as a separate node 
-	//		--> add them in the pattern too
-	//		--> increases complexity
-	//	2) don't allow them as a separate node
-	//		--> make sure only classes and edges are included below
-	//			--> hard: how to check if an element is an attribute or a link to an attribute?
-	//			--> breaks generality
+	//find all nodes in the graph that are not related to attributes: ie a userdefined type 
 	
 	log("=== finding nodes in host")
 	Element hostmodel_mm //metamodel of hostgraph
@@ -116,8 +119,9 @@ Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Elem
 	Element host_model_key
 	while (integer_lt(0, read_nr_out(hostmodel_keys))):
 		host_model_key = set_pop(hostmodel_keys)
-		printNode(tf_ma_model, tf_ma_model["model"][host_model_key])
-		set_add(host_nodes, tf_ma_model["model"][host_model_key])
+		if bool_not(isAttributeRelated(tf_ma_model, tf_ma_model["model"][host_model_key])):
+			//printNode(tf_ma_model, tf_ma_model["model"][host_model_key])
+			set_add(host_nodes, tf_ma_model["model"][host_model_key])
 	
 	// initialise the start-state