IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33768 for trunk/ippToPsps


Ignore:
Timestamp:
Apr 12, 2012, 11:10:09 AM (14 years ago)
Author:
rhenders
Message:

new method to get list of filters in the order they appear in the DVO Photcodes table

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/scratchdb.py

    r33689 r33768  
    540540
    541541    '''
    542     Gets the 'code' for the provided filter
    543     '''
    544     def getCodeForThisFilter(self, filter):
    545 
    546         code = -1
    547         sql = "SELECT CODE FROM " + self.dvoPhotcodesTable + " WHERE NAME = '" + filter + "'"
    548         try:
    549             rs = self.executeQuery(sql)
    550             rs.first()
    551             code = rs.getInt(1)
     542    Gets a list of filters ordered as thy are in the DVO Photcodes table, as this reflects the order they apper in the cps file
     543    '''
     544    def getOrderedListOfFiltersFromPhotcodesTable(self, interestedFilters):
     545
     546        sql = "SELECT NAME FROM " + self.dvoPhotcodesTable + " WHERE "
     547
     548        count = 0
     549        for filter in interestedFilters:
     550           if count != 0: sql = sql + " OR "
     551           sql = sql + " name = '" + filter + "'"
     552           count += 1
     553
     554        sql = sql + " ORDER BY CODE"
     555        print sql
     556
     557        orderedFilters = []
     558        try:
     559            rs = self.executeQuery(sql)
     560            row = 1
     561            while (rs.next()):
     562                orderedFilters.append([row,rs.getString(1)])
     563                row += 1
    552564            rs.close()
    553565        except:
    554             self.logger.errorPair("Could not get filter code using", sql )
    555 
    556         return code
    557 
     566            self.logger.errorPair("Could not get ordered filter list", sql )
     567
     568        return orderedFilters
     569
Note: See TracChangeset for help on using the changeset viewer.