Class: 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.



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

def initialize(ontology)
  @ontology = ontology
end

Instance Method Details

#find(options) ⇒ Object



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

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



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

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

#find_by_description(description) ⇒ Object



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

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

#find_by_sensor(sensor) ⇒ Object



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

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

#find_by_type(type) ⇒ Object



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

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