示例#1
0
    def setup_static_instances(self):
        '''
		These are instances that are used statically in the code. For example, when we
		provide attribution of an identifier to Getty, or use a Lugt number, we need to
		serialize the related Group or Person record for that attribution, even if it does
		not appear in the source data.
		'''
        lugt_ulan = 500321736
        gri_ulan = 500115990
        gci_ulan = 500115991
        GETTY_GRI_URI = self.helper.make_proj_uri('ORGANIZATION',
                                                  'LOCATION-CODE', 'JPGM')
        GETTY_GCI_URI = self.helper.make_shared_uri(
            'STATIC', 'ORGANIZATION', 'Getty Conservation Institute')
        LUGT_URI = self.helper.make_proj_uri('PERSON', 'ULAN', lugt_ulan)

        gci = model.Group(ident=GETTY_GCI_URI,
                          label='Getty Conservation Institute')
        gci.identified_by = vocab.PrimaryName(
            ident='', content='Getty Conservation Institute')
        gci.exact_match = model.BaseResource(
            ident=f'http://vocab.getty.edu/ulan/{gci_ulan}')

        gri = model.Group(ident=GETTY_GRI_URI,
                          label='Getty Research Institute')
        gri.identified_by = vocab.PrimaryName(
            ident='', content='Getty Research Institute')
        gri.exact_match = model.BaseResource(
            ident=f'http://vocab.getty.edu/ulan/{gri_ulan}')

        lugt = model.Person(ident=LUGT_URI, label='Frits Lugt')
        lugt.identified_by = vocab.PrimaryName(ident='', content='Frits Lugt')
        lugt.exact_match = model.BaseResource(
            ident=f'http://vocab.getty.edu/ulan/{lugt_ulan}')

        instances = defaultdict(dict)
        instances.update({
            'Group': {
                'gci': gci,
                'gri': gri
            },
            'Person': {
                'lugt': lugt
            }
        })
        return instances
示例#2
0
	def test_breadth(self):
		x = model.TransferOfCustody()
		e = model.Activity()
		fr = model.Group()
		to = model.Group()
		w = model.ManMadeObject()
		fr.label = "From"
		to.label = "To"
		x.transferred_custody_of = w
		x.transferred_custody_from = fr
		x.transferred_custody_to = to
		e.used_specific_object = w
		e.carried_out_by = to
		w.current_owner = fr
		x.specific_purpose = e
		js = model.factory.toJSON(x)
		# Okay ... if we're breadth first, then custody_from is a resource
		# And now it's the first in the list
		self.assertTrue(isinstance(js['transferred_custody_from'][0], OrderedDict))
示例#3
0
    def model_publisher_group(self, record, data, seq):
        record.setdefault('_publishings', [])

        series_label = record['label']
        corp_id = data.get('gaia_corp_id')
        geog_id = data.get('gaia_geog_id')

        a_uri = record['uri'] + f'-pub-{seq}'
        cb_label = f' by CB{corp_id}' if corp_id else f' by publisher #{seq}'
        a = vocab.Publishing(ident=a_uri,
                             label=f'Publishing of {series_label}' + cb_label)
        if corp_id:
            uri = self.helper.corporate_body_uri(corp_id)
            a.carried_out_by = model.Group(ident=uri)
        if geog_id:
            uri = self.helper.place_uri(geog_id)
            a.took_place_at = model.Place(ident=uri)
        record['_publishings'].append(a)
