/*** * 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 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()); } }
PrefixManager prefixManager = specificationFactory.createPrefixManager(ImmutableMap.copyOf(prefixes)); ImmutableList<SQLPPTriplesMap> mappingAxioms = ImmutableList.copyOf(mappings);
@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 )); }
mappingFactory.createMetadata( mappingFactory.createPrefixManager(ImmutableMap.of()), uriTemplateMatcher ));