@Override public String getProvenanceInfo() { String info = "id: " + triplesMap.getId(); info += "\ntarget atom: " + targetAtom.toString(); info += "\nsource query: " + triplesMap.getSourceQuery(); return info; }
@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) { 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); }
private void menuExecuteBodyActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_menuExecuteBodyActionPerformed SQLPPTriplesMap mapping = mappingList.getSelectedValue(); if (mapping == null) { return; } final String sqlQuery = mapping.getSourceQuery().toString(); SQLQueryPanel pnlQueryResult = new SQLQueryPanel(selectedSource, sqlQuery); JDialog dlgQueryResult = new JDialog(); DialogUtils.installEscapeCloseOperation(dlgQueryResult); dlgQueryResult.setContentPane(pnlQueryResult); dlgQueryResult.pack(); dlgQueryResult.setLocationRelativeTo(this); dlgQueryResult.setVisible(true); dlgQueryResult.setTitle("SQL Query Result"); }// GEN-LAST:event_menuExecuteBodyActionPerformed
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; }
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(); } }
for (SQLPPTriplesMap axiom : mappings) { try { if (!(axiom.getSourceQuery() instanceof OBDASQLQuery)) { throw new IllegalArgumentException("getRealTables() only works for SQL-* mappings"); OBDASQLQuery sourceQuery = axiom.getSourceQuery(); net.sf.jsqlparser.statement.Statement statement = CCJSqlParserUtil.parse(sourceQuery.toString()); if (!(statement instanceof Select))
for (SQLPPTriplesMap axiom : mappings) { try { if (!(axiom.getSourceQuery() instanceof OBDASQLQuery)) { throw new IllegalArgumentException("getRealTables() only works for SQL-* mappings"); OBDASQLQuery sourceQuery = axiom.getSourceQuery(); net.sf.jsqlparser.statement.Statement statement = CCJSqlParserUtil.parse(sourceQuery.toString()); if (!(statement instanceof Select))
/*** * Sets the current mapping to the input. Note, if the current mapping is * set, this means that this dialog is "updating" a mapping, and not * creating a new one. */ public void setMapping(SQLPPTriplesMap mapping) { this.mapping = mapping; cmdInsertMapping.setText("Update"); txtMappingID.setText(mapping.getId()); OBDASQLQuery sourceQuery = mapping.getSourceQuery(); String srcQuery = SourceQueryRenderer.encode(sourceQuery); txtSourceQuery.setText(srcQuery); ImmutableList<TargetAtom> targetQuery = mapping.getTargetAtoms(); String trgQuery = TargetQueryRenderer.encode(targetQuery, prefixManager); txtTargetQuery.setText(trgQuery); } }
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(); } } }
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 refresh() { OBDADataSource source = obdaModel.getDatasource(); List<SQLPPTriplesMap> mappingList = obdaModel.generatePPMapping().getTripleMaps(); HashMap<String, Integer> mappingStat = new HashMap<String, Integer>(); for (SQLPPTriplesMap mapping : mappingList) { String mappingId = mapping.getId(); int triplesCount = 0; try { OBDASQLQuery sourceQuery = mapping.getSourceQuery(); int tuples = getTuplesCount(sourceQuery, source); ImmutableList<TargetAtom> targetQuery = mapping.getTargetAtoms(); int atoms = targetQuery.size(); triplesCount = tuples * atoms; } catch (Exception e) { triplesCount = -1; // fails to count log.error(e.getMessage()); } mappingStat.put(mappingId, triplesCount); } statistics.put(source.getSourceID().toString(), mappingStat); }
@Override public boolean match(SQLPPTriplesMap object) { boolean isMatch = false; for (String keyword : vecKeyword) { // Check in the Mapping ID final String mappingId = object.getId(); isMatch = MappingIDTreeModelFilter.match(keyword.trim(), mappingId); if (isMatch) { break; // end loop if a match is found! } // Check in the Mapping Target Query for (TargetAtom targetAtom : object.getTargetAtoms()) { isMatch = isMatch || TreeModelTools.match(keyword.trim(), targetAtom); } if (isMatch) { break; // end loop if a match is found! } // Check in the Mapping Source Query final OBDASQLQuery query = object.getSourceQuery(); isMatch = MappingSQLStringTreeModelFilter.match(keyword.trim(), query.toString()); if (isMatch) { break; // end loop if a match is found! } } // no match found! return bNegation != isMatch; } }
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(); }
.map(target -> new Expansion(mapping.getId(), mapping.getSourceQuery(), target)) .iterator());
.properties(DataSource2PropertiesConvertor.convert(selectedSource)) .build(); validator = new SQLSourceQueryValidator(config.getSettings(), o.getSourceQuery()); long timestart = System.nanoTime();
formerTriplesMap.getSourceQuery(), newTargetAtoms);
OBDASQLQuery sourceQuery = mappingAxiom.getSourceQuery();
SQLPPTriplesMap newmapping = new OntopNativeSQLPPTriplesMap(newId, oldmapping.getSourceQuery(), oldmapping.getTargetAtoms()); controller.addTriplesMap(current_srcuri, newmapping, false);
trgQueryTextPane.setText(trgQuery); OBDASQLQuery sourceQuery = value.getSourceQuery(); String srcQuery = SourceQueryRenderer.encode(sourceQuery); srcQueryTextPane.setText(srcQuery);