示例#4
0
    def __call__(self, data: dict, location_codes, unique_catalogs):
        '''Add information about the ownership of a physical copy of an auction catalog'''
        # Add the URI of this physical catalog to `unique_catalogs`. This data will be used
        # later to figure out which catalogs can be uniquely identified by a catalog number
        # and owner code (e.g. for owners who do not have multiple copies of a catalog).
        cno = data['catalog_number']
        owner_code = data['owner_code']
        copy_number = data.get('copy_number', '')
        owner_name = None
        entry_record = get_crom_object(data.get('_catalog'))
        with suppress(KeyError):
            owner_name = location_codes[owner_code]
            owner_uri = self.helper.make_proj_uri('ORGANIZATION',
                                                  'LOCATION-CODE', owner_code)
            data['_owner'] = {
                'label':
                owner_name,
                'uri':
                owner_uri,
                'referred_to_by': [entry_record],
                'identifiers': [
                    model.Name(ident='', content=owner_name),
                    model.Identifier(ident='', content=str(owner_code))
                ],
            }
            owner = model.Group(ident=owner_uri)
            owner.referred_to_by = entry_record
            add_crom_data(data['_owner'], owner)
            if not owner_code:
                warnings.warn(f'Setting empty identifier on {owner.id}')
            add_crom_data(data=data['_owner'], what=owner)
            catalog = get_crom_object(data)
            catalog.current_owner = owner

        owner_uri = self.helper.physical_catalog_uri(
            cno, owner_code, None
        )  # None here because we want a key that will stand in for all the copies belonging to a single owner
        copy_uri = self.helper.physical_catalog_uri(cno, owner_code,
                                                    copy_number)
        unique_catalogs[owner_uri].add(copy_uri)
        return data
示例#5
0
    def setup_static_instances(self):
        '''
		These are instances that are used statically in the code. For example, when we
		provide attribution of an identifier to Getty, or use a Lugt number, we need to
		serialize the related Group or Person record for that attribution, even if it does
		not appear in the source data.
		'''
        lugt_ulan = 500321736
        gri_ulan = 500115990
        gci_ulan = 500115991
        knoedler_ulan = 500304270
        GETTY_GRI_URI = self.helper.make_proj_uri('ORGANIZATION',
                                                  'LOCATION-CODE', 'JPGM')
        GETTY_GCI_URI = self.helper.make_shared_uri(
            'STATIC', 'ORGANIZATION', 'Getty Conservation Institute')
        LUGT_URI = self.helper.make_proj_uri('PERSON', 'ULAN', lugt_ulan)
        KNOEDLER_URI = self.helper.make_shared_uri('ORGANIZATION', 'ULAN',
                                                   str(knoedler_ulan))

        gci = model.Group(ident=GETTY_GCI_URI,
                          label='Getty Conservation Institute')
        gci.identified_by = vocab.PrimaryName(
            ident='', content='Getty Conservation Institute')
        gci.exact_match = model.BaseResource(
            ident=f'http://vocab.getty.edu/ulan/{gci_ulan}')

        gri = model.Group(ident=GETTY_GRI_URI,
                          label='Getty Research Institute')
        gri.identified_by = vocab.PrimaryName(
            ident='', content='Getty Research Institute')
        gri.exact_match = model.BaseResource(
            ident=f'http://vocab.getty.edu/ulan/{gri_ulan}')

        lugt = model.Person(ident=LUGT_URI, label='Frits Lugt')
        lugt.identified_by = vocab.PrimaryName(ident='', content='Frits Lugt')
        lugt.exact_match = model.BaseResource(
            ident=f'http://vocab.getty.edu/ulan/{lugt_ulan}')

        knoedler_name = 'M. Knoedler & Co.'
        knoedler = model.Group(ident=KNOEDLER_URI, label=knoedler_name)
        knoedler.identified_by = vocab.PrimaryName(ident='',
                                                   content=knoedler_name)
        knoedler.exact_match = model.BaseResource(
            ident=f'http://vocab.getty.edu/ulan/{knoedler_ulan}')

        materials = {
            aat: model.Material(ident=f'http://vocab.getty.edu/aat/{aat}',
                                label=label)
            for aat, label in self.services['materials'].items()
        }

        instances = defaultdict(dict)
        instances.update({
            'Group': {
                'gci': gci,
                'gri': gri,
                'knoedler': knoedler
            },
            'Person': {
                'lugt': lugt
            },
            'Material': materials,
            'Place': self._static_place_instances()
        })

        return instances
