Changeset 4295 for exist


Ignore:
Timestamp:
07/10/08 15:26:22 (11 years ago)
Author:
cbyrom
Message:

Extend vocabtermdata module to provide utility methods to check if a
vocab data item is of the type deployable (i.e. usable as part of a
deployment) and is of the type deployment + expose method to retrieve
'pretty' title for subtypes + adjust search xqueries to retrieve the
full term urls for atom types and subtypes.

Location:
exist/trunk/python/ndgUtils
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • exist/trunk/python/ndgUtils/eXistInterface.py

    r4280 r4295  
    183183<id>{$DE/atom:entry/atom:id/text()}</id> \ 
    184184<name>{$DE/atom:entry/atom:title/text()}</name> \ 
    185 <type>{string($DE/atom:entry/atom:category[@term='ATOM_TYPE']/@label)}</type> \ 
    186 <subtype>{string($DE/atom:entry/atom:category[@term='ATOM_SUBTYPE']/@label)}</subtype> \ 
     185<type>{string($DE/atom:entry/atom:category[@term='ATOM_TYPE']/@scheme)}</type> \ 
     186<subtype>{string($DE/atom:entry/atom:category[@term='ATOM_SUBTYPE']/@scheme)}</subtype> \ 
    187187<href>{string($DE/atom:entry/atom:link[@rel='self']/@href)}</href> \ 
    188188<providerID>{$DE/atom:entry/moles:entity/moles:molesISO/moles:providerID/text()}</providerID> \ 
  • exist/trunk/python/ndgUtils/vocabtermdata.py

    r4281 r4295  
    298298 
    299299 
     300    def tidySubTypeTitle(self, title): 
     301        ''' 
     302        Tidy up the title of subtypes slightly, if need be 
     303        - NB, these are inherited from original moles format so are 
     304        not really 'human readable' 
     305        ''' 
     306        if title and title.startswith('dg'): 
     307            title = title[2:] 
     308            # and fix any camelcase - putting into words 
     309            title = re.sub('([A-Z])', r" \1", title).strip() 
     310 
     311        return title 
     312 
    300313    def getValidSubTypes(self, atomType): 
    301314        ''' 
     
    310323        for st in subTypes: 
    311324            item = self.TERM_DATA[st] 
    312             # tidy up the title slightly, if need be 
    313             if item.title and item.title.startswith('dg'): 
    314                 item.title = item.title[2:] 
    315                 # and fix any camelcase - putting into words 
    316                 item.title = re.sub('([A-Z])', r" \1", item.title).strip() 
     325            item.title = self.tidySubTypeTitle(item.title) 
    317326            types.append(item) 
    318327        logging.debug("Found subtypes: %s" %subTypes) 
     
    478487     
    479488        return vti 
    480          
    481489     
    482490     
     
    505513        logging.debug("Found matching term - '%s'" %vti.termID) 
    506514        return vti 
     515     
     516     
     517    def isDeployable(self, vti): 
     518        ''' 
     519        Determines whether a vocab term item can be used as part of a deployment 
     520        @param vti: vocab term item to check 
     521        @return True if allowed as part of deployment, false otherwise 
     522        ''' 
     523        logging.debug("Checking if item is deployable") 
     524        if vti: 
     525            if vti.termID == self.ACTIVITY_TERM or \ 
     526                vti.termID == self.DPT_TERM or \ 
     527                vti.termID == self.OBS_TERM: 
     528                logging.debug("- item is deployable") 
     529                return True 
     530         
     531        logging.debug("- item is not deployable") 
     532        return False 
     533     
     534     
     535    def isDeployment(self, vti): 
     536        ''' 
     537        Determines whether a vocab term item is a deployment item 
     538        @param vti: vocab term item to check 
     539        @return True if a deployment, false otherwise 
     540        ''' 
     541        logging.debug("Checking if item is a deployment") 
     542        if vti: 
     543            if vti.termID == self.DEPLOYMENT_TERM: 
     544                logging.debug("- item is a deployment") 
     545                return True 
     546         
     547        logging.debug("- item is not a deployment") 
     548        return False 
    507549                 
Note: See TracChangeset for help on using the changeset viewer.