class Order

OpenIrekia v4.0.0

Copyright 2009-2013 eFaber, S.L. Copyright 2009-2013 Ejie, S.A. Copyrigth 2009-2013 Dirección de Gobierno Abierto y Comunicación en Internet;

Gobernu Irekirako eta Interneteko Komunikaziorako Zuzendaritza; Lehendakaritza.
Gobierno Vasco – Eusko Jaurlaritza

Licencia con arreglo a la EUPL, Versión 1.1 o –en cuanto sean aprobadas por la Comisión Europea– versiones posteriores de la EUPL (la Licencia); Solo podrá usarse esta obra si se respeta la Licencia. Puede obtenerse una copia de la Licencia en: ec.europa.eu/idabc/eupl Salvo cuando lo exija la legislación aplicable o se acuerde por escrito, el programa distribuido con arreglo a la Licencia se distribuye TAL CUAL, SIN GARANTÍAS NI CONDICIONES DE NINGÚN TIPO, ni expresas ni implícitas. Véase la Licencia en el idioma concreto que rige los permisos y limitaciones que establece la Licencia

http://open.irekia.net, openirekia@efaber.net

Attributes

explanation[RW]

Search methods ####

score[RW]

Search methods ####

total_rating[RW]

Search methods ####

Public Class Methods

match_attribute_in_es(an, line) click to toggle source
# File app/models/order.rb, line 67
def self.match_attribute_in_es(an, line)
  an = case line
    when /^\.DEPARTAMENTO:/, /^\.\.DEPA:/
      "dept_es"
    when /^\.FECHA BOLETIN:/, /^\.\.FEBO:/
      "fecha_bol" 
    when /^\.FECHA DISPOSICION:/,  /^\.\.FEDI:/
      "fecha_disp"
    when /^\.NUMERO BOLETIN:/, /^\.\.NBOL:/  
      "no_bol"
    when /^\.NUMERO ORDEN:/, /^\.\.NORD:/
      "no_orden"
    when /^\.SECCION:/, /^\.\.SECC:/
      "seccion_es"
    when /^\.RANGO:/, /^\.\.RANG:/
      "rango_es" 
    when /^\.MATERIAS:/, /^\.\.MATE:/
      "materias_es"
    when /^\.TITULO:/, /^\.\.TITU:/
      "titulo_es"
    when /^\.TEXTO:/, /^\.\.TEXT:/
      "texto_es"
    when /^\.NUMERO DISPOSICION:/, /^\.\.NUMD:/
      "no_disp"
    when /^\.REF ANTERIOR:/, /^\.\.REFA:/
      "ref_ant_es" 
    when /^\.REF POSTERIOR:/, /^\.\.REPO:/
      "ref_pos_es"
    when /^\.VIGENCIA:/, /^\.\.VIGE:/
      "vigencia_es"          
    else
      an  
  end      
  return an  
end
match_attribute_in_eu(an, line) click to toggle source
# File app/models/order.rb, line 103
def self.match_attribute_in_eu(an, line)
  an = case line
    when /^\.SAILA:/, /^\.\.DEPA:/
      "dept_eu"
    when /^\.ALDIZKARIAREN DATA:/, /^\.\.FEBO:/
      "fecha_bol" 
    when /^\.XEDAPENAREN DATA:/,  /^\.\.FEDI:/
      "fecha_disp"
    when /^\.ALDIZKARIAREN ZENBAKIA:/, /^\.\.NBOL:/  
      "no_bol"
    when /^\.HURRENKENAREN ZENBAKIA:/, /^\.\.NORD:/
      "no_orden"
    when /^\.SEKZIOA:/, /^\.\.SECC:/
      "seccion_eu"
    when /^\.MAILA:/, /^\.\.RANG:/
      "rango_eu" 
    when /^\.GAIAK:/, /^\.\.MATE:/
      "materias_eu"
    when /^\.IZENBURUA:/, /^\.\.TITU:/
      "titulo_eu"
    when /^\.TESTUA:/, /^\.\.TEXT:/
      "texto_eu"
    when /^\.XEDAPENAREN ZENBAKIA:/, /^\.\.NUMD:/
      "no_disp"
    when /^\.AURREKO ERREFERENTZIAK:/, /^\.\.REFA:/
      "ref_ant_eu" 
    when /^\.GEROKO ERREFERENTZIAK:/, /^\.\.REPO:/
      "ref_pos_eu"
    when /^\.NOIZ JARRI DEN INDARREAN:/, /^\.\.VIGE:/
      "vigencia_eu"          
    else
      an  
  end      
  return an  
