Class: Model::ApplicationByCapabilityFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/services/application_by_capability_finder.rb

Instance Method Summary collapse

Constructor Details

#initialize(ontology) ⇒ ApplicationByCapabilityFinder

Returns a new instance of ApplicationByCapabilityFinder.



3
4
5
# File 'lib/services/application_by_capability_finder.rb', line 3

def initialize(ontology)
  @ontology = ontology
end

Instance Method Details

#find(options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/services/application_by_capability_finder.rb', line 7

def find(options)
  solutions = RDF::Query.execute(@ontology, {
    application: {
      LV.hasDeploymentPlan => {
        LV.capability => options
      }
    }
  })

  solutions.map do |solution|
    solution[:application]
  end.uniq.map do |node|
    Application.new(node, @ontology)
  end
end

#find_by_actuator(actuator) ⇒ Object



31
32
33
# File 'lib/services/application_by_capability_finder.rb', line 31

def find_by_actuator(actuator)
  find({ LV.actuator => actuator })
end

#find_by_description(description) ⇒ Object



27
28
29
# File 'lib/services/application_by_capability_finder.rb', line 27

def find_by_description(description)
  find({ LV.description => description })
end

#find_by_sensor(sensor) ⇒ Object



35
36
37
# File 'lib/services/application_by_capability_finder.rb', line 35

def find_by_sensor(sensor)
  find({ LV.sensor => sensor })
end

#find_by_type(type) ⇒ Object



23
24
25
# File 'lib/services/application_by_capability_finder.rb', line 23

def find_by_type(type)
  find({ RDF.type => type })
end