app/models/bplmodels/mods_desc_metadata.rb
def insert_date(date_type, dateStarted=nil, dateEnding=nil, dateQualifier=nil, dateOther=nil, keydate=nil)
      #begin

      #date_index = self.mods(0).date.count
      date_index = 0

      #This is horrid. Can't use count as other elements use origin_info at the same depth....
      if keydate.blank?
        keydate = true if (self.mods(0).date.dates_created.key_date.blank? and self.mods(0).date.dates_issued.key_date.blank? and self.mods(0).date.dates_copyright.key_date.blank? and self.mods(0).date.date_other.key_date.blank?)
        keydate ||= false
      end

      date_type = 'dates_created' if date_type == 'dateCreated'
      date_type = 'dates_copyright' if date_type == 'copyrightDate'
      date_type = 'dates_issued' if date_type == 'dateIssued'
      date_type = 'date_other' if date_type == 'dateOther'

      date_type_with_equal = date_type + '='

      #Range case - broken...fixme ... under same mods:originInfo ?
      if dateStarted.present? and dateEnding.present?
        self.mods(0).date(date_index).send(date_type.to_sym, 0).point = 'start'
        self.mods(0).date(date_index).send(date_type.to_sym, 0).encoding = 'w3cdtf'
        self.mods(0).date(date_index).send(date_type.to_sym, 0).qualifier = dateQualifier unless dateQualifier.blank?
        self.mods(0).date(date_index).send(date_type.to_sym, 0).key_date = "yes" unless keydate == false

        self.mods(0).date(date_index).send(date_type.to_sym, 1).point = 'end'
        self.mods(0).date(date_index).send(date_type.to_sym, 1).encoding = 'w3cdtf'
        self.mods(0).date(date_index).send(date_type.to_sym, 1).qualifier = dateQualifier unless dateQualifier.blank?

        #Hackish way to set the node values....
        self.mods(0).date(date_index).send(date_type_with_equal.to_sym, [dateStarted, dateEnding])
      elsif dateStarted.present?
        self.mods(0).date(date_index).send(date_type.to_sym, 0).encoding = 'w3cdtf'
        self.mods(0).date(date_index).send(date_type.to_sym, 0).qualifier = dateQualifier unless dateQualifier.blank?
        self.mods(0).date(date_index).send(date_type.to_sym, 0).key_date = "yes" unless keydate == false
        self.mods(0).date(date_index).send(date_type_with_equal.to_sym, dateStarted)
      elsif dateOther.present?
        self.mods(0).date(date_index).send(date_type_with_equal.to_sym, dateOther)
      end


    end
#include Hydra::Datastream::CommonModsIndexMethods
# MODS XML constants.
include Hydra::Datastream::CommonModsIndexMethods
MODS XML constants.
include Hydra :: Datastream :: CommonModsIndexMethods MODS XML constants .
def insert_date(date_type, dateStarted=nil, dateEnding=nil, dateQualifier=nil, dateOther=nil, keydate=nil)
      date_index = 0
      if keydate.blank?
        keydate = true if (self.mods(0).date.dates_created.key_date.blank? and self.mods(0).date.dates_issued.key_date.blank? and self.mods(0).date.dates_copyright.key_date.blank? and self.mods(0).date.date_other.key_date.blank?)
        keydate ||= false
      end
      date_type = 'dates_created' if date_type == 'dateCreated'
      date_type = 'dates_copyright' if date_type == 'copyrightDate'
      date_type = 'dates_issued' if date_type == 'dateIssued'
      date_type = 'date_other' if date_type == 'dateOther'
      date_type_with_equal = date_type + '='
      if dateStarted.present? and dateEnding.present?
        self.mods(0).date(date_index).send(date_type.to_sym, 0).point = 'start'
        self.mods(0).date(date_index).send(date_type.to_sym, 0).encoding = 'w3cdtf'
        self.mods(0).date(date_index).send(date_type.to_sym, 0).qualifier = dateQualifier unless dateQualifier.blank?
        self.mods(0).date(date_index).send(date_type.to_sym, 0).key_date = "yes" unless keydate == false
        self.mods(0).date(date_index).send(date_type.to_sym, 1).point = 'end'
        self.mods(0).date(date_index).send(date_type.to_sym, 1).encoding = 'w3cdtf'
        self.mods(0).date(date_index).send(date_type.to_sym, 1).qualifier = dateQualifier unless dateQualifier.blank?
        self.mods(0).date(date_index).send(date_type_with_equal.to_sym, [dateStarted, dateEnding])
      elsif dateStarted.present?
        self.mods(0).date(date_index).send(date_type.to_sym, 0).encoding = 'w3cdtf'
        self.mods(0).date(date_index).send(date_type.to_sym, 0).qualifier = dateQualifier unless dateQualifier.blank?
        self.mods(0).date(date_index).send(date_type.to_sym, 0).key_date = "yes" unless keydate == false
        self.mods(0).date(date_index).send(date_type_with_equal.to_sym, dateStarted)
      elsif dateOther.present?
        self.mods(0).date(date_index).send(date_type_with_equal.to_sym, dateOther)
      end
    end
