Skip to content

Commit

Permalink
Addresses Issue ooici#53
Browse files Browse the repository at this point in the history
Fixes RR id in SQL calls based on changes to RR service calls.
  • Loading branch information
oceanzus committed Jun 10, 2014
1 parent c36dc3b commit 74df560
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions resync_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,9 @@ def get_meta_data_records_for_harvester(self, site_dict):
self.logger.info('Error getting record from metadata record.'+str(e))
continue


try:
#add the data to the RR
if rec_rruuid == None:
if rec_rruuid is None:
# The metadata record is new
data_product_id = self.create_new_resource(uuid,rec_name,rec_descrip,ref_url,rec_params)
if data_product_id is None:
Expand All @@ -194,7 +193,7 @@ def get_meta_data_records_for_harvester(self, site_dict):
self.logger.info("new meta data record:"+str(data_product_id))
rruuid = data_product_id
# Add record to metadataregistry table with registerdate and rruuid
insert_values = {'uuid': uuid, 'rruuid': rruuid, 'changedate': rec_changedate}
insert_values = {'uuid': uuid, 'rruuid': data_product_id, 'changedate': rec_changedate}
insert_stmt = "INSERT INTO metadataregistry (gnuuid,rruuid,registerdate) VALUES ('%(uuid)s','%(rruuid)s','%(changedate)s')" % insert_values
cursor.execute(insert_stmt)
self.logger.info("update meta data registry:"+str(insert_stmt))
Expand All @@ -207,14 +206,14 @@ def get_meta_data_records_for_harvester(self, site_dict):
dp["description"] = rec_descrip
dp["reference_urls"] = [ref_url]
# update new resource in the RR
rruuid = self.request_resource_action('resource_registry', 'update', object=dp)
self.request_resource_action('resource_registry', 'update', object=dp)

# UPDATE metadataregistry table record with updated registerdate and rruuid
update_values = {'uuid': uuid, 'rruuid': rruuid, 'changedate': rec_changedate}
update_values = {'uuid': uuid, 'rruuid': rec_rruuid, 'changedate': rec_changedate}
update_stmt = ("UPDATE metadataregistry SET rruuid='%(rruuid)s', registerdate='%(changedate)s' WHERE gnuuid='%(uuid)s'" % update_values)
cursor.execute(update_stmt)

elif uuid == None:
elif uuid is None:
# Metadata record was deleted by the harvester, cleanup the lookup table and the OOI RR
# Delete from RR
self.request_resource_action('resource_registry', 'delete', object_id=rec_rruuid)
Expand All @@ -224,13 +223,9 @@ def get_meta_data_records_for_harvester(self, site_dict):
delete_stmt = ("DELETE FROM metadataregistry WHERE rruuid='%(rruuid)s'" % delete_values)
cursor.execute(delete_stmt)
except Exception, e:
self.logger.info(str(e)+ ": error performining sql commands")


break

self.logger.info(str(e) + ": error performing sql commands")
except Exception, e:
self.logger.info(str(e)+ ": I am unable to connect to the database...")
self.logger.info(str(e) + ": I am unable to connect to the database...")

def generate_param_from_metadata(self,param_item):
#param should look like this
Expand Down

0 comments on commit 74df560

Please sign in to comment.