module TaliaCore
  
  # This represents a macrocontribution.
  #
  # Everything valid for a normal source is also valid here
  #
  # It offers some methods for dealing with Macrocontributions  
  class MacroContribution < Source
 
    def initialize(uri, *types)
      super(uri, *types)
      self.primary_source = false
    end
    # Used to add a new source to this macrcontribution.
    # The adding is done by just creating a new RDF triple.
    def add_source(new_source_uri)
      new_source = Source.new(new_source_uri)
      new_source[N::HYPER::isPartOfMacrocontribution] << self
      new_source.save!
    end
    
    def title=(title)
      self.predicate_set(:hyper, "title", title)
    end
    
    def editors_notes=(notes)
      self.predicate_set(:hyper, 'editorsNotes', notes)
    end
    
    def macrocontribution_type=(type)
      self.predicate_set(:hyper, "macrocontributionType", type)      
    end
    
    def title
      self.hyper::title
    end
    
    def editors_notes
      self.hyper::editorsNotes
    end
    
    def macrocontribution_type
      self.hyper::macrocontributionType
    end
    
  end  
    
      
end
  

module TaliaCore #:nodoc:
  # A +MacroContribution+ is a generic collection of sources.
  class MacroContribution < Source
    SOURCE_PREDICATE = N::HYPER::hasAsPart

    def initialize(uri, *types) #:nodoc:
      super(uri, *types)
      self.primary_source = false
    end

    def sources #:nodoc:
      @sources ||= self[SOURCE_PREDICATE]
    end

    # Add a +Source+ to the collection
    def add(source)
      raise ArgumentError unless source
      case source
        when String
          self.add Source.new(source)
        else 
          sources << source
      end
    end
    alias_method :<<, :add

    # Remove the given +Source+ from the collection.
    def remove(source)
      sources.remove source
    end
    
    def title=(title)
      self.predicate_set(:hyper, "title", title)
    end
    
    def editors_notes=(notes)
      self.predicate_set(:hyper, 'editorsNotes', notes)
    end
    
    def macrocontribution_type=(type)
      self.predicate_set(:hyper, "macrocontributionType", type)      
    end
    
    def title
      self.hyper::title
    end
    
    def editors_notes
      self.hyper::editorsNotes
    end
    
    def macrocontribution_type
      self.hyper::macrocontributionType
    end
  end  
end  

Make sure has_many_polymorphs gem is loaded if missing in local paths
Make sure has_many_polymorphs gem is loaded if missing in local paths

git-svn-id: 0c007ce6f683c3a50607bc1a0b961fa833bb4e37@735 2960d7dc-a92c-0410-a2fe-c68badc242c0