def insert_date ( date_type , dateStarted = nil , dateEnding = nil , dateQualifier = nil , dateOther = nil , keydate = nil ) date_index = 0 if keydate . blank? keydate = true if ( self . mods ( 0 ) . date . dates_created . key_date . blank? and self . mods ( 0 ) . date . dates_issued . key_date . blank? and self . mods ( 0 ) . date . dates_copyright . key_date . blank? and self . mods ( 0 ) . date . date_other . key_date . blank? ) keydate ||= false end date_type = 'dates_created' if date_type == 'dateCreated' date_type = 'dates_copyright' if date_type == 'copyrightDate' date_type = 'dates_issued' if date_type == 'dateIssued' date_type = 'date_other' if date_type == 'dateOther' date_type_with_equal = date_type + '=' if dateStarted . present? and dateEnding . present? self . mods ( 0 ) . date ( date_index ) . send ( date_type . to_sym , 0 ) . point = 'start' self . mods ( 0 ) . date ( date_index ) . send ( date_type . to_sym , 0 ) . encoding = 'w3cdtf' self . mods ( 0 ) . date ( date_index ) . send ( date_type . to_sym , 0 ) . qualifier = dateQualifier unless dateQualifier . blank? self . mods ( 0 ) . date ( date_index ) . send ( date_type . to_sym , 0 ) . key_date = "yes" unless keydate == false self . mods ( 0 ) . date ( date_index ) . send ( date_type . to_sym , 1 ) . point = 'end' self . mods ( 0 ) . date ( date_index ) . send ( date_type . to_sym , 1 ) . encoding = 'w3cdtf' self . mods ( 0 ) . date ( date_index ) . send ( date_type . to_sym , 1 ) . qualifier = dateQualifier unless dateQualifier . blank? self . mods ( 0 ) . date ( date_index ) . send ( date_type_with_equal . to_sym , [ dateStarted , dateEnding ] ) elsif dateStarted . present? self . mods ( 0 ) . date ( date_index ) . send ( date_type . to_sym , 0 ) . encoding = 'w3cdtf' self . mods ( 0 ) . date ( date_index ) . send ( date_type . to_sym , 0 ) . qualifier = dateQualifier unless dateQualifier . blank? self . mods ( 0 ) . date ( date_index ) . send ( date_type . to_sym , 0 ) . key_date = "yes" unless keydate == false self . mods ( 0 ) . date ( date_index ) . send ( date_type_with_equal . to_sym , dateStarted ) elsif dateOther . present? self . mods ( 0 ) . date ( date_index ) . send ( date_type_with_equal . to_sym , dateOther ) end end
include Hydra::Datastream::CommonModsIndexMethods
MODS XML constants.
include Hydra :: Datastream :: CommonModsIndexMethods MODS XML constants .
#begin #date_index = self.mods(0).date.count #This is horrid. Can't use count as other elements use origin_info at the same depth.... #Range case - broken...fixme ... under same mods:originInfo ? #Hackish way to set the node values....
date_type
dateStarted
dateEnding
dateQualifier
dateOther
keydate