How to use the platform/api/sparql.SparqlClient.select function in platform

To help you get started, we’ve selected a few platform examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github researchspace / researchspace / researchspace / web / src / main / components / arguments / ArgumentsStore.ts View on Github external
function findArgumentsForAssertion(assertionIri: Rdf.Iri): Kefir.Property> {
  const query =
    SparqlClient.setBindings(FIND_ARGUMENTS_QUERY, {'__assertion__': assertionIri});
  return SparqlClient.select(
    query, {context: {repository: 'assets'}}
  ).map(res => res.results.bindings.map(b => b['argument'] as Rdf.Iri));
}
github researchspace / researchspace / researchspace / web / src / main / components / timeline / SemanticTimeline.tsx View on Github external
private prepareData(props: SemanticTimelineConfigProps) {
    const context = this.context.semanticContext;
    const stream = SparqlClient.select(props.query, {context});

    stream.onValue(res => {
      if (SparqlUtil.isSelectResultEmpty(res)) {
        this.setState({noResults: true, errorMessage: maybe.Nothing(), isLoading: false});
      } else {
        const {dataSet, errorMessage} = this.getDataSetAndError(res);
        this.setState({
          dataSet,
          noResults: false,
          errorMessage,
          isLoading: false,
        });
      }
    });

    stream.onError(error => this.setState({errorMessage: maybe.Just(error), isLoading: false}));
github researchspace / researchspace / researchspace / web / src / main / components / search / facet / FacetStore.ts View on Github external
const query =
      SparqlClient.setBindings(
        facetsQuery, _.assign({
          [FACET_VARIABLES.RELATION_VAR]: relation.iri,
          [FACET_VARIABLES.RANGE_VAR]: relation.hasRange.iri,
        }, {
          [SEMANTIC_SEARCH_VARIABLES.SELECTED_ALIGNMENT]:
            this.context.selectedAlignment.map(a => a.iri).getOrElse(undefined),
        })
      );

    const federatedQuery =
      generateQueryForMultipleDatasets(
        query, this.context.selectedDatasets, this.context.baseConfig.datasetsConfig
      );
    return SparqlClient.select(federatedQuery, {context: this.context.semanticContext});
  }
github researchspace / researchspace / researchspace / web / src / main / components / panel-system / IIIFViewerPanel.tsx View on Github external
const requests = repositories.map(repository =>
        SparqlClient.select(sparql, {context: {repository}}).map(
          ({results}) => ({iri, images: results.bindings.map(({image}) => image.value)})
        )
      );
github researchspace / researchspace / researchspace / web / src / main / components / common / ShareComponent.tsx View on Github external
componentDidMount() {
    const iriString = this.props.iri || getCurrentResource().value;
    const query = SparqlClient.select(
      `SELECT ?visibility WHERE {
         OPTIONAL { <${iriString}> <${vocabularies.VocabPlatform.visibility.value}> ?vis }
         BIND(COALESCE(?vis, <${vocabularies.VocabPlatform.privateVisibility.value}>) as ?visibility).
      }`
    );

    query
      .onValue(res => {
        const vis = res.results.bindings[0].visibility.value;
        this.setState({ visibility: vis });

        if (vis === visibility.group) {
          this.selectGroups(iriString);
        }
      })
      .onError(
github researchspace / researchspace / metaphacts-platform / web / src / main / components / semantic / table / SemanticTable.ts View on Github external
private prepareConfigAndExecuteQuery = (props: SemanticTableProps, context: ComponentContext) => {
    this.setState({
      isLoading: true,
      error: undefined,
    });
    this.querying = this.cancellation.deriveAndCancel(this.querying);
    const loading = this.querying.map(
      SparqlClient.select(props.query, {context: context.semanticContext})
    ).onValue(
      res => this.setState({data: res, isLoading: false})
    ).onError(
      error => this.setState({isLoading: false, error})
    ).onEnd(() => {
      if (this.props.id) {
        trigger({eventType: BuiltInEvents.ComponentLoaded, source: this.props.id});
      }
    });
    if (this.props.id) {
      trigger({
        eventType: BuiltInEvents.ComponentLoading,
        source: this.props.id,
        data: loading,
      });
    }
github researchspace / researchspace / metaphacts-platform / web / src / main / components / ui / inputs / AutoCompletionInput.ts View on Github external
(token: string, tokenVariable: string) => {
        const parsedQuery: SparqlJs.SparqlQuery =
            typeof query === 'string' ?
            this.replaceTokenAndParseQuery(query as string, tokenVariable, token) :
            query as SparqlJs.SparqlQuery;
        const {escapeLuceneSyntax, tokenizeLuceneQuery} = this.props;
        const queryParam = SparqlUtil.makeLuceneQuery(
          token, escapeLuceneSyntax, tokenizeLuceneQuery,
        );
        const queryWithToken = SparqlClient.setBindings(
          parsedQuery, {[SEARCH_INPUT_VARIABLE]: queryParam}
        );
        const context = this.context.semanticContext;
        return SparqlClient.select(queryWithToken, {context: context}).map(
          res => res.results.bindings
        );
      }