Esempio n. 1
0
 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')
Esempio n. 2
0
 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']
Esempio n. 3
0
 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']
Esempio n. 4
0
 def get_geo_chrono_metadata(self, uuid, parent_uuid, context_metadata):
     """ gets and saves geo and chrono metadata """
     act_contain = Containment()
     geo_meta = False
     event_meta = False
     uuid_geo = Geospace.objects.filter(uuid=uuid)[:1]
     if len(uuid_geo) > 0:
         geo_meta = uuid_geo[0]
     else:
         # geo information for this item not found, look to parents
         if parent_uuid is not False \
            and 'p_list' in context_metadata:
             # we have at least 1 parent
             if 'p_geo' not in context_metadata:
                 # no saved geo information in this context path, so look it up
                 p_list = context_metadata['p_list']
                 geo_meta = act_contain.get_geochron_from_subject_list(
                     p_list, 'geo')
                 context_metadata['p_geo'] = geo_meta
                 self.parents[parent_uuid] = context_metadata
             else:
                 # we have saved geo information for this context path so use it
                 geo_meta = context_metadata['p_geo']
     uuid_event = Event.objects.filter(uuid=uuid)[:1]
     if len(uuid_event) > 0:
         event_meta = uuid_event
     else:
         # chrono information for this item not found, look to parents
         if parent_uuid is not False \
            and 'p_list' in context_metadata:
             # we have at least 1 parent
             if 'p_event' not in context_metadata:
                 # no saved chrono information in this context path, so look it up
                 p_list = context_metadata['p_list']
                 event_meta = act_contain.get_geochron_from_subject_list(
                     p_list, 'event')
                 context_metadata['p_event'] = event_meta
                 self.parents[parent_uuid] = context_metadata
             else:
                 # we have saved chrono information for this context path so use it
                 event_meta = context_metadata['p_event']
     context_metadata['geo'] = geo_meta
     context_metadata['event'] = event_meta
     return context_metadata
Esempio n. 5
0
 def get_geo_chrono_metadata(self, uuid, parent_uuid, context_metadata):
     """ gets and saves geo and chrono metadata """ 
     act_contain = Containment()
     geo_meta = False
     event_meta = False
     uuid_geo = Geospace.objects.filter(uuid=uuid)[:1]
     if len(uuid_geo) > 0:
         geo_meta = uuid_geo[0]
     else:
         # geo information for this item not found, look to parents
         if parent_uuid is not False \
            and 'p_list' in context_metadata:
             # we have at least 1 parent
             if 'p_geo' not in context_metadata:
                 # no saved geo information in this context path, so look it up 
                 p_list = context_metadata['p_list']
                 geo_meta = act_contain.get_geochron_from_subject_list(p_list, 'geo')
                 context_metadata['p_geo'] = geo_meta
                 self.parents[parent_uuid] = context_metadata
             else:
                 # we have saved geo information for this context path so use it
                 geo_meta = context_metadata['p_geo']
     uuid_event = Event.objects.filter(uuid=uuid)[:1]
     if len(uuid_event) > 0:
         event_meta = uuid_event
     else:
         # chrono information for this item not found, look to parents
         if parent_uuid is not False \
            and 'p_list' in context_metadata:
             # we have at least 1 parent
             if 'p_event' not in context_metadata:
                 # no saved chrono information in this context path, so look it up 
                 p_list = context_metadata['p_list']
                 event_meta = act_contain.get_geochron_from_subject_list(p_list, 'event')
                 context_metadata['p_event'] = event_meta
                 self.parents[parent_uuid] = context_metadata
             else:
                 # we have saved chrono information for this context path so use it
                 event_meta = context_metadata['p_event']
     context_metadata['geo'] = geo_meta
     context_metadata['event'] = event_meta
     return context_metadata
Esempio n. 6
0
 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')
         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)