from invenio.ext.sqlalchemy import db from datetime import date domain = "drihm" display_name = "Hydro-Meteorology" table_name = 'DRIHM' image = 'domain-drihm.png' kind = 'project' domaindesc = 'Meteorology and climate data.' # note that fields will need more stuff like validators later fields = [{ 'name': 'ref_date', 'col_type': db.Date(), 'display_text': 'Reference date', 'required': True, 'default': date.today() }, { 'name': 'reference_system', 'col_type': db.String(256), 'display_text': 'Reference System', 'required': True }, { 'name': 'topic', 'col_type': db.String(256), 'display_text': 'Topic Category', 'required': True }, { 'name': 'responsible_party', 'col_type': db.String(256),
class SubmissionMetadata(db.Model): """DataCite-based metadata class. Format description is here: http://schema.datacite.org/meta/kernel-2.2/doc/DataCite-MetadataKernel_v2.2.pdf """ __tablename__ = 'submission_metadata' domain = 'Generic' icon = 'icon-question-sign' kind = 'domain' field_args = {} publisher_default = current_app.config.get('CFG_SITE_URL') publication_date_now = date.today() language_default = 'en' id = db.Column(db.Integer, primary_key=True) description = db.Column(db.Text(), nullable=False) creator = db.Column(db.String(256)) title = db.Column(db.String(256), nullable=False) open_access = db.Column(db.Boolean(), default=True) embargo_till = db.Column(db.String(128)) licence = db.Column(db.String(128)) # note we set licences in __init__ publisher = db.Column(db.String(128), default=publisher_default) publication_date = db.Column('publication_year', db.Date(), default=publication_date_now) keywords = db.Column(db.String(256)) # split on , discipline = db.Column(db.String(256)) # optional contributors = db.Column(db.String(256)) # language = db.Column(db.Enum(*babel.core.LOCALE_ALIASES.keys())) language = db.Column(db.String(128), default=language_default) resource_type = db.Column( db.String(256)) # XXX should be extracted to a separate class alternate_identifier = db.Column(db.String(256)) version = db.Column(db.String(128)) contact_email = db.Column(db.String(256)) basic_fields = [ 'title', 'description', 'creator', 'open_access', 'embargo_till', 'licence', 'publication_date', 'keywords', 'contact_email', 'discipline', ] optional_fields = [ 'contributors', 'resource_type', 'alternate_identifier', 'version', 'publisher', 'language', ] # using joined table inheritance for the specific domains submission_type = db.Column(db.String(50)) __mapper_args__ = { 'polymorphic_identity': 'generic', 'polymorphic_on': submission_type } def __repr__(self): return '<SubmissionMetadata %s>' % self.id def __init__(self): self.fieldsets = [(FieldSet("Generic", basic_fields=self.basic_fields, optional_fields=self.optional_fields))] self.field_args['title'] = { 'placeholder': "Title of the resource", 'description': 'The title of the uploaded resource - a name ' 'that indicates the content to be expected.' } self.field_args['description'] = { 'description': 'A more elaborate description of the resource. ' 'Focus on a description of content making it ' 'easy for others to find it and to interpret ' 'its relevance quickly.' } self.field_args['publisher'] = { 'value': self.publisher_default, 'description': 'The entity responsible for making the resource ' 'available, either a person, an organization, or ' 'a service.' } self.field_args['publication_date'] = { 'hidden': True, 'value': self.publication_date_now # 'description': # 'This is the date that the resource was uploaded and thus ' # 'being available broadly. Also this date can be extracted ' # 'automatically.' } self.field_args['version'] = { 'placeholder': 'e.g. v1.02', 'description': 'Denote the version of the resource.' } self.field_args['licence'] = { 'description': 'Specify the license under which this data set ' 'is available to the users (e.g. GPL, Apache v2 ' 'or Commercial). Please use the License Selector ' 'for help and additional information.' } self.field_args['keywords'] = { 'placeholder': "keyword1, keyword2, ...", 'cardinality': 'n', 'description': 'A comma separated list of keywords that ' 'characterize the content.' } self.field_args['open_access'] = { 'description': 'Indicate whether the resource is open or ' 'access is restricted. In case of restricted ' 'access the uploaded files will not be public, ' 'however the metadata will be.' } self.field_args['embargo_till'] = { #'placeholder': 'Embargo end date', 'description': 'Submitted files are hidden under embargo and will ' 'become accessible the day the embargo ends' } self.field_args['contributors'] = { 'placeholder': 'contributor', 'cardinality': 'n', 'description': 'A semicolon separated list of all other ' 'contributors. Mention all other persons that ' 'were relevant in the creation of the resource.' } self.field_args['language'] = { 'value': self.language_default, 'description': 'The name of the language the document is written in.' } self.field_args['resource_type'] = { 'data_provide': 'select', 'cardinality': 'n', 'data_source': ['Text', 'Image', 'Video', 'Audio', 'Time-Series', 'Other'], 'description': 'Select the type of the resource.' } self.field_args['alternate_identifier'] = { 'placeholder': 'Other reference, such as URI, ISBN, etc.', 'description': 'Any kind of other reference such as a URN, URI ' 'or an ISBN number.' } self.field_args['creator'] = { 'placeholder': 'author', 'cardinality': 'n', 'description': 'The author(s) of the resource.' } self.field_args['contact_email'] = { 'placeholder': 'contact email', 'description': 'Contact email information for this record' } self.field_args['discipline'] = { 'data_provide': 'select', 'cardinality': 'n', 'data_source': [(d[2], ' / '.join(d)) for d in generate_disciplines()], 'description': 'Select the discipline of the resource.' }