Esempio n. 1
0
class Bibvid(models.Model):
    '''
    Use id as unique index
    consider bibvid as alternate unique index that allows NULL because
    may consider items 'being constructed' might not have bibvids assigned.

    Todo: add utility to go ahead and descend the resources directory and
    add a row to this table where the named bibvid folder (...AA12345678/00001)
    exists. Maybe it will also get extra data from sobek, if extant.

    Fields to consider:
      bibid, vid, bibvid(with underbar separator)
      resource_subpath
      counts of various file types, pdf, jpeg, etc.
      total file count, including mets, etc in main folder
      count of subfolders, maybe a count
      mets (foreignkey of a mptt model's row that reps the top node
            of the mets file)
    '''
    id = models.AutoField(primary_key=True)

    bibvid = SpaceCharField(
        verbose_name='Bibvid AA12345678_NNNNN',
        max_length=255,
        unique=False,
        blank=False,
        null=False,
        default='bibvid',
        help_text=("UF Bibvid with 10-character bib, underbar, and 5-digit"
                   " vid value."),
        editable=True)

    resource_subpath = SpaceCharField(
        max_length=255,
        null=True,
        default='subpath',
        blank=True,
        editable=True,
    )
    count_files = models.PositiveIntegerField(default=0, null=False)
    count_pdf = models.PositiveIntegerField(default=0, null=False)
    count_jp2 = models.PositiveIntegerField(default=0, null=False)
    count_jpeg = models.PositiveIntegerField(default=0, null=False)
    count_alto = models.PositiveIntegerField(default=0, null=False)
    count_pro = models.PositiveIntegerField(default=0, null=False)
    count_xml = models.PositiveIntegerField(default=0, null=False)

    note = SpaceTextField(
        max_length=2550,
        null=True,
        default='note',
        blank=True,
        help_text=("General note"),
        editable=True,
    )

    def __str__(self):
        return str(self.bibvid)
Esempio n. 2
0
class X2018Subject(models.Model):
    # Must declare thesis as primary_key to suppress auto 'id'
    # field that django creates
    sn = models.IntegerField(primary_key=True)
    thesis = models.ForeignKey(X2018Thesis,
                               on_delete=models.CASCADE,
                               db_index=True,
                               db_column='thesis',
                               blank=True,
                               null=True)
    subject = models.IntegerField(blank=True, null=True)
    xtag = models.CharField(max_length=8, blank=True, null=True)
    term = SpaceCharField(max_length=100, blank=True, null=True)
    matches = models.IntegerField(blank=True, null=True)
    # Column 'source' is 'subject category source code': max 12 chars, per:
    # https://www.loc.gov/standards/sourcelist/subject.html
    source = models.CharField(max_length=12, blank=True, null=True)
    keep = models.CharField(max_length=1, blank=True, null=True)
    marc = models.CharField(max_length=3, blank=True, null=True)
    ind1 = models.CharField(max_length=1, blank=True, null=True)
    ind2 = models.CharField(max_length=1, blank=True, null=True)

    def __str__(self):
        # return(f"{self.thesis}.{self.subject}.{self.xtag}")
        # Only viewing these as inlines, and need no label there
        # return empty string. 'None' triggers an error.
        return ''

    class Meta:
        managed = False
        db_table = 'x2018_subject'
        unique_together = (('thesis', 'subject', 'xtag'), )
Esempio n. 3
0
class RelatedTerm(models.Model):
    id = models.AutoField(primary_key=True)

    # Only one relation in a schema has a null parent
    primary_term = models.ForeignKey(
        'ThesTree',
        blank=False,
        related_name='related_term',
        db_index=True,
        help_text="Primary term in thesauri to which this term is related",
        on_delete=models.CASCADE,
    )

    # Note, internally a unique suffix for the relation name
    # NOTE: it must be unique within the snow flake tree
    name = SpaceCharField(
        verbose_name='Related term name',
        max_length=255,
        unique=False,
        blank=False,
        null=False,
        default='name',
        help_text=("If no parent, name of thesaurus, else the name"
                   " for this narrower term under the broader parent."),
        editable=True)

    def __str__(self):
        return str(self.name)
