Skip to content

Commit 7acae99

Browse files
committed
add woql post
1 parent a806292 commit 7acae99

File tree

6 files changed

+95
-8
lines changed

6 files changed

+95
-8
lines changed

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ CHANGELOG.md
2626
.prettierrc
2727
.gitignore
2828
app.js
29+
30+
.demo

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,16 @@ branches:
2525
before_deploy:
2626
- |
2727
if [[ ! $TRAVIS_VAR ]]; then
28-
printf "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc
2928
npm run build
3029
echo "___TRAVIS_VAR____"
3130
export TRAVIS_VAR="1.$TRAVIS_BUILD_NUMBER"
32-
3331
git commit --amend -m "[skip travis] version changed $PACKAGE_VERSION"
3432
git push https://${GITHUB_TOKEN}@github.com/$TRAVIS_REPO_SLUG HEAD:$TRAVIS_BRANCH
3533
git tag -f -a "$PACKAGE_VERSION" -m "new version $PACKAGE_VERSION"
3634
export LAST_HASH=$(git ls-remote https://github.com/$TRAVIS_REPO_SLUG $TRAVIS_BRANCH | awk '{ print $1}')
3735
echo $LAST_HASH
3836
fi
39-
#https://blog.travis-ci.com/2018-04-11-how_to_publish_node_js_packages_with_travis_ci_and_packagecloud/
37+
4038
deploy:
4139
- provider: script
4240
skip_cleanup: true
@@ -55,10 +53,13 @@ deploy:
5553
branch: clientBuild
5654
condition: $TRAVIS_COMMIT_MESSAGE == *"[run deploy]"*
5755
- provider: npm
56+
registry: "https://registry.npmjs.org/"
5857
skip_cleanup: true
58+
access: public
5959
6060
api_key: $NPM_TOKEN
6161
keep_history: true
62+
auth_method: "authToken"
6263
on:
6364
branch : clientBuild
6465
condition: $TRAVIS_COMMIT_MESSAGE == *"[run deploy]"*

demo/multiFile/multi.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
var dbClient = new TerminusClient.WOQLClient();
3+
var connection=dbClient.connect("http://195.201.12.87:6365/", "connectors wanna plans compressed","rational_warehouse");
4+
5+
var WOQL = TerminusClient.WOQL;
6+
7+
(function () {
8+
var fileCatcher = document.getElementById('file-catcher');
9+
var fileInput = document.getElementById('file-input');
10+
var fileListDisplay = document.getElementById('file-list-display');
11+
12+
var fileList = [];
13+
var renderFileList, sendFile;
14+
15+
fileCatcher.addEventListener('submit', function (evnt) {
16+
evnt.preventDefault();
17+
fileList.forEach(function (file) {
18+
sendFile(file);
19+
});
20+
});
21+
22+
fileInput.addEventListener('change', function (evnt) {
23+
fileList = [];
24+
25+
console.log("__FILELIST___",fileInput.files);
26+
27+
for (var i = 0; i < fileInput.files.length; i++) {
28+
fileList.push(fileInput.files[i]);
29+
}
30+
renderFileList();
31+
});
32+
33+
renderFileList = function () {
34+
fileListDisplay.innerHTML = '';
35+
fileList.forEach(function (file, index) {
36+
var fileDisplayEl = document.createElement('p');
37+
fileDisplayEl.innerHTML = (index + 1) + ': ' + file.name;
38+
fileListDisplay.appendChild(fileDisplayEl);
39+
40+
const query=WOQL.and(
41+
WOQL.quad("v:Element","type","Class","schema"),
42+
WOQL.opt().quad("v:Element","label","v:Label","schema"),
43+
WOQL.opt().quad("v:Element","comment","v:Comment","schema"),
44+
WOQL.opt().quad("v:Element","tcs:tag","v:Abstract","schema")
45+
)
46+
47+
console.log(formData);
48+
49+
query.execute(dbClient,formData);
50+
});
51+
52+
53+
54+
};
55+
56+
sendFile = function (file) {
57+
var formData = new FormData();
58+
formData.set('file', file);
59+
60+
var request = new XMLHttpRequest();
61+
62+
request.open("POST", 'https://localhost');
63+
request.send(formData);
64+
};
65+
})();

demo/multiFile/testMultiFile.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script src="http://localhost/terminus-client/public_pages/1.1.2/dist/terminus-client.min.js"></script>
2+
3+
4+
<form id='file-catcher'>
5+
<input id='file-input' type='file' multiple/>
6+
<button type='submit'>
7+
Submit
8+
</button>
9+
</form>
10+
<div id='file-list-display'></div>
11+
12+
<script src="multi.js"></script>

lib/woql.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ WOQLQuery.prototype.addStart = function(s){
18691869
/**
18701870
* Executes the query using the passed client to connect to a server
18711871
*/
1872-
WOQLQuery.prototype.execute = function(client){
1872+
WOQLQuery.prototype.execute = function(client,fileList){
18731873
if(!this.query["@context"]){
18741874
this.query['@context'] = client.connection.getJSONContext();
18751875
for(var pref in UTILS.standard_urls){
@@ -1882,12 +1882,14 @@ WOQLQuery.prototype.execute = function(client){
18821882
var json = this.json();
18831883
}
18841884
this.query["@context"]["_"] = "_:";
1885+
const opts=fileList ? {fileList:fileList} : null;
18851886
if(this.contains_update){
1886-
return client.select(false, json);
1887+
return client.select(false, json,opts);
18871888
//return client.update(false, json);
18881889
}
18891890
else {
1890-
return client.select(false, json);
1891+
return client.select(false, json,opts);
1892+
//return client.update(false, json);
18911893
}
18921894
}
18931895

lib/woqlClient.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@ WOQLClient.prototype.select = function (qurl, woql, opts) {
297297
new URIError(ErrorMessage.getInvalidURIMessage(qurl, 'Select'))
298298
);
299299
}
300-
let q = { 'terminus:query': JSON.stringify(woql) };
300+
const fileList = opts ? opts.fileList : {};
301+
let q = {'terminus:query' : JSON.stringify(woql), ...fileList};
302+
301303
q = this.addOptionsToWOQL(q, opts);
302304
return this.dispatch(this.connectionConfig.queryURL(), CONST.WOQL_SELECT, q);
303305
};
@@ -317,7 +319,10 @@ WOQLClient.prototype.update = function (qurl, woql, opts) {
317319
new URIError(ErrorMessage.getInvalidURIMessage(qurl, 'Update'))
318320
);
319321
}
320-
woql = this.addOptionsToWOQL(woql, opts);
322+
//{fileName01,filePath,fileName02:filePath02....}
323+
const fileList = opts ? opts.fileList : {};
324+
let q = {'terminus:query' : JSON.stringify(woql), ...fileList};
325+
q = this.addOptionsToWOQL(q, opts);
321326
return this.dispatch(this.connectionConfig.queryURL(), 'woql_update', woql);
322327
};
323328

0 commit comments

Comments
 (0)