Generates and saves the coun treport for the provider, sending SPARQL
 queries as necessary.

 @return [Hash]
323276
def generate_count_report!
      report = count_queries.inject({}) do |report_hash, (k, v)|
        report_hash[k] = solutions_to_counts(v.execute)
        report_hash
      end

      update(count_report: report)
    end
540313
def <<(statement)
      # ActiveTriples::Resource expects: RDF::Statement, Hash, or Array
      statement = RDF::Statement.from(statement) unless statement.is_a? RDF::Statement

      # Only push statement if the statement's predicate is defined on the class
      field_name = field_from_predicate(statement.predicate)
      return unless field_name

      objects = statement.object.is_a?(RDF::Node) && block_given? ? yield : statement.object

      update_field(field_name, *objects) if fields[field_name]
      update_relation(field_name, *objects) if relations[field_name]
    end
1342891
def update_modified_providers_after_save
      # Save password provider
      if @password_updated or @username_updated
        Challah.providers[:password].save(self)
        @password_updated = false
        @username_updated = false
        @password = nil
      end

      # Save any other providers
      Challah.custom_providers.each do |name, klass|
        custom_provider_attributes = provider_attributes[name]

        if custom_provider_attributes.respond_to?(:fetch)
          if klass.valid?(self)
            klass.save(self)
          end
        end
      end
    end
1321091
def save(connection)
      nsc                                   = REXML::XPath.first(@xml, 'NeXposeSecurityConsole')
      nsc.attributes['scanThreadsLimit']    = @scan_threads_limit.to_i
      nsc.attributes['realtimeIntegration'] = @incremental_scan_results ? '1' : '0'

      web_server                              = REXML::XPath.first(nsc, 'WebServer')
      web_server.attributes['sessionTimeout'] = @session_timeout.to_i

      response = REXML::Document.new(Nexpose::AJAX.post(connection, '/data/admin/config/nsc', @xml))
      saved    = REXML::XPath.first(response, 'SaveConfig')
      saved.attributes['success'] == '1'
    end
717999
def generate_field_report!
      report = field_queries.inject({}) do |report_hash, (k, v)|
        report_hash[k] = solutions_to_hash(v.execute)
        report_hash
      end
      update(field_report: report)
    end
1206869
def _buildPredicateHash(self, subject):  # XXX unmodified
        
        properties = {}
        for s, p, o in self.store.triples((subject, None, None)):
            oList = properties.get(p, [])
            oList.append(o)
            properties[p] = oList

        return properties
256295
def connection
      if ::Fog::const_defined? @account[:service]
        service_mod = ::Fog::const_get @account[:service]
        provider_class = service_mod.send(:const_get, @account[:provider])
        @fog_service ||= provider_class.new(@account[:credentials])
      else
        provider_mod = ::Fog::const_get @account[:provider]
        service_class = provider_mod.send(:const_get, @account[:service])
        @fog_service ||= service_class.new(@account[:credentials])
      end
    end
106903
def to_uri
      # map the URL scheme to a URI class
      url_class = SCHEMES.fetch(self.scheme.name,::URI::Generic)

      host = if self.host_name
               self.host_name.address
             end
      port = if self.port
               self.port.number
             end

      query = unless self.query_params.empty?
                self.query_string
              end

      # build the URI
      return url_class.build(
        :scheme   => self.scheme.name,
        :host     => host,
        :port     => port,
        :path     => self.path,
        :query    => query,
        :fragment => self.fragment
      )
    end
530755
def save(self):
        
        props = self.deflate(self.__properties__)
        query = "MATCH ()-[r]->() WHERE id(r)={self} "
        for key in props:
            query += " SET r.{0} = {{{1}}}".format(key, key)
        props['self'] = self.id

        db.cypher_query(query, props)

        return self
440942
def build_http_object(uri)
      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = true if uri.scheme == 'https'
      if @ssl_enabled
        http.cert_store = @cert_store if @cert_store
      else http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      end
      http.read_timeout = @timeout if @timeout # Timeout for a request
      http.open_timeout = @timeout if @timeout # Timeout for a connection
      http
    end
1059190
def load
      resp = @client.describe_tags(filters: [
        {
          name: "key",
          values: [@key]
        },
        {
          name: "value",
          values: [@value]
        }
      ])
      @data = resp.tags[0]
      self
    end
245676
def to_hash
      OPTIONS.inject({}) do |hash, option|
        key = option.first
        hash[key] = self.send(key)
        hash
      end
    end
1115086
def run_sparql_on(q, ontology):
    
    logging.info("Connecting to " + ontology.value + " SPARQL endpoint...")
    sparql = SPARQLWrapper(ontology.value)
    logging.info("Made wrapper: {}".format(sparql))
    sparql.setQuery(q)
    sparql.setReturnFormat(JSON)
    logging.info("Query: {}".format(q))
    results = sparql.query().convert()
    bindings = results['results']['bindings']
    logging.info("Rows: {}".format(len(bindings)))
    for r in bindings:
        curiefy(r)
    return bindings
1013695
def get_endpoints(query = nil)
      @client.make_request(:get, @client.concat_user_path("#{DOMAIN_PATH}/#{id}/endpoints"), query)[0].map do |i|
        endpoint = EndPoint.new(i, @client)
        endpoint.domain_id = id
        endpoint
      end
    end
1170299
def to_h
      Hash[
        attribute_names.
        map do |name| [
          name.to_s.gsub("@","").to_sym,  # key
          (instance_variable_get(name) rescue send(name))] # val
        end
      ]
    end
442711
def generate_table(collection, headers=nil, options={})
      return if collection.blank?
      thead = content_tag(:thead) do
        content_tag(:tr) do
          headers.map {|header| content_tag(:th, header)}
        end
      end unless headers.nil?
      tbody = content_tag(:tbody) do
        collection.map do |values|
          content_tag(:tr) do
            values.map {|value| content_tag(:td, value)}
          end
        end
      end
      content_tag(:table, [thead, tbody].compact.join("\n"), options)
    end
1338958
def http_build_query(params = {})
        params.collect do |k,v|
          "#{URI.encode(k.to_s)}=#{URI.encode(v.to_s)}" unless v.nil?
        end.compact.join('&')
      end