Changeset 4780


Ignore:
Timestamp:
12/01/09 09:59:29 (11 years ago)
Author:
cbyrom
Message:

Create AtomState? object to represent the different atom publication
states - tieing together the associated name and collection paths.
Update Atom model to use this.

Location:
exist/trunk/python/ndgUtils/models
Files:
1 added
1 edited

Legend:

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

    r4721 r4780  
    2222import csml.parser as CsmlParser 
    2323from ndgUtils.models import Deployment as Deployment 
    24  
     24from ndgUtils.models import AtomState 
    2525 
    2626class AtomError(Exception): 
     
    246246 
    247247    def __init__(self, atomType = None, vocabTermData = None, ndgObject = None, \ 
    248                  xmlString = None, state = eXistConnector.WORKING_COLLECTION_PATH, **inputs): 
     248                 xmlString = None, state = AtomState.WORKING_STATE, **inputs): 
    249249        ''' 
    250250        Constructor - initialise the atom variables 
     251        @keyword atomType: type of atom to set up 
     252        @keyword vocabTermData: instance of VocabTermData object to use with atom 
     253        @keywork ndgObject: instance of ndgObject to use with atom 
     254        @keyword xmlString: XML representation of atom - will be parsed to populate 
     255        the atom data 
     256        @keyword state:  AtomState object representing the state of the atom 
    251257        ''' 
    252258        logging.info("Initialising atom") 
     
    405411        self.relatedLinks = updatedLinks 
    406412        logging.debug("Links removed") 
    407          
    408  
    409     def getDefaultCollectionPath(self): 
    410         ''' 
    411         Determine the correct collection to use for the atom in eXist 
    412         ''' 
    413         collectionPath = eXistConnector.BASE_COLLECTION_PATH + self.state 
     413 
     414    def getPublicationStatePath(self): 
     415        ''' 
     416        Determine the correct publication state collection for the atom 
     417        @return collectionPath: collection path for the publication state of the atom 
     418        ''' 
     419        logging.debug("Getting collection path for atom publication state") 
     420        collectionPath = eXistConnector.BASE_COLLECTION_PATH + self.state.collectionPath 
     421        logging.debug("Returning publication state collection, '%s'" %collectionPath) 
     422        return collectionPath 
     423         
     424 
     425    def getDefaultEntityCollectionPath(self): 
     426        ''' 
     427        Determine the correct collection for the entity type of the atom 
     428        @return entityPath: collection path for the data type of the atom 
     429        ''' 
     430        logging.debug("Getting collection path for atom entity type") 
     431        collectionPath = self.getPublicationStatePath() 
    414432         
    415433        if self.atomTypeID == VTD.DE_TERM: 
     
    423441            collectionPath += eXistConnector.DEPLOYMENT_COLLECTION_PATH 
    424442         
     443        logging.debug("Returning entity collection, '%s'" %collectionPath) 
     444        return collectionPath 
     445         
     446 
     447    def getDefaultCollectionPath(self): 
     448        ''' 
     449        Determine the correct collection to use for the atom in eXist 
     450        ''' 
     451        logging.debug("Getting default collection path for atom") 
     452        collectionPath = self.getDefaultEntityCollectionPath() 
    425453        if not self.ME.providerID: 
    426454            raise AtomError("Error: cannot determine atom collection path because " + \ 
     
    428456             
    429457        collectionPath += self.ME.providerID + "/" 
     458        logging.debug("Returning collection, '%s'" %collectionPath) 
    430459        return collectionPath 
    431460 
     
    10681097            return True 
    10691098        return False 
     1099     
     1100    def isPublished(self): 
     1101        ''' 
     1102        Check state of atom doc - if published or Published return True,  
     1103        otherwise return False 
     1104        ''' 
     1105        return self.state.isPublishedState() 
    10701106         
    10711107         
     
    13051341                dataArray.append(link) 
    13061342        logging.debug("Finished adding links") 
     1343 
     1344         
     1345    def getFullPath(self): 
     1346        ''' 
     1347        Return full path to atom in eXist, if it exists, or None, otherwise 
     1348        @return fullPath: string - collection + filename of atom in eXist 
     1349        ''' 
     1350        # NB, name assigned when atom created in eXist - so if not defined, not 
     1351        # in eXist 
     1352        logging.debug("Getting full path to atom") 
     1353        if self.atomName: 
     1354            logging.debug("Return full path to atom in eXist") 
     1355            return self.getDefaultCollectionPath() + self.atomName 
     1356        logging.debug("Atom doesn't currently exist in eXist - return 'None'") 
     1357        return None 
Note: See TracChangeset for help on using the changeset viewer.