require 'voruby/resources/voresource/loader' module VORuby module Resources module VOResource module V0_10 # Forward declarations class Resource; end class ShortName; end class AnyURI; end class IdentifierURI < AnyURI; end class Curation; end class ResourceName; end class Creator; end class Date; end class Contact; end class Content; end class String; end class Source; end class Type; end class ContentLevel; end class Relationship; end class RelationshipType; end class AuthorityID; end class ResourceKey; end class Organisation < Resource; end class Service < Resource; end class Interface; end class AccessURL < AnyURI; end class WebBrowser < Interface; end class Capability; end # Any entity that is describable and identifiable by a IVOA Identifier. class Resource include XML::Mapping # the full name given to the resource text_node :title, 'title', :optional => false # the date this resource metadata description was created date_time_node :created, '@created', :optional => true # the date this resource metadata description was last updated date_time_node :updated, '@updated', :optional => true # a tag indicating whether this resource is believed to be still actively maintained. text_enumeration_node :status, '@status', :optional => true, :default_value => 'active', :choices => ['active', 'inactive', 'deleted'] # a short name or abbreviation given to the resource. object_node :short_name, 'shortName', :class => ShortName, :optional => true # unambiguous reference to the resource conforming to the IVOA standard for identifiers object_node :identifier, 'identifier', :class => IdentifierURI, :optional => false # information regarding the general curation of the resource object_node :curation, 'curation', :class => Curation, :optional => false # information regarding the general content of the resource object_node :content, 'content', :class => Content, :optional => false end # A short name or abbreviation given to something. class ShortName include XML::Mapping text_node :value, '', :optional => false def value=(short_name) raise RuntimeError, "ShortName '#{short_name}' must have <= 16 characters" if short_name.size > 16 @value = short_name end end class AnyURI include XML::Mapping text_node :value, '', :optional => false def value=(uri) @value = URI.parse(uri.strip) end end class IdentifierURI def value=(uri) # Strictly, this should be ivo only, but I notice that sometimes http is used. #raise RuntimeError, "IdentifierURI '#{uri}' in wrong format" if !uri.strip.match('^(ivo|http):') @value = URI.parse(uri.strip) end end # Information regarding the general curation of a resource. class Curation include XML::Mapping # label associated with creation or availablilty of a version of a resource text_node :version, 'version', :optional => true # entity (e.g. person or organisation) responsible for making the resource available object_node :publisher, 'publisher', :class => ResourceName, :optional => true # the entity (e.g. person or organisation) primarily responsible for creating the content or constitution of the resource object_node :creator, 'creator', :class => Creator, :optional => true # information that can be used for contacting someone with regard to this resource object_node :contact, 'contact', :class => Contact, :optional => true # entity responsible for contributions to the content of the resource array_node :contributors, 'contributor', :class => ResourceName, :optional => true, :default_value => [] # date associated with an event in the life cycle of the resource array_node :dates, 'date', :class => Date, :optional => true, :default_value => [] end # The name of a potentially registered resource. That is, the entity referred to may have an associated identifier. class ResourceName include XML::Mapping text_node :value, '', :optional => false # the URI form of the IVOA identifier for the resource refered to object_node :ivo_id, '@ivo-id', :class => IdentifierURI, :optional => true end # The entity (e.g. person or organisation) primarily responsible for creating something. class Creator include XML::Mapping # the name or title of the creating person or organization object_node :name, 'name', :class => ResourceName, :optional => false # URL pointing to a graphical logo, which may be used to help identify the information source object_node :logo, 'logo', :class => AnyURI, :optional => true end class Date include XML::Mapping text_node :value, '', :optional => false # a string indicating what the date refers to text_node :role, 'role', :optional => true, :default_value => 'representative' def value=(v) @value = DateTime.parse(v) end end # Information that can be used for contacting someone. class Contact include XML::Mapping # the contact mailing address text_node :address, 'address', :optional => true # the contact email address text_node :email, 'email', :optional => true # the contact telephone number text_node :telephone, 'telephone', :optional => true # the name or title of the contact person object_node :name, 'name', :class => ResourceName, :optional => false end # Information regarding the general content of a resource. class Content include XML::Mapping # an account of the nature of the resource text_node :description, 'description', :optional => false # a bibliographic reference from which the present resource is derived or extracted object_node :source, 'source', :class => Source, :optional => true # URL pointing to a human-readable document describing this resource. object_node :reference_url, 'referenceURL', :class => AnyURI, :optional => true # list of topics, object types, or other descriptive keywords about the resource array_node :subjects, 'subject', :class => String, :optional => true, :default_value => [] # nature or genre of the content of the resource array_node :types, 'type', :class => Type, :optional => true, :default_value => [] # description of the content level or intended audience array_node :content_levels, 'contentLevel', :class => ContentLevel, :optional => true, :default_value => [] # a description of a relationship to another resource array_node :relationships, 'relationship', :class => Relationship, :optional => true, :default_value => [] end class String include XML::Mapping text_node :value, '', :optional => false end class Source include XML::Mapping text_node :value, '', :optional => false # the reference format. Recognized values include "bibcode", refering to a standard astronomical bibcode bibcode # (http://cdsweb.u-strasbg.fr/simbad/refcode.html). text_node :format, '@format', :optional => true end class Type include XML::Mapping text_enumeration_node :value, '', :optional => false, :choices => ['Other', 'Archive', 'Bibliography', 'Catalog', 'Journal', 'Library', 'Simulation', 'Survey', 'Transformation', 'Education', 'Outreach', 'EPOResource', 'Animation', 'Artwork', 'Background', 'BasicData', 'Historical', 'Photographic', 'Press', 'Organisation', 'Project', 'Registry'] end class ContentLevel include XML::Mapping text_enumeration_node :value, '', :optional => false, :choices => ['General', 'Elementary Education', 'Middle School Education', 'Secondary Education', 'Community College', 'University', 'Research', 'Amateur', 'Informal Education'] end # A description of the relationship between one resource and one or more other resources. class Relationship include XML::Mapping # the named type of relationship object_node :relationship_type, 'relationshipType', :class => RelationshipType, :optional => false # the name of resource that this resource is related to array_node :related_resources, 'relatedResource', :class => ResourceName, :optional => false end class RelationshipType include XML::Mapping text_enumeration_node :value, '', :optional => false, :choices => ['mirror-of', 'service-for', 'derived-from', 'related-to'] end class AuthorityID include XML::Mapping text_node :value, '', :optional => false def value=(authid) raise RuntimeError, "AuthorityID '#{authid} in wrong format" if !authid.match(/^[\w\d][\w\d\-_\.!~\*'\(\)\+=]{2,}$/) @value = authid end end class ResourceKey include XML::Mapping text_node :value, '', :optional => false def value=(reskey) raise RuntimeError, "ResourceKey '#{reskey} in wrong format" if !reskey.match("^[\w\d\-_\.!~\*'\(\)\+=]+(/[\w\d\-_\.!~\*'\(\)\+=]+)*$") @value = reskey end end # A named group of one or more persons brought together to pursue participation in VO applications. class Organisation # the observatory or facility used to collect the data contained or managed by this resource array_node :facilities, 'facility', :class => ResourceName, :optional => true, :default_value => [] # the instrument used to collect the data contain or managed by a resource. array_node :instruments, 'instrument', :class => ResourceName, :optional => true, :default_value => [] end # A resource that can be invoked by a client to perform some action on its behalf. class Service # a description of how a client invokes the service unmarshaller = Proc.new{ |xml| ns_prefix, type = xml.attributes['type'].split(':') type = ns_prefix if !type the_module = NAMESPACE_MODULE_MAP[xml.namespace(ns_prefix)] the_module = 'VORuby::Resources::VOResource::V_10' if !the_module # The name of the appropriate class corresponds to the type. begin eval("#{the_module}::#{type}.load_from_xml(xml)") # Would like to get rid of this eval somehow... rescue NameError Interface.load_from_xml(xml) end } array_node :interfaces, 'interface', :unmarshaller => unmarshaller, :optional => true, :default_value => [] end # A description of a service interface. Since this type is abstract, one must use an Interface subclass # to describe an actual interface. class Interface include XML::Mapping # the URL (or base URL) that a client uses to access the # service. How this URL is to be interpreted and used # depends on the specific Interface subclass object_node :access_url, 'accessURL', :class => AccessURL, :optional => false end # A flag indicating whether this should be interpreted as a base # URL, a full URL, or a URL to a directory that will produce a # listing of files. class AccessURL text_enumeration_node :use, '@use', :optional => true, :choices => ['full', 'base', 'dir'] end # A (form-based) interface intended to be accesed interactively by a user via a web browser. class WebServer; end # To provide a metadata specific to a particular Service type, # this type is usually extended and added as a child of the # specific Service subclass. class Capability include XML::Mapping # an IVOA identifier for a standard service object_node :standard_id, '@standardID', :class => IdentifierURI, :optional => true # a URL that points to a human-readable document that describes the standard upon which a service is based. object_node :standard_url, '@standardURL', :class => AnyURI, :optional => true end end end end end