Changeset 4301 for exist


Ignore:
Timestamp:
07/10/08 17:38:34 (11 years ago)
Author:
cbyrom
Message:

Add convenience methods to determine whether a data item is a granule +
selected atom related links according to their type - to allow granules + deployments
to be associated with data entities.

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

Legend:

Unmodified
Added
Removed
  • exist/trunk/python/ndgUtils/models/Atom.py

    r4296 r4301  
    903903        logging.info("Created formatted version of XML object") 
    904904        return prettyXML 
     905 
     906 
     907    def getLinksOfType(self, termID): 
     908        ''' 
     909        Returns links in the atom related links attribute which match the specified 
     910        term ID 
     911        @param termID: the termID to look for in the related links - NB, this is 
     912        matched to the end of the link.rel value 
     913        @return links: array of Link objects with matching term type  
     914        ''' 
     915        logging.debug("Getting atom links of type, '%s'" %termID) 
     916        matchingLinks = [] 
     917        for link in self.relatedLinks: 
     918            if link and link.rel and link.rel.lower().endswith(termID.lower()): 
     919                logging.debug("- found link with matching term type") 
     920                matchingLinks.append(link) 
     921 
     922        logging.debug("Returning matched links") 
     923        return matchingLinks 
  • exist/trunk/python/ndgUtils/vocabtermdata.py

    r4295 r4301  
    185185 
    186186    ATOM_TYPES = [ACTIVITY_TERM, DE_TERM, DPT_TERM, GRANULE_TERM, OBS_TERM] 
     187     
     188    DEPLOYABLE_ATOM_TYPES = [ACTIVITY_TERM, DPT_TERM, OBS_TERM] 
    187189 
    188190    PROVIDER_TYPES = [BADC_TERM, NEODC_TERM] 
     
    196198 
    197199    ATOM_CATEGORY = "atom" 
     200    DEPLOYABLE_ATOM_CATEGORY = "deployableatom" 
    198201    ONLINE_REF_CATEGORY = "onlineref" 
    199202    PROVIDER_CATEGORY = "provider" 
     
    283286        if category == self.ATOM_CATEGORY: 
    284287            catList = self.ATOM_TYPES 
     288        elif category == self.DEPLOYABLE_ATOM_CATEGORY: 
     289            catList = self.DEPLOYABLE_ATOM_TYPES 
    285290        elif category == self.PROVIDER_CATEGORY: 
    286291            catList = self.PROVIDER_TYPES 
     
    547552        logging.debug("- item is not a deployment") 
    548553        return False 
     554     
     555     
     556    def isGranule(self, vti): 
     557        ''' 
     558        Determines whether a vocab term item is a granule item 
     559        @param vti: vocab term item to check 
     560        @return True if a granule, false otherwise 
     561        ''' 
     562        logging.debug("Checking if item is a granule") 
     563        if vti: 
     564            if vti.termID == self.GRANULE_TERM: 
     565                logging.debug("- item is a granule") 
     566                return True 
     567         
     568        logging.debug("- item is not a granule") 
     569        return False 
    549570                 
Note: See TracChangeset for help on using the changeset viewer.