@Override public Mapping merge(ImmutableSet<Mapping> mappings) { if (mappings.isEmpty()) { throw new IllegalArgumentException("The set of mappings is assumed to be nonempty"); } MappingMetadata metadata = mergeMetadata(mappings); ImmutableTable<RDFAtomPredicate, IRI, IQ> propertyTable = mergeMappingPropertyTables(mappings); ImmutableTable<RDFAtomPredicate, IRI, IQ> classTable = mergeMappingClassTables(mappings); return specificationFactory.createMapping(metadata, propertyTable, classTable); }
@Override public Mapping toRegularMapping() { ImmutableMap<IQ, MappingTools.RDFPredicateInfo> iqClassificationMap = getMappingAssertions().stream() .collect(ImmutableCollectors.toMap( iq -> iq, MappingTools::extractRDFPredicate )); return specFactory.createMapping(mappingMetadata, extractTable(iqClassificationMap, false), extractTable(iqClassificationMap, true)); }
@Override public Mapping normalize(Mapping mapping) { AtomicInteger i = new AtomicInteger(0); ImmutableTable<RDFAtomPredicate, IRI, IQ> newPropertyTable = normalize(mapping.getRDFPropertyQueries(), i); ImmutableTable<RDFAtomPredicate, IRI, IQ> newClassTable = normalize(mapping.getRDFClassQueries(), i); return specificationFactory.createMapping(mapping.getMetadata(), newPropertyTable, newClassTable); }
@Override public Mapping toRegularMapping() { ImmutableMultimap<AtomPredicate, IntermediateQuery> assertionMultimap = getMappingAssertions().stream() .collect(ImmutableCollectors.toMultimap( q -> q.getProjectionAtom().getPredicate(), q -> q)); ImmutableMap<AtomPredicate, IntermediateQuery> definitionMap = assertionMultimap.asMap().values().stream() .map(queryMerger::mergeDefinitions) .filter(Optional::isPresent) .map(Optional::get) .collect(ImmutableCollectors.toMap( q -> q.getProjectionAtom().getPredicate(), q -> q)); return specFactory.createMapping(mappingMetadata, definitionMap, executorRegistry); }
@Override public Mapping normalize(Mapping mapping) { Stream<IntermediateQuery> queryStream = mapping.getPredicates().stream() .map(mapping::getDefinition) .filter(Optional::isPresent) .map(Optional::get); ImmutableMap<AtomPredicate, IntermediateQuery> normalizedMappingMap = renameQueries(queryStream) .collect(ImmutableCollectors.toMap( q -> q.getProjectionAtom().getPredicate(), q -> q )); return specificationFactory.createMapping(mapping.getMetadata(), normalizedMappingMap, mapping.getExecutorRegistry()); }
@Override public Mapping update(ImmutableTable<RDFAtomPredicate, IRI, IQ> propertyUpdateTable, ImmutableTable<RDFAtomPredicate, IRI, IQ> classUpdateTable) { ImmutableTable<RDFAtomPredicate, IRI, IQ> newPropertyDefs = propertyUpdateTable.isEmpty() ? propertyDefinitions : updateDefinitions(propertyDefinitions, propertyUpdateTable); ImmutableTable<RDFAtomPredicate, IRI, IQ> newTripleClassDefs = classUpdateTable.isEmpty() ? classDefinitions : updateDefinitions(classDefinitions, classUpdateTable); return specificationFactory.createMapping(metadata, newPropertyDefs, newTripleClassDefs); }
return specificationFactory.createMapping(mappingMetadata, mappingMap, executorRegistry);
@Override public Mapping merge(ImmutableSet<Mapping> mappings) { if (mappings.isEmpty()) { throw new IllegalArgumentException("The set of mappings is assumed to be nonempty"); } MappingMetadata metadata = mergeMetadata(mappings); ImmutableMap<AtomPredicate, IntermediateQuery> mappingMap = mergeMappingMaps(mappings); // TODO: check that the ExecutorRegistry is identical for all mappings ? return specificationFactory.createMapping( metadata, mappingMap, mappings.iterator().next().getExecutorRegistry() ); }
)); return specificationFactory.createMapping(mappingMetadata, extractTable(iqClassificationMap, false), extractTable(iqClassificationMap, true));