Changeset 5047


Ignore:
Timestamp:
27/02/09 11:24:51 (10 years ago)
Author:
sdonegan
Message:

Handle a bug re. timestamps and ingest.

Location:
TI01-discovery/tags/stable-TI01-ingestAutomation_Proglue_upgradesAndReporting/temp/OAIBatch
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TI01-discovery/tags/stable-TI01-ingestAutomation_Proglue_upgradesAndReporting/temp/OAIBatch/DIF.py

    r5040 r5047  
    7373         
    7474        #add some extra parameters here to extract further columns to aid in ranking & ordering         
    75         self.metadataCreationDate=helper.getText(self.tree,'DIF_Creation_Date') 
     75        if len(helper.getText(self.tree,'DIF_Creation_Date')) < 1:             
     76            #set to null as bad timestamp will screw up the sql commands (will scan for it later) 
     77            self.metadataCreationDate='null' 
     78        else: 
     79            self.metadataCreationDate=helper.getText(self.tree,'DIF_Creation_Date') 
     80             
    7681        self.datacentreName=helper.getText(self.tree,'Data_Center/Data_Center_Name/Short_Name') 
    7782         
  • TI01-discovery/tags/stable-TI01-ingestAutomation_Proglue_upgradesAndReporting/temp/OAIBatch/MDIP.py

    r5040 r5047  
    2828         
    2929        #add in extra stuff for new DatasetBasicParameters object 
    30         self.metadataCreationDate=helper.getText(self.tree,'DateOfUpdateOfMetadata') 
     30        if len(helper.getText(self.tree,'DateOfUpdateOfMetadata')) < 1:             
     31            #set to null as bad timestamp will screw up the sql commands (will scan for it later) 
     32            self.metadataCreationDate='null' 
     33        else: 
     34            self.metadataCreationDate=helper.getText(self.tree,'DateOfUpdateOfMetadata') 
     35         
     36         
    3137        self.datacentreName=helper.getText(self.tree,'Distributor/DistributorName/DistributorNameName') 
    3238         
  • TI01-discovery/tags/stable-TI01-ingestAutomation_Proglue_upgradesAndReporting/temp/OAIBatch/PostgresDAO.py

    r5040 r5047  
    44C Byrom Apr 08 
    55''' 
    6 import sys, os, logging 
     6import sys, os, logging,re 
    77import db_funcs 
    88from SpatioTemporalData import * 
     
    302302            self._record.dataset_name + "', '" + self._record.datacentre_name + "', '" + self._record.dataset_lastEdit + "');"  
    303303 
    304         '''logging.info("SELECT create_document('" + self._record.shortFilename + "', '" + \ 
    305             self._record.discovery_id + "', '" + self._record.docType + "', '" + \ 
    306             self._record.originalFormat + "', '" + self._record.getAuthorsInfo() + "', '" + \ 
    307             self._record.getParametersInfo() + "', '" + self._record.getScopeInfo() + "', '" + \ 
    308             self._record.dataset_name + "', '" + self._record.datacentre_name + "', '" + self._record.dataset_lastEdit + "');" )''' 
     304        #scan the sql string for any 'null' characters - if there are some, get rid of the quote marks.  Easier to do this now..         
     305        sqlCmd = self.sqlCommandNullScan(sqlCmd) 
     306         
     307        #logging.info("Update Command:  " + sqlCmd) 
    309308         
    310309        id = db_funcs.runSQLCommand(self._connection, sqlCmd) 
     
    323322         
    324323        sqlCmd = "SELECT delete_document('" + str(self._record.db_id) + "');"  
     324         
     325        #scan the sql string for any 'null' characters - if there are some, get rid of the quote marks.  Easier to do this now.. 
     326        sqlCmd = self.sqlCommandNullScan(sqlCmd) 
    325327 
    326328        db_funcs.runSQLCommand(self._connection, sqlCmd) 
     
    340342            self._record.dataset_name + "', '" + self._record.datacentre_name + "', '" + self._record.dataset_lastEdit +"');" 
    341343             
     344        #scan the sql string for any 'null' characters - if there are some, get rid of the quote marks.  Easier to do this now.. 
     345        sqlCmd = self.sqlCommandNullScan(sqlCmd) 
     346         
    342347        db_funcs.runSQLCommand(self._connection, sqlCmd) 
    343348         
     
    363368                docType + "', '" + doc + "', current_timestamp, 1);" 
    364369             
     370            #scan the sql string for any 'null' characters - if there are some, get rid of the quote marks.  Easier to do this now.. 
     371            sqlCmd = self.sqlCommandNullScan(sqlCmd) 
     372         
     373             
    365374            db_funcs.runSQLCommand(self._connection, sqlCmd) 
    366375         
     
    382391                str(self._record.db_id) + " AND transformed_format = '" + docType + "';" 
    383392 
     393            #scan the sql string for any 'null' characters - if there are some, get rid of the quote marks.  Easier to do this now.. 
     394            sqlCmd = self.sqlCommandNullScan(sqlCmd) 
     395         
    384396            db_funcs.runSQLCommand(self._connection, sqlCmd) 
    385397     
    386398        logging.info("Transformed records updated in DB") 
    387399 
     400 
     401    def sqlCommandNullScan(self,sqlCmd): 
     402        ''' 
     403        Scan completed sql command for any text 'null', then use re module to convert to null 
     404        '''        
     405        return re.sub("'null'","null",sqlCmd) 
     406         
     407     
    388408 
    389409    def setRecord(self, record): 
Note: See TracChangeset for help on using the changeset viewer.