示例#6
0
    def model_imprint_group(self, record, data):
        if not data:
            return
        record.setdefault('referred_to_by', [])
        record.setdefault('used_for', [])
        record.setdefault('part_of', [])
        record.setdefault('_activities', [])
        record.setdefault('_groups', [])
        record.setdefault('_places', [])
        record.setdefault('identifiers', [])

        edition = data.get('edition')
        series_number = data.get('series_number')
        doi = data.get('doi')
        coden = data.get('coden')
        website = data.get('website_address')
        publishers = _as_list(data.get('publisher'))
        distributors = _as_list(data.get('distributor'))
        journal = data.get('journal_info')
        # imprint_group/journal_info/aata_journal_id
        # imprint_group/journal_info/aata_issue_id
        degree = data.get('thesis_degree')
        tr = data.get('technical_report_number')

        if edition:
            record['referred_to_by'].append(
                vocab.EditionStatement(ident='', content=edition))

        if series_number:
            record['referred_to_by'].append(
                vocab.Note(ident='',
                           content=series_number))  # TODO: classify this Note

        if doi:
            record['identifiers'].append(
                vocab.DoiIdentifier(ident='', content=doi))

        if coden:
            record['identifiers'].append(
                vocab.CodenIdentifier(ident='', content=coden))

        if website:
            record['referred_to_by'].append(
                vocab.Note(ident='', content=website))

        article_label = record['label']
        for i, publisher in enumerate(publishers):
            corp_id = publisher.get('gaia_corp_id')
            geog_id = publisher.get('publisher_location',
                                    {}).get('gaia_geog_id')
            a_uri = record['uri'] + f'-pub-{i}'
            a = vocab.Publishing(ident=a_uri,
                                 label=f'Publishing of {article_label}')
            if corp_id:
                uri = self.helper.corporate_body_uri(corp_id)
                g = model.Group(ident=uri)
                a.carried_out_by = g
                record['_groups'].append(add_crom_data({}, g))
            if geog_id:
                uri = self.helper.place_uri(geog_id)
                p = model.Place(ident=uri)
                a.took_place_at = p
                record['_places'].append(add_crom_data({}, p))
            record['used_for'].append(a)
# 			record['_activities'].append(add_crom_data({}, a))

        for i, distributor in enumerate(distributors):
            corp_id = distributor.get('gaia_corp_id')
            geog_id = distributor.get('distributor_location',
                                      {}).get('gaia_geog_id')
            a_uri = record['uri'] + f'-dist-{i}'
            a = vocab.Distributing(ident=a_uri,
                                   label=f'Distribution of {article_label}')
            if corp_id:
                uri = self.helper.corporate_body_uri(corp_id)
                g = model.Group(ident=uri)
                a.carried_out_by = g
                record['_groups'].append(add_crom_data({}, g))
            if geog_id:
                uri = self.helper.place_uri(geog_id)
                p = model.Place(ident=uri)
                a.took_place_at = p
                record['_places'].append(add_crom_data({}, p))
            record['used_for'].append(a)
# 			record['_activities'].append(add_crom_data({}, a))

        if journal:
            journal_id = journal.get('aata_journal_id')
            issue_id = journal.get('aata_issue_id')
            issue_uri = self.helper.issue_uri(journal_id, issue_id)
            issue = vocab.IssueText(ident=issue_uri)
            record['part_of'].append(add_crom_data({'uri': issue_uri}, issue))

        if degree:
            record['referred_to_by'].append(
                vocab.Note(ident='', content=degree))

        if tr:
            record['identifiers'].append(model.Identifier(
                ident='', content=tr))  # TODO: classify this Identifier
