openseek-api 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +34 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +20 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +106 -0
- data/LICENSE +24 -0
- data/README.md +23 -0
- data/Rakefile +9 -0
- data/jars/lib/aopalliance.jar +0 -0
- data/jars/lib/aspectjweaver.jar +0 -0
- data/jars/lib/cglib-nodep.jar +0 -0
- data/jars/lib/cisd-args4j.jar +0 -0
- data/jars/lib/commons-codec.jar +0 -0
- data/jars/lib/commons-io.jar +0 -0
- data/jars/lib/commons-lang.jar +0 -0
- data/jars/lib/commons-logging.jar +0 -0
- data/jars/lib/dom4j-1.6.1.jar +0 -0
- data/jars/lib/dss_upload_gui.jar +0 -0
- data/jars/lib/geronimo-stax-api_1.0_spec-1.0.jar +0 -0
- data/jars/lib/guava-11.0.2.jar +0 -0
- data/jars/lib/httpclient.jar +0 -0
- data/jars/lib/httpcore.jar +0 -0
- data/jars/lib/ij.jar +0 -0
- data/jars/lib/image-viewer.jar +0 -0
- data/jars/lib/jackson-annotations-2.8.5.jar +0 -0
- data/jars/lib/jackson-core-2.8.5.jar +0 -0
- data/jars/lib/jackson-databind-2.8.5.jar +0 -0
- data/jars/lib/javassist-3.16.1-GA.jar +0 -0
- data/jars/lib/jline.jar +0 -0
- data/jars/lib/json-simple-1.1.jar +0 -0
- data/jars/lib/jsr305-1.3.9.jar +0 -0
- data/jars/lib/jython.jar +0 -0
- data/jars/lib/log4j.jar +0 -0
- data/jars/lib/openbis_api-16.05.2-r37019.jar +0 -0
- data/jars/lib/poi-ooxml-schemas.jar +0 -0
- data/jars/lib/poi-ooxml.jar +0 -0
- data/jars/lib/poi.jar +0 -0
- data/jars/lib/reflections-0.9.9-RC1.jar +0 -0
- data/jars/lib/sis-base.jar +0 -0
- data/jars/lib/spring-aop.jar +0 -0
- data/jars/lib/spring-beans.jar +0 -0
- data/jars/lib/spring-context.jar +0 -0
- data/jars/lib/spring-core.jar +0 -0
- data/jars/lib/spring-expression.jar +0 -0
- data/jars/lib/spring-web.jar +0 -0
- data/jars/lib/spring-webmvc.jar +0 -0
- data/jars/lib/stax-api.jar +0 -0
- data/jars/lib/stream-supporting-httpinvoker.jar +0 -0
- data/jars/lib/xml-apis-1.0.b2.jar +0 -0
- data/jars/lib/xmlbeans-2.3.0.jar +0 -0
- data/jars/openseek-api-0.9.jar +0 -0
- data/lib/fairdom/openbis_api/application_server_query.rb +16 -0
- data/lib/fairdom/openbis_api/authentication.rb +25 -0
- data/lib/fairdom/openbis_api/data_store_download.rb +13 -0
- data/lib/fairdom/openbis_api/data_store_query.rb +18 -0
- data/lib/fairdom/openbis_api/java_execution.rb +46 -0
- data/lib/fairdom/openbis_api/openbis_query.rb +27 -0
- data/lib/fairdom/openbis_api/openbis_query_exception.rb +5 -0
- data/lib/fairdom/openbis_api/versions.rb +6 -0
- data/lib/openseek-api-gem.rb +12 -0
- data/openseek-api-gem.gemspec +27 -0
- data/test/application_query_test.rb +111 -0
- data/test/authentication_test.rb +30 -0
- data/test/data_store_download_test.rb +62 -0
- data/test/data_store_query_test.rb +60 -0
- metadata +180 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9d09a04d182af1ff95a8bfeeac27b0ce337ce951
|
4
|
+
data.tar.gz: 1f97c0b533e95d4c33b65a69583294f4c546960c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9cf6b345c70e1434fa35611f7dfbfee696c0a67e879f7c7b57338400fe10a80301fede9fb0022ddb5f35b6b04642e161c61bfee3c76b951c964a6799ea3b9966
|
7
|
+
data.tar.gz: b21e81c4a38ce206c886de149aaaa3a33a7eab0671b64e68ed0318d98ff649e4f2a9392b246607e0cab2870bd0ed78b26e46c419a964cbd1378c2e68521cf905
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.rbc
|
2
|
+
capybara-*.html
|
3
|
+
.rspec
|
4
|
+
/log
|
5
|
+
/tmp
|
6
|
+
/db/*.sqlite3
|
7
|
+
/public/system
|
8
|
+
/coverage/
|
9
|
+
/test/coverage/
|
10
|
+
/spec/tmp
|
11
|
+
**.orig
|
12
|
+
rerun.txt
|
13
|
+
pickle-email-*.html
|
14
|
+
.idea/
|
15
|
+
|
16
|
+
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo
|
17
|
+
config/initializers/secret_token.rb
|
18
|
+
config/secrets.yml
|
19
|
+
|
20
|
+
## Environment normalisation:
|
21
|
+
/.bundle
|
22
|
+
/vendor/bundle
|
23
|
+
|
24
|
+
# these should all be checked in to normalise the environment:
|
25
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
26
|
+
|
27
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
28
|
+
.rvmrc
|
29
|
+
|
30
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
31
|
+
/vendor/assets/bower_components
|
32
|
+
*.bowerrc
|
33
|
+
bower.json
|
34
|
+
test/tmp
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
openbis-api-gem
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.9
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
sudo: false
|
4
|
+
|
5
|
+
cache: bundler
|
6
|
+
|
7
|
+
rvm:
|
8
|
+
- 2.1.9
|
9
|
+
|
10
|
+
jdk:
|
11
|
+
- oraclejdk8
|
12
|
+
- oraclejdk7
|
13
|
+
- openjdk7
|
14
|
+
|
15
|
+
script:
|
16
|
+
- bundle exec rake test
|
17
|
+
|
18
|
+
notifications:
|
19
|
+
slack:
|
20
|
+
secure: fK3kbDHg/kwFCjxhFkg0wkOcwXoFwkfJJdRFwZQtnMDkY4yHNtr9SWIHWOiI9OceNgWLeHwvvm/7737WBWnTf4RF3mn0/D9xYtOn+DfV2gb1xXVjDb33oBQWrFN8P1x4xFNOMw38LQ46NYvsv6bfPmZRJpKuvHPVJUsBCINx14w=
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
openseek-api (0.9.1)
|
5
|
+
cocaine
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.5.0)
|
11
|
+
public_suffix (~> 2.0, >= 2.0.2)
|
12
|
+
ast (2.3.0)
|
13
|
+
axiom-types (0.1.1)
|
14
|
+
descendants_tracker (~> 0.0.4)
|
15
|
+
ice_nine (~> 0.11.0)
|
16
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
17
|
+
climate_control (0.1.0)
|
18
|
+
cocaine (0.5.8)
|
19
|
+
climate_control (>= 0.0.3, < 1.0)
|
20
|
+
codeclimate-engine-rb (0.4.0)
|
21
|
+
virtus (~> 1.0)
|
22
|
+
coercible (1.0.0)
|
23
|
+
descendants_tracker (~> 0.0.1)
|
24
|
+
coveralls (0.8.19)
|
25
|
+
json (>= 1.8, < 3)
|
26
|
+
simplecov (~> 0.12.0)
|
27
|
+
term-ansicolor (~> 1.3)
|
28
|
+
thor (~> 0.19.1)
|
29
|
+
tins (~> 1.6)
|
30
|
+
descendants_tracker (0.0.4)
|
31
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
32
|
+
docile (1.1.5)
|
33
|
+
equalizer (0.0.11)
|
34
|
+
erubis (2.7.0)
|
35
|
+
flay (2.8.1)
|
36
|
+
erubis (~> 2.7.0)
|
37
|
+
path_expander (~> 1.0)
|
38
|
+
ruby_parser (~> 3.0)
|
39
|
+
sexp_processor (~> 4.0)
|
40
|
+
flog (4.6.1)
|
41
|
+
path_expander (~> 1.0)
|
42
|
+
ruby_parser (~> 3.1, > 3.1.0)
|
43
|
+
sexp_processor (~> 4.8)
|
44
|
+
ice_nine (0.11.2)
|
45
|
+
json (2.0.3)
|
46
|
+
launchy (2.4.3)
|
47
|
+
addressable (~> 2.3)
|
48
|
+
parser (2.3.3.1)
|
49
|
+
ast (~> 2.2)
|
50
|
+
path_expander (1.0.1)
|
51
|
+
powerpack (0.1.1)
|
52
|
+
public_suffix (2.0.5)
|
53
|
+
rainbow (2.2.1)
|
54
|
+
rake (10.4.2)
|
55
|
+
reek (4.5.6)
|
56
|
+
codeclimate-engine-rb (~> 0.4.0)
|
57
|
+
parser (>= 2.3.1.2, < 2.5)
|
58
|
+
rainbow (~> 2.0)
|
59
|
+
rubocop (0.47.1)
|
60
|
+
parser (>= 2.3.3.1, < 3.0)
|
61
|
+
powerpack (~> 0.1)
|
62
|
+
rainbow (>= 1.99.1, < 3.0)
|
63
|
+
ruby-progressbar (~> 1.7)
|
64
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
65
|
+
ruby-progressbar (1.8.1)
|
66
|
+
ruby_parser (3.8.4)
|
67
|
+
sexp_processor (~> 4.1)
|
68
|
+
rubycritic (3.1.3)
|
69
|
+
flay (~> 2.8)
|
70
|
+
flog (~> 4.4)
|
71
|
+
launchy (= 2.4.3)
|
72
|
+
parser (= 2.3.3.1)
|
73
|
+
rainbow (~> 2.1)
|
74
|
+
reek (~> 4.4)
|
75
|
+
ruby_parser (~> 3.8)
|
76
|
+
virtus (~> 1.0)
|
77
|
+
sexp_processor (4.8.0)
|
78
|
+
simplecov (0.12.0)
|
79
|
+
docile (~> 1.1.0)
|
80
|
+
json (>= 1.8, < 3)
|
81
|
+
simplecov-html (~> 0.10.0)
|
82
|
+
simplecov-html (0.10.0)
|
83
|
+
term-ansicolor (1.4.0)
|
84
|
+
tins (~> 1.0)
|
85
|
+
thor (0.19.4)
|
86
|
+
thread_safe (0.3.6)
|
87
|
+
tins (1.13.2)
|
88
|
+
unicode-display_width (1.1.3)
|
89
|
+
virtus (1.0.5)
|
90
|
+
axiom-types (~> 0.1)
|
91
|
+
coercible (~> 1.0)
|
92
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
93
|
+
equalizer (~> 0.0, >= 0.0.9)
|
94
|
+
|
95
|
+
PLATFORMS
|
96
|
+
ruby
|
97
|
+
|
98
|
+
DEPENDENCIES
|
99
|
+
coveralls
|
100
|
+
openseek-api!
|
101
|
+
rake (~> 10.0)
|
102
|
+
rubocop
|
103
|
+
rubycritic
|
104
|
+
|
105
|
+
BUNDLED WITH
|
106
|
+
1.13.6
|
data/LICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2015, FAIRdom
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
15
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
16
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
17
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
18
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
19
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
20
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
21
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
22
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
23
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
24
|
+
|
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/FAIRdom/openseek-api-gem.png?branch=master)](https://travis-ci.org/FAIRdom/openseek-api-gem)
|
2
|
+
|
3
|
+
[![Coverage Status](https://coveralls.io/repos/github/FAIRdom/openseek-api/badge.svg)](https://coveralls.io/github/FAIRdom/openseek-api)
|
4
|
+
|
5
|
+
[![Code Climate](https://codeclimate.com/github/FAIRdom/openseek-api-gem/badges/gpa.svg)](https://codeclimate.com/github/FAIRdom/openseek-api-gem)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Java 1.8 (JRE) is required.
|
10
|
+
|
11
|
+
gem "openseek-api-gem", :git=>"https://github.com/FAIRdom/openseek-api-gem.git"
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
* Use to query entities in Openbis, filtered on a property with a defined property value.
|
16
|
+
* Entity type is for example Experiment, Sample, DataSet.
|
17
|
+
* Property is normally the SEEK_ID, which is used to map Openbis entity with SEEK entity.
|
18
|
+
|
19
|
+
include Fairdom::OpenbisApi
|
20
|
+
|
21
|
+
instance = Fairdom::OpenbisApi::Query.new(username, password, endpoint)
|
22
|
+
|
23
|
+
json_result = instance.query(type, property, property_value)
|
data/Rakefile
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/jars/lib/ij.jar
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/jars/lib/jline.jar
ADDED
Binary file
|
Binary file
|
Binary file
|
data/jars/lib/jython.jar
ADDED
Binary file
|
data/jars/lib/log4j.jar
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/jars/lib/poi.jar
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Fairdom
|
2
|
+
module OpenbisApi
|
3
|
+
class ApplicationServerQuery < OpenbisQuery
|
4
|
+
attr_reader :as_endpoint
|
5
|
+
|
6
|
+
def initialize(as_endpoint, token)
|
7
|
+
super(token)
|
8
|
+
@as_endpoint = as_endpoint
|
9
|
+
end
|
10
|
+
|
11
|
+
def root_command_options
|
12
|
+
" -endpoints {%as%:%#{as_endpoint}%\,%sessionToken%:%#{token}%}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Fairdom
|
2
|
+
module OpenbisApi
|
3
|
+
class Authentication < OpenbisQuery
|
4
|
+
attr_reader :as_endpoint, :username, :password
|
5
|
+
|
6
|
+
def initialize(username, password, as_endpoint)
|
7
|
+
@username = username
|
8
|
+
@password = password
|
9
|
+
@as_endpoint = as_endpoint
|
10
|
+
end
|
11
|
+
|
12
|
+
def login
|
13
|
+
execute []
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute_command(_options)
|
17
|
+
java_root_command
|
18
|
+
end
|
19
|
+
|
20
|
+
def root_command_options
|
21
|
+
" -account {%username%:%#{username}%\,%password%:%#{password}%} -endpoints {%as%:%#{as_endpoint}%}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Fairdom
|
4
|
+
module OpenbisApi
|
5
|
+
class DataStoreQuery < OpenbisQuery
|
6
|
+
attr_reader :dss_endpoint
|
7
|
+
|
8
|
+
def initialize(dss_endpoint, token)
|
9
|
+
super(token)
|
10
|
+
@dss_endpoint = dss_endpoint
|
11
|
+
end
|
12
|
+
|
13
|
+
def root_command_options
|
14
|
+
" -endpoints {%dss%:%#{dss_endpoint}%\,%sessionToken%:%#{token}%}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'cocaine'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Fairdom
|
5
|
+
module OpenbisApi
|
6
|
+
class JavaExecution
|
7
|
+
attr_reader :query_object
|
8
|
+
|
9
|
+
def initialize(query_object)
|
10
|
+
@query_object = query_object
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute(options)
|
14
|
+
command = execute_command(options)
|
15
|
+
output = Cocaine::CommandLine.new(command).run
|
16
|
+
JSON.parse(output.strip)
|
17
|
+
rescue Cocaine::ExitStatusError => exception
|
18
|
+
raise OpenbisQueryException, exception.message
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def execute_command(options)
|
24
|
+
"#{java_root_command} -#{query_object.command_option_key} {#{command_from_options(options)}}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def command_from_options(options)
|
28
|
+
options.collect do |key, value|
|
29
|
+
"%#{key}%:%#{value.tr(' ', '+')}%"
|
30
|
+
end.join("\,")
|
31
|
+
end
|
32
|
+
|
33
|
+
def java_root_command
|
34
|
+
"java -jar #{jar_path} #{query_object.root_command_options}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def jar_path
|
38
|
+
File.join(File.dirname(__dir__), "../../jars/#{jar_file}")
|
39
|
+
end
|
40
|
+
|
41
|
+
def jar_file
|
42
|
+
"openseek-api-#{Fairdom::OpenbisApi::JAR_VERSION}.jar"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'fairdom/openbis_api/java_execution'
|
2
|
+
|
3
|
+
module Fairdom
|
4
|
+
module OpenbisApi
|
5
|
+
class OpenbisQuery
|
6
|
+
attr_reader :token
|
7
|
+
|
8
|
+
def initialize(token)
|
9
|
+
@token = token
|
10
|
+
end
|
11
|
+
|
12
|
+
def query(options)
|
13
|
+
execute(options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def command_option_key
|
17
|
+
'query'
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def execute(options)
|
23
|
+
JavaExecution.new(self).execute(options)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'fairdom/openbis_api/versions'
|
5
|
+
require 'fairdom/openbis_api/openbis_query'
|
6
|
+
require 'fairdom/openbis_api/openbis_query_exception'
|
7
|
+
|
8
|
+
require 'fairdom/openbis_api/authentication'
|
9
|
+
|
10
|
+
require 'fairdom/openbis_api/application_server_query'
|
11
|
+
require 'fairdom/openbis_api/data_store_query'
|
12
|
+
require 'fairdom/openbis_api/data_store_download'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'fairdom/openbis_api/versions'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "openseek-api"
|
7
|
+
s.version = Fairdom::OpenbisApi::VERSION
|
8
|
+
s.authors = ["quyen"]
|
9
|
+
s.email = ["thucquyendn@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{ruby gem to talk to openbis-api java}
|
12
|
+
s.description = %q{ruby gem to talk to openbis-api java}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
# specify any dependencies here; for example:
|
20
|
+
s.add_development_dependency("coveralls", ['>= 0'])
|
21
|
+
s.add_development_dependency('rubocop', ['>= 0'])
|
22
|
+
s.add_development_dependency('rubycritic', ['>= 0'])
|
23
|
+
s.add_development_dependency("rake",['~> 10.0'])
|
24
|
+
|
25
|
+
s.add_dependency('cocaine', ['>= 0'])
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require 'coveralls'
|
3
|
+
Coveralls.wear!
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'openseek-api-gem'
|
7
|
+
|
8
|
+
class ApplicationServerQueryTest < Test::Unit::TestCase
|
9
|
+
include Fairdom::OpenbisApi
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@as_endpoint = 'https://openbis-api.fair-dom.org/openbis/openbis'
|
13
|
+
username = 'apiuser'
|
14
|
+
password = 'apiuser'
|
15
|
+
@token = Authentication.new(username, password, @as_endpoint).login['token']
|
16
|
+
|
17
|
+
@options = { entityType: 'Experiment', queryType: 'PROPERTY', property: 'SEEK_STUDY_ID', propertyValue: 'Study_1' }
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_query_property
|
21
|
+
instance = ApplicationServerQuery.new(@as_endpoint, @token)
|
22
|
+
result = instance.query(@options)
|
23
|
+
experiments = result['experiments']
|
24
|
+
refute experiments.empty?
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_query_for_spaces
|
28
|
+
@options = { entityType: 'Space', queryType: 'ATTRIBUTE', attribute: 'PermID', attributeValue: '' }
|
29
|
+
instance = ApplicationServerQuery.new(@as_endpoint, @token)
|
30
|
+
result = instance.query(@options)
|
31
|
+
spaces = result['spaces']
|
32
|
+
refute spaces.empty?
|
33
|
+
assert_equal 2, spaces.count
|
34
|
+
space = spaces[0]
|
35
|
+
assert_equal 'API-SPACE', space['code']
|
36
|
+
assert_equal 'use for testing openbis api integration', space['description'].strip
|
37
|
+
experiments = space['experiments']
|
38
|
+
assert_equal 1, experiments.size
|
39
|
+
assert_equal ['20151216143716562-2'], experiments
|
40
|
+
|
41
|
+
projects = space['projects']
|
42
|
+
assert_equal ['20151216135152196-1'], projects
|
43
|
+
|
44
|
+
datasets = space['datasets']
|
45
|
+
assert_equal 8, datasets.size
|
46
|
+
assert_includes datasets, '20160210130359377-22'
|
47
|
+
|
48
|
+
space = spaces[1]
|
49
|
+
assert_equal 'DEFAULT', space['code']
|
50
|
+
assert_nil space['description']
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_query_property_no_result
|
54
|
+
instance = ApplicationServerQuery.new(@as_endpoint, @token)
|
55
|
+
@options[:propertyValue] = 'Some_value'
|
56
|
+
result = instance.query(@options)
|
57
|
+
assert result.empty?
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_unrecognized_type
|
61
|
+
instance = ApplicationServerQuery.new(@as_endpoint, @token)
|
62
|
+
invalid_type = 'SomeType'
|
63
|
+
@options[:entityType] = 'Some_value'
|
64
|
+
assert_raise OpenbisQueryException do
|
65
|
+
instance.query(@options)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_empty_property
|
70
|
+
instance = ApplicationServerQuery.new(@as_endpoint, @token)
|
71
|
+
@options[:property] = ''
|
72
|
+
result = instance.query(@options)
|
73
|
+
assert result.empty?
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_any_property
|
77
|
+
instance = ApplicationServerQuery.new(@as_endpoint, @token)
|
78
|
+
@options[:property] = 'any_property'
|
79
|
+
result = instance.query(@options)
|
80
|
+
assert result.empty?
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_query_perm_id_attribute
|
84
|
+
instance = ApplicationServerQuery.new(@as_endpoint, @token)
|
85
|
+
@options[:queryType] = 'ATTRIBUTE'
|
86
|
+
@options[:attribute] = 'permId'
|
87
|
+
@options[:attributeValue] = '20151216143716562-2'
|
88
|
+
result = instance.query(@options)
|
89
|
+
experiments = result['experiments']
|
90
|
+
refute experiments.empty?
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_query_multiple_perm_id_attribute_values
|
94
|
+
instance = ApplicationServerQuery.new(@as_endpoint, @token)
|
95
|
+
@options[:queryType] = 'ATTRIBUTE'
|
96
|
+
@options[:attribute] = 'permId'
|
97
|
+
@options[:attributeValue] = '20151216112932823-1,20151216143716562-2'
|
98
|
+
result = instance.query(@options)
|
99
|
+
experiments = result['experiments']
|
100
|
+
refute experiments.empty?
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_query_all_permid
|
104
|
+
instance = ApplicationServerQuery.new(@as_endpoint, @token)
|
105
|
+
@options[:queryType] = 'ATTRIBUTE'
|
106
|
+
@options[:attribute] = 'PermID'
|
107
|
+
@options[:attributeValue] = ''
|
108
|
+
result = instance.query(@options)
|
109
|
+
refute result['experiments'].empty?
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require 'coveralls'
|
3
|
+
Coveralls.wear!
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'openseek-api-gem'
|
7
|
+
|
8
|
+
class AuthenticationTest < Test::Unit::TestCase
|
9
|
+
include Fairdom::OpenbisApi
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@as_endpoint = 'https://openbis-api.fair-dom.org/openbis/openbis'
|
13
|
+
@username = 'apiuser'
|
14
|
+
@password = 'apiuser'
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_successful_authentication
|
18
|
+
au = Authentication.new(@username, @password, @as_endpoint)
|
19
|
+
session_token = au.login
|
20
|
+
assert_not_nil session_token['token']
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_failed_authentication
|
24
|
+
invalid_password = 'blabla'
|
25
|
+
au = Authentication.new(@username, invalid_password, @as_endpoint)
|
26
|
+
assert_raise OpenbisQueryException do
|
27
|
+
au.login
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require 'coveralls'
|
3
|
+
Coveralls.wear!
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'openseek-api-gem'
|
7
|
+
|
8
|
+
class DataStoreDownloadTest < Test::Unit::TestCase
|
9
|
+
include Fairdom::OpenbisApi
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@dss_endpoint = 'https://openbis-api.fair-dom.org/datastore_server'
|
13
|
+
@as_endpoint = 'https://openbis-api.fair-dom.org/openbis/openbis'
|
14
|
+
username = 'apiuser'
|
15
|
+
password = 'apiuser'
|
16
|
+
@token = Authentication.new(username, password, @as_endpoint).login['token']
|
17
|
+
|
18
|
+
@dest_folder = File.dirname(__FILE__) + '/tmp/'
|
19
|
+
FileUtils.mkdir_p @dest_folder unless File.exist?(@dest_folder)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_download_file
|
23
|
+
instance = DataStoreDownload.new(@dss_endpoint, @token)
|
24
|
+
dest = @dest_folder + 'utf8.txt'
|
25
|
+
options = { downloadType: 'file', permID: '20160210130359377-22', source: 'original/utf8.txt', dest: dest }
|
26
|
+
FileUtils.remove_file(dest) if File.exist?(dest)
|
27
|
+
result = instance.download(options)
|
28
|
+
assert File.exist?(dest)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_download_file_with_space_in_name
|
32
|
+
instance = DataStoreDownload.new(@dss_endpoint, @token)
|
33
|
+
dest = @dest_folder + 'Genes List Nature Paper Test.docx'
|
34
|
+
options = { downloadType: 'file', permID: '20160322172551664-35', source: 'original/Genes List Nature Paper Test.docx', dest: dest }
|
35
|
+
FileUtils.remove_file(dest) if File.exist?(dest)
|
36
|
+
result = instance.download(options)
|
37
|
+
assert File.exist?(dest)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_download_folder
|
41
|
+
instance = DataStoreDownload.new(@dss_endpoint, @token)
|
42
|
+
source = 'original/DEFAULT'
|
43
|
+
dest = @dest_folder
|
44
|
+
options = { downloadType: 'folder', permID: '20160215111736723-31', source: source, dest: dest }
|
45
|
+
FileUtils.remove_dir(dest + source) if File.exist?(dest + source)
|
46
|
+
result = instance.download(options)
|
47
|
+
assert File.exist?(dest + source)
|
48
|
+
assert File.exist?(dest + source + '/fairdom-logo-compact.svg')
|
49
|
+
assert File.exist?(dest + source + '/Stanford_et_al-2015-Molecular_Systems_Biology.pdf')
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_download_dataset_files
|
53
|
+
instance = DataStoreDownload.new(@dss_endpoint, @token)
|
54
|
+
source = 'original'
|
55
|
+
dest = @dest_folder
|
56
|
+
options = { downloadType: 'dataset', permID: '20151217153943290-5', source: source, dest: dest }
|
57
|
+
FileUtils.remove_dir(dest + source) if File.exist?(dest + source)
|
58
|
+
result = instance.download(options)
|
59
|
+
assert File.exist?(dest + source)
|
60
|
+
assert File.exist?(dest + source + '/api-test')
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require 'coveralls'
|
3
|
+
Coveralls.wear!
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'openseek-api-gem'
|
7
|
+
|
8
|
+
class DataStoreQueryTest < Test::Unit::TestCase
|
9
|
+
include Fairdom::OpenbisApi
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@dss_endpoint = 'https://openbis-api.fair-dom.org/datastore_server'
|
13
|
+
@as_endpoint = 'https://openbis-api.fair-dom.org/openbis/openbis'
|
14
|
+
username = 'apiuser'
|
15
|
+
password = 'apiuser'
|
16
|
+
@token = Authentication.new(username, password, @as_endpoint).login['token']
|
17
|
+
|
18
|
+
@options = { entityType: 'DataSetFile', queryType: 'PROPERTY', property: 'SEEK_DATAFILE_ID', propertyValue: 'DataFile_1' }
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_query
|
22
|
+
instance = DataStoreQuery.new(@dss_endpoint, @token)
|
23
|
+
result = instance.query(@options)
|
24
|
+
assert !result['datasetfiles'].empty?
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_query_permid_attribute
|
28
|
+
instance = DataStoreQuery.new(@dss_endpoint, @token)
|
29
|
+
@options[:queryType] = 'ATTRIBUTE'
|
30
|
+
@options[:attribute] = 'PermID'
|
31
|
+
@options[:attributeValue] = '20151217153943290-5'
|
32
|
+
result = instance.query(@options)
|
33
|
+
assert !result['datasetfiles'].empty?
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_query_multiple_permid_attribute_values
|
37
|
+
instance = DataStoreQuery.new(@dss_endpoint, @token)
|
38
|
+
@options[:queryType] = 'ATTRIBUTE'
|
39
|
+
@options[:attribute] = 'PermID'
|
40
|
+
@options[:attributeValue] = '20151217153943290-5,20160210130359377-22'
|
41
|
+
result = instance.query(@options)
|
42
|
+
assert !result['datasetfiles'].empty?
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_query_all_permid
|
46
|
+
instance = DataStoreQuery.new(@dss_endpoint, @token)
|
47
|
+
@options[:queryType] = 'ATTRIBUTE'
|
48
|
+
@options[:attribute] = 'PermID'
|
49
|
+
@options[:attributeValue] = ''
|
50
|
+
result = instance.query(@options)
|
51
|
+
assert !result['datasetfiles'].empty?
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_query_no_result
|
55
|
+
instance = DataStoreQuery.new(@dss_endpoint, @token)
|
56
|
+
@options[:propertyValue] = 'Some_value'
|
57
|
+
result = instance.query(@options)
|
58
|
+
assert result.empty?
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: openseek-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- quyen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: coveralls
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubycritic
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: cocaine
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: ruby gem to talk to openbis-api java
|
84
|
+
email:
|
85
|
+
- thucquyendn@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".coveralls.yml"
|
91
|
+
- ".gitignore"
|
92
|
+
- ".ruby-gemset"
|
93
|
+
- ".ruby-version"
|
94
|
+
- ".travis.yml"
|
95
|
+
- Gemfile
|
96
|
+
- Gemfile.lock
|
97
|
+
- LICENSE
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- jars/lib/aopalliance.jar
|
101
|
+
- jars/lib/aspectjweaver.jar
|
102
|
+
- jars/lib/cglib-nodep.jar
|
103
|
+
- jars/lib/cisd-args4j.jar
|
104
|
+
- jars/lib/commons-codec.jar
|
105
|
+
- jars/lib/commons-io.jar
|
106
|
+
- jars/lib/commons-lang.jar
|
107
|
+
- jars/lib/commons-logging.jar
|
108
|
+
- jars/lib/dom4j-1.6.1.jar
|
109
|
+
- jars/lib/dss_upload_gui.jar
|
110
|
+
- jars/lib/geronimo-stax-api_1.0_spec-1.0.jar
|
111
|
+
- jars/lib/guava-11.0.2.jar
|
112
|
+
- jars/lib/httpclient.jar
|
113
|
+
- jars/lib/httpcore.jar
|
114
|
+
- jars/lib/ij.jar
|
115
|
+
- jars/lib/image-viewer.jar
|
116
|
+
- jars/lib/jackson-annotations-2.8.5.jar
|
117
|
+
- jars/lib/jackson-core-2.8.5.jar
|
118
|
+
- jars/lib/jackson-databind-2.8.5.jar
|
119
|
+
- jars/lib/javassist-3.16.1-GA.jar
|
120
|
+
- jars/lib/jline.jar
|
121
|
+
- jars/lib/json-simple-1.1.jar
|
122
|
+
- jars/lib/jsr305-1.3.9.jar
|
123
|
+
- jars/lib/jython.jar
|
124
|
+
- jars/lib/log4j.jar
|
125
|
+
- jars/lib/openbis_api-16.05.2-r37019.jar
|
126
|
+
- jars/lib/poi-ooxml-schemas.jar
|
127
|
+
- jars/lib/poi-ooxml.jar
|
128
|
+
- jars/lib/poi.jar
|
129
|
+
- jars/lib/reflections-0.9.9-RC1.jar
|
130
|
+
- jars/lib/sis-base.jar
|
131
|
+
- jars/lib/spring-aop.jar
|
132
|
+
- jars/lib/spring-beans.jar
|
133
|
+
- jars/lib/spring-context.jar
|
134
|
+
- jars/lib/spring-core.jar
|
135
|
+
- jars/lib/spring-expression.jar
|
136
|
+
- jars/lib/spring-web.jar
|
137
|
+
- jars/lib/spring-webmvc.jar
|
138
|
+
- jars/lib/stax-api.jar
|
139
|
+
- jars/lib/stream-supporting-httpinvoker.jar
|
140
|
+
- jars/lib/xml-apis-1.0.b2.jar
|
141
|
+
- jars/lib/xmlbeans-2.3.0.jar
|
142
|
+
- jars/openseek-api-0.9.jar
|
143
|
+
- lib/fairdom/openbis_api/application_server_query.rb
|
144
|
+
- lib/fairdom/openbis_api/authentication.rb
|
145
|
+
- lib/fairdom/openbis_api/data_store_download.rb
|
146
|
+
- lib/fairdom/openbis_api/data_store_query.rb
|
147
|
+
- lib/fairdom/openbis_api/java_execution.rb
|
148
|
+
- lib/fairdom/openbis_api/openbis_query.rb
|
149
|
+
- lib/fairdom/openbis_api/openbis_query_exception.rb
|
150
|
+
- lib/fairdom/openbis_api/versions.rb
|
151
|
+
- lib/openseek-api-gem.rb
|
152
|
+
- openseek-api-gem.gemspec
|
153
|
+
- test/application_query_test.rb
|
154
|
+
- test/authentication_test.rb
|
155
|
+
- test/data_store_download_test.rb
|
156
|
+
- test/data_store_query_test.rb
|
157
|
+
homepage: ''
|
158
|
+
licenses: []
|
159
|
+
metadata: {}
|
160
|
+
post_install_message:
|
161
|
+
rdoc_options: []
|
162
|
+
require_paths:
|
163
|
+
- lib
|
164
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
requirements: []
|
175
|
+
rubyforge_project:
|
176
|
+
rubygems_version: 2.4.8
|
177
|
+
signing_key:
|
178
|
+
specification_version: 4
|
179
|
+
summary: ruby gem to talk to openbis-api java
|
180
|
+
test_files: []
|