Changeset 3860


Ignore:
Timestamp:
07/05/08 15:52:04 (11 years ago)
Author:
cbyrom
Message:

Add new function, escapeSpecialCharacters() to PostgresRecord? to correct
the input docs and moles docs - so that they don't feature exposed
apostrophes - to avoid errors when running the PL/SQL stuff.

Location:
TI01-discovery/branches/ingestAutomation-upgrade
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TI01-discovery/branches/ingestAutomation-upgrade/OAIBatch/PostgresDAO.py

    r3858 r3860  
    229229        sqlCmd = "SELECT create_document('" + self._record.filename + "', '" + \ 
    230230            self._record.discovery_id + "', '" + self._record.docType + "', '" + \ 
    231             self._record.originalFormat + "');"       
     231            self._record.originalFormat + "');"  
    232232 
    233233        id = db_funcs.runSQLCommand(self._connection, sqlCmd) 
  • TI01-discovery/branches/ingestAutomation-upgrade/OAIBatch/PostgresRecord.py

    r3853 r3860  
    1414        from ndgUtils.elementtree import cElementTree 
    1515 
    16 import os, sys, logging 
    17 #from ETxmlView import loadET, nsdumb 
     16import os, sys, logging, re 
    1817import molesReadWrite as MRW 
    1918from ndgUtils.ndgObject import ndgObject 
     
    6463        self.originalFormat = file(filename).read() 
    6564         
     65        # escape any apostrophes  
     66        self.originalFormat = self.escapeSpecialCharacters(self.originalFormat) 
     67 
    6668        # initialise the various record fields 
    6769        self.db_id = None    # the DB ID of the record, for easy reference when it is created 
     
    7678        self.getSpatioTemporalData() 
    7779 
     80 
     81    def escapeSpecialCharacters(self, inputString): 
     82        ''' 
     83        Adjust the input string to escape any characters that would interfere with string or DB 
     84        operations 
     85        @param inputString: string to correct 
     86        @return: corrected string  
     87        ''' 
     88        return re.sub(r'\'', '\\\'', inputString) 
     89     
    7890     
    7991    def doRecordTransforms(self): 
     
    156168         
    157169        logging.info("Transform completed successfully") 
    158          
    159 #        f=open(xQueryType + "_doc.xml", 'w') 
    160 #        f.write(output) 
    161 #        f.close() 
    162              
     170 
    163171        return output 
    164172 
     
    184192        # now run the appropriate transform and set the attribute 
    185193        setattr(self, "_molesFormat", self.doTransform(xqName)) 
     194         
     195        # escape any apostrophes 
     196        self._molesFormat = self.escapeSpecialCharacters(self._molesFormat) 
     197 
    186198        logging.info("moles document created") 
    187199         
  • TI01-discovery/branches/ingestAutomation-upgrade/database/ingest_procedures.sql

    r3859 r3860  
    2626$$ 
    2727        DECLARE 
    28                 db_id integer := -1; 
     28                db_id integer; 
    2929    BEGIN 
    3030        -- This inserts a new document into the DB 
Note: See TracChangeset for help on using the changeset viewer.