case_model 0.0.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -11
- data/case_model.gemspec +6 -1
- data/lib/models/action.rb +35 -33
- data/lib/models/answer.rb +23 -19
- data/lib/models/application.rb +54 -41
- data/lib/models/capability.rb +43 -15
- data/lib/models/deployment_plan.rb +36 -29
- data/lib/models/device.rb +24 -18
- data/lib/models/ecosystem_host.rb +5 -3
- data/lib/models/http_request.rb +20 -18
- data/lib/models/installation.rb +46 -0
- data/lib/models/installation_used_device.rb +18 -0
- data/lib/models/location.rb +13 -11
- data/lib/models/number.rb +27 -0
- data/lib/models/ontology.rb +54 -33
- data/lib/models/property.rb +46 -0
- data/lib/models/question.rb +42 -37
- data/lib/models/question_reply_type.rb +15 -11
- data/lib/models/requirement.rb +16 -10
- data/lib/models/scenario.rb +30 -0
- data/lib/models/selection.rb +25 -23
- data/lib/models/state_change.rb +15 -13
- data/lib/models/temperature.rb +13 -11
- data/lib/ontology/http_vocabulary.rb +14 -12
- data/lib/ontology/local_vocabulary.rb +24 -18
- data/lib/ontology/math_vocabulary.rb +13 -11
- data/lib/ontology/rdf_vocabulary.rb +10 -8
- data/lib/ontology/state_vocabulary.rb +8 -6
- data/lib/services/application_by_capability_finder.rb +29 -27
- data/lib/services/eye_serializer.rb +17 -15
- data/lib/services/helper.rb +12 -0
- data/lib/services/node_builder.rb +26 -24
- data/lib/services/node_query.rb +46 -40
- data/lib/services/reasoner.rb +60 -58
- data/spec/spec_helper.rb +2 -0
- metadata +64 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72e29c0014b3114f458188576bd4dff663b229f5
|
4
|
+
data.tar.gz: b09b410f07d55180399626468d2238d0262171f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ae5a7b702617b06ee831a41a367f9c0a096933ebc4c3258792b0ac292e13040fafb732d10aa9e288fcb4b47864ad34f37aa75ee15670ae90c40501042515e18
|
7
|
+
data.tar.gz: 206f32e422a9e239d7c63560e4aeeeb7cd284acd90e8631d66e51aa32a5d211f2963da69994da57d7bf3aeec9eabbf62f7cedf8c4ea69d4283d857fc1daa681b
|
data/README.md
CHANGED
@@ -4,13 +4,6 @@ CASE (Context-aware Software Ecosystem)
|
|
4
4
|
Evaluation of application models
|
5
5
|
--------------------------------
|
6
6
|
|
7
|
-
Supplementary evaluation for the paper **Semantic Model of Variability and Capabilities of IoT Applications for Embedded Software Ecosystems**.
|
8
|
-
|
9
|
-
# Browsing the sample scenarios
|
10
|
-
|
11
|
-
To investigate the tested application models and scenarios, see the folder
|
12
|
-
[spec/use_cases](spec/use_cases).
|
13
|
-
|
14
7
|
# Installation
|
15
8
|
|
16
9
|
1. Install the Eye reasoner
|
@@ -21,7 +14,3 @@ To investigate the tested application models and scenarios, see the folder
|
|
21
14
|
2. Install [Ruby](https://www.ruby-lang.org/en/) version 2.x.x
|
22
15
|
3. Run in inside a folder for this repository: `gem install bundler`
|
23
16
|
4. Run in inside a folder for this repository: `bundle install`
|
24
|
-
|
25
|
-
# Running the specs
|
26
|
-
|
27
|
-
To run the tests, simply execute `rspec` in the folder of this repository.
|
data/case_model.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'case_model'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.4'
|
4
4
|
s.date = '2016-01-28'
|
5
5
|
s.summary = 'Resolver for the CASE ecosystem application models'
|
6
6
|
s.description = 'Built for the Context-Aware Software Ecosystem. Resolves application model requirements using semantic reasoning.'
|
@@ -12,6 +12,11 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
13
13
|
s.require_paths = ["lib"]
|
14
14
|
|
15
|
+
s.add_runtime_dependency 'rdf-n3', '1.99.0'
|
16
|
+
s.add_runtime_dependency 'rdf-vocab', '0.8.7.1'
|
17
|
+
s.add_runtime_dependency 'webmock', '1.22.3'
|
18
|
+
s.add_runtime_dependency 'rest-client', '1.8.0'
|
19
|
+
|
15
20
|
s.homepage = 'https://github.com/case-iot/app_model'
|
16
21
|
s.license = 'MIT'
|
17
22
|
end
|
data/lib/models/action.rb
CHANGED
@@ -1,48 +1,50 @@
|
|
1
1
|
require_relative '../services/question_references'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Model
|
4
|
+
class Action
|
5
|
+
attr_reader :query
|
5
6
|
|
6
|
-
|
7
|
+
include QuestionReferences
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def initialize(node, repository)
|
10
|
+
@query = NodeQuery.new(node, repository)
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def description
|
14
|
+
query.value(LV.description)
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
def requirements
|
18
|
+
list = RDF::List.new(query.value(LV.requirement), query.repository)
|
19
|
+
list.map { |node| Requirement.new(node, query.repository) }
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
def failed_requirements
|
23
|
+
requirements.select {|r| not r.satisfied? }
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
def compatible?
|
27
|
+
not failed_requirements.any?
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
def questions
|
31
|
+
q = []
|
32
|
+
q << question if has_question?
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
with_question = requirements.select { |r| r.has_question? }
|
35
|
+
q + with_question.map { |r| r.question }
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
def open_questions
|
39
|
+
questions.select { |q| not q.has_answer? }
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
def execution
|
43
|
+
ActionExecution.new(query.value(LV.executes), query.repository)
|
44
|
+
end
|
44
45
|
|
45
|
-
|
46
|
-
|
46
|
+
def effect
|
47
|
+
StateChange.new(query.value(LV.effect), query.repository)
|
48
|
+
end
|
47
49
|
end
|
48
50
|
end
|
data/lib/models/answer.rb
CHANGED
@@ -1,25 +1,29 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
module Model
|
2
|
+
module Answer
|
3
|
+
def self.create(reply_type, node, repository)
|
4
|
+
case reply_type
|
5
|
+
when :number
|
6
|
+
Number.new(node, repository)
|
7
|
+
when :location
|
8
|
+
Location.new(node, repository)
|
9
|
+
when :temperature
|
10
|
+
Temperature.new(node, repository)
|
11
|
+
when :select
|
12
|
+
Selection.new(node, repository)
|
13
|
+
else
|
14
|
+
nil
|
15
|
+
end
|
12
16
|
end
|
13
|
-
end
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
+
def reply_type
|
19
|
+
question.reply_type
|
20
|
+
end
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
+
def question
|
23
|
+
node = query.value(QV.answers)
|
24
|
+
return nil if node.nil?
|
22
25
|
|
23
|
-
|
26
|
+
Question.new(node, query.repository)
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
data/lib/models/application.rb
CHANGED
@@ -1,57 +1,70 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Model
|
2
|
+
class Application
|
3
|
+
attr_reader :query
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
def initialize(node, repository)
|
6
|
+
@query = NodeQuery.new(node, repository)
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
query.value(RDF::Vocab::FOAF.name)
|
11
|
-
else
|
12
|
-
query.value(LV.name)
|
9
|
+
def uri
|
10
|
+
query.node_uri
|
13
11
|
end
|
14
|
-
end
|
15
12
|
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
def name
|
14
|
+
if query.value_exists?(RDF::Vocab::FOAF.name)
|
15
|
+
query.value(RDF::Vocab::FOAF.name)
|
16
|
+
else
|
17
|
+
query.value(LV.name)
|
18
|
+
end
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
21
|
+
def description
|
22
|
+
query.value(LV.description)
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
def questions
|
26
|
+
list = repo.query([nil, RDF.type, QV.Question]).map { |s| s.subject }
|
27
|
+
list.map { |node| Question.new(node, repo) }
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
def open_questions
|
31
|
+
questions.select { |q| not q.has_answer? }
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
34
|
+
def question_with_text(text)
|
35
|
+
questions.find { |q| q.text == text }
|
36
|
+
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
def requirements
|
39
|
+
list = repo.query([nil, RDF.type, QV.Requirement]).map { |s| s.subject }
|
40
|
+
list.map { |node| Requirement.new(node, repo) }
|
41
|
+
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
DeploymentPlan.new(node, repo)
|
43
|
+
def requirement_with_description(description)
|
44
|
+
requirements.find { |r| r.description == description }
|
45
45
|
end
|
46
|
-
end
|
47
46
|
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
def deployment_plans
|
48
|
+
query.values(LV.hasDeploymentPlan).map do |node|
|
49
|
+
DeploymentPlan.new(node, repo)
|
50
|
+
end
|
51
|
+
end
|
51
52
|
|
52
|
-
|
53
|
+
def deployment_plan_with_description(description)
|
54
|
+
deployment_plans.find { |a| a.description == description }
|
55
|
+
end
|
56
|
+
|
57
|
+
def category
|
58
|
+
value = query.value(LV.category)
|
59
|
+
return nil if value.nil?
|
60
|
+
t = value.to_s.remove LV.prefix
|
61
|
+
Helper.underscore(t).to_sym
|
62
|
+
end
|
53
63
|
|
54
|
-
|
55
|
-
|
64
|
+
private
|
65
|
+
|
66
|
+
def repo
|
67
|
+
query.repository
|
68
|
+
end
|
56
69
|
end
|
57
70
|
end
|
data/lib/models/capability.rb
CHANGED
@@ -1,23 +1,51 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Model
|
2
|
+
class Capability
|
3
|
+
attr_reader :query
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
def initialize(node, repository)
|
6
|
+
@query = NodeQuery.new(node, repository)
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def description
|
10
|
+
query.value(LV.description)
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def value
|
14
|
+
query.value(LV.value).to_s if query.value_exists?(LV.value)
|
15
|
+
end
|
16
|
+
|
17
|
+
def type
|
18
|
+
value = query.value(RDF.type)
|
19
|
+
return nil if value.nil?
|
20
|
+
t = value.to_s.remove LV.prefix
|
21
|
+
Helper.underscore(t).to_sym
|
22
|
+
end
|
23
|
+
|
24
|
+
def device
|
25
|
+
device_node = query.value(LV.device)
|
26
|
+
Device.new device_node, query.repository if device_node
|
27
|
+
end
|
28
|
+
|
29
|
+
def property
|
30
|
+
node = query.value(LV.property)
|
31
|
+
Property.new node, query.repository if node
|
32
|
+
end
|
33
|
+
|
34
|
+
def question
|
35
|
+
node = query.value(LV.question)
|
36
|
+
Question.new node, query.repository if node
|
37
|
+
end
|
38
|
+
|
39
|
+
def actuators
|
40
|
+
query.values(LV.actuator).map do |node|
|
41
|
+
Device.new node, query.repository
|
42
|
+
end
|
15
43
|
end
|
16
|
-
end
|
17
44
|
|
18
|
-
|
19
|
-
|
20
|
-
|
45
|
+
def sensors
|
46
|
+
query.values(LV.sensor).map do |node|
|
47
|
+
Device.new node, query.repository
|
48
|
+
end
|
21
49
|
end
|
22
50
|
end
|
23
51
|
end
|
@@ -1,44 +1,51 @@
|
|
1
1
|
require_relative '../services/question_references'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Model
|
4
|
+
class DeploymentPlan
|
5
|
+
attr_reader :query
|
5
6
|
|
6
|
-
|
7
|
+
include QuestionReferences
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def initialize(node, repository)
|
10
|
+
@query = NodeQuery.new(node, repository)
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def description
|
14
|
+
query.value(LV.description)
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
def host
|
18
|
+
return nil unless query.value_exists?(LV.host)
|
19
|
+
EcosystemHost.new(query.value(LV.host), query.repository)
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
def arguments
|
23
|
+
node = query.value(LV.arguments)
|
24
|
+
arg_query = NodeQuery.new(node, query.repository)
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
if arg_query.value_exists?(RDFV.first)
|
27
|
+
RDF::List.new(node, query.repository)
|
28
|
+
else
|
29
|
+
arg_query.predicates_and_objects
|
30
|
+
end
|
29
31
|
end
|
30
|
-
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
def deployment_plans
|
34
|
+
query.values(LV.hasDeploymentPlan).map do |node|
|
35
|
+
DeploymentPlan.new(node, query.repository)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def properties
|
40
|
+
query.values(LV.property).map do |node|
|
41
|
+
Property.new(node, query.repository)
|
42
|
+
end
|
35
43
|
end
|
36
|
-
end
|
37
44
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
45
|
+
def capabilities
|
46
|
+
query.values(LV.capability).map do |node|
|
47
|
+
Capability.new(node, query.repository)
|
48
|
+
end
|
42
49
|
end
|
43
50
|
end
|
44
51
|
end
|
data/lib/models/device.rb
CHANGED
@@ -1,26 +1,32 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Model
|
2
|
+
class Device
|
3
|
+
attr_reader :query
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
def initialize(node, repository)
|
6
|
+
@query = NodeQuery.new(node, repository)
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def uri
|
10
|
+
query.node_uri
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def manufacturer_name
|
14
|
+
query.value(LV.manufacturerName)
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def description
|
18
|
+
query.value(LV.description)
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
def location
|
22
|
+
node = query.value(LV.locatedAt)
|
23
|
+
return nil if node.nil?
|
24
|
+
|
25
|
+
Location.new(node, query.repository)
|
26
|
+
end
|
22
27
|
|
23
|
-
|
24
|
-
|
28
|
+
def node
|
29
|
+
query.node
|
30
|
+
end
|
25
31
|
end
|
26
32
|
end
|
data/lib/models/http_request.rb
CHANGED
@@ -1,27 +1,29 @@
|
|
1
1
|
require 'rest-client'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Model
|
4
|
+
class HttpRequest
|
5
|
+
attr_reader :query
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
def initialize(node, repository)
|
8
|
+
@query = NodeQuery.new(node, repository)
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def uri
|
12
|
+
query.value(HttpVocabulary.request_uri)
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def body
|
16
|
+
query.value(HttpVocabulary.body)
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def method_name
|
20
|
+
query.value(HttpVocabulary.method_name)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
def execute
|
24
|
+
raise "Unsupported method #{method_name}" unless method_name == 'POST'
|
25
|
+
RestClient.post(uri.to_s, body.to_s)
|
26
|
+
true
|
27
|
+
end
|
26
28
|
end
|
27
29
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Model
|
2
|
+
class Installation
|
3
|
+
attr_reader :query
|
4
|
+
|
5
|
+
def initialize(node, repository)
|
6
|
+
@query = NodeQuery.new(node, repository)
|
7
|
+
end
|
8
|
+
|
9
|
+
def type
|
10
|
+
query.value(LV.type).to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
query.value(LV.name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def description
|
18
|
+
query.value(LV.description)
|
19
|
+
end
|
20
|
+
|
21
|
+
def category
|
22
|
+
value = query.value(LV.category)
|
23
|
+
return nil if value.nil?
|
24
|
+
t = value.to_s.remove LV.prefix
|
25
|
+
Helper.underscore(t).to_sym
|
26
|
+
end
|
27
|
+
|
28
|
+
def used_devices
|
29
|
+
query.values(LV.uses).map do |node|
|
30
|
+
InstallationUsedDevice.new(node, query.repository)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def questions
|
35
|
+
query.values(LV.question).map do |node|
|
36
|
+
Question.new(node, query.repository)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def properties
|
41
|
+
query.values(LV.property).map do |node|
|
42
|
+
Property.new(node, query.repository)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Model
|
2
|
+
class InstallationUsedDevice
|
3
|
+
attr_reader :query
|
4
|
+
|
5
|
+
def initialize(node, repository)
|
6
|
+
@query = NodeQuery.new(node, repository)
|
7
|
+
end
|
8
|
+
|
9
|
+
def device
|
10
|
+
return nil unless query.value_exists?(LV.target)
|
11
|
+
Device.new(query.value(LV.target), query.repository)
|
12
|
+
end
|
13
|
+
|
14
|
+
def role
|
15
|
+
query.value(LV.role)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/models/location.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Model
|
2
|
+
class Location
|
3
|
+
attr_reader :query
|
3
4
|
|
4
|
-
|
5
|
+
include Answer
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
def initialize(node, repository)
|
8
|
+
@query = NodeQuery.new(node, repository)
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def name
|
12
|
+
query.value(LV.locationName)
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def name=(value)
|
16
|
+
query.set_value(LV.locationName, value)
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|