end

Public Instance Methods

cache_path(locale=I18n.locale) click to toggle source
# File app/models/order.rb, line 220
def cache_path(locale=I18n.locale)
  "#{locale}/orders/#{self.no_orden}_in_related"
end
delete_from_elasticsearch_server() click to toggle source
# File app/models/order.rb, line 184
def delete_from_elasticsearch_server
  begin
    uri=(URI.parse("#{ELASTICSEARCH_BOPV_URI}/#{self.class.to_s.tableize}/#{self.id}"))
    Net::HTTP.start(uri.host, uri.port) do |http|
      response = http.send_request("DELETE", uri.request_uri)
      # puts "Elasticsearch Response: #{response.code} #{response.message} #{response.body}"
      # puts "Elasticsearch Response: #{response.code} #{response.message}"          
    end      
  rescue => e
    logger.info "Elasticsearch server is not available. Probably, this item has not been correctly indexed. #{e}"  
  end
end
draft() click to toggle source
# File app/models/order.rb, line 46
def draft
  false
end
enet_url() click to toggle source
# File app/models/order.rb, line 59
 def enet_url
"https://www.lehendakaritza.ejgv.euskadi.net/r48-bopv2/#{I18n.locale.eql?(:eu) ? 'eu' : 'es'}/bopv2/datos/#{self.fecha_bol.year}/#{self.fecha_bol.strftime("%m")}/#{self.no_orden[2..-1]}#{I18n.locale.eql?('eu') ? 'e' : 'a'}.shtml"
 end
materias_for_elasticsearch() click to toggle source
# File app/models/order.rb, line 197
def materias_for_elasticsearch
  list = []
  if self.materias_es.present? && self.materias_eu.present?
    list_es = self.materias_es.split(';')
    list_eu = self.materias_eu.split(';')
    for i in 0..[list_es.size, list_eu.size].max do
      list << [list_es[i], list_es[i], list_eu[i]].join('|')
    end  
  elsif self.materias_es.present? || self.materias_eu.present?
    list_es = (self.materias_es || self.materias_eu).split(';')
    list_es.each do |item|
      list << [item, item, item].join('|')
    end  
  end     
  list.join(';')
end
pretty_materias() click to toggle source
# File app/models/order.rb, line 63
def pretty_materias
  self.materias.split(';').join('; ')
end
published?() click to toggle source
# File app/models/order.rb, line 55
def published?
  true
end
show_in_irekia()
Alias for: show_in_irekia?
show_in_irekia?() click to toggle source
# File app/models/order.rb, line 50
def show_in_irekia?
  true
end
Also aliased as: show_in_irekia
update_elasticsearch_server() click to toggle source
# File app/models/order.rb, line 167
def update_elasticsearch_server
  begin    
    h= self.my_fields_for_search
    h.each {|k, v| h[k] = v.tildes if v.is_a?(String) && k.match(/_an/).nil?}
    uri=(URI.parse("#{ELASTICSEARCH_BOPV_URI}/#{self.class.to_s.tableize}/#{self.id}"))
    Net::HTTP.start(uri.host, uri.port) do |http|
      headers = { 'Content-Type' => 'application/json'}
      data = h.to_json
      response = http.send_request("PUT", uri.request_uri, data, headers)
      # puts "Elasticsearch Response: #{response.code} #{response.message} #{response.body}"  
      # puts "Elasticsearch Response: #{response.code} #{response.message}"              
    end    
  rescue => e
    Rails.logger.error "Elasticsearch server is not available. Probably, this item has not been correctly indexed. #{e}"
  end    
end