private Stream<ForeignKeyConstraint> extractMatchedFKsForARelation( DatabaseRelationDefinition leftRelation, Collection<ImmutableList<? extends VariableOrGroundTerm>> leftArgumentLists, ImmutableList<? extends VariableOrGroundTerm> rightArguments, DatabaseRelationDefinition rightRelation) { return leftRelation.getForeignKeys().stream() .filter(fk -> fk.getReferencedRelation().equals(rightRelation)) .filter(fk -> leftArgumentLists.stream() .anyMatch(leftArguments -> isFkMatching(fk, leftArguments, rightArguments))); }
public Map<String, ImmutableList<TargetAtom>> getRefAxioms(DatabaseRelationDefinition table) { Map<String, ImmutableList<TargetAtom>> refAxioms = new HashMap<>(); for (ForeignKeyConstraint fk : table.getForeignKeys()) refAxioms.put(getRefSQL(fk), getRefCQ(fk)); return refAxioms; }
public Map<String, ImmutableList<ImmutableFunctionalTerm>> getRefAxioms(DatabaseRelationDefinition table) { Map<String, ImmutableList<ImmutableFunctionalTerm>> refAxioms = new HashMap<>(); for (ForeignKeyConstraint fk : table.getForeignKeys()) refAxioms.put(getRefSQL(fk), getRefCQ(fk)); return refAxioms; }
@Override public String printKeys() { StringBuilder builder = new StringBuilder(); Collection<DatabaseRelationDefinition> table_list = getDatabaseRelations(); // Prints all primary keys builder.append("\n====== Unique constraints ==========\n"); for (DatabaseRelationDefinition dd : table_list) { builder.append(dd + ";\n"); for (UniqueConstraint uc : dd.getUniqueConstraints()) builder.append(uc + ";\n"); builder.append("\n"); } // Prints all foreign keys builder.append("====== Foreign key constraints ==========\n"); for(DatabaseRelationDefinition dd : table_list) { for (ForeignKeyConstraint fk : dd.getForeignKeys()) builder.append(fk + ";\n"); } return builder.toString(); }
@Override public String printKeys() { StringBuilder builder = new StringBuilder(); Collection<DatabaseRelationDefinition> table_list = getDatabaseRelations(); // Prints all primary keys builder.append("\n====== Unique constraints ==========\n"); for (DatabaseRelationDefinition dd : table_list) { builder.append(dd + ";\n"); for (UniqueConstraint uc : dd.getUniqueConstraints()) builder.append(uc + ";\n"); builder.append("\n"); } // Prints all foreign keys builder.append("====== Foreign key constraints ==========\n"); for(DatabaseRelationDefinition dd : table_list) { for (ForeignKeyConstraint fk : dd.getForeignKeys()) builder.append(fk + ";\n"); } return builder.toString(); }
private ImmutableSet<DataNode> findRedundantNodes(IntermediateQuery query, InnerJoinNode joinNode, ImmutableMultimap<DatabaseRelationDefinition, DataNode> dataNodeMap) { return dataNodeMap.keySet().stream() .flatMap(r -> r.getForeignKeys().stream() .flatMap(c -> selectRedundantNodesForConstraint(r, c, query, joinNode, dataNodeMap))) .collect(ImmutableCollectors.toSet()); }
@Override public Mapping saturate(Mapping mapping, DBMetadata dbMetadata, ClassifiedTBox saturatedTBox) { ImmutableList<LinearInclusionDependency> foreignKeyRules = dbMetadata.getDatabaseRelations().stream() .map(r -> r.getForeignKeys()) .flatMap(List::stream) .map(fk -> getLinearInclusionDependency(fk)) .collect(ImmutableCollectors.toList()); CQContainmentCheckUnderLIDs foreignKeyCQC = new CQContainmentCheckUnderLIDs(foreignKeyRules, datalogFactory, unifierUtilities, substitutionUtilities, termFactory); ImmutableList<CQIE> initialMappingRules = mapping2DatalogConverter.convert(mapping) .collect(ImmutableCollectors.toList()); ImmutableSet<CQIE> saturatedMappingRules = ImmutableSet.copyOf( tMappingProcessor.getTMappings(initialMappingRules, saturatedTBox, foreignKeyCQC, tMappingExclusionConfig)); return datalog2MappingConverter.convertMappingRules(ImmutableList.copyOf(saturatedMappingRules), mapping.getMetadata()); }
for (ForeignKeyConstraint fks : def.getForeignKeys()) {