Skip to content

Commit

Permalink
gather
Browse files Browse the repository at this point in the history
  • Loading branch information
adlius committed Jan 24, 2024
1 parent 476f22d commit b9f1d5d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions osf/metadata/osf_gathering.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,12 @@ def osfmap_for_type(rdftype_iri: str):
OSF.Project: {
**OSF_OBJECT,
OSF.supplements: OSF_OBJECT_REFERENCE,
OSF.usesCedarTemplate: None,
},
OSF.ProjectComponent: {
**OSF_OBJECT,
OSF.supplements: OSF_OBJECT_REFERENCE,
OSF.usesCedarTemplate: None,
},
OSF.Registration: {
**OSF_OBJECT,
Expand All @@ -161,6 +163,7 @@ def osfmap_for_type(rdftype_iri: str):
OSF.hasMaterialsResource: OSF_OBJECT_REFERENCE,
OSF.hasPapersResource: OSF_OBJECT_REFERENCE,
OSF.hasSupplementalResource: OSF_OBJECT_REFERENCE,
OSF.usesCedarTemplate: None,
},
OSF.RegistrationComponent: {
**OSF_OBJECT,
Expand All @@ -171,6 +174,7 @@ def osfmap_for_type(rdftype_iri: str):
OSF.hasMaterialsResource: OSF_OBJECT_REFERENCE,
OSF.hasPapersResource: OSF_OBJECT_REFERENCE,
OSF.hasSupplementalResource: OSF_OBJECT_REFERENCE,
OSF.usesCedarTemplate: None,
},
OSF.Preprint: {
**OSF_OBJECT,
Expand All @@ -195,6 +199,7 @@ def osfmap_for_type(rdftype_iri: str):
OSF.filePath: None,
OSF.funding: None,
OSF.hasFunding: None,
OSF.usesCedarTemplate: None,
OWL.sameAs: None,
},
DCTERMS.Agent: {
Expand Down Expand Up @@ -1010,3 +1015,15 @@ def _omitted_metadata(focus, omitted_property_set, description):
for property_iri in omitted_property_set:
yield (bnode, OSF.omittedMetadataProperty, property_iri)
yield (bnode, DCTERMS.description, _language_text(focus, description))

@gather.er(OSF.usesCedarTemplate)
def gather_cedar_templates(focus):
try:
_guids = focus.dbmodel.guids.all()
except AttributeError:
return # no guids
records = osfdb.CedarMetadataRecord.objects.filter(guid__in=_guids, public=True)
for record in records:
template_iri = rdflib.URIRef(record.get_template_semantic_iri())
yield (OSF.usesCedarTemplate, template_iri)
yield (template_iri, DCTERMS.title, record.get_template_name())
9 changes: 9 additions & 0 deletions osf/models/cedar_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class Meta:
def __unicode__(self):
return f'(name=[{self.schema_name}], version=[{self.template_version}], id=[{self.cedar_id}])'

def get_semantic_iri(self):
return self.template['@id']


class CedarMetadataRecord(ObjectIDMixin, BaseModel):

Expand All @@ -30,3 +33,9 @@ class Meta:

def __unicode__(self):
return f'(guid=[{self.guid._id}], template=[{self.template._id}])'

def get_template_semantic_iri(self):
return self.template.get_semantic_iri()

def get_template_name(self):
return self.template.name

0 comments on commit b9f1d5d

Please sign in to comment.