Changeset 4935 for ndgCommon/trunk/ndg/common/src
- Timestamp:
- 10/02/09 17:38:55 (12 years ago)
- Location:
- ndgCommon/trunk/ndg/common/src/models
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
ndgCommon/trunk/ndg/common/src/models/Atom.py
r4842 r4935 7 7 from xml.etree import cElementTree as ET 8 8 import csml.parser as CsmlParser 9 from ndg.common.src.clients.xmldb.eXist.eXistConnector import eXistConnector 9 import ndg.common.src.clients.xmldb.eXist.dbconstants as dc 10 10 from ndg.common.src.lib.ETxmlView import et2text 11 11 import ndg.common.src.lib.utilities as utilities … … 410 410 ''' 411 411 logging.debug("Getting collection path for atom publication state") 412 collectionPath = eXistConnector.BASE_COLLECTION_PATH + self.state.collectionPath412 collectionPath = dc.ATOM_COLLECTION_PATH + self.state.collectionPath 413 413 logging.debug("Returning publication state collection, '%s'" %collectionPath) 414 414 return collectionPath … … 424 424 425 425 if self.atomTypeID == VTD.DE_TERM: 426 collectionPath += eXistConnector.DE_COLLECTION_PATH426 collectionPath += dc.DE_COLLECTION_PATH 427 427 elif self.atomTypeID == VTD.GRANULE_TERM: 428 collectionPath += eXistConnector.GRANULE_COLLECTION_PATH428 collectionPath += dc.GRANULE_COLLECTION_PATH 429 429 elif self.atomTypeID == VTD.ACTIVITY_TERM and \ 430 430 self.subtypeID == VTD.DEPLOYMENT_TERM: 431 collectionPath += eXistConnector.DEPLOYMENTS_COLLECTION_PATH431 collectionPath += dc.DEPLOYMENTS_COLLECTION_PATH 432 432 else: 433 collectionPath += eXistConnector.DEPLOYMENT_COLLECTION_PATH433 collectionPath += dc.DEPLOYMENT_COLLECTION_PATH 434 434 435 435 logging.debug("Returning entity collection, '%s'" %collectionPath) … … 1230 1230 1231 1231 1232 def lookupAssociatedData(self, type, dr, lookupIndirectReferences=False):1232 def lookupAssociatedData(self, type, searchClient, lookupIndirectReferences=False): 1233 1233 ''' 1234 1234 Check through the atom links and retrieve any associated data of the … … 1236 1236 @param type: type of associated data to lookup - currently VTD.DEPLOYMENT_TERM 1237 1237 or VTD.DE_TERM 1238 @param dr: Instance of DocumentRetrieve object - NB, this requires eXist 1239 config details which are not available to the Atom object 1238 @param searchClient: Client implementing the AbstractSearchXMLDBClient class 1240 1239 @keyword lookupIndirectReferences: if True, the atom ID is used to search 1241 1240 defined deployments to find those which reference it, otherwise only … … 1263 1262 # deployments info looked up first 1264 1263 if type == VTD.DE_TERM and self.isDeployable() and not self.deployments: 1265 self.lookupAssociatedData(VTD.DEPLOYMENT_TERM, dr, lookupIndirectReferences) 1264 self.lookupAssociatedData(VTD.DEPLOYMENT_TERM, searchClient, 1265 lookupIndirectReferences = lookupIndirectReferences) 1266 1266 1267 1267 logging.info("Looking up references to this atom from other %s" %type) … … 1279 1279 links = [] 1280 1280 for url in urls: 1281 doc = dr.get(type, dr.ATOM_TYPE, url, \1282 targetCollection = eXistConnector.BASE_COLLECTION_PATH)1281 doc = searchClient.getNDGDoc(type, ndgObject.ASSOCIATED_ATOM_DOC_TYPE, url, 1282 targetCollection = dc.ATOM_COLLECTION_PATH) 1283 1283 # now need to turn this results set into actual atoms 1284 1284 tree = ET.fromstring(doc) … … 1301 1301 else: 1302 1302 localID = link.href.split("__ATOM__")[-1] 1303 deploymentAtom = dr.get(self.ME.providerID, 'ATOM', localID, \ 1304 targetCollection = eXistConnector.BASE_COLLECTION_PATH) 1303 deploymentAtom = searchClient.getNDGDoc(self.ME.providerID, 1304 'ATOM', localID, 1305 targetCollection = dc.ATOM_COLLECTION_PATH) 1305 1306 1306 1307 deployment = Deployment.Deployment(Atom(xmlString=str(deploymentAtom))) -
ndgCommon/trunk/ndg/common/src/models/AtomState.py
r4793 r4935 5 5 ''' 6 6 import logging 7 from ndg.common.src.clients.xmldb.eXist.eXistConnector import eXistConnector as ec7 import ndg.common.src.clients.xmldb.eXist.dbconstants as dc 8 8 9 9 # flags to specify published state of atom … … 61 61 return False 62 62 63 OLD_STATE = AtomState(OLD_STATE_FLAG, 'Old', ec.OLD_COLLECTION_PATH)64 WORKING_STATE = AtomState(WORKING_STATE_FLAG, 'Working', ec.WORKING_COLLECTION_PATH)63 OLD_STATE = AtomState(OLD_STATE_FLAG, 'Old', dc.OLD_COLLECTION_PATH) 64 WORKING_STATE = AtomState(WORKING_STATE_FLAG, 'Working', dc.WORKING_COLLECTION_PATH) 65 65 SMALL_P_PUBLISHED_STATE = AtomState(SMALL_P_PUBLISHED_STATE_FLAG, 'published', 66 ec.SMALL_P_PUBLISHED_COLLECTION_PATH)66 dc.SMALL_P_PUBLISHED_COLLECTION_PATH) 67 67 PUBLISHED_STATE = AtomState(PUBLISHED_STATE_FLAG, 'Published', 68 ec.PUBLISHED_COLLECTION_PATH)68 dc.PUBLISHED_COLLECTION_PATH) -
ndgCommon/trunk/ndg/common/src/models/Deployment.py
r4837 r4935 51 51 else: 52 52 logging.debug("Not a valid deployment type (%s) - ignoring" \ 53 %deploymentLink. vocabUrl)53 %deploymentLink.rel) 54 54 return 55 55 -
ndgCommon/trunk/ndg/common/src/models/ndgObject.py
r4793 r4935 5 5 (2) a printable xml representation 6 6 ''' 7 from ndg.common.src.lib import xmlHandler28 7 import logging 9 8 … … 26 25 ATOM_DOC_TYPE = 'ATOM' 27 26 ATOM_BACKUP_DOC_TYPE = 'ATOM-BACKUP' 27 # NB, this is used to look up associated atoms - e.g. when the type is Deployment, 28 # the lookup will return all deployment data atoms listed in the deployment 29 ASSOCIATED_ATOM_DOC_TYPE = 'ASSOCIATED-ATOM' 28 30 29 31 # NB, DIF records are stored in local eXist DB to allow feeds to serve them … … 46 48 NUMSIM_DOC_TYPE, ATOM_DOC_TYPE, \ 47 49 ATOM_BACKUP_DOC_TYPE, BROWSE_DIF_DOC_TYPE] 50 51 discoveryURL = None 52 baseURL = None 53 xmlURL = None 54 printableURL = None 55 useDiscoveryService = 1 56 BURL=None 48 57 49 def __init__(self,uri,config=None): 50 ''' Parse the uri and prepare for obtaining the actual content''' 58 def __init__(self, uri, config=None): 59 ''' 60 Parse the uri and prepare for obtaining the actual content 61 @param uri: ndgURI to set up object with 62 @keyword config: config object to use for retrieving the underlying doc 63 ''' 51 64 logging.debug("Initialising ndgObject with uri: '%s'" %uri) 52 65 #Dom had problem with unicode coming in here ... dunno why @@@@ … … 89 102 self.setConfig(config) 90 103 91 def setDefaultProperties(self): 92 ''' 93 Set default properties for object 94 ''' 95 self.discoveryURL,self.baseURL,self.xmlURL,\ 96 self.printableURL =None,None,None,None 97 self.useDiscoveryService = 1 98 self.BURL=None 99 100 104 101 105 def setConfig(self, config): 102 106 ''' … … 105 109 logging.debug("Setting up configuration for retrieving document") 106 110 self.config=config 107 if config is None: 108 self.setDefaultProperties() 111 if not config: 109 112 return 113 110 114 111 115 self.server=self.config.get('DISCOVERY','default') … … 122 126 logging.info("Default discovery format set to: %s" %fmt) 123 127 124 self.BURL=None125 128 # We'll build the following even if it can't be used (as would be the case for 126 129 # a non data entity B record or an A record) because it's a useful template. … … 159 162 #currently we don't know how to get this one 160 163 self.URL='unknown' 161 self. setDefaultProperties()164 self.discoveryURL = None 162 165 163 166 logging.debug("Set up URL: '%s', discoveryURL: '%s'" %(self.URL, self.discoveryURL)) … … 187 190 return None 188 191 from ndg.common.src.dal.ndgRetrieve import ndgRetrieve 189 status,xmlh = ndgRetrieve(self, self.config, \190 192 status,xmlh = ndgRetrieve(self, self.config, 193 discovery = self.useDiscoveryService) 191 194 if status: 192 x=xmlHandler2.xmlHandler(xmlh,string=1) 193 return x.xmls 195 return xmlh 194 196 else: 195 197 return status
Note: See TracChangeset
for help on using the changeset viewer.