Merge "bugs fixes:" into stable/ocata

This commit is contained in:
Jenkins 2017-04-27 06:47:14 +00:00 committed by Gerrit Code Review
commit a1945b5b0b
3 changed files with 32 additions and 5 deletions

View File

@ -163,7 +163,9 @@ class ScenarioEvaluator(object):
if matches:
for match in matches:
spec, action_id = self._get_action_spec(action, match)
match_hash = hash(tuple(sorted(match.items())))
items_ids = \
[match[1].vertex_id for match in match.items()]
match_hash = hash(tuple(sorted(items_ids)))
actions[action_id] = \
ActionInfo(spec, mode, scenario.id, match_hash)
return actions
@ -211,6 +213,7 @@ class ScenarioEvaluator(object):
if term.type == ENTITY:
term.variable[VProps.IS_DELETED] = False
term.variable[VProps.IS_PLACEHOLDER] = False
condition_g.add_vertex(term.variable)
else: # type = relationship
@ -228,7 +231,9 @@ class ScenarioEvaluator(object):
@staticmethod
def _set_relationship_not_deleted(edge_description):
edge_description.source[VProps.IS_DELETED] = False
edge_description.source[VProps.IS_PLACEHOLDER] = False
edge_description.target[VProps.IS_DELETED] = False
edge_description.target[VProps.IS_PLACEHOLDER] = False
edge_description.edge[EProps.IS_DELETED] = False
@staticmethod

View File

@ -129,7 +129,7 @@ class ScenarioRepository(object):
key = self._create_edge_scenario_key(edge_desc)
scenarios = self.relationship_scenarios[key]
if not self.contains(scenarios, scenario):
if not self._edge_contains(scenarios, scenario, edge_desc):
self.relationship_scenarios[key].append((edge_desc, scenario))
@staticmethod
@ -144,9 +144,17 @@ class ScenarioRepository(object):
key = frozenset(list(entity.properties.items()))
scenarios = self.entity_scenarios[key]
if not self.contains(scenarios, scenario):
if not self._entity_contains(scenarios, scenario, entity):
self.entity_scenarios[key].append((entity, scenario))
@staticmethod
def contains(scenarios, scenario):
return any(s[1].id == scenario.id for s in scenarios)
def _edge_contains(scenarios, scenario, edge):
return any(e.edge.source_id == edge.edge.source_id and
e.edge.target_id == edge.edge.target_id and
e.edge.label == edge.edge.label and s.id == scenario.id
for e, s in scenarios)
@staticmethod
def _entity_contains(scenarios, scenario, entity):
return any(e.vertex_id == entity.vertex_id and s.id == scenario.id
for e, s in scenarios)

View File

@ -111,6 +111,10 @@ def subgraph_matching(base_graph, subgraph, matches, validate=False):
v_id=v_with_unmapped_neighbors[MAPPED_V_ID],
vertex_attr_filter=subgraph_vertex_to_map)
graph_candidate_vertices = \
_remove_used_graph_candidates(graph_candidate_vertices,
curr_subgraph)
# STEP 5: STRUCTURE CHECK
edges = _get_edges_to_mapped_vertices(curr_subgraph,
subgraph_vertex_to_map.vertex_id)
@ -239,3 +243,13 @@ def _update_mapping_for_edge(known_match, mapping, graph, validate):
t_id = known_match.graph_element.target_id
sub_t_id = known_match.subgraph_element.target_id
return _update_mapping(mapping, graph, sub_t_id, t_id, validate)
def _remove_used_graph_candidates(graph_candidate_vertices, curr_subgraph):
ver_to_remove = []
for candidate in graph_candidate_vertices:
for sub_ver in curr_subgraph.get_vertices():
if sub_ver.get(GRAPH_VERTEX, False) and \
sub_ver[GRAPH_VERTEX].vertex_id == candidate.vertex_id:
ver_to_remove.append(candidate)
return [v for v in graph_candidate_vertices if v not in ver_to_remove]