@Override public String toString() { if (dependencies != null) return dependencies.toString(); return "(empty)"; } }
for (CQIE rule : sigma.getRules(atom.getFunctionSymbol())) {
@Override public Mapping saturate(Mapping mapping, DBMetadata dbMetadata, ClassifiedTBox saturatedTBox) { ImmutableList<CQIE> initialMappingRules = mapping2DatalogConverter.convert(mapping) .collect(ImmutableCollectors.toList()); LinearInclusionDependencies foreignKeyRules = new LinearInclusionDependencies(dbMetadata.generateFKRules()); CQContainmentCheckUnderLIDs foreignKeyCQC = new CQContainmentCheckUnderLIDs(foreignKeyRules); ImmutableSet<CQIE> saturatedMappingRules = TMappingProcessor.getTMappings(initialMappingRules, saturatedTBox, foreignKeyCQC, tMappingExclusionConfig).stream() .collect(ImmutableCollectors.toSet()); List<CQIE> allMappingRules = new ArrayList<>(saturatedMappingRules); allMappingRules.addAll(generateTripleMappings(saturatedMappingRules)); return datalog2MappingConverter.convertMappingRules(ImmutableList.copyOf(allMappingRules), dbMetadata, mapping.getExecutorRegistry(), mapping.getMetadata()); }
/** * This method is used to chase foreign key constraint rule in which the rule * has only one atom in the body. * * IMPORTANT: each rule is applied only ONCE to each atom * * @param atoms * @return set of atoms */ private Set<Function> chaseAtoms(Collection<Function> atoms) { Set<Function> derivedAtoms = new HashSet<>(); for (Function fact : atoms) { derivedAtoms.add(fact); for (CQIE rule : dependencies.getRules(fact.getFunctionSymbol())) { rule = DATALOG_FACTORY.getFreshCQIECopy(rule); Function ruleBody = rule.getBody().get(0); Substitution theta = UnifierUtilities.getMGU(ruleBody, fact); if (theta != null && !theta.isEmpty()) { Function ruleHead = rule.getHead(); Function newFact = (Function)ruleHead.clone(); // unify to get fact is needed because the dependencies are not necessarily full // (in other words, they may contain existentials in the head) SubstitutionUtilities.applySubstitution(newFact, theta); derivedAtoms.add(newFact); } } } return derivedAtoms; }