@Override public SQLPPTriplesMap extractPPMappingAssertions(String newId, ImmutableList<TargetAtom> atoms) { return new OntopNativeSQLPPTriplesMap(newId, getSourceQuery(), atoms); } }
@Override public SQLPPTriplesMap extractPPMappingAssertions(String newId, ImmutableList<ImmutableFunctionalTerm> atoms) { return new OntopNativeSQLPPTriplesMap(newId, getSourceQuery(), atoms); } }
@Override public SQLPPTriplesMap extractPPMappingAssertion(TargetAtom atom) { return new OntopNativeSQLPPTriplesMap(getSourceQuery(), ImmutableList.of(atom)); }
private static List<SQLPPTriplesMap> addNewMapping(String mappingId, String sourceQuery, ImmutableList<TargetAtom> targetQuery, List<SQLPPTriplesMap> currentSourceMappings) { SQLPPTriplesMap mapping = new OntopNativeSQLPPTriplesMap( mappingId, SQL_MAPPING_FACTORY.getSQLQuery(sourceQuery), targetQuery); if (!currentSourceMappings.contains(mapping)) { currentSourceMappings.add(mapping); } else { LOG.warn("Duplicate mapping %s", mappingId); } return currentSourceMappings; }
@Override public SQLPPTriplesMap extractPPMappingAssertion(ImmutableFunctionalTerm atom) { return new OntopNativeSQLPPTriplesMap(getSourceQuery(), ImmutableList.of(atom)); }
private List<SQLPPTriplesMap> getMapping(DatabaseRelationDefinition table, String baseUri) { DirectMappingAxiomProducer dmap = new DirectMappingAxiomProducer(baseUri, termFactory, targetAtomFactory, rdfFactory); List<SQLPPTriplesMap> axioms = new ArrayList<>(); axioms.add(new OntopNativeSQLPPTriplesMap("MAPPING-ID"+ currentMappingIndex, SQL_MAPPING_FACTORY.getSQLQuery(dmap.getSQL(table)), dmap.getCQ(table))); currentMappingIndex++; Map<String, ImmutableList<TargetAtom>> refAxioms = dmap.getRefAxioms(table); for (Map.Entry<String, ImmutableList<TargetAtom>> e : refAxioms.entrySet()) { OBDASQLQuery sqlQuery = SQL_MAPPING_FACTORY.getSQLQuery(e.getKey()); ImmutableList<TargetAtom> targetQuery = e.getValue(); axioms.add(new OntopNativeSQLPPTriplesMap("MAPPING-ID"+ currentMappingIndex, sqlQuery, targetQuery)); currentMappingIndex++; } return axioms; } }
private SQLPPTriplesMap updateMapping(SQLPPTriplesMap formerTriplesMap, IRI removedPredicateIRI, AtomicInteger counter) { int initialCount = counter.get(); ImmutableList<TargetAtom> newTargetAtoms = getNewTargetAtoms(formerTriplesMap, removedPredicateIRI, counter); if (counter.get() > initialCount) { if (newTargetAtoms.isEmpty()) { throw new IllegalStateException("Mapping should be deleted"); } else { SQLPPTriplesMap newTriplesMap = new OntopNativeSQLPPTriplesMap(formerTriplesMap.getId(), formerTriplesMap.getSourceQuery(), newTargetAtoms); return newTriplesMap; } } else return formerTriplesMap; }
/** * Get OBDA mapping axiom from R2RML TriplesMap * @param tm * @return * @throws Exception */ private SQLPPTriplesMap getMapping(TriplesMap tm) throws Exception { String sourceQuery = r2rmlParser.getSQLQuery(tm).trim(); ImmutableList<TargetAtom> body = getMappingTripleAtoms(tm); //Function head = getHeadAtom(body); //CQIE targetQuery = DATALOG_FACTORY.getCQIE(head, body); // TODO: consider a R2RML-specific type of triples map SQLPPTriplesMap mapping = new OntopNativeSQLPPTriplesMap("mapping-"+tm.hashCode(), MAPPING_FACTORY.getSQLQuery(sourceQuery), body); if (body.isEmpty()){ //we do not have a target query System.out.println("WARNING a mapping without target query will not be introduced : "+ mapping.toString()); return null; } return mapping; }
public void updateMappingsSourceQuery(String triplesMapId, OBDASQLQuery sourceQuery) { SQLPPTriplesMap formerTriplesMap = getTriplesMap(triplesMapId); if (formerTriplesMap != null) { SQLPPTriplesMap newTriplesMap = new OntopNativeSQLPPTriplesMap(triplesMapId, sourceQuery, formerTriplesMap.getTargetAtoms()); triplesMapMap.put(triplesMapId, newTriplesMap); fireMappingUpdated(); } }
public void updateTargetQueryMapping(String id, ImmutableList<TargetAtom> targetQuery) { SQLPPTriplesMap formerTriplesMap = getTriplesMap(id); if (formerTriplesMap != null) { SQLPPTriplesMap newTriplesMap = new OntopNativeSQLPPTriplesMap(id, formerTriplesMap.getSourceQuery(), targetQuery); triplesMapMap.put(id, newTriplesMap); fireMappingUpdated(); } }
/*** * generate a mapping axiom from a table of a database * * @param table : the data definition from which mappings are extraced * @param baseUri : the base uri needed for direct mapping axiom * * @return a List of OBDAMappingAxiom-s */ private List<SQLPPTriplesMap> getMapping(DatabaseRelationDefinition table, String baseUri) { DirectMappingAxiomProducer dmap = new DirectMappingAxiomProducer(baseUri, TERM_FACTORY); List<SQLPPTriplesMap> axioms = new ArrayList<>(); axioms.add(new OntopNativeSQLPPTriplesMap("MAPPING-ID"+ currentMappingIndex, SQL_MAPPING_FACTORY.getSQLQuery(dmap.getSQL(table)), dmap.getCQ(table))); currentMappingIndex++; Map<String, ImmutableList<ImmutableFunctionalTerm>> refAxioms = dmap.getRefAxioms(table); for (Map.Entry<String, ImmutableList<ImmutableFunctionalTerm>> e : refAxioms.entrySet()) { OBDASQLQuery sqlQuery = SQL_MAPPING_FACTORY.getSQLQuery(e.getKey()); ImmutableList<ImmutableFunctionalTerm> targetQuery = e.getValue(); axioms.add(new OntopNativeSQLPPTriplesMap("MAPPING-ID"+ currentMappingIndex, sqlQuery, targetQuery)); currentMappingIndex++; } return axioms; } }
/*** * generate a mapping axiom from a table of a database * * @param table : the data definition from which mappings are extraced * @param baseUri : the base uri needed for direct mapping axiom * * @return a List of OBDAMappingAxiom-s */ private List<SQLPPTriplesMap> getMapping(DatabaseRelationDefinition table, String baseUri) { DirectMappingAxiomProducer dmap = new DirectMappingAxiomProducer(baseUri, termFactory, targetAtomFactory, rdfFactory); List<SQLPPTriplesMap> axioms = new ArrayList<>(); axioms.add(new OntopNativeSQLPPTriplesMap("MAPPING-ID"+ currentMappingIndex, SQL_MAPPING_FACTORY.getSQLQuery(dmap.getSQL(table)), dmap.getCQ(table))); currentMappingIndex++; Map<String, ImmutableList<TargetAtom>> refAxioms = dmap.getRefAxioms(table); for (Map.Entry<String, ImmutableList<TargetAtom>> e : refAxioms.entrySet()) { OBDASQLQuery sqlQuery = SQL_MAPPING_FACTORY.getSQLQuery(e.getKey()); ImmutableList<TargetAtom> targetQuery = e.getValue(); axioms.add(new OntopNativeSQLPPTriplesMap("MAPPING-ID"+ currentMappingIndex, sqlQuery, targetQuery)); currentMappingIndex++; } return axioms; } }
public void updateMappingId(String formerMappingId, String newMappingId) throws DuplicateMappingException { //if the id are the same no need to update the mapping if(!formerMappingId.equals(newMappingId)) { SQLPPTriplesMap formerTriplesMap = getTriplesMap(formerMappingId); if (formerTriplesMap != null) { SQLPPTriplesMap newTriplesMap = new OntopNativeSQLPPTriplesMap(newMappingId, formerTriplesMap.getSourceQuery(), formerTriplesMap.getTargetAtoms()); addTriplesMap(newTriplesMap, false); triplesMapMap.remove(formerMappingId); fireMappingUpdated(); } } }
public MetaMappingExpander(Collection<SQLPPTriplesMap> mappings) { ImmutableList.Builder<SQLPPTriplesMap> builder1 = ImmutableList.builder(); ImmutableList.Builder<Expansion> builder2 = ImmutableList.builder(); for (SQLPPTriplesMap mapping : mappings) { ImmutableList<ImmutableFunctionalTerm> toBeExpanded = mapping.getTargetAtoms().stream() .filter(atom -> atom.getFunctionSymbol().isTriplePredicate()) .collect(ImmutableCollectors.toList()); if (toBeExpanded.isEmpty()) { builder1.add(mapping); } else { builder2.addAll(toBeExpanded.stream() .map(target -> new Expansion(mapping.getId(), mapping.getSourceQuery(), target)) .iterator()); ImmutableList<ImmutableFunctionalTerm> toBeLeft = mapping.getTargetAtoms().stream() .filter(atom -> !atom.getFunctionSymbol().isTriplePredicate()) .collect(ImmutableCollectors.toList()); if (!toBeLeft.isEmpty()) { // TODO: see how to keep the provenance SQLPPTriplesMap newMapping = new OntopNativeSQLPPTriplesMap( IDGenerator.getNextUniqueID(mapping.getId() + "#"), mapping.getSourceQuery(), toBeLeft); builder1.add(newMapping); } } } nonExpandableMappings = builder1.build(); mappingsToBeExpanded = builder2.build(); }
SQLPPTriplesMap mapping = new OntopNativeSQLPPTriplesMap("mapping-join-"+robm.hashCode(), MAPPING_FACTORY.getSQLQuery(sourceQuery), bodyBuilder.build()); System.out.println("WARNING joinMapping introduced : " + mapping);
OntopNativeSQLPPTriplesMap newmapping = new OntopNativeSQLPPTriplesMap(newId, body, targetQuery); mapcon.addTriplesMap(newmapping, false); } else {
SQLPPTriplesMap newMapping = new OntopNativeSQLPPTriplesMap( IDGenerator.getNextUniqueID(m.id + "#"), MAPPING_FACTORY.getSQLQuery(newSourceQuery),
SQLPPTriplesMap mappingAxiom = new OntopNativeSQLPPTriplesMap(MAPPING_FACTORY.getSQLQuery(source), target); obdaModel.addTriplesMap(mappingAxiom, false);
SQLPPTriplesMap newTriplesMap = new OntopNativeSQLPPTriplesMap(formerTriplesMap.getId(), formerTriplesMap.getSourceQuery(), newTargetAtoms);
SQLPPTriplesMap newmapping = new OntopNativeSQLPPTriplesMap(newId, oldmapping.getSourceQuery(), oldmapping.getTargetAtoms()); controller.addTriplesMap(current_srcuri, newmapping, false);