Newer
Older
dmpopidor / app / models / fragment / dmp.rb
# == Schema Information
#
# Table name: madmp_fragments

#  id                        :integer          not null, primary key
#  data                      :json
#  answer_id                 :integer
#  madmp_schema_id :integer
#  created_at                :datetime         not null
#  updated_at                :datetime         not null
#  classname                 :string
#  dmp_id                    :integer
#  parent_id                 :integer

# Indexes

#  index_madmp_fragments_on_answer_id                  (answer_id)
#  index_madmp_fragments_on_madmp_schema_id  (madmp_schema_id)


# WARNING !! : si changement de cardinalité de project, maintenance à prévoir dans les scripts appelants

class Fragment::Dmp < MadmpFragment

  def plan
    Plan.find(data["plan_id"])
  end

  def meta
    Fragment::Meta.where(parent_id: id).first
  end

  def project
    Fragment::Project.where(parent_id: id).first
  end

  def research_outputs
    Fragment::ResearchOutput.where(parent_id: id)
  end

  def properties
    "plan, meta, project, research_output"
  end

  def contributors
    Fragment::Person.where(dmp_id: id)
  end

  def costs
    Fragment::Cost.where(dmp_id: id)
  end

  def persons
    Fragment::Person.where(dmp_id: id)
  end

  def locale
    meta.data["dmpLanguage"]
  end

  def dmp
    self
  end

  def self.sti_name
    "dmp"
  end

end