private static String generatePropertyOrClassConflictMessage(String predicateIRI, PPMappingAssertionProvenance provenance, String declaredTypeString, String usedTypeString) { return predicateIRI + " is declared as " + declaredTypeString + " in the ontology, but is used as " + usedTypeString + " in the triplesMap: \n[\n" + provenance.getProvenanceInfo() + "\n]"; }
@Override public String getProvenanceInfo() { String info = "id: " + triplesMap.getId(); info += "\ntarget atom: " + targetAtom.toString(); info += "\nsource query: " + triplesMap.getSourceQuery(); return info; }
public SQLPPMappingToR2RMLConverter(SQLPPMapping ppMapping, OWLOntology ontology, RDF rdfFactory) { this.ppMappingAxioms = ppMapping.getTripleMaps(); this.prefixmng = ppMapping.getMetadata().getPrefixManager(); this.ontology = ontology; this.rdfFactory = rdfFactory; }
private void writeMappingDeclaration(BufferedWriter writer) throws IOException { writer.write(OntopNativeMappingParser.MAPPING_DECLARATION_TAG + " " + OntopNativeMappingParser.START_COLLECTION_SYMBOL); writer.write("\n"); boolean needLineBreak = false; for (SQLPPTriplesMap axiom : ppMapping.getTripleMaps()) { if (needLineBreak) { writer.write("\n"); } writer.write(OntopNativeMappingParser.Label.mappingId.name() + "\t" + axiom.getId() + "\n"); ImmutableList<TargetAtom> targetQuery = axiom.getTargetAtoms(); writer.write(OntopNativeMappingParser.Label.target.name() + "\t\t" + printTargetQuery(targetQuery) + "\n"); OBDASQLQuery sourceQuery = axiom.getSourceQuery(); writer.write(OntopNativeMappingParser.Label.source.name() + "\t\t" + printSourceQuery(sourceQuery) + "\n"); needLineBreak = true; } writer.write(OntopNativeMappingParser.END_COLLECTION_SYMBOL); writer.write("\n\n"); }
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 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(); } }
public int indexOf(URI currentSource, String mappingId) { ImmutableList<SQLPPTriplesMap> sourceMappings = ImmutableList.copyOf(triplesMapMap.values()); if (sourceMappings == null) { return -1; } for(int i=0; i < sourceMappings.size(); i++) { if (sourceMappings.get(i).getId().equals(mappingId)) return i; } return -1; }
@Override public MappingWithProvenance convert(SQLPPMapping ppMapping, RDBMetadata dbMetadata, ExecutorRegistry executorRegistry) throws InvalidMappingSourceQueriesException { ImmutableMap<CQIE, PPMappingAssertionProvenance> datalogMap = convertIntoDatalog(ppMapping, dbMetadata); return mappingConverter.convertMappingRules(datalogMap, ppMapping.getMetadata()); }
@Override public boolean match(SQLPPTriplesMap object) { ImmutableList<TargetAtom> atoms = object.getTargetAtoms(); boolean isMatch = false; for (String keyword : vecKeyword) { for (TargetAtom atom : atoms) { isMatch = isMatch || TreeModelTools.match(keyword.trim(), atom); } if (isMatch) { break; // end loop if a match is found! } } return bNegation != isMatch; }
private String printTargetQuery(ImmutableList<TargetAtom> query) { return TargetQueryRenderer.encode(query, ppMapping.getMetadata().getPrefixManager()); }
@Override public boolean match(SQLPPTriplesMap object) { final OBDASQLQuery bodyquery = (OBDASQLQuery) object.getSourceQuery(); boolean isMatch = false; for (String keyword : vecKeyword) { isMatch = match(keyword.trim(), bodyquery.toString()); if (isMatch) { break; // end loop if a match is found! } } // no match found! return (bNegation ? !isMatch : isMatch); }
@Override public String getProvenanceInfo() { String info = "id: " + triplesMap.getId(); info += "\ntarget atom: " + targetAtom.toString(); info += "\nsource query: " + triplesMap.getSourceQuery(); return info; }
@Override public boolean match(SQLPPTriplesMap object) { boolean isMatch = false; for (String keyword : vecKeyword) { isMatch = match(keyword.trim(), object.getId()); if (isMatch) { break; // end loop if a match is found! } } // no match found! return (bNegation ? !isMatch : isMatch); }
@Override public MappingWithProvenance convert(SQLPPMapping ppMapping, RDBMetadata dbMetadata, ExecutorRegistry executorRegistry) throws InvalidMappingSourceQueriesException { ImmutableMap<CQIE, PPMappingAssertionProvenance> datalogMap = convertIntoDatalog(ppMapping, dbMetadata); return mappingConverter.convertMappingRules(datalogMap, dbMetadata, executorRegistry, ppMapping.getMetadata()); }
private static String generatePropertyOrClassConflictMessage(IRI predicateIRI, PPMappingAssertionProvenance provenance, String declaredTypeString, String usedTypeString) { return predicateIRI + " is declared as " + declaredTypeString + " in the ontology, but is used as " + usedTypeString + " in the triplesMap: \n[\n" + provenance.getProvenanceInfo() + "\n]"; }
private String getSplitMappingAxiomIdDelimiterSubstring(List<SQLPPTriplesMap> mappingAxioms) { String delimiterSubstring = ""; boolean matched; do { delimiterSubstring += "_"; Pattern pattern = Pattern.compile(delimiterSubstring + "(\\d)*$"); matched = mappingAxioms.stream() .anyMatch(a -> pattern.matcher(a.getId()).matches()); } while (matched); return delimiterSubstring; }
private static ImmutableMap<String, SQLPPTriplesMap> indexMappingsById(ImmutableList<SQLPPTriplesMap> mappings) throws IllegalArgumentException { Map<String, SQLPPTriplesMap> mappingIndexById = new HashMap<>(); for (SQLPPTriplesMap axiom : mappings) { String id = axiom.getId(); if (mappingIndexById.containsKey(id)) { // Should have already been detected by checkDuplicates. throw new IllegalArgumentException(String.format("Not unique mapping ID found : %s", id)); } mappingIndexById.put(id, axiom); } return ImmutableMap.copyOf(mappingIndexById); }
@Deprecated public void addTriplesMap(URI sourceID, SQLPPTriplesMap triplesMap, boolean disableFiringMappingInsertedEvent) throws DuplicateMappingException { String mapId = triplesMap.getId(); if (triplesMapMap.containsKey(mapId)) throw new DuplicateMappingException("ID " + mapId); triplesMapMap.put(mapId, triplesMap); if (!disableFiringMappingInsertedEvent) fireMappingInserted(sourceID); }
public void addTriplesMap(SQLPPTriplesMap triplesMap, boolean disableFiringMappingInsertedEvent) throws DuplicateMappingException { String mapId = triplesMap.getId(); if (triplesMapMap.containsKey(mapId)) throw new DuplicateMappingException("ID " + mapId); triplesMapMap.put(mapId, triplesMap); if (!disableFiringMappingInsertedEvent) fireMappingInserted(source.getSourceID()); }