Tabnine Logo
SQLPPMapping
Code IndexAdd Tabnine to your IDE (free)

How to use
SQLPPMapping
in
it.unibz.inf.ontop.spec.mapping.pp

Best Java code snippets using it.unibz.inf.ontop.spec.mapping.pp.SQLPPMapping (Showing top 20 results out of 315)

origin: ontop/ontop

public SQLPPMappingToR2RMLConverter(SQLPPMapping ppMapping, OWLOntology ontology, RDF rdfFactory) {
  this.ppMappingAxioms = ppMapping.getTripleMaps();
  this.prefixmng = ppMapping.getMetadata().getPrefixManager();
  this.ontology = ontology;
  this.rdfFactory = rdfFactory;
}
origin: it.unibz.inf.ontop/ontop-mapping-sql-owlapi

/***
 * 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);
}
origin: ontop/ontop

private void writePrefixDeclaration(BufferedWriter writer) throws IOException {
  final ImmutableMap<String, String> prefixMap = ppMapping.getMetadata().getPrefixManager().getPrefixMap();
  if (prefixMap.size() == 0) {
    return; // do nothing if there is no prefixes to write
  }
  writer.write(OntopNativeMappingParser.PREFIX_DECLARATION_TAG);
  writer.write("\n");
  for (String prefix : prefixMap.keySet()) {
    String uri = prefixMap.get(prefix);
    writer.write(prefix + (prefix.length() >= 9 ? "\t" : "\t\t") + uri + "\n");
  }
  writer.write("\n");
}
origin: ontop/ontop

/**
 * Assumption: one CQIE per mapping axiom (no nested union)
 */
private ImmutableMap<CQIE, PPMappingAssertionProvenance> convertIntoDatalog(SQLPPMapping ppMapping, RDBMetadata dbMetadata)
    throws InvalidMappingSourceQueriesException {
  /*
   * May also add views in the DBMetadata!
   */
  ImmutableMap<CQIE, PPMappingAssertionProvenance> datalogMap = ppMapping2DatalogConverter.convert(
      ppMapping.getTripleMaps(), dbMetadata);
  LOGGER.debug("Original mapping size: {}", datalogMap.size());
  // Normalizing language tags and equalities (SIDE-EFFECT!)
  normalizeMapping(datalogMap.keySet());
  return datalogMap;
}
origin: ontop/ontop

@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());
}
origin: ontop/ontop

private SQLPPMapping bootstrapMappings(RDBMetadata metadata, SQLPPMapping ppMapping) throws DuplicateMappingException {
  if (baseIRI == null || baseIRI.isEmpty())
    this.baseIRI = ppMapping.getMetadata().getPrefixManager().getDefaultPrefix();
  Collection<DatabaseRelationDefinition> tables = metadata.getDatabaseRelations();
  List<SQLPPTriplesMap> mappingAxioms = new ArrayList<>();
  for (DatabaseRelationDefinition td : tables) {
    mappingAxioms.addAll(getMapping(td, baseIRI));
  }
  List<SQLPPTriplesMap> mappings = new ArrayList<>();
  mappings.addAll(ppMapping.getTripleMaps());
  mappings.addAll(mappingAxioms);
  return ppMappingFactory.createSQLPreProcessedMapping(ImmutableList.copyOf(mappings), ppMapping.getMetadata());
}
origin: it.unibz.inf.ontop/ontop-mapping-sql-core

/**
 * Assumption: one CQIE per mapping axiom (no nested union)
 */
private ImmutableMap<CQIE, PPMappingAssertionProvenance> convertIntoDatalog(SQLPPMapping ppMapping, RDBMetadata dbMetadata)
    throws InvalidMappingSourceQueriesException {
  /*
   * May also add views in the DBMetadata!
   */
  ImmutableMap<CQIE, PPMappingAssertionProvenance> datalogMap = SQLPPMapping2DatalogConverter.convert(
      ppMapping.getTripleMaps(), dbMetadata);
  LOGGER.debug("Original mapping size: {}", datalogMap.size());
  // Normalizing language tags and equalities (SIDE-EFFECT!)
  normalizeMapping(datalogMap.keySet());
  return datalogMap;
}
origin: ontop/ontop

private String printTargetQuery(ImmutableList<TargetAtom> query) {
  return TargetQueryRenderer.encode(query, ppMapping.getMetadata().getPrefixManager());
}
origin: it.unibz.inf.ontop/ontop-mapping-sql-owlapi

private SQLPPMapping bootstrapMappings(RDBMetadata metadata, SQLPPMapping ppMapping) throws DuplicateMappingException {
  if (baseIRI == null || baseIRI.isEmpty())
    this.baseIRI = ppMapping.getMetadata().getPrefixManager().getDefaultPrefix();
  Collection<DatabaseRelationDefinition> tables = metadata.getDatabaseRelations();
  List<SQLPPTriplesMap> mappingAxioms = new ArrayList<>();
  for (DatabaseRelationDefinition td : tables) {
    mappingAxioms.addAll(getMapping(td, baseIRI));
  }
  List<SQLPPTriplesMap> mappings = new ArrayList<>();
  mappings.addAll(ppMapping.getTripleMaps());
  mappings.addAll(mappingAxioms);
  return ppMappingFactory.createSQLPreProcessedMapping(ImmutableList.copyOf(mappings), ppMapping.getMetadata());
}
origin: ontop/ontop

