private MappingMetadata mergeMetadata(ImmutableSet<Mapping> mappings) { PrefixManager prefixManager = mergePrefixManagers(mappings); UriTemplateMatcher uriTemplateMatcher = mergeURITemplateMatchers(mappings); return specificationFactory.createMetadata(prefixManager, uriTemplateMatcher); }
private MappingMetadata mergeMetadata(ImmutableSet<Mapping> mappings) { PrefixManager prefixManager = mergePrefixManagers(mappings); UriTemplateMatcher uriTemplateMatcher = mergeURITemplateMatchers(mappings); return specificationFactory.createMetadata(prefixManager, uriTemplateMatcher); }
/*** * extract all the mappings from a datasource * * @return a new OBDA Model containing all the extracted mappings */ private SQLPPMapping extractPPMapping(Optional<SQLPPMapping> ppMapping) throws MappingException, SQLException { SQLPPMapping mapping; if (!ppMapping.isPresent()) { it.unibz.inf.ontop.spec.mapping.PrefixManager prefixManager = specificationFactory.createPrefixManager(ImmutableMap.of()); MappingMetadata mappingMetadata = specificationFactory.createMetadata(prefixManager, UriTemplateMatcher.create(Stream.empty())); mapping = ppMappingFactory.createSQLPreProcessedMapping(ImmutableList.of(), mappingMetadata); } else mapping = ppMapping.get(); currentMappingIndex = mapping.getTripleMaps().size() + 1; return bootstrapMappings(mapping); }
/*** * extract all the mappings from a datasource * * @return a new OBDA Model containing all the extracted mappings */ private SQLPPMapping extractPPMapping(Optional<SQLPPMapping> ppMapping) throws MappingException, SQLException { SQLPPMapping mapping; if (!ppMapping.isPresent()) { it.unibz.inf.ontop.spec.mapping.PrefixManager prefixManager = specificationFactory.createPrefixManager(ImmutableMap.of()); MappingMetadata mappingMetadata = specificationFactory.createMetadata(prefixManager, UriTemplateMatcher.create(Stream.empty(), termFactory)); mapping = ppMappingFactory.createSQLPreProcessedMapping(ImmutableList.of(), mappingMetadata); } else mapping = ppMapping.get(); currentMappingIndex = mapping.getTripleMaps().size() + 1; return bootstrapMappings(mapping); }
public SQLPPMapping generatePPMapping() { ImmutableList<SQLPPTriplesMap> triplesMaps = ImmutableList.copyOf(triplesMapMap.values()); try { UriTemplateMatcher uriTemplateMatcher = UriTemplateMatcher.create( triplesMaps.stream() .flatMap(ax -> ax.getTargetAtoms().stream()) .flatMap(targetAtom -> targetAtom.getSubstitution().getImmutableMap().values().stream()) .filter(t -> t instanceof ImmutableFunctionalTerm) .map(t -> (ImmutableFunctionalTerm) t), termFactory); return ppMappingFactory.createSQLPreProcessedMapping(triplesMaps, // TODO: give an immutable prefix manager!! specificationFactory.createMetadata(prefixManager, uriTemplateMatcher)); /** * No mapping so should never happen */ } catch(DuplicateMappingException e) { throw new RuntimeException("A DuplicateMappingException has been thrown while no mapping has been given." + "What is going on? Message: " + e.getMessage()); } }
public SQLPPMapping createMappings() { OntopMappingConfiguration defaultConfiguration = OntopMappingConfiguration.defaultBuilder() .build(); SpecificationFactory specificationFactory = defaultConfiguration.getInjector().getInstance(SpecificationFactory.class); PrefixManager prefixManager = specificationFactory.createPrefixManager(ImmutableMap.of()); ImmutableList<SQLPPTriplesMap> mappingAxioms = dataRepository.getMappings(); UriTemplateMatcher uriTemplateMatcher = UriTemplateMatcher.create( mappingAxioms.stream() .flatMap(ax -> ax.getTargetAtoms().stream()) .flatMap(atom -> atom.getSubstitution().getImmutableMap().values().stream()) .filter(t -> t instanceof ImmutableFunctionalTerm) .map(t -> (ImmutableFunctionalTerm) t), termFactory); try { return new SQLPPMappingImpl(mappingAxioms, specificationFactory.createMetadata(prefixManager, uriTemplateMatcher)); } catch (DuplicateMappingException e) { throw new IllegalStateException(e.getMessage()); } } }
private SQLPPMapping parse(R2RMLManager manager) throws DuplicateMappingException, InvalidMappingException { try { //TODO: make the R2RMLManager simpler. ImmutableList<SQLPPTriplesMap> sourceMappings = manager.getMappings(manager.getModel()); UriTemplateMatcher uriTemplateMatcher = UriTemplateMatcher.create( sourceMappings.stream() .flatMap(ax -> ax.getTargetAtoms().stream()) .flatMap(atom -> atom.getSubstitution().getImmutableMap().values().stream()) .filter(t -> t instanceof ImmutableFunctionalTerm) .map(t -> (ImmutableFunctionalTerm) t), termFactory); //TODO: try to extract prefixes from the R2RML mappings PrefixManager prefixManager = specificationFactory.createPrefixManager(ImmutableMap.of()); MappingMetadata mappingMetadata = specificationFactory.createMetadata(prefixManager, uriTemplateMatcher); return ppMappingFactory.createSQLPreProcessedMapping(sourceMappings, mappingMetadata); } catch (InvalidR2RMLMappingException e) { throw new InvalidMappingException(e.getMessage()); } }
termFactory); MappingMetadata metadata = specificationFactory.createMetadata(prefixManager, uriTemplateMatcher); return ppMappingFactory.createSQLPreProcessedMapping(mappingAxioms, metadata);
@Override public Mapping convert(OntologyABox ontology, boolean isOntologyAnnotationQueryingEnabled, UriTemplateMatcher uriTemplateMatcher) { List<AnnotationAssertion> annotationAssertions = isOntologyAnnotationQueryingEnabled ? ontology.getAnnotationAssertions() : Collections.emptyList(); // Mutable !! // UriTemplateMatcher uriTemplateMatcher = UriTemplateMatcher.create(Stream.empty()); ImmutableList<CQIE> rules = convertAssertions( ontology.getClassAssertions(), ontology.getObjectPropertyAssertions(), ontology.getDataPropertyAssertions(), annotationAssertions, uriTemplateMatcher ); return datalog2QueryMappingConverter.convertMappingRules( rules, mappingFactory.createMetadata( //TODO: parse the ontology prefixes ?? mappingFactory.createPrefixManager(ImmutableMap.of()), uriTemplateMatcher )); }
dummyDBMetadata, executorRegistry, mappingFactory.createMetadata(