332 self._set_source_for_term(self.system_source, varobj) |
332 self._set_source_for_term(self.system_source, varobj) |
333 continue |
333 continue |
334 for i, sol in enumerate(self._solutions): |
334 for i, sol in enumerate(self._solutions): |
335 vartype = sol[varname] |
335 vartype = sol[varname] |
336 # skip final variable |
336 # skip final variable |
337 if eschema(vartype).is_final(): |
337 if eschema(vartype).final: |
338 break |
338 break |
339 for source in repo.sources: |
339 for source in repo.sources: |
340 if source.support_entity(vartype): |
340 if source.support_entity(vartype): |
341 # the source support the entity type, though we will |
341 # the source support the entity type, though we will |
342 # actually have to fetch from it only if |
342 # actually have to fetch from it only if |
379 termssources = {} |
379 termssources = {} |
380 for rel in self.rqlst.iget_nodes(Relation): |
380 for rel in self.rqlst.iget_nodes(Relation): |
381 # process non final relations only |
381 # process non final relations only |
382 # note: don't try to get schema for 'is' relation (not available |
382 # note: don't try to get schema for 'is' relation (not available |
383 # during bootstrap) |
383 # during bootstrap) |
384 if not rel.is_types_restriction() and not rschema(rel.r_type).is_final(): |
384 if not rel.is_types_restriction() and not rschema(rel.r_type).final: |
385 # nothing to do if relation is not supported by multiple sources |
385 # nothing to do if relation is not supported by multiple sources |
386 # or if some source has it listed in its cross_relations |
386 # or if some source has it listed in its cross_relations |
387 # attribute |
387 # attribute |
388 # |
388 # |
389 # XXX code below don't deal if some source allow relation |
389 # XXX code below don't deal if some source allow relation |
455 else: |
455 else: |
456 inserted = {} |
456 inserted = {} |
457 repo = self._repo |
457 repo = self._repo |
458 rschema = self._schema.rschema |
458 rschema = self._schema.rschema |
459 for rel in self.plan.rqlst.main_relations: |
459 for rel in self.plan.rqlst.main_relations: |
460 if not rschema(rel.r_type).is_final(): |
460 if not rschema(rel.r_type).final: |
461 # nothing to do if relation is not supported by multiple sources |
461 # nothing to do if relation is not supported by multiple sources |
462 if len(repo.rel_type_sources(rel.r_type)) < 2: |
462 if len(repo.rel_type_sources(rel.r_type)) < 2: |
463 continue |
463 continue |
464 lhs, rhs = rel.get_variable_parts() |
464 lhs, rhs = rel.get_variable_parts() |
465 try: |
465 try: |
728 self._exists_relation(rel, terms, needsel) |
728 self._exists_relation(rel, terms, needsel) |
729 # if relation is supported by all sources and some of |
729 # if relation is supported by all sources and some of |
730 # its lhs/rhs variable isn't in "terms", and the |
730 # its lhs/rhs variable isn't in "terms", and the |
731 # other end *is* in "terms", mark it have to be |
731 # other end *is* in "terms", mark it have to be |
732 # selected |
732 # selected |
733 if source.uri != 'system' and not rschema(rel.r_type).is_final(): |
733 if source.uri != 'system' and not rschema(rel.r_type).final: |
734 lhs, rhs = rel.get_variable_parts() |
734 lhs, rhs = rel.get_variable_parts() |
735 try: |
735 try: |
736 lhsvar = lhs.variable |
736 lhsvar = lhs.variable |
737 except AttributeError: |
737 except AttributeError: |
738 lhsvar = lhs |
738 lhsvar = lhs |
1001 inputmapkey = tuple(sorted(solindices)) |
1001 inputmapkey = tuple(sorted(solindices)) |
1002 inputmap = self._inputmaps.setdefault(inputmapkey, {}) |
1002 inputmap = self._inputmaps.setdefault(inputmapkey, {}) |
1003 for varname, mapping in step.outputmap.iteritems(): |
1003 for varname, mapping in step.outputmap.iteritems(): |
1004 if varname in inputmap and \ |
1004 if varname in inputmap and \ |
1005 not (mapping == inputmap[varname] or |
1005 not (mapping == inputmap[varname] or |
1006 self._schema.eschema(solutions[0][varname]).is_final()): |
1006 self._schema.eschema(solutions[0][varname]).final): |
1007 self._conflicts.append((varname, inputmap[varname])) |
1007 self._conflicts.append((varname, inputmap[varname])) |
1008 inputmap.update(step.outputmap) |
1008 inputmap.update(step.outputmap) |
1009 self.plan.add_step(step) |
1009 self.plan.add_step(step) |
1010 |
1010 |
1011 |
1011 |
1357 if not source.support_relation(rtype) or ( |
1357 if not source.support_relation(rtype) or ( |
1358 rtype in source.cross_relations and not relation in self.terms): |
1358 rtype in source.cross_relations and not relation in self.terms): |
1359 return False |
1359 return False |
1360 if not self.final and not relation in self.terms: |
1360 if not self.final and not relation in self.terms: |
1361 rschema = self.schema.rschema(relation.r_type) |
1361 rschema = self.schema.rschema(relation.r_type) |
1362 if not rschema.is_final(): |
1362 if not rschema.final: |
1363 for term in relation.get_nodes((VariableRef, Constant)): |
1363 for term in relation.get_nodes((VariableRef, Constant)): |
1364 term = getattr(term, 'variable', term) |
1364 term = getattr(term, 'variable', term) |
1365 termsources = sorted(set(x[0] for x in self.ppi._term_sources(term))) |
1365 termsources = sorted(set(x[0] for x in self.ppi._term_sources(term))) |
1366 if termsources and termsources != self.sources: |
1366 if termsources and termsources != self.sources: |
1367 return False |
1367 return False |
1368 return True |
1368 return True |
1369 |
1369 |
1370 def visit_relation(self, node, newroot, terms): |
1370 def visit_relation(self, node, newroot, terms): |
1371 if not node.is_types_restriction(): |
1371 if not node.is_types_restriction(): |
1372 if node in self.skip and self.solindices.issubset(self.skip[node]): |
1372 if node in self.skip and self.solindices.issubset(self.skip[node]): |
1373 if not self.schema.rschema(node.r_type).is_final(): |
1373 if not self.schema.rschema(node.r_type).final: |
1374 # can't really skip the relation if one variable is selected and only |
1374 # can't really skip the relation if one variable is selected and only |
1375 # referenced by this relation |
1375 # referenced by this relation |
1376 for vref in node.iget_nodes(VariableRef): |
1376 for vref in node.iget_nodes(VariableRef): |
1377 stinfo = vref.variable.stinfo |
1377 stinfo = vref.variable.stinfo |
1378 if stinfo['selected'] and len(stinfo['relations']) == 1: |
1378 if stinfo['selected'] and len(stinfo['relations']) == 1: |
1401 # introduced variable refs |
1401 # introduced variable refs |
1402 for vref in self._pending_vrefs: |
1402 for vref in self._pending_vrefs: |
1403 vref.unregister_reference() |
1403 vref.unregister_reference() |
1404 raise |
1404 raise |
1405 ored = node.ored() |
1405 ored = node.ored() |
1406 if rschema.is_final() or rschema.inlined: |
1406 if rschema.final or rschema.inlined: |
1407 vrefs = node.children[1].get_nodes(VariableRef) |
1407 vrefs = node.children[1].get_nodes(VariableRef) |
1408 if not vrefs: |
1408 if not vrefs: |
1409 if not ored: |
1409 if not ored: |
1410 self.skip.setdefault(node, set()).update(self.solindices) |
1410 self.skip.setdefault(node, set()).update(self.solindices) |
1411 else: |
1411 else: |