public void run(File file) throws Exception { SQLPPMappingToR2RMLConverter writer = new SQLPPMappingToR2RMLConverter(obdaModel.generatePPMapping(), modelManager.getActiveOntology(), obdaModel.getRdfFactory()); writer.write(file); }
private ImmutableSet<SQLPPTriplesMap> splitMappingAxioms(List<SQLPPTriplesMap> mappingAxioms) { /* * Delimiter string d used for assigning ids to split mapping axioms. * If a mapping axiom with id j is split into multiple ones, * each of then will have "j"+"d"+int as an identifier */ String delimiterSubstring = getSplitMappingAxiomIdDelimiterSubstring(mappingAxioms); return mappingAxioms.stream() .flatMap(m -> splitMappingAxiom(m, delimiterSubstring).stream()) .collect(ImmutableCollectors.toSet()); }
SQLPPMappingToR2RMLConverter converter = new SQLPPMappingToR2RMLConverter(ppMapping, ontology, config.getRdfFactory()); final Collection<TriplesMap> tripleMaps = converter.getTripleMaps();
/** * the method to write the R2RML mappings * from an rdf Model to a file * * @param file the ttl file to write to */ public void write(File file) throws Exception { try { FileOutputStream fos = new FileOutputStream(file); write(fos); } catch (Exception e) { e.printStackTrace(); throw e; } }
try { JenaR2RMLMappingManager mm = JenaR2RMLMappingManager.getInstance(); Collection<TriplesMap> tripleMaps = getTripleMaps();
private ImmutableList<SQLPPTriplesMap> splitMappingAxiom(SQLPPTriplesMap mappingAxiom, String delimiterSubstring) { Multimap<ImmutableFunctionalTerm, TargetAtom> subjectTermToTargetTriples = ArrayListMultimap.create(); for (TargetAtom targetTriple : mappingAxiom.getTargetAtoms()) { ImmutableFunctionalTerm subjectTerm = getFirstFunctionalTerm(targetTriple) .orElseThrow(() -> new IllegalStateException("Invalid OBDA mapping")); subjectTermToTargetTriples.put(subjectTerm, targetTriple); } // If the partition per target triple subject is non trivial if (subjectTermToTargetTriples.size() > 1) { // Create ids for the new mapping axioms Map<ImmutableFunctionalTerm, String> subjectTermToMappingIndex = new HashMap<>(); int i = 1; for (ImmutableFunctionalTerm subjectTerm : subjectTermToTargetTriples.keySet()) { subjectTermToMappingIndex.put(subjectTerm, mappingAxiom.getId() + delimiterSubstring + i); i++; } // Generate one mapping axiom per subject return subjectTermToTargetTriples.asMap().entrySet().stream() .map(e -> mappingAxiom.extractPPMappingAssertions( subjectTermToMappingIndex.get(e.getKey()), ImmutableList.copyOf(e.getValue()))) .collect(ImmutableCollectors.toList()); } return ImmutableList.of(mappingAxiom); }
public Collection<TriplesMap> getTripleMaps() { OBDAMappingTransformer transformer = new OBDAMappingTransformer(rdfFactory); transformer.setOntology(ontology); return splitMappingAxioms(this.ppMappingAxioms).stream() .map(a -> transformer.getTriplesMap(a, prefixmng)) .collect(Collectors.toList()); }