Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "sparqljs in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'sparqljs' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

import { getCurrentResource } from 'platform/api/navigation';
import { ConfigHolder } from 'platform/api/services/config-holder';

import { isQuery, isTerm, isIri } from './TypeGuards';

// by default we initialized parser without prefixes so we don't need
// to initialize it explicitly in all tests, but the expectation is that
// in production run init is called on the system startup
let Parser: SparqlJs.SparqlParser = new SparqlJs.Parser();
export let RegisteredPrefixes: { [key: string]: string } = {};
export function init(registeredPrefixes: { [key: string]: string }) {
  RegisteredPrefixes = registeredPrefixes;
  Parser = new SparqlJs.Parser(registeredPrefixes);
}

const Generator = new SparqlJs.Generator();

export type RDFResultFormat = 'application/ld+json'
  | 'application/n-quads'
  | 'application/n-triples'
  | 'application/rdf+json'
  | 'application/rdf+xml'
  | 'application/trig'
  | 'application/trix'
  | 'application/x-binary-rdf'
  | 'application/x-trig'
  | 'application/x-turtle'
  | 'application/xml'
  | 'text/n3'
  | 'text/nquads'
  | 'text/plain'
  | 'text/rdf+n3'
constructor (dataset: Dataset, prefixes: any = {}, customFunctions?: CustomFunctions) {
    this._dataset = dataset
    this._parser = new Parser(prefixes)
    this._optimizer = Optimizer.getDefault()
    this._customFunctions = customFunctions
    this._stageBuilders = new Map()

    // add default stage builders
    this.use(SPARQL_OPERATION.AGGREGATE, new AggregateStageBuilder(this._dataset))
    this.use(SPARQL_OPERATION.BGP, new BGPStageBuilder(this._dataset))
    this.use(SPARQL_OPERATION.BIND, new BindStageBuilder(this._dataset))
    this.use(SPARQL_OPERATION.DISTINCT, new DistinctStageBuilder(this._dataset))
    this.use(SPARQL_OPERATION.FILTER, new FilterStageBuilder(this._dataset))
    this.use(SPARQL_OPERATION.GRAPH, new GraphStageBuilder(this._dataset))
    this.use(SPARQL_OPERATION.MINUS, new MinusStageBuilder(this._dataset))
    this.use(SPARQL_OPERATION.SERVICE, new ServiceStageBuilder(this._dataset))
    this.use(SPARQL_OPERATION.OPTIONAL, new OptionalStageBuilder(this._dataset))
    this.use(SPARQL_OPERATION.ORDER_BY, new OrderByStageBuilder(this._dataset))
    this.use(SPARQL_OPERATION.PROPERTY_PATH, new GlushkovStageBuilder(this._dataset))
function post (req, res) {
  req.setTimeout(0) // no timeout

  var graphUri

  if (req.body.graph === 'user') {
    graphUri = req.user.graphUri
  } else {
    graphUri = null
  }

  const parser = new SparqlParser()
  const generator = new SparqlGenerator()

  var query

  try {
    query = parser.parse(req.body.query)
  } catch (e) {
    form(req, res, {
      query: req.body.query,
      graph: req.body.graph,
      errors: [
        e.stack
      ]
    })

    return
function SparqlIterator(source, query, options) {
  // Set argument defaults
  if (typeof source.read !== 'function')
    options = query, query = source, source = null;
  options = options || {};
  source = source || AsyncIterator.single({});

  // Transform the query into a cascade of iterators
  try {
    // Parse the query if needed
    if (typeof query === 'string')
      query = new SparqlParser(options.prefixes).parse(query);

    // Create an iterator that projects the bindings according to the query type
    var queryIterator, QueryConstructor = queryConstructors[query.queryType];
    if (!QueryConstructor)
      throw new Error('No iterator available for query type: ' + query.queryType);
    queryIterator = new QueryConstructor(null, query, options);
    // Create an iterator for bindings of the query's graph pattern
    var graphIterator = new SparqlGroupsIterator(source,
                              queryIterator.patterns || query.where, options);

    // Create iterators for each order
    for (var i = query.order && (query.order.length - 1); i >= 0; i--) {
      var order = new SparqlExpressionEvaluator(query.order[i].expression),
          ascending = !query.order[i].descending;
      graphIterator = new SortIterator(graphIterator, function (a, b) {
        var orderA = '', orderB = '';
import RemoteSparqlService from '../remote-sparql-service'
import {getPrefixesFromQuery} from '../query'
import _ from 'lodash'
import {Parser, Generator} from 'sparqljs'

const parser = new Parser()
const generator = new Generator()
const sparqlService = new RemoteSparqlService()

export default {
  state: {
    'query': '',
    'isLoading': false,
    outstandingQuery: undefined // Used to store query for aborting
  },
  getters: {
    query: state => {
      return state.query
    },
    isLoading: state => {
      return state.isLoading
    }
let limitStr = "";
  if (limit) {
    limitStr = `LIMIT ${parseInt(limit)}`;
  }

  const queryTemplate = `
${prefixesString(prefixes)}
SELECT ${distinctStr} ${variables.join(" ")}
WHERE {
  ${where ? where.join(" \n") : ""}
} ${orderByStr} ${groupByStr} ${limitStr}`;

  // ---------- parse root-query ----------

  const queryAST = new SparqlParser().parse(queryTemplate);

  // ---------- if there are sub-queries, add their ASTs and prefixes ----------
  addSubQueries(queryAST, subQueries);

  // ---------- return AST ----------

  return queryAST;
}
build (query, options = { format: 'raw' }) {
    // If needed, parse the string query into a logical query execution plan
    if (typeof query === 'string') {
      query = new Parser(options.prefixes).parse(query)
    }
    switch (query.type) {
      case 'query':
        const iterator = this._buildQueryPlan(query, options)
        // only use results formatters for select & ask queries
        if (query.queryType === 'CONSTRUCT' || query.queryType === 'DESCRIBE') {
          return iterator
        }
        switch (options.format) {
          case 'xml':
          case 'application/xml':
          case 'application/sparql-results+xml':
            return new XMLFormatter(iterator, query.variables)
          default:
            return iterator
        }
function post (req, res) {
  req.setTimeout(0) // no timeout

  var graphUri = req.body.graph

  const parser = new SparqlParser()
  const generator = new SparqlGenerator()

  var query

  try {
    query = parser.parse(req.body.query)
  } catch (e) {
    form(req, res, {
      query: req.body.query,
      graph: req.body.graph,
      errors: [
        e.stack
      ]
    })
  }

  const queryString = generator.stringify(query)
function post (req, res) {
  req.setTimeout(0) // no timeout

  var graphUri

  if (req.body.graph === 'user') {
    graphUri = req.user.graphUri
  } else {
    graphUri = null
  }

  const parser = new SparqlParser()
  const generator = new SparqlGenerator()

  var query

  try {
    query = parser.parse(req.body.query)
  } catch (e) {
    form(req, res, {
      query: req.body.query,
      graph: req.body.graph,
      errors: [
        e.stack
      ]
    })

    return
  }
import RemoteSparqlService from '../remote-sparql-service'
import {getPrefixesFromQuery} from '../query'
import _ from 'lodash'
import {Parser, Generator} from 'sparqljs'

const parser = new Parser()
const generator = new Generator()
const sparqlService = new RemoteSparqlService()

export default {
  state: {
    'query': '',
    'isLoading': false,
    outstandingQuery: undefined // Used to store query for aborting
  },
  getters: {
    query: state => {
      return state.query
    },
    isLoading: state => {
      return state.isLoading
    }
  },

Is your System Free of Underlying Vulnerabilities?
Find Out Now