def get_spatial_temporal_context(self): """ gets the item spatial context """ act_contain = Containment() if self.manifest.item_type == 'subjects': # get item geospatial and chronological metadata if subject item # will do it differently if not a subject item parents = act_contain.get_parents_by_child_uuid(self.manifest.uuid) self.contexts = parents # prepare a list of contexts (including the current item) to check for # geospatial and event / chronology metadata subject_list = act_contain.contexts_list subject_list.insert(0, self.manifest.uuid) self.geo_meta = act_contain.get_geochron_from_subject_list( subject_list, 'geo') self.temporal_meta = act_contain.get_geochron_from_subject_list( subject_list, 'temporal') self.event_meta = act_contain.get_geochron_from_subject_list( subject_list, 'event') # now get any children items, contained in this "subjects" item act_contain = Containment() self.contents = act_contain.get_children_by_parent_uuid( self.manifest.uuid) else: parents = act_contain.get_related_context(self.manifest.uuid) self.contexts = False self.linked_contexts = parents if self.manifest.item_type == 'projects': # get project metadata objects directly pm = ProjectMeta() project = self.item_gen_cache.get_project_model_object( self.manifest.uuid) sub_projects = self.item_gen_cache.get_project_subprojects( self.manifest.uuid) if project is not None: if isinstance(project.meta_json, dict): if Project.META_KEY_GEO_SPECIFICITY in project.meta_json: # the project has some default geographic specificity noted # use this value when making geo_meta pm.project_specificity = project.meta_json[ Project.META_KEY_GEO_SPECIFICITY] self.geo_meta = pm.get_project_geo_from_db(self.manifest.uuid) if self.geo_meta is False: # make geospatial metadata for the project, and sub-projects if they exist pm.make_geo_meta(self.manifest.uuid, sub_projects) self.geo_meta = pm.geo_objs act_contain = Containment() if self.geo_meta is False: self.geo_meta = act_contain.get_related_geochron( self.manifest.uuid, self.manifest.item_type, 'geo') if self.temporal_meta is False: self.temporal_meta = act_contain.get_related_geochron( self.manifest.uuid, self.manifest.item_type, 'temporal') if self.temporal_meta is False: # now look in the project for temporal metadata self.temporal_meta = act_contain.get_temporal_from_project( self.manifest.project_uuid) if self.event_meta is False: self.event_meta = act_contain.get_related_geochron( self.manifest.uuid, self.manifest.item_type, 'event')
def get_geo_event_metadata(self): """ gets geospatial and event metadata for the item """ if self.is_valid: act_contain = Containment() if self.manifest.item_type == 'subjects': parents = act_contain.get_parents_by_child_uuid( self.manifest.uuid) subject_list = act_contain.contexts_list subject_list.insert(0, self.manifest.uuid) self.geo_meta = act_contain.get_geochron_from_subject_list( subject_list, 'geo') self.event_meta = act_contain.get_geochron_from_subject_list( subject_list, 'event') else: self.geo_meta = act_contain.get_related_geochron( self.manifest.uuid, self.manifest.item_type, 'geo') self.event_meta = act_contain.get_related_geochron( self.manifest.uuid, self.manifest.item_type, 'event') if self.event_meta is not False and self.event_meta is not None: start = None stop = None for event in self.event_meta: if start is None: start = event.start if stop is None: stop = event.stop if start < event.start: start = event.start if stop > event.stop: stop = event.stop if stop is None: stop = start if start is not None: if stop < start: stop_temp = start start = stop stop = stop_temp # we have a start year, so make a temporal value in ISON 8601 format self.temporal = ISOyears().make_iso_from_float(start) if stop != start: # stop year different from start, so add a / sep and the stop # year in ISO 8601 format self.temporal += '/' + ISOyears().make_iso_from_float( stop) if self.temporal is None and self.manifest.item_type == 'projects': # get project teporal metadata via solr # now query Solr for temporal data cq = CompleteQuery() payload = {'proj': self.manifest.slug} ass_metadata = cq.get_json_query(payload, None) if 'dc-terms:temporal' in ass_metadata: self.temporal = ass_metadata['dc-terms:temporal']
def get_geo_event_metadata(self): """ gets geospatial and event metadata for the item """ if self.is_valid: act_contain = Containment() if self.manifest.item_type == 'subjects': parents = act_contain.get_parents_by_child_uuid(self.manifest.uuid) subject_list = act_contain.contexts_list subject_list.insert(0, self.manifest.uuid) self.geo_meta = act_contain.get_geochron_from_subject_list(subject_list, 'geo') self.event_meta = act_contain.get_geochron_from_subject_list(subject_list, 'event') else: self.geo_meta = act_contain.get_related_geochron(self.manifest.uuid, self.manifest.item_type, 'geo') self.event_meta = act_contain.get_related_geochron(self.manifest.uuid, self.manifest.item_type, 'event') if self.event_meta is not False and self.event_meta is not None: start = None stop = None for event in self.event_meta: if start is None: start = event.start if stop is None: stop = event.stop if start < event.start: start = event.start if stop > event.stop: stop = event.stop if stop is None: stop = start if start is not None: if stop < start: stop_temp = start start = stop stop = stop_temp # we have a start year, so make a temporal value in ISON 8601 format self.temporal = ISOyears().make_iso_from_float(start) if stop != start: # stop year different from start, so add a / sep and the stop # year in ISO 8601 format self.temporal += '/' + ISOyears().make_iso_from_float(stop) if self.temporal is None and self.manifest.item_type == 'projects': # get project teporal metadata via solr # now query Solr for temporal data cq = CompleteQuery() payload = {'proj': self.manifest.slug} ass_metadata = cq.get_json_query(payload, None) if 'dc-terms:temporal' in ass_metadata: self.temporal = ass_metadata['dc-terms:temporal']