|
|
|
@ -8,6 +8,8 @@ class Cdao::Jurisprudence < Cdao::Base |
|
|
|
has_many :annotation_documents, as: :document, dependent: :restrict_with_error |
|
|
|
has_many :annotation_documents, as: :document, dependent: :restrict_with_error |
|
|
|
has_many :annotations_as_cited, through: :annotation_documents, source: :annotation |
|
|
|
has_many :annotations_as_cited, through: :annotation_documents, source: :annotation |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
has_many :citation_finders, dependent: :restrict_with_error |
|
|
|
|
|
|
|
|
|
|
|
alias_attribute :doc_date, :docdate |
|
|
|
alias_attribute :doc_date, :docdate |
|
|
|
|
|
|
|
|
|
|
|
def cited_documents |
|
|
|
def cited_documents |
|
|
|
@ -99,4 +101,49 @@ class Cdao::Jurisprudence < Cdao::Base |
|
|
|
|
|
|
|
|
|
|
|
join(:phil_rep, :target => Annotation, :type => :string, :join => { :from => :document_id, :to => :id }) |
|
|
|
join(:phil_rep, :target => Annotation, :type => :string, :join => { :from => :document_id, :to => :id }) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def phil_rep |
|
|
|
|
|
|
|
names = citation_finders_names.keep_if { |a| a.match?("Phil") } |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def scra |
|
|
|
|
|
|
|
names = citation_finders_names.keep_if { |a| a.match?(Cdao::CitationFinder::TYPES[0]) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
names |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def citation_finders_names |
|
|
|
|
|
|
|
return [] if citation_finders.blank? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
names = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
citation_finders.each do |citation_finder| |
|
|
|
|
|
|
|
volumes = citation_finder.volume.gsub(/\s+/, "").gsub(/\A0*/, "") if citation_finder.volume.present? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pages = if citation_finder.first_page.present? && citation_finder.last_page.present? |
|
|
|
|
|
|
|
(citation_finder.first_page..citation_finder.last_page).to_a |
|
|
|
|
|
|
|
elsif citation_finder.first_page.present? |
|
|
|
|
|
|
|
[citation_finder.first_page] |
|
|
|
|
|
|
|
elsif citation_finder.last_page.present? |
|
|
|
|
|
|
|
[citation_finder.last_page] |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
[] |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
types = if citation_finder.citation_source_id.present? |
|
|
|
|
|
|
|
citation_finder.citation_source_id == 0 ? ["SCRA"] : ["Phil"] |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
[] |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
types.each do |type| |
|
|
|
|
|
|
|
names << ("#{volumes.presence} #{type}").strip |
|
|
|
|
|
|
|
pages.each do |page| |
|
|
|
|
|
|
|
names << ("#{volumes.presence} #{type} #{page}").strip |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
names |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|