Пример #1
0
 def check_string_exists(self, content, show_uuid=False):
     """
     Checks to see if a given string exists in a project
     """
     found = False
     ch_string = OCstring()
     ch_string.project_uuid = self.project_uuid
     ch_string.content = content
     hash_id = OCstring.make_hash_id(ch_string)
     self.oc_string = OCstring.objects.filter(hash_id=hash_id).first()
     if not self.oc_string:
         self.oc_string = False
         return False
     found = True
     if show_uuid:
         found = self.oc_string.uuid
     return found
Пример #2
0
 def check_string_exists(self, content, show_uuid=False):
     """
     Checks to see if a given string exists in a project
     """
     found = False
     ch_string = OCstring()
     ch_string.project_uuid = self.project_uuid
     ch_string.content = content
     hash_id = OCstring.make_hash_id(ch_string)
     try:
         self.oc_string = OCstring.objects.get(hash_id=hash_id)
     except OCstring.DoesNotExist:
         self.oc_string = False
     if (self.oc_string is not False):
         found = True
         if show_uuid:
             found = self.oc_string.uuid
     return found
Пример #3
0
 def check_string_exists(self, content, show_uuid=False):
     """
     Checks to see if a given string exists in a project
     """
     found = False
     ch_string = OCstring()
     ch_string.project_uuid = self.project_uuid
     ch_string.content = content
     hash_id = OCstring.make_hash_id(ch_string)
     try:
         self.oc_string = OCstring.objects.get(hash_id=hash_id)
     except OCstring.DoesNotExist:
         self.oc_string = False
     if(self.oc_string is not False):
         found = True
         if show_uuid:
             found = self.oc_string.uuid
     return found
Пример #4
0
 def store_records(self, act_table, recs):
     """
     stores records retrieved for a given table
     """
     i = 0
     for record in recs:
         i += 1
         allow_write = self.check_allow_write(act_table, record)
         record = self.prep_update_keep_old(act_table, record)
         if (allow_write is False and self.update_keep_old is False):
             print('\n Not allowed to overwite record.' + str(i))
         else:
             # print('\n Adding record:' + str(record))
             newr = False
             if (act_table == 'link_annotations'):
                 newr = LinkAnnotation(**record)
             elif (act_table == 'link_entities'):
                 newr = LinkEntity(**record)
             elif (act_table == 'oc_assertions'):
                 newr = Assertion(**record)
             elif (act_table == 'oc_manifest'):
                 newr = Manifest(**record)
             elif (act_table == 'oc_subjects'):
                 newr = Subject(**record)
             elif (act_table == 'oc_mediafiles'):
                 newr = Mediafile(**record)
             elif (act_table == 'oc_documents'):
                 newr = OCdocument(**record)
             elif (act_table == 'oc_persons'):
                 newr = Person(**record)
             elif (act_table == 'oc_projects'):
                 newr = Project(**record)
             elif (act_table == 'oc_strings'):
                 newr = OCstring(**record)
             elif (act_table == 'oc_types'):
                 newr = OCtype(**record)
             elif (act_table == 'oc_geospace'):
                 newr = Geospace(**record)
             elif (act_table == 'oc_events'):
                 newr = Event(**record)
             elif (act_table == 'oc_predicates'):
                 newr = Predicate(**record)
             elif (act_table == 'oc_identifiers'):
                 newr = StableIdentifer(**record)
             elif (act_table == 'oc_obsmetadata'):
                 newr = ObsMetadata(**record)
             if (newr is not False):
                 try:
                     newr.save(force_insert=self.force_insert,
                               force_update=self.update_keep_old)
                 except Exception as error:
                     print('Something slipped past in ' + act_table +
                           '...' + str(error))
Пример #5
0
 def store_records(self, act_table, recs):
     """
     stores records retrieved for a given table
     """
     for rkey, record in recs.items():
         if (act_table == 'link_annotations'):
             newr = LinkAnnotation(**record)
             newr.save()
         elif (act_table == 'link_entities'):
             newr = LinkEntity(**record)
             newr.save()
         elif (act_table == 'link_hierarchies'):
             newr = LinkHierarchy(**record)
             newr.save()
         elif (act_table == 'oc_chronology'):
             newr = Chronology(**record)
             newr.save()
         elif (act_table == 'oc_geodata'):
             newr = Geodata(**record)
             newr.save()
         elif (act_table == 'oc_mediafiles'):
             newr = Mediafile(**record)
             newr.save()
         elif (act_table == 'oc_documents'):
             newr = OCdocument(**record)
             newr.save()
         elif (act_table == 'oc_persons'):
             newr = Person(**record)
             newr.save()
         elif (act_table == 'oc_projects'):
             newr = Project(**record)
             newr.save()
         elif (act_table == 'oc_strings'):
             newr = OCstring(**record)
             newr.save()
         elif (act_table == 'oc_types'):
             newr = OCtype(**record)
             newr.save()
         elif (act_table == 'oc_events'):
             newr = Event(**record)
             newr.save()
         elif (act_table == 'oc_predicates'):
             newr = Predicate(**record)
             newr.save()
         elif (act_table == 'oc_identifiers'):
             newr = StableIdentifer(**record)
             newr.save()
         elif (act_table == 'oc_obsmetadata'):
             newr = ObsMetadata(**record)
             newr.save()
Пример #6
0
 def get_make_string(self, content):
     """
     returns an oc_string object from the database if it already exists,
     or creates one if it does not yet exist
     """
     found = self.check_string_exists(content)
     if found is False:
         if self.suggested_uuid is not False:
             uuid = self.suggested_uuid
         else:
             # string is new to the project so make it.
             uuid = GenUUID.uuid4()
         newstring = OCstring()
         newstring.uuid = uuid
         newstring.project_uuid = self.project_uuid
         newstring.source_id = self.source_id
         newstring.content = content
         newstring.save()
         self.oc_string = newstring
     return self.oc_string
Пример #7
0
 def get_make_string(self, content):
     """
     returns an oc_string object from the database if it already exists,
     or creates one if it does not yet exist
     """
     found = self.check_string_exists(content)
     if(found is False):
         if self.suggested_uuid is not False:
             uuid = self.suggested_uuid
         else:
             # string is new to the project so make it.
             uuid = GenUUID.uuid4()
         newstring = OCstring()
         newstring.uuid = uuid
         newstring.project_uuid = self.project_uuid
         newstring.source_id = self.source_id
         newstring.content = content
         newstring.save()
         self.oc_string = newstring
     return self.oc_string