-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added db authentication and minor modifications to getAllProperties q…
…uery
- Loading branch information
Showing
9 changed files
with
1,220 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
#!/bin/sh | ||
|
||
set -e; | ||
uname=`grep -oP '(?<="vocserver.database.username": ")[^"]*' /docker-entrypoint-initdb.d/vocserver.json` | ||
passwd=`grep -oP '(?<="vocserver.database.password": ")[^"]*' /docker-entrypoint-initdb.d/vocserver.json` | ||
|
||
mongo <<EOF | ||
use voc | ||
db.createUser({user: "$uname", pwd: "$passwd", roles: [ { role: "readWrite", db: "voc" }]}) | ||
db.createCollection("master") | ||
db.createCollection("properties") | ||
db.originTable.createIndex("@id") | ||
db.properties.createIndex({"@id": 1}) | ||
db.createCollection("classes") | ||
db.originTable.createIndex("@id") | ||
db.classes.createIndex({"@id": 1}) | ||
quit() | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,9 +37,9 @@ class DBServiceImpl implements DBService { | |
+ " { \"$project\": {\"_id\": 0, \"rdfs:label\": \"[email protected]:label\", \"rdfs:comment\": \"[email protected]:comment\" } } ])"; | ||
|
||
// Find all properties | ||
// TODO: Temporary fix for searching all kinds of properties | ||
private static final String QUERY_FIND_ALL_PROPERTIES = | ||
"[ {\"$unwind\": \"$@graph\"}," | ||
+ " { \"$match\": {\"@graph.@type\": { \"$in\": [\"rdf:Property\"] }}}," | ||
+ " { \"$project\": {\"_id\": 0, \"rdfs:label\": \"[email protected]:label\", \"rdfs:comment\": \"[email protected]:comment\" } } ])"; | ||
|
||
// Find a class | ||
|
@@ -169,12 +169,37 @@ public DBService getClass(String name, Handler<AsyncResult<JsonObject>> resultHa | |
return this; | ||
} | ||
|
||
/** | ||
* @{@inheritDoc} | ||
*/ | ||
@Override | ||
public DBService insertMasterContext(JsonObject context, | ||
Handler<AsyncResult<Boolean>> resultHandler) { | ||
dbClient.dropCollection("master", | ||
res -> { | ||
if (!res.succeeded()) { | ||
LOGGER.error("Failed inserting master schema"); | ||
resultHandler.handle(Future.failedFuture(res.cause())); | ||
} | ||
}); | ||
dbClient.insert("master", context, | ||
res -> { | ||
if (res.succeeded()) { | ||
resultHandler.handle(Future.succeededFuture()); | ||
} else { | ||
LOGGER.error("Failed inserting master schema"); | ||
resultHandler.handle(Future.failedFuture(res.cause())); | ||
} | ||
}); | ||
return this; | ||
} | ||
|
||
/** | ||
* @{@inheritDoc} | ||
*/ | ||
@Override | ||
public DBService insertProperty(String name, JsonObject prop, | ||
Handler<AsyncResult<JsonObject>> resultHandler) { | ||
Handler<AsyncResult<Boolean>> resultHandler) { | ||
dbClient.updateCollectionWithOptions("properties", | ||
new JsonObject(QUERY_MATCH_ID.replace("$1", "iudx:"+name)), | ||
new JsonObject().put("$set", prop), | ||
|
@@ -196,7 +221,7 @@ public DBService insertProperty(String name, JsonObject prop, | |
*/ | ||
@Override | ||
public DBService insertClass(String name, JsonObject cls, | ||
Handler<AsyncResult<JsonObject>> resultHandler) { | ||
Handler<AsyncResult<Boolean>> resultHandler) { | ||
dbClient.updateCollectionWithOptions("classes", | ||
new JsonObject(QUERY_MATCH_ID.replace("$1", "iudx:"+name)), | ||
new JsonObject().put("$set", cls), | ||
|
@@ -219,7 +244,7 @@ public DBService insertClass(String name, JsonObject cls, | |
*/ | ||
@Override | ||
public DBService deleteClass(String name, | ||
Handler<AsyncResult<JsonObject>> resultHandler) { | ||
Handler<AsyncResult<Boolean>> resultHandler) { | ||
dbClient.findOneAndDelete("classes", | ||
new JsonObject(QUERY_MATCH_ID.replace("$1", "iudx:"+name)), | ||
res -> { | ||
|
@@ -238,7 +263,7 @@ public DBService deleteClass(String name, | |
*/ | ||
@Override | ||
public DBService deleteProperty(String name, | ||
Handler<AsyncResult<JsonObject>> resultHandler) { | ||
Handler<AsyncResult<Boolean>> resultHandler) { | ||
dbClient.findOneAndDelete("property", | ||
new JsonObject(QUERY_MATCH_ID.replace("$1", "iudx:"+name)), | ||
res -> { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.