Skip to content

Commit 6d86654

Browse files
author
Jim Amsden
committedJun 26, 2018
Refactored storage services abstract implementation
The implementation now expects an rdflib.js IndexedFormula to be the interface with the storage services. a db.read operation asynchronously returns an IndexedFormula for the resource.
1 parent 0e18dec commit 6d86654

10 files changed

+2718
-308
lines changed
 

‎jsonld.js

-125
This file was deleted.

‎media.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ function define(name, value) {
2222
Object.defineProperty(exports, name, {
2323
value: value,
2424
enumerable: true
25-
});
25+
})
2626
}
2727

28-
define('turtle', 'text/turtle');
29-
define('text', 'text/plain');
30-
define('n3', 'text/n3');
31-
define('jsonld', 'application/ld+json');
32-
define('json', 'application/json');
28+
define('turtle', 'text/turtle')
29+
define('text', 'text/plain')
30+
define('n3', 'text/n3')
31+
define('jsonld', 'application/ld+json')
32+
define('json', 'application/json')
33+
define('rdfxml', 'application/rdf+xml')

‎package-lock.json

+2,520
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
"contributors": "Jim Amsden <jamsden@us.ibm.com>",
99
"dependencies": {
1010
"express": "~4.16.3",
11-
"n3": "~0.11.3",
1211
"jsonld": "~1.0.1",
12+
"ldp-service-jena": "file:~/Developer/LDP/ldp-service-jena",
1313
"mongodb": "~3.0.7",
14-
"ldp-service-mongodb": ""
14+
"n3": "~1.0.0-alpha",
15+
"rdflib": "^0.17.0"
1516
},
1617
"engines": {
17-
"node": "~5.1.0"
18+
"node": "~8.11.1"
1819
},
1920
"repository": {
2021
"type": "git",

‎service.js

+108-108
Large diffs are not rendered by default.

‎storage.js

+29-7
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,52 @@ function ensureIndex() {
4949
}
5050

5151
/*
52-
* Initialize the database
52+
* Initialize the database. This could be done using
53+
* the facilities of the DBMS and may not need to be implemented
54+
* in all cases. It does provide a way to specify the env.dbName
55+
* for the database you want to use, and makes sure the database
56+
* exists and is initialized, possibly with at least one root
57+
* container graph.
5358
*/
5459
exports.init = function init(env, callback) {
55-
throw "storage method init(env, callback) not implemented"
60+
console.log("storage method init(env, callback) not implemented")
5661
}
5762

63+
/*
64+
* Drop an initialized database. This could be done using
65+
* the facilities of the DBMS and may not need to be implemented
66+
* in all cases. Implement this if you want init/drop to be able
67+
* to dynamically create and remove databases. Don't implement
68+
* it if you want the database to be already implemented outside
69+
* the app.
70+
*/
5871
exports.drop = function drop(callback) {
59-
throw "storage method drop(callback) not implemented"
72+
console.log("storage method drop(callback) not implemented")
6073
}
6174

75+
/*
76+
* Used in create methods to reserve a URI for subsequent update.
77+
* Simply creates an empty graph.
78+
*/
6279
exports.reserveURI = function reserveURI(uri, callback) {
6380
throw "storage method reserveURI(uri, callback) not implemented"
6481
}
6582

83+
/*
84+
* Releases a reserved URI that is no longer needed (i.e., the update
85+
* will never be done)
86+
*/
6687
exports.releaseURI = function releaseURI(uri) {
6788
throw "storage method releaseURI(uri) not implemented"
6889
}
6990

70-
exports.put = function put(resource, callback) {
71-
throw "storage method put(resource, callback) not implemented"
91+
92+
exports.update = function update(resource, callback) {
93+
throw "storage method uptate(resource, callback) not implemented"
7294
}
7395

74-
exports.get = function get(uri, callback) {
75-
throw "storage method get(uri, callback) not implemented"
96+
exports.read = function read(uri, callback) {
97+
throw "storage method read(uri, callback) not implemented"
7698
}
7799

78100
exports.remove = function remove(uri, callback) {
File renamed without changes.
File renamed without changes.

‎tests/test-app.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2014 IBM Corporation.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* Initializes the ldp-server and opens a client view for
19+
* accessing LDP resouces and displaying a graph of their links
20+
*/
21+
22+
var express = require('express')
23+
var ldpService = require('../../ldp-service')
24+
25+
// define a simple environment for testing
26+
var env = {
27+
"scheme": "http",
28+
"host": "localhost",
29+
"port": 3000,
30+
"context": "/r",
31+
"storageImpl": "ldp-service-jena",
32+
"jenaURL": "http://localhost:3030/mrm/",
33+
}
34+
35+
// setup LDP middleware
36+
var app = express()
37+
app.use(express.static(__dirname + '/public'))
38+
39+
// initialize database and set up LDP services and viz when ready
40+
app.use(ldpService(env))
41+
42+
// error handling (developer centric)
43+
app.use(function(err, req, res, next){
44+
console.error(err.stack)
45+
res.send(500, 'Something broke!')
46+
})
47+
48+
// Start server
49+
app.listen(env.port, env.host)
50+
console.log('App started on port ' + env.port)

‎turtle.js

-59
This file was deleted.

0 commit comments

Comments
 (0)