/***
 * 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);
}
origin: it.unibz.inf.ontop/ontop-mapping-sql-core

@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());
}
origin: ontop/ontop

public void parseMapping(Reader mappingReader, Properties properties) throws DuplicateMappingException,
    InvalidMappingException, IOException, MappingIOException {
  OntopMappingSQLAllConfiguration configuration = OntopMappingSQLAllConfiguration.defaultBuilder()
      .nativeOntopMappingReader(mappingReader)
      .properties(properties)
      .build();
  SQLMappingParser mappingParser = configuration.getInjector().getInstance(SQLMappingParser.class);
  SQLPPMapping ppMapping = mappingParser.parse(mappingReader);
  prefixManager.addPrefixes(ppMapping.getMetadata().getPrefixManager().getPrefixMap());
  // New map
  triplesMapMap = ppMapping.getTripleMaps().stream()
      .collect(collectTriplesMaps(
          SQLPPTriplesMap::getId,
          m -> m));
}
origin: ontop/ontop

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");
}
origin: it.unibz.inf.ontop/ontop-mapping-sql-core

protected SQLPPMapping expandPPMapping(SQLPPMapping ppMapping, OntopMappingSQLSettings settings, RDBMetadata dbMetadata)
    throws MetaMappingExpansionException {
  MetaMappingExpander expander = new MetaMappingExpander(ppMapping.getTripleMaps());
  final ImmutableList<SQLPPTriplesMap> expandedMappingAxioms;
  if (expander.hasMappingsToBeExpanded()) {
    try (Connection connection = LocalJDBCConnectionUtils.createConnection(settings)) {
      expandedMappingAxioms = expander.getExpandedMappings(connection, dbMetadata);
    }
    // Problem while creating the connection
    catch (SQLException e) {
      throw new MetaMappingExpansionException(e.getMessage());
    }
  }
  else
    expandedMappingAxioms = expander.getNonExpandableMappings();
  try {
    return new SQLPPMappingImpl(expandedMappingAxioms, ppMapping.getMetadata());
  }
  catch (DuplicateMappingException e) {
    // Internal bug
    throw new IllegalStateException(e);
  }
}
origin: ontop/ontop

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);
}
origin: ontop/ontop

protected SQLPPMapping expandPPMapping(SQLPPMapping ppMapping, OntopMappingSQLSettings settings, RDBMetadata dbMetadata)
    throws MetaMappingExpansionException {
  MetaMappingExpander expander = new MetaMappingExpander(ppMapping.getTripleMaps(), termFactory,
      substitutionFactory);
  final ImmutableList<SQLPPTriplesMap> expandedMappingAxioms;
  if (expander.hasMappingsToBeExpanded()) {
    try (Connection connection = LocalJDBCConnectionUtils.createConnection(settings)) {
      expandedMappingAxioms = expander.getExpandedMappings(connection, dbMetadata);
    }
    // Problem while creating the connection
    catch (SQLException e) {
      throw new MetaMappingExpansionException(e.getMessage());
    }
  }
  else
    expandedMappingAxioms = expander.getNonExpandableMappings();
  try {
    return new SQLPPMappingImpl(expandedMappingAxioms, ppMapping.getMetadata());
  }
  catch (DuplicateMappingException e) {
    // Internal bug
    throw new IllegalStateException(e);
  }
}
origin: it.unibz.inf.ontop/ontop-mapping-sql-core

Set<RelationID> realTables = getRealTables(metadata.getQuotedIDFactory(), ppMapping.getTripleMaps());
implicitConstraints.ifPresent(c -> {
origin: ontop/ontop

currentMappingIndex = ppMapping.getTripleMaps().size() + 1;
  baseURI = ppMapping.getMetadata().getPrefixManager().getDefaultPrefix();
origin: ontop/ontop

Set<RelationID> realTables = getRealTables(metadata.getQuotedIDFactory(), ppMapping.getTripleMaps());
implicitConstraints.ifPresent(c -> {
origin: it.unibz.inf.ontop/ontop-mapping-sql-owlapi

/**
 * NOT THREAD-SAFE (not reentrant)
 */
private BootstrappingResults bootstrapMappingAndOntology(String baseIRI, Optional<SQLPPMapping> inputPPMapping,
                             Optional<OWLOntology> inputOntology)
    throws MappingBootstrappingException {
  this.baseIRI = fixBaseURI(baseIRI);
  try {
    SQLPPMapping newPPMapping = extractPPMapping(inputPPMapping);
    OWLOntology ontology = inputOntology.isPresent()
        ? inputOntology.get()
        : OWLManager.createOWLOntologyManager().createOntology(IRI.create(baseIRI));
    // update ontology
    OWLOntologyManager manager = ontology.getOWLOntologyManager();
    Set<OWLDeclarationAxiom> declarationAxioms = extractDeclarationAxioms(manager,
        newPPMapping.getTripleMaps().stream()
            .flatMap(ax -> ax.getTargetAtoms().stream()));
    manager.addAxioms(ontology, declarationAxioms);
    return new DefaultBootstrappingResults(newPPMapping, ontology);
  }
  catch (SQLException | MappingException | OWLOntologyCreationException e) {
    throw new MappingBootstrappingException(e);
  }
}
it.unibz.inf.ontop.spec.mapping.ppSQLPPMapping

Javadoc

SQL-specific PreProcessedMapping

Most used methods

  • getMetadata
  • getTripleMaps

Popular in Java

  • Making http requests using okhttp
  • onCreateOptionsMenu (Activity)
  • runOnUiThread (Activity)
  • setRequestProperty (URLConnection)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Collectors (java.util.stream)
  • JFileChooser (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now