Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(mediatorResolveQuadPattern: Mediator, IActionRdfResolveQuadPattern, IActorTest, IActorRdfResolveQuadPatternOutput>,
context: ActionContext, emptyPatterns: Map,
skipEmptyPatterns: boolean) {
this.mediatorResolveQuadPattern = mediatorResolveQuadPattern;
this.sources = context.get(KEY_CONTEXT_SOURCES);
this.contextDefault = context.delete(KEY_CONTEXT_SOURCES);
this.emptyPatterns = emptyPatterns;
this.skipEmptyPatterns = skipEmptyPatterns;
this.algebraFactory = new Factory();
// Initialize sources in the emptyPatterns datastructure
if (this.skipEmptyPatterns) {
this.sources.iterator().on('data', (source: IDataSource) => {
if (!this.emptyPatterns.has(source)) {
this.emptyPatterns.set(source, []);
}
});
}
}
public static patternToCountQuery(pattern: RDF.Quad): string {
return toSparql(ActorRdfResolveQuadPatternSparqlJson.FACTORY.createProject(
ActorRdfResolveQuadPatternSparqlJson.FACTORY.createExtend(
ActorRdfResolveQuadPatternSparqlJson.FACTORY.createGroup(
ActorRdfResolveQuadPatternSparqlJson.patternToBgp(pattern),
[],
[ActorRdfResolveQuadPatternSparqlJson.FACTORY.createBoundAggregate(
variable('var0'),
'count',
ActorRdfResolveQuadPatternSparqlJson.FACTORY.createTermExpression(namedNode('*')),
false,
)],
),
variable('count'),
ActorRdfResolveQuadPatternSparqlJson.FACTORY.createTermExpression(variable('var0')),
),
[ variable('count') ],
));
async function run() {
process.stdout.write(toSparql(await new Converter().graphqlToSparqlAlgebra(query, context)) + '\n');
}
run();
public static patternToSelectQuery(pattern: RDF.Quad): string {
const variables: RDF.Variable[] = getVariables(getTerms(pattern));
return toSparql(ActorRdfResolveQuadPatternSparqlJson.FACTORY.createProject(
ActorRdfResolveQuadPatternSparqlJson.patternToBgp(pattern),
variables,
));
}
private extractSortExpression(expr: Algebra.Expression): Algebra.Expression {
const { expressionType, operator } = expr;
if (expressionType !== Algebra.expressionTypes.OPERATOR) { return expr; }
return (operator === 'desc')
? expr.args[0]
: expr;
}
private substitute(operation: Algebra.Operation, bindings: Bindings): Algebra.Operation {
return Util.mapOperation(operation, {
path: (op: Algebra.Path, factory: Factory) => {
return {
recurse: false,
result: factory.createPath(
this.substituteSingle(op.subject, bindings),
op.predicate,
this.substituteSingle(op.object, bindings),
this.substituteSingle(op.graph, bindings),
),
};
},
pattern: (op: Algebra.Pattern, factory: Factory) => {
return {
recurse: false,
result: factory.createPattern(
this.substituteSingle(op.subject, bindings),
public async run(action: IActionSparqlParse): Promise {
return { operation: translate(action.query,
{ quads: true, prefixes: this.prefixes, blankToVariable: true, baseIRI: action.baseIRI }) };
}