diff --git a/hydra_agent/classes_objects.py b/hydra_agent/classes_objects.py index 1b8dc29..02d99e8 100644 --- a/hydra_agent/classes_objects.py +++ b/hydra_agent/classes_objects.py @@ -188,6 +188,13 @@ def load_from_server( # save the new data. self.redis_graph.commit() + def connect_nodes(self, endpoint_properties, node_alias): + for class_endpoint in endpoint_properties: + src_node = node_alias.get(class_endpoint) + for endpoint in endpoint_properties[class_endpoint]: + node = node_alias.get(endpoint) + self.addEdge(src_node, 'has_endpoint_property', node) + def endpointclasses( self, entrypoint_node, @@ -200,6 +207,7 @@ def endpointclasses( """ print("classes endpoint or accessing classes") endpoint_property_list = {} + node_alias = {} # endpoint_property_list contain all endpoints # which have other endpoints as a property ex: State. for endpoint in self.class_endpoints: @@ -230,19 +238,5 @@ def endpointclasses( "classes", str(endpoint), node_properties) # set edge between the entrypoint and the class endpoint. self.addEdge(entrypoint_node, "has" + endpoint, class_object_node) - - # for connect the nodes to endpoint which have endpoint as a property. - if endpoint_property_list: - for endpoint_property in endpoint_property_list: - for src_node in self.redis_graph.nodes.values(): - if str(endpoint_property) == src_node.alias: - for endpoints in endpoint_property_list[ - endpoint_property]: - for nodes in self.redis_graph.nodes.values(): - if endpoints == nodes.alias: - self.addEdge( - src_node, - "has_endpoint_property", - nodes) - break - break + node_alias[str(endpoint)] = class_object_node + self.connect_nodes(endpoint_property_list, node_alias) diff --git a/hydra_agent/hydra_graph.py b/hydra_agent/hydra_graph.py index 1d380a0..414c747 100644 --- a/hydra_agent/hydra_graph.py +++ b/hydra_agent/hydra_graph.py @@ -55,7 +55,6 @@ def get_endpoints(self,api_doc, redis_connection): alias="Entrypoint", properties=entrypoint_properties) self.redis_graph.add_node(entrypoint_node) - redis_connection.set("EntryPoint", entrypoint_properties) return self.get_apistructure(entrypoint_node, api_doc)