Esempio n. 4
0
class TermEval(models.Model):
    id = models.AutoField(primary_key=True)
    response = models.ForeignKey(
        'TermSuggestion',
        null=False,
        on_delete=models.CASCADE,
        help_text="GetSuggestedTerm API search which generated this term.")

    # name of the suggested term
    suggested_term = SpaceCharField(max_length=255,
                                    unique=True,
                                    default="Term name",
                                    editable=True)

    # The parent result's value for the 'count' of this suggested term.
    count_suggested = models.PositiveIntegerField(default=0, null=False)

    # A web site user edits this field to record the decision whether to
    # insert the  term as a subject into the item's METS file.
    approval_rating = models.PositiveIntegerField(
        'Your Rating',
        default=50,
        null=False,
        help_text="If rated over 50, this term will be recorded in the METS.")

    def __str__(self):
        return str(self.suggested_term)

    ''' note: Do -not- set Meta.db_table
Esempio n. 5
0
class BibvidTerm(models.Model):
    id = models.AutoField(primary_key=True)

    bibvid = models.ForeignKey(
        'Bibvid',
        null=False,
        on_delete=models.CASCADE,
        help_text=('The Bib_vid now using this term'
                   'suggested terms'),
    )

    # Note, internally a unique suffix for the relation name
    # NOTE: it must be unique within the snow flake tree

    mets_element = SpaceCharField(
        max_length=255,
        unique=False,
        blank=False,
        null=False,
        default='name',
        help_text=("METS element that contains this term."),
        editable=True)

    name = SpaceCharField(
        verbose_name='Related term name',
        max_length=255,
        unique=False,
        blank=False,
        null=False,
        default='name',
        help_text=("If no parent, name of thesaurus, else the name"
                   " for this narrower term under the broader parent."),
        editable=True)

    def __str__(self):
        return str(self.name)
Esempio n. 6
0
class ThesTree(MPTTModel):
    '''
    A master thesauri tree including all a tree for each thesaurus with terms
    of interest.
    Each row with a null parent value (ie without a parent), is a 'root node'
    of a separate thesaurus tree identified by a row in model Thesaurus

    TODO: Add some custom save() validations
    (1) For added 'root' rows with null parent value:
    The name corresponds to exactly one row's name in model Thesaurus.
    (2) Among all rows with the same parent value (including Null),
    validate that the row name is unique
    '''

    id = models.AutoField(primary_key=True)

    # Only one relation in a schema has a null parent
    parent = TreeForeignKey(
        'self',
        null=True,
        blank=True,
        related_name='children',
        db_index=True,
        verbose_name="Parent relation",
        on_delete=models.CASCADE,
    )

    # Note, internally a unique suffix for the relation name
    # NOTE: it must be unique within the snow flake tree
    name = SpaceCharField(
        verbose_name='Thesaurus term name',
        max_length=255,
        unique=False,
        blank=False,
        null=False,
        default='name',
        help_text=("If no parent, name of thesaurus, else the name"
                   " for this narrower term under the broader parent."),
        editable=True)

    def __str__(self):
        return str(self.name)

    class MPTTMeta:
        order_by = ['name']
Esempio n. 7
0
class BatchItem(models.Model):
    '''
    Model BatchItem stores a UFDC Bib_vid identifier and
    a foreign key to a batch set.
    '''
    # try removing this - maybe it 'spooks' admin impots to be explicit?
    # nope.

    uuid = models.UUIDField(primary_key=True,
                            default=uuid.uuid4,
                            editable=False)

    # Adding this to quell django import-export complaints about lack
    # of id field
    # id0 = models.AutoField(primary_key=True)

    row_count = models.IntegerField('Item', default=0)

    batch_set = models.ForeignKey(
        'BatchSet',
        blank=True,
        null=True,
        db_index=True,
        help_text="BatchSet ID that contains this item.",
        on_delete=models.CASCADE,
    )

    # Note: delete of 1 effectively allows delete of this item before
    # importing the same item again -- so that would be effectively an UPDATE
    # for such item.
    # TODO: once a batchSet is used with any maw process, should set
    # delete=0 for all items in that batchset. This will freeze the
    # items of the batchset for historical reports. IE, no future import
    # for this batch set may be made, if dup insert errors on import
    # prevent it).
    delete = models.IntegerField(
        verbose_name='Delete on next import of this item?',
        unique=False,
        blank=False,
        null=False,
        default=1,
        help_text=("1 (delete on next import of this item) or 0 (do not)"),
    )

    bibid = SpaceCharField(
        verbose_name='Bibliographic ID',
        max_length=10,
        unique=False,
        blank=False,
        null=False,
        default='',
        help_text=("Enter alphabetic characters followed by digit characters"
                   " for a total of 10 characters."),
    )

    vid = SpaceCharField(
        verbose_name='Volume ID',
        max_length=10,
        unique=False,
        blank=False,
        null=False,
        default='',
        help_text=("Five digit characters with zeroes on the left. "),
    )

    def __str__(self):
        return str(f"{self.bibid.upper()}_{self.vid}")

    class Meta:
        unique_together = ["batch_set", "bibid", "vid"]
Esempio n. 8
0
class BatchSet(models.Model):
    '''
    Model BatchSet stores information about a set of BatchItem rows
    that were created via a spreadsheet import operation.
    Fields include an identifier, the username of the user who created the
    import, the date-time of the import.
    Consider to include a count of items imported.

    TODO: Do not allow users to delete rows. The import operations themselves
    are historical data desired for UFDC management.
    '''

    id = models.AutoField(primary_key=True)
    # batch_datetime is time the batch was created/imported
    name = SpaceCharField(verbose_name='Custom Unique Batch Name',
                          max_length=255,
                          unique=False,
                          blank=True,
                          null=True,
                          default='',
                          db_index=True,
                          help_text=("Up to 255 characters."),
                          editable=True)
    notes = SpaceTextField(
        verbose_name='Notes about the imported batch of bib-vids.',
        max_length=3000,
        unique=False,
        blank=True,
        null=True,
        default='',
        help_text='Optional Notes about the imported batch of bib-vids.',
        editable=True)
    import_datetime = models.DateTimeField('Importing DateTime (UTC)',
                                           null=False,
                                           auto_now=True,
                                           editable=False)
    import_username = SpaceCharField(verbose_name='User who did the import',
                                     max_length=255,
                                     unique=False,
                                     blank=False,
                                     null=False,
                                     default='',
                                     db_index=True,
                                     help_text=("Up to 255 characters."),
                                     editable=True)

    import_filename = SpaceCharField(verbose_name='Imported File Name',
                                     max_length=255,
                                     unique=False,
                                     blank=False,
                                     null=False,
                                     default='',
                                     db_index=True,
                                     help_text=("Up to 255 characters."),
                                     editable=True)
    import_bibfield = SpaceCharField(
        verbose_name='Import field with BibID',
        max_length=255,
        unique=False,
        blank=False,
        null=False,
        default='BibID',
        help_text=("Import file's BibID Field Name"),
        editable=True)
    # Individual process executions  may query the use whether to interpret
    # devfault vid 00001 as to mean all vids found under UFDC resoures for the
    # bib or the literal one  and only 00001 vid.
    import_vidfield = SpaceCharField(
        verbose_name='Import field with VID',
        max_length=255,
        unique=False,
        blank=True,
        null=True,
        default='VID',
        help_text=("Import file's field name for Volume ID (VID). "
                   "If empty, value 00001 will be set for the VID value."),
        editable=True)
    item_count = models.IntegerField(
        verbose_name='Item Count',
        db_index=True,
        unique=False,
        blank=False,
        null=False,
        default=0,
        help_text=("Count of import bibvid items from the import."),
    )

    def __str__(self):
        return (f"{self.id}")
Esempio n. 9
0
class Item(models.Model):

    # Field 'id' is 'special', and if not defined here, Django defines
    # it as I do below anyway.
    # However I do include it per python Zen:
    # explicit is better than implicit.
    id = models.AutoField(primary_key=True)

    # Many fields based on Jessica English UF email of 20180319
    # Jessica informed us that accession_number is or should beUniversity of
    # North Carolina at Chapel Hill
    # unique to UF and all other cuba_libro partners.
    accession_number = models.CharField('OCLC accession number',
                                        max_length=255,
                                        unique=True,
                                        default="Enter accession number here",
                                        editable=True)
    '''
    charagent = models.CharField('Institution', max_length=255,
      blank=True, null=True,
      db_index=True,
      help_text="Institution that claimed this item via an 'Action:' on the "
           "parent 'Items' web page."
      )
    '''

    agent = models.ForeignKey(
        'Institution',
        on_delete=models.CASCADE,
        blank=True,
        null=True,
        db_index=True,
        help_text="Institution that claimed this item via an 'Action:' on the "
        "parent 'Items' web page.")

    agent_modify_date = models.DateTimeField('Modify Date (UTC)',
                                             null=True,
                                             auto_now=True,
                                             editable=False)

    STATUS_CHOICES = (
        ('', '-'),
        ('PG', 'Pending'),
        ('IP', 'In Process'),
        ('DZ', 'Digitized'),
    )

    status = models.CharField('Status',
                              blank=True,
                              default='',
                              null=False,
                              max_length=50,
                              choices=STATUS_CHOICES,
                              help_text="Status of processing for this item.")

    status_notes = SpaceTextField(null=True,
                                  default='',
                                  blank=True,
                                  editable=True)

    # Original source data for holding is of the form XXX[-NNN[-MMM]]
    # Later I may modify this model to separate them into: holder,
    # hold_count_low, hold_count_high values if needed.
    # If only NNN is given in imported input, then an import process will
    # set both hold_count_low and hold_count_high to NNN
    # If neither NNN nor MMM is given, set both to 0

    # HOLDING CHOICES are long-standing OCLC codes, so they differ
    # from more friendly PARTNER_CHOICES codes above
    HOLDING_CHOICES = (
        ('NDD', 'Duke University'),
        ('FXG', 'Florida International'),
        ('HLS', 'Harvard'),
        ('NYP', 'New York Public'),
        ('FUG', 'University of Florida'),
        ('FQG', 'University of Miami'),
        ('NOC', 'U of North Carolina'),
    )

    holding = SpaceCharField(max_length=255,
                             default='',
                             blank=True,
                             null=False,
                             editable=False,
                             choices=HOLDING_CHOICES)

    #reference type on imported files from UF and Harverd as of 20180320
    # seems to empirically comport with one of the values: [' Book, Whole', 'Journal Article', 'Map',
    #    'Web Page', 'Generic','Music Score', 'Book,Section']
    # New received from partners' import data may expand the list..

    # import column 1
    reference_type = models.CharField(null=True,
                                      default='',
                                      max_length=20,
                                      blank=True,
                                      editable=True)
    # import column 2
    authors_primary = models.TextField(null=True,
                                       default='',
                                       blank=True,
                                       editable=True)

    title_primary = models.TextField(null=True,
                                     default='',
                                     blank=True,
                                     editable=True)
    periodical_full = models.TextField(null=True,
                                       default='',
                                       blank=True,
                                       editable=True)

    # pub_year_span spreadsheet index = 5
    periodical_abbrev = models.TextField(null=True,
                                         default='',
                                         blank=True,
                                         editable=True)

    pub_year_span = models.CharField(
        null=True,
        max_length=50,
        default='2018',
        editable=True,
    )
    pub_date_free_from = models.TextField(null=True,
                                          default='',
                                          blank=True,
                                          editable=True)
    volume = models.CharField(null=True,
                              max_length=30,
                              default='',
                              blank=True,
                              editable=True)
    issue = models.CharField(null=True,
                             max_length=30,
                             default='',
                             blank=True,
                             editable=True)

    # index k =  10
    start_page = models.CharField(null=True,
                                  max_length=30,
                                  default='',
                                  blank=True,
                                  editable=True)
    other_pages = models.CharField(null=True,
                                   max_length=30,
                                   default='',
                                   blank=True,
                                   editable=True)
    keywords = models.TextField(null=True,
                                default='',
                                blank=True,
                                editable=True)
    abstract = models.TextField(null=True,
                                default='',
                                blank=True,
                                editable=True)
    personal_notes = SpaceTextField(null=True,
                                    default='',
                                    blank=True,
                                    editable=True)

    authors_secondary = models.TextField(null=True,
                                         default='',
                                         blank=True,
                                         editable=True)
    title_secondary = models.TextField(null=True,
                                       default='',
                                       blank=True,
                                       editable=True)
    edition = models.TextField(null=True,
                               default='',
                               blank=True,
                               editable=True)
    publisher = models.CharField(null=True,
                                 default='',
                                 max_length=255,
                                 blank=True,
                                 editable=True)
    place_of_publication = models.CharField(null=True,
                                            default='',
                                            max_length=255,
                                            blank=True,
                                            editable=True)

    #index 20
    authors_tertiary = models.TextField(null=True,
                                        default='',
                                        blank=True,
                                        editable=True)
    authors_quaternary = models.TextField(null=True,
                                          default='',
                                          blank=True,
                                          editable=True)
    authors_quinary = models.TextField(null=True,
                                       default='',
                                       blank=True,
                                       editable=True)
    titles_tertiary = models.TextField(null=True,
                                       default='',
                                       blank=True,
                                       editable=True)
    isbn_issn = models.CharField("ISSN/ISBN",
                                 null=True,
                                 max_length=255,
                                 blank=True,
                                 editable=True)

    availability = models.TextField(null=True,
                                    default='',
                                    blank=True,
                                    editable=True)
    author_address = models.TextField("Author/Address",
                                      null=True,
                                      default='',
                                      blank=True,
                                      editable=True)
    language = models.TextField(null=True,
                                default='',
                                blank=True,
                                editable=True)
    classification = models.TextField(null=True,
                                      default='',
                                      blank=True,
                                      editable=True)

    #index=30
    original_foreign_title = models.TextField(null=True,
                                              default='',
                                              blank=True,
                                              editable=True)
    links = models.TextField(null=True, default='', blank=True, editable=True)
    url = models.TextField('URL',
                           null=True,
                           default='',
                           blank=True,
                           editable=True)
    doi = models.TextField('DOI',
                           null=True,
                           default='',
                           blank=True,
                           editable=True)
    pmid = models.TextField('PMID',
                            null=True,
                            default='',
                            blank=True,
                            editable=True)
    pmcid = models.TextField('PMCID',
                             null=True,
                             default='',
                             blank=True,
                             editable=True)

    call_number = models.TextField(null=True,
                                   default='',
                                   blank=True,
                                   editable=True)
    database = models.TextField(null=True,
                                default='',
                                blank=True,
                                editable=True)
    data_source = models.TextField(null=True,
                                   default='',
                                   blank=True,
                                   editable=True)
    identifying_phrase = models.TextField(null=True,
                                          default='',
                                          blank=True,
                                          editable=True)
    retrieved_date = models.CharField(null=True,
                                      max_length=255,
                                      blank=True,
                                      editable=True)

    # index 40
    user_1 = models.TextField(null=True,
                              default='',
                              blank=True,
                              editable=False)
    user_2 = models.TextField(null=True,
                              default='',
                              blank=True,
                              editable=False)
    user_3 = models.TextField(null=True,
                              default='',
                              blank=True,
                              editable=False)
    user_4 = models.TextField(null=True,
                              default='',
                              blank=True,
                              editable=False)
    user_5 = models.TextField(null=True,
                              default='',
                              blank=True,
                              editable=False)
    user_6 = models.TextField(null=True,
                              default='',
                              blank=True,
                              editable=False)
    user_7 = models.TextField(null=True,
                              default='',
                              blank=True,
                              editable=False)
    user_8 = models.TextField(null=True,
                              default='',
                              blank=True,
                              editable=False)
    user_9 = models.TextField(null=True,
                              default='',
                              blank=True,
                              editable=False)
    user_10 = models.TextField(null=True,
                               default='',
                               blank=True,
                               editable=False)
    user_11 = models.TextField(null=True,
                               default='',
                               blank=True,
                               editable=False)
    user_12 = models.TextField(null=True,
                               default='',
                               blank=True,
                               editable=False)
    user_13 = models.TextField(null=True,
                               default='',
                               blank=True,
                               editable=False)
    user_14 = models.TextField(null=True,
                               default='',
                               blank=True,
                               editable=False)
    user_15 = models.TextField(null=True,
                               default='',
                               blank=True,
                               editable=False)

    notes = SpaceTextField(null=True, default='', blank=True, editable=True)
    place_of_publication = models.CharField(
        null=True,
        max_length=255,
        blank=True,
        editable=True,
    )

    link_url = models.URLField('Link_URL', blank=True, null=True)
    edition_url = models.URLField('Edition_URL', blank=True, null=True)
    sub_file_database = models.CharField("Sub file/database",
                                         blank=True,
                                         null=True,
                                         max_length=255,
                                         editable=True)

    def __str__(self):
        return str(self.id)

    ''' note: Do -not- set db_table. Let Django do its thing