示例#7
0
    def setup_static_instances(self):
        '''
		These are instances that are used statically in the code. For example, when we
		provide attribution of an identifier to Getty, or use a Lugt number, we need to
		serialize the related Group or Person record for that attribution, even if it does
		not appear in the source data.
		'''
        lugt_ulan = 500321736
        gri_ulan = 500115990
        gci_ulan = 500115991
        knoedler_ulan = 500304270
        GETTY_PSCP_URI = self.helper.make_shared_uri(
            'STATIC', 'ORGANIZATION',
            'Project for the Study of Collecting and Provenance')
        GETTY_GPI_URI = self.helper.make_shared_uri('STATIC', 'ORGANIZATION',
                                                    'Getty Provenance Index')
        GETTY_GRI_URI = self.helper.make_proj_uri('ORGANIZATION',
                                                  'LOCATION-CODE', 'JPGM')
        GETTY_GCI_URI = self.helper.make_shared_uri(
            'STATIC', 'ORGANIZATION', 'Getty Conservation Institute')
        LUGT_URI = self.helper.make_proj_uri('PERSON', 'ULAN', lugt_ulan)
        KNOEDLER_URI = self.helper.make_shared_uri('ORGANIZATION', 'ULAN',
                                                   str(knoedler_ulan))
        NEWYORK_URI = self.helper.make_shared_uri('PLACE', 'USA', 'NY',
                                                  'New York')

        gci = model.Group(ident=GETTY_GCI_URI,
                          label='Getty Conservation Institute')
        gci.identified_by = vocab.PrimaryName(
            ident='', content='Getty Conservation Institute')
        gci.exact_match = model.BaseResource(
            ident=f'http://vocab.getty.edu/ulan/{gci_ulan}')

        gri = model.Group(ident=GETTY_GRI_URI,
                          label='Getty Research Institute')
        gri.identified_by = vocab.PrimaryName(
            ident='', content='Getty Research Institute')
        gri.exact_match = model.BaseResource(
            ident=f'http://vocab.getty.edu/ulan/{gri_ulan}')

        gpi = model.Group(ident=GETTY_GPI_URI, label='Getty Provenance Index')
        gpi.identified_by = vocab.PrimaryName(ident='',
                                              content='Getty Provenance Index')

        pscp = model.Group(
            ident=GETTY_PSCP_URI,
            label='Project for the Study of Collecting and Provenance')
        pscp.identified_by = vocab.PrimaryName(
            ident='',
            content='Project for the Study of Collecting and Provenance')

        lugt = model.Person(ident=LUGT_URI, label='Frits Lugt')
        lugt.identified_by = vocab.PrimaryName(ident='', content='Frits Lugt')
        lugt.exact_match = model.BaseResource(
            ident=f'http://vocab.getty.edu/ulan/{lugt_ulan}')

        knoedler_name = 'M. Knoedler & Co.'
        knoedler = model.Group(ident=KNOEDLER_URI, label=knoedler_name)
        knoedler.identified_by = vocab.PrimaryName(ident='',
                                                   content=knoedler_name)
        knoedler.exact_match = model.BaseResource(
            ident=f'http://vocab.getty.edu/ulan/{knoedler_ulan}')

        newyork_name = 'New York, NY'
        newyork = model.Place(ident=NEWYORK_URI, label=newyork_name)
        newyork.identified_by = vocab.PrimaryName(ident='',
                                                  content=newyork_name)

        materials = {}
        if 'materials' in self.services:
            materials.update({
                aat: model.Material(ident=f'http://vocab.getty.edu/aat/{aat}',
                                    label=label)
                for aat, label in self.services['materials'].items()
            })

        places = self._static_place_instances()
        places.update({'newyork': newyork})

        db_people = self.static_db_instance(
            'PEOPLE', name='STAR Person Authority Database', creator=gpi)
        db_knoedler = self.static_db_instance('Knoedler',
                                              name='STAR Knoedler Database',
                                              creator=gpi)
        db_sales_events = self.static_db_instance(
            'Sales',
            'Descriptions',
            name='STAR Sales Catalogue Database',
            creator=gpi)
        db_sales_catalogs = self.static_db_instance(
            'Sales',
            'Catalogue',
            name='STAR Physical Sales Catalogue Database',
            creator=gpi)
        db_sales_contents = self.static_db_instance(
            'Sales',
            'Contents',
            name='STAR Sales Contents Database',
            creator=gpi)

        instances = defaultdict(dict)
        instances.update({
            'LinguisticObject': {
                'db-people': db_people,
                'db-knoedler': db_knoedler,
                'db-sales_events': db_sales_events,
                'db-sales_catalogs': db_sales_catalogs,
                'db-sales_contents': db_sales_contents,
            },
            'Group': {
                'gci': gci,
                'pscp': pscp,
                'gri': gri,
                'gpi': gpi,
                'knoedler': knoedler
            },
            'Person': {
                'lugt': lugt
            },
            'Material': materials,
            'Place': places
        })

        return instances