Skip to content

Commit

Permalink
Merge pull request #1147 from Ontotext-AD/GDB-9198-allow-WB-user-to-p…
Browse files Browse the repository at this point in the history
…rovide-context-link

GDB-9198 allow WB user to provide context link
  • Loading branch information
VPetrova00 authored Jan 3, 2024
2 parents 6312c76 + 97e79b2 commit 6dd5b09
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
GDB_VERSION=10.5.0-TR1
GDB_VERSION=10.5.0
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
environment:
GDB_JAVA_OPTS: >-
-Dgraphdb.workbench.importDirectory=/opt/home/import-data/
-Dgraphdb.jsonld.whitelist=https://w3c.github.io/json-ld-api/tests/*
-Dgraphdb.stats.default=disabled
expose:
- 7200
Expand Down
3 changes: 2 additions & 1 deletion scripts/run-cypress-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ if ! "$GDB_TMPDIR/graphdb-${GDB_VERSION}/bin/graphdb" -d \
-Denable.cypress.hack=true \
-Dgraphdb.workbench.home="$(pwd)/dist/" \
-Dgraphdb.stats.default=disabled \
-Dgraphdb.workbench.importDirectory="$(pwd)/test-cypress/fixtures/graphdb-import/" ]; then
-Dgraphdb.workbench.importDirectory="$(pwd)/test-cypress/fixtures/graphdb-import/" \
-Dgraphdb.jsonld.whitelist="https://w3c.github.io/json-ld-api/tests/*" ]; then
echo "Unable to start GraphDB"
cleanup 1
fi
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@
"import.label.bnodes": "BNodes",
"import.label.datatype": "Datatype",
"import.popover.relative.iri": "RDF data may contain relative IRIs. In order to make sense of them, they need to be resolved against a Base IRI. Typically data does not contain relative IRIs and this field may be left empty.",
"import.popover.context.link": "Context link is used when importing JSONLD documents only.",
"import.alert.not.valid.iri": "Not a valid IRI!",
"import.target.graphs": "Target graphs",
"import.into.graphs": "Data is imported into one or more graphs. Some RDF formats may specify graphs, while others do not support that. The latter are treated as if they specify the default graph.",
Expand Down Expand Up @@ -930,6 +931,7 @@
"import.last.import.settings": "Last import settings",
"import.mode.not.supported.constraint": "This mode is not supported when importing multiple items.",
"import.enable.replace.option": "Enable this to replace the data in one or more graphs with the imported data.",
"import.context.link": "Context link",
"text.snippet.text.aria.placeholder": "# Example: rdf:predicate a rdf:Property .",
"url.import.input.placeholder": "Data URL",
"filesTable.interrupt.import": "Interrupt import",
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/locale-fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@
"import.label.bnodes": "BNodes",
"import.label.datatype": "Datatype",
"import.popover.relative.iri": "Les données RDF peuvent contenir des IRI relatifs. Afin de leur donner un sens, ils doivent être résolus par rapport à un IRI de base. En général, les données ne contiennent pas d'IRI relatifs et ce champ peut être laissé vide.",
"import.popover.context.link": "Le lien contextuel est utilisé uniquement lors de l'importation de documents JSONLD.",
"import.alert.not.valid.iri": "Pas un IRI valide !",
"import.target.graphs": "Graphes cibles",
"import.into.graphs": "Les données sont importées dans un ou plusieurs graphes. Certains formats RDF peuvent spécifier des graphes, tandis que d'autres ne le supportent pas. Ces derniers sont traités comme s'ils spécifiaient le graphe par défaut.",
Expand Down Expand Up @@ -930,6 +931,7 @@
"import.last.import.settings": "Paramètres de la dernière importation",
"import.mode.not.supported.constraint": "Ce mode n'est pas pris en charge lors de l'importation de plusieurs éléments.",
"import.enable.replace.option": "Activez cette option pour remplacer les données d'un ou plusieurs graphes par les données importées.",
"import.context.link": "Lien contextuel",
"text.snippet.text.aria.placeholder": "# Exemple : rdf:predicate a rdf:Property .",
"url.import.input.placeholder": "URL des données",
"filesTable.interrupt.import": "Interrompre l'importation",
Expand Down
1 change: 1 addition & 0 deletions src/js/angular/import/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ importCtrl.controller('CommonCtrl', ['$scope', '$http', 'toastr', '$interval', '
$scope.setSettingsFor = function (fileName, withDefaultSettings) {
$scope.settingsFor = fileName;
$scope.settings = $scope.getSettingsFor(fileName, withDefaultSettings);
$scope.settings.isJSONLDFile = fileName.endsWith("jsonld");

const options = {
templateUrl: 'js/angular/import/templates/settingsModal.html',
Expand Down
18 changes: 17 additions & 1 deletion src/js/angular/import/templates/settingsModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,23 @@ <h4 class="modal-title">{{'import.settings' | translate}}</h4>
</div>
</div>


<div ng-show="showAdvancedSettings && settings.isJSONLDFile" class="form-group row contextLinkRow">
<label class="col-lg-3 col-form-label">
{{'import.context.link' | translate}}
<span class="btn btn-link p-0"
uib-popover="{{'import.popover.context.link' | translate}}"
popover-trigger="mouseenter"
popover-placement="right"><em class="icon icon-info"></em></span>
</label>
<div class="col-lg-9">
<input validate-uri name="contextLink" type="text"
ng-model="settings['parserSettings']['contextLink']" class="form-control"
placeholder="http://example.com/example.jsonld">
<div class="alert alert-danger" ng-if="hasError(settingsForm.$error.validateUri, 'contextLink')">
{{'import.alert.not.valid.iri' | translate}}
</div>
</div>
</div>
</div>
</form>
</div>
Expand Down
27 changes: 27 additions & 0 deletions test-cypress/fixtures/graphdb-import/0007-import-file.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"@graph": [
{
"@id": "http://example.org/test#chapter",
"http://purl.org/dc/elements/1.1/description": ["Fun"],
"http://purl.org/dc/elements/1.1/title": ["Chapter One"]
},
{
"@id": "http://example.org/test#jane",
"http://example.org/vocab#authored": [{"@id": "http://example.org/test#chapter"}],
"http://xmlns.com/foaf/0.1/name": ["Jane"]
},
{
"@id": "http://example.org/test#john",
"http://xmlns.com/foaf/0.1/name": ["John"]
},
{
"@id": "http://example.org/test#library",
"http://example.org/vocab#contains": [{
"@id": "http://example.org/test#book",
"http://example.org/vocab#contains": [ "this-is-not-an-IRI" ],
"http://purl.org/dc/elements/1.1/contributor": ["Writer"],
"http://purl.org/dc/elements/1.1/title": ["My Book"]
}]
}
]
}
2 changes: 2 additions & 0 deletions test-cypress/fixtures/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@
"import.label.bnodes": "BNodes",
"import.label.datatype": "Datatype",
"import.popover.relative.iri": "RDF data may contain relative IRIs. In order to make sense of them, they need to be resolved against a Base IRI. Typically data does not contain relative IRIs and this field may be left empty.",
"import.popover.context.link": "Context link is used when importing JSONLD documents only.",
"import.alert.not.valid.iri": "Not a valid IRI!",
"import.target.graphs": "Target graphs",
"import.into.graphs": "Data is imported into one or more graphs. Some RDF formats may specify graphs, while others do not support that. The latter are treated as if they specify the default graph.",
Expand Down Expand Up @@ -919,6 +920,7 @@
"import.last.import.settings": "Last import settings",
"import.mode.not.supported.constraint": "This mode is not supported when importing multiple items.",
"import.enable.replace.option": "Enable this to replace the data in one or more graphs with the imported data.",
"import.context.link": "Context link",
"text.snippet.text.aria.placeholder": "# Example: rdf:predicate a rdf:Property .",
"url.import.input.placeholder": "Data URL",
"filesTable.interrupt.import": "Interrupt import",
Expand Down
3 changes: 2 additions & 1 deletion test-cypress/fixtures/url-import-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"normalizeLanguageTags": false,
"verifyURISyntax": true,
"verifyRelativeURIs": true,
"stopOnError": true
"stopOnError": true,
"contextLink": null
},
"xRequestIdHeaders": null
}
18 changes: 18 additions & 0 deletions test-cypress/integration/import/import.server.files.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ describe('Import screen validation - server files', () => {
const FILE_FOR_IMPORT = 'italian_public_schools_links.nt.gz';
const TTLS_FOR_IMPORT = 'test_turtlestar.ttls';
const TRIGS_FOR_IMPORT = 'test-trigstar.trigs';
const JSONLD_FILE_FOR_IMPORT = '0007-import-file.jsonld';
const JSONLD_CONTEXT = 'https://w3c.github.io/json-ld-api/tests/compact/0007-context.jsonld';

beforeEach(() => {
repositoryId = 'server-import-' + Date.now();
Expand Down Expand Up @@ -42,6 +44,22 @@ describe('Import screen validation - server files', () => {
.verifyImportStatusDetails(FILE_FOR_IMPORT, [CONTEXT, BASE_URI, '"preserveBNodeIds": true,']);
});

// for this test it is necessary to set up a whitelist to GraphDB in this way: -Dgraphdb.jsonld.whitelist=https://w3c.github.io/json-ld-api/tests/*
it('Test import Server files successfully with JSONLD context link settings', () => {
ImportSteps.selectServerFile(JSONLD_FILE_FOR_IMPORT)
.importServerFiles(true)
.fillBaseURI(BASE_URI)
.selectNamedGraph()
.fillNamedGraph(CONTEXT)
.expandAdvancedSettings()
.setContextLinkToBeVisible()
.enablePreserveBNodes()
.fillContextLink(JSONLD_CONTEXT)
.importFromSettingsDialog()
.verifyImportStatus(JSONLD_FILE_FOR_IMPORT, SUCCESS_MESSAGE)
.verifyImportStatusDetails(JSONLD_FILE_FOR_IMPORT, [CONTEXT, BASE_URI, '"preserveBNodeIds": true,', JSONLD_CONTEXT]);
});

it('Test import with resetting status of imported file', () => {
ImportSteps
.selectServerFile(FILE_FOR_IMPORT)
Expand Down
14 changes: 14 additions & 0 deletions test-cypress/steps/import-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,20 @@ class ImportSteps {
return ImportSteps;
}

static fillContextLink(contextLink) {
ImportSteps.getSettingsForm().find('input[name="contextLink"]').type(contextLink).should('have.value', contextLink);

return ImportSteps;
}

static setContextLinkToBeVisible() {
ImportSteps.getSettingsForm().within(() => {
cy.get('.contextLinkRow').invoke('attr', 'style', 'display: block !important');
});

return ImportSteps;
}

static resetStatusOfUploadedFiles() {
// Button should disappear
cy.get('#import-server #wb-import-clearStatuses')
Expand Down

0 comments on commit 6dd5b09

Please sign in to comment.