Skip to content

Commit

Permalink
Merge pull request #3180 from OriginTrail/v6/prerelease/devnet
Browse files Browse the repository at this point in the history
OriginTrail Devnet Release v6.4.0 Hotfix 3
  • Loading branch information
NZT48 authored Jun 5, 2024
2 parents c7967f8 + 66544cc commit fc3bce7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "origintrail_node",
"version": "6.4.0+hotfix.2",
"version": "6.4.0",
"description": "OTNode V6",
"main": "index.js",
"type": "module",
Expand Down
38 changes: 23 additions & 15 deletions src/commands/query/query-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@ class QueryCommand extends Command {
}

async execute(command) {
const {
queryType,
operationId,
repository = TRIPLE_STORE_REPOSITORIES.PRIVATE_CURRENT,
} = command.data;
const { queryType, operationId } = command.data;

let { query } = command.data;
let { query, repository = TRIPLE_STORE_REPOSITORIES.PRIVATE_CURRENT } = command.data;

let data;

Expand All @@ -33,15 +29,21 @@ class QueryCommand extends Command {
null,
OPERATION_ID_STATUS.QUERY.QUERY_START,
);
this.validateRepositoryName(repository);
repository = this.validateRepositoryName(repository);
// check if it's federated query
const pattern = /SERVICE\s+<[^>]+>/g;
const matches = query.match(pattern);
if (matches) {
for (const repositoryInOriginalQuery in matches) {
const federatedQueryRepositoryName =
this.paranetService.getParanetRepositoryName(repositoryInOriginalQuery);
this.validateRepositoryName(federatedQueryRepositoryName);
const pattern = /SERVICE\s+<([^>]+)>/g;
const matches = [];
let match;
// eslint-disable-next-line no-cond-assign
while ((match = pattern.exec(query)) !== null) {
matches.push(match[1]);
}
if (matches.length > 0) {
for (const repositoryInOriginalQuery of matches) {
const federatedQueryRepositoryName = `http://localhost:9999/blazegraph/namespace/${this.paranetService.getParanetRepositoryName(
repositoryInOriginalQuery,
)}/sparql`;
this.validateRepositoryName(repositoryInOriginalQuery);
query = query.replace(repositoryInOriginalQuery, federatedQueryRepositoryName);
}
}
Expand Down Expand Up @@ -85,10 +87,16 @@ class QueryCommand extends Command {
let isParanetRepoValid = false;
if (this.ualService.isUAL(repository)) {
const paranetRepoName = this.paranetService.getParanetRepositoryName(repository);
isParanetRepoValid = this.config.assetSync?.syncParanets.includes(paranetRepoName);
isParanetRepoValid = this.config.assetSync?.syncParanets.includes(repository);
if (isParanetRepoValid) {
return paranetRepoName;
}
}
const isTripleStoreRepoValid =
Object.values(TRIPLE_STORE_REPOSITORIES).includes(repository);
if (isTripleStoreRepoValid) {
return repository;
}

if (!isParanetRepoValid && !isTripleStoreRepoValid) {
throw new Error(`Query failed! Repository with name: ${repository} doesn't exist`);
Expand Down

0 comments on commit fc3bce7

Please sign in to comment.