Created
August 29, 2018 23:28
-
-
Save mcritchlow/26477cd6d0bab31d4e906fda8d27d75a to your computer and use it in GitHub Desktop.
Work rdms schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a crazy idea. but, do we really need a graph-based approach? | |
# Is this stuff really going to change that often? | |
# Could we use something like Single Table Inheritance to make this more sane since so much data is shared? | |
class Work < ApplicationRecord | |
has_many :subjects | |
has_namy :agents | |
delegate :topics, :names, :anatomies, to: :subjects | |
delegate :creators, :contributors, :publishers, to: :agents | |
end | |
class Subject < ApplicationRecord | |
#define fields in schema: label, altLabel, closeMatch, note, broader, exactMatch. | |
# validations | |
validates :label, presence: true | |
def self.types | |
%w(Topic Name Anatomy) | |
end | |
scope :topics, -> { where(type: 'Topic') } | |
scope :names, -> { where(type: 'Name') } | |
scope :anatomies, -> { where(type: 'Anatonmy') } | |
end | |
class Topic < Subject | |
end | |
class Name < Subject | |
end | |
class Anatomy < Subject | |
end | |
class Agent < ApplicationRecord | |
#define fields in schema: label, alternateLabel,orcid,note, etc. | |
# validations | |
validates :label, presence: true | |
def self.types | |
%w(Creator Contributor Publisher) | |
end | |
scope :creators, -> { where(type: 'Creator') } | |
scope :contributors, -> { where(type: 'Contributor') } | |
scope :publishers, -> { where(type: 'Publisher') } | |
end | |
class Contributor < Agent | |
end | |
class Creator < Agent | |
end | |
class Publisher < Agent | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment