Ignore:
Timestamp:
07/08/12 16:24:30 (9 years ago)
Author:
mnagni
Message:

Incomplete - # 22534: Add versiojn number to the gui page
 http://team.ceda.ac.uk/trac/ceda/ticket/22534
fixing some pylint issues
changing the versioning strategy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/cedaMoles/libs/migration/processor/deployment.py

    r8486 r8489  
    3737    hasMOSameHash, getAtomDocumentHashByMO, extractTitle,\ 
    3838        createCEDA_Result,\ 
    39     createEX_GeographicBoundingBox, extractGeographicExtentInMigrationDocument, findDownloadLinksInMigrationDocument,\ 
     39    createEX_GeographicBoundingBox, extractGeographicExtentInMigrationDocument, \ 
     40    findDownloadLinksInMigrationDocument,\ 
    4041    extractContent, createCI_Citation, createCI_Date, createDate,\ 
    4142    createTM_Position, createTM_Instant, extractMolesCreationDate,\ 
     
    4344    DO_UKSSDC, createMO_Organization,\ 
    4445    createCI_Contact, createCI_Address, createCI_OnlineResource,\ 
    45     createCI_Telephone, extractMolesTemporalRange, isoDateStringToTimeDate,\ 
    46     createTM_Period, findAccessLinksInMigrationDocument,\ 
     46    createCI_Telephone, extractMolesTemporalRange,\ 
     47    findAccessLinksInMigrationDocument,\ 
    4748    findLinksInDeployment, createMD_LegalConstraints,\ 
    4849    createDQ_Element, createDQ_ConformanceResult, findUpdatedDate,\ 
     
    5152    findLinksInMigrationDocument, findSubTypeInDPT, extractMolesPublishedDate,\ 
    5253    createMD_Keywords, hasMOBeenProcessed, createMO_Individual,\ 
    53     fromDateStringToPhenomenonTime, fromPhenomenonTimeToString,\ 
     54    fromDateStringToPhenomenonTime, \ 
    5455    comparePhenomenonTimes, compareGeographicBoundingBoxes 
    5556from cedaMoles.libs.epb import EPB 
    5657from cedaMoles.libs.migration.processor.deployment_data import DeploymentDataProcessor 
    57 from cedaMoles.libs.migration.exception.exceptions import NoDataLineage,\ 
     58from cedaMoles.libs.migration.exception.exceptions import NoDataLineage, \ 
    5859    NoAssociatedAuthor, NoAssociatedDeployments,\ 
    5960    NoGeographicalExtensionException 
     
    6263import logging 
    6364from datetime import date 
    64 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_onlinefunctioncode import CI_OnLineFunctionCode 
    65 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_datetypecode import CI_DateTypeCode 
    66 from ea_model.iso_19115_2006_metadata_corrigendum.constraint_information.md_restrictioncode import MD_RestrictionCode 
     65from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     66    citation_and_responsible_party_information.ci_onlinefunctioncode \ 
     67        import CI_OnLineFunctionCode 
     68from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     69    citation_and_responsible_party_information.ci_datetypecode \ 
     70        import CI_DateTypeCode 
     71from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     72    constraint_information.md_restrictioncode import MD_RestrictionCode 
    6773from copy import deepcopy 
    6874import datetime 
    6975from cedaMoles.MolesManager.ceda_guid import CedaGUID 
    70 from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_rolecode import CI_RoleCode 
    71 from ea_model.iso_19115_2006_metadata_corrigendum.maintenance_information.md_maintenancefrequencycode import MD_MaintenanceFrequencyCode 
    72 from ea_model.moles3_4.utilities.ceda_rolevalue import CEDA_RoleValue 
    73 from ea_model.moles3_4.observation.mo_observationpublicationstatevalue import MO_ObservationPublicationStateValue 
     76from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     77    citation_and_responsible_party_information.ci_rolecode import CI_RoleCode 
     78from ea_model.iso_19115_2006_metadata_corrigendum.\ 
     79    maintenance_information.md_maintenancefrequencycode \ 
     80        import MD_MaintenanceFrequencyCode 
    7481from cedaMoles.MolesManager.codelist import MM_RoleValue,\ 
    7582    MM_ObservationPublicationStateValue, getCLValue 
    76 from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
    77 from ea_model.ceda_metadatamodel.ceda_result.ceda_curationvalue import CEDA_CurationValue 
    78 from ea_model.ceda_metadatamodel.ceda_utilities.ceda_reviewstatusvalue import CEDA_ReviewStatusValue 
    79 from ea_model.ceda_metadatamodel.ceda_utilities.ceda_reviewfrequencyvalue import CEDA_ReviewFrequencyValue 
     83from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation \ 
     84    import CEDA_Observation 
     85from ea_model.ceda_metadatamodel.ceda_result.ceda_curationvalue \ 
     86    import CEDA_CurationValue 
     87from ea_model.ceda_metadatamodel.ceda_utilities.ceda_reviewstatusvalue \ 
     88    import CEDA_ReviewStatusValue 
     89from ea_model.ceda_metadatamodel.ceda_utilities.ceda_reviewfrequencyvalue \ 
     90    import CEDA_ReviewFrequencyValue 
    8091 
    8192MET_GEO_FEATURE = 'Meteorological geographical features' 
     
    91102    log.addHandler(StreamHandler()) 
    92103    log.setLevel(logging.INFO)     
    93     def __init__(self, dataEntityMigration, deploymentMigration, epbRepo): 
     104    def __init__(self, data_entity_migration, deployment_migration, epbRepo): 
    94105        ''' 
    95106            Initializes the class 
     
    98109            @param epbRepo: an instance of EPBRepo               
    99110        '''               
    100         self._dataEntityMigration = dataEntityMigration 
    101         self._deploymentMigration = deploymentMigration 
     111        self._data_entity_migration = data_entity_migration 
     112        self._deployment_migration = deployment_migration 
    102113        self.epbRepo = epbRepo 
    103         self._dataEntityHasSameHash = hasMOSameHash(self._dataEntityMigration) 
    104         self._deploymentHasSameHash = hasMOSameHash(self._deploymentMigration) 
    105         self._deploymentHasBeenProcessed = hasMOBeenProcessed(self._deploymentMigration) 
     114        self._dataEntityHasSameHash = hasMOSameHash(self._data_entity_migration) 
     115        self._deploymentHasSameHash = hasMOSameHash(self._deployment_migration) 
     116        self._deploymentHasBeenProcessed = hasMOBeenProcessed(self._deployment_migration) 
    106117        self._report = [] 
    107118 
     
    128139        try: 
    129140            if tmp_auth['author'] == 'unknown': 
    130                 doc_authors = findAuthorsInResource(self._dataEntityMigration) 
     141                doc_authors = findAuthorsInResource(self._data_entity_migration) 
    131142                tmp_auth = authors[doc_authors['authors']] 
    132143             
     
    143154            for item in tmp_auth['co_author_type']:            
    144155                if (tmp_auth['co_author'][tmp_auth['co_author_type'].index(item)] == 'unknown'): 
    145                     doc_authors = findAuthorsInResource(self._dataEntityMigration) 
     156                    doc_authors = findAuthorsInResource(self._data_entity_migration) 
    146157                    tmp_auth = authors[doc_authors['contributors']] 
    147158                    break 
     
    163174        
    164175    def updateObservation(self): 
    165         return EPB.searchOrCreate(CEDA_Observation, self._deploymentMigration.ceda_observation_id) 
     176        return EPB.searchOrCreate(CEDA_Observation, self._deployment_migration.ceda_observation_id) 
    166177 
    167178    def assignDOI(self, observation, doi): 
     
    201212            return 
    202213         
    203         provider_id = extractMolesProviderID(self._deploymentMigration) 
     214        provider_id = extractMolesProviderID(self._deployment_migration) 
    204215        i_keywords = [] 
    205216        if provider_id == DO_BADC: 
     
    218229            return 
    219230         
    220         data_lineage = findMolesLineage(self._dataEntityMigration) 
     231        data_lineage = findMolesLineage(self._data_entity_migration) 
    221232        if data_lineage is None: 
    222             raise NoDataLineage(self._dataEntityMigration) 
     233            raise NoDataLineage(self._data_entity_migration) 
    223234         
    224235        if data_lineage != observation.dataLineage: 
     
    230241 
    231242        i_sources = []                 
    232         download = findDownloadLinksInMigrationDocument(self._deploymentMigration) 
     243        download = findDownloadLinksInMigrationDocument(self._deployment_migration) 
    233244        content = None 
    234245        if len(download) == 0: 
    235             download = findDownloadLinksInMigrationDocument(self._dataEntityMigration) 
    236             content = extractContent(self._dataEntityMigration) 
     246            download = findDownloadLinksInMigrationDocument(self._data_entity_migration) 
     247            content = extractContent(self._data_entity_migration) 
    237248        else: 
    238             content = extractContent(self._deploymentMigration) 
     249            content = extractContent(self._deployment_migration) 
    239250        for dwn in download: 
    240251            int_description = None 
     
    249260                                                   description = int_description, applicationProfile = int_applicationProfile)) 
    250261             
    251         dataentity_id = '%s__ATOM__%s' % (self._dataEntityMigration.doc_owner, self._dataEntityMigration.doc_name) 
     262        dataentity_id = '%s__ATOM__%s' % (self._data_entity_migration.doc_owner, self._data_entity_migration.doc_name) 
    252263        dataentity_id = dataentity_id.replace('.atom', '')            
    253264        infodb_de = self.epbRepo.infodbEPB.getCedaInfoApp_dataentityByDE_ID(dataentity_id) 
     
    279290            return 
    280291            
    281         provider_id = extractMolesProviderID(self._deploymentMigration) 
     292        provider_id = extractMolesProviderID(self._deployment_migration) 
    282293        party = None 
    283294        if provider_id == DO_BADC: 
     
    322333            return 
    323334                 
    324         doc_quality = extractQuality(self._dataEntityMigration) 
    325         doc_date = findUpdatedDate(self._dataEntityMigration) 
     335        doc_quality = extractQuality(self._data_entity_migration) 
     336        doc_date = findUpdatedDate(self._data_entity_migration) 
    326337        ci_dates = []             
    327338        if doc_date: 
     
    345356            return 
    346357         
    347         description = extractSummary(self._deploymentMigration) 
     358        description = extractSummary(self._deployment_migration) 
    348359        if description is None: 
    349             description = extractSummary(self._dataEntityMigration) 
     360            description = extractSummary(self._data_entity_migration) 
    350361             
    351362        if description: 
     
    356367            return 
    357368                      
    358         doc_title = extractTitle(self._deploymentMigration) 
     369        doc_title = extractTitle(self._deployment_migration) 
    359370        if doc_title is None: 
    360             doc_title = extractTitle(self._dataEntityMigration) 
     371            doc_title = extractTitle(self._data_entity_migration) 
    361372         
    362373        if doc_title.startswith('deployment_') or doc_title.startswith('Deployment_'): 
    363             links = findLinksInMigrationDocument(self._deploymentMigration) 
     374            links = findLinksInMigrationDocument(self._deployment_migration) 
    364375            dptList = links['DPT'] 
    365376            if links.has_key('DPT'): 
     
    371382                        doc_title += ' and ' + dptList[-1] 
    372383                                                         
    373             links = findLinksInDeployment(self._deploymentMigration) 
     384            links = findLinksInDeployment(self._deployment_migration) 
    374385            if links.has_key('OBS'): 
    375386                obsList = [] 
    376387                for obs in links['OBS']: 
    377                     observationStation = self.epbRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, obs + '.atom') 
     388                    observationStation = self.epbRepo.migrationEPB.getDeploymentDataMigrationByName(self._deployment_migration, obs + '.atom') 
    378389                    obsList.append((extractTitle(observationStation), findSubTypeInDPT(observationStation))) 
    379390                 
     
    391402            if links.has_key('ACTIVITY'):              
    392403                for link in links['ACTIVITY']: 
    393                     activity = self.epbRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, link + '.atom')                     
     404                    activity = self.epbRepo.migrationEPB.getDeploymentDataMigrationByName(self._deployment_migration, link + '.atom')                     
    394405      
    395406                    projSubType = findSubTypeInDPT(activity) 
     
    414425            return   
    415426         
    416         ge = extractGeographicExtentInMigrationDocument(self._deploymentMigration)         
     427        ge = extractGeographicExtentInMigrationDocument(self._deployment_migration)         
    417428        if ge is None: 
    418             ge = extractGeographicExtentInMigrationDocument(self._dataEntityMigration) 
     429            ge = extractGeographicExtentInMigrationDocument(self._data_entity_migration) 
    419430         
    420431        if ge is None: 
    421             self._report.append(NoGeographicalExtensionException(self._deploymentMigration)) 
    422             self._report.append(NoGeographicalExtensionException(self._dataEntityMigration)) 
     432            self._report.append(NoGeographicalExtensionException(self._deployment_migration)) 
     433            self._report.append(NoGeographicalExtensionException(self._data_entity_migration)) 
    423434         
    424435        geographicExtent = createEX_GeographicBoundingBox(ge['east'], ge['north'], ge['west'], ge['south']) 
     
    434445            return   
    435446         
    436         creation_date = extractMolesPublishedDate(self._deploymentMigration) 
     447        creation_date = extractMolesPublishedDate(self._deployment_migration) 
    437448        if creation_date is None: 
    438             creation_date = extractMolesCreationDate(self._deploymentMigration) 
     449            creation_date = extractMolesCreationDate(self._deployment_migration) 
    439450        py_datetime = isoDateTimeStringToTimeDate(creation_date) 
    440451        date_time = createDateTime(py_datetime)     
     
    450461            return   
    451462               
    452         doc_phenomenon_time = extractMolesTemporalRange(self._deploymentMigration)  
     463        doc_phenomenon_time = extractMolesTemporalRange(self._deployment_migration)  
    453464        pt = fromDateStringToPhenomenonTime(doc_phenomenon_time)     
    454465         
     
    461472            return  
    462473         
    463         access_link = findAccessLinksInMigrationDocument(self._deploymentMigration) 
    464         dwn_link = findDownloadLinksInMigrationDocument(self._deploymentMigration) 
     474        access_link = findAccessLinksInMigrationDocument(self._deployment_migration) 
     475        dwn_link = findDownloadLinksInMigrationDocument(self._deployment_migration) 
    465476        if len(access_link) == 0: 
    466             access_link = findAccessLinksInMigrationDocument(self._dataEntityMigration)  
     477            access_link = findAccessLinksInMigrationDocument(self._data_entity_migration)  
    467478 
    468479        i_accessConstraints = [] 
     
    472483        if len(access_link) == 0: 
    473484            if len(dwn_link) == 0: 
    474                 dwn_link = findDownloadLinksInMigrationDocument(self._dataEntityMigration) 
     485                dwn_link = findDownloadLinksInMigrationDocument(self._data_entity_migration) 
    475486                if dwn_link and len(dwn_link) == 1:                 
    476487                    i_use_limitation.append("These data are open access and available through %s." % (dwn_link[0]['href']) ) 
     
    488499                                     
    489500        '''                                 
    490         contentDict = extractContent(self._deploymentMigration) 
     501        contentDict = extractContent(self._deployment_migration) 
    491502        if not contentDict.has_key('access-restricted'): 
    492             contentDict = extractContent(self._dataEntityMigration) 
     503            contentDict = extractContent(self._data_entity_migration) 
    493504        '''             
    494505 
     
    497508            return  
    498509                 
    499         i_code = 'http://badc.nerc.ac.uk/view/%s__ATOM__%s' % (self._deploymentMigration.doc_owner, self._deploymentMigration.doc_name) 
     510        i_code = 'http://badc.nerc.ac.uk/view/%s__ATOM__%s' % (self._deployment_migration.doc_owner, self._deployment_migration.doc_name) 
    500511        i_code = i_code.replace('.atom', '') 
    501         #i_code = buildExistDocPath(self._deploymentMigration.doc_status, DT_DEPLOYMENTS, self._deploymentMigration.doc_owner, self._deploymentMigration.doc_name) 
     512        #i_code = buildExistDocPath(self._deployment_migration.doc_status, DT_DEPLOYMENTS, self._deployment_migration.doc_owner, self._deployment_migration.doc_name) 
    502513        i_authority = createCI_Citation('moles2url') 
    503514        identifier = createMD_Identifier(code = i_code, authority = i_authority) 
     
    529540            return                       
    530541 
    531             updateFrequency = extractUpdateFrequency(self._dataEntityMigration) 
     542            updateFrequency = extractUpdateFrequency(self._data_entity_migration) 
    532543            if updateFrequency: 
    533544                resultAccumulation = MD_MaintenanceFrequencyCode.from_string(updateFrequency) 
     
    545556            return  
    546557         
    547         whereAreAuthors = self._deploymentMigration         
    548         doc_authors = findAuthorsInResource(self._deploymentMigration)         
     558        whereAreAuthors = self._deployment_migration         
     559        doc_authors = findAuthorsInResource(self._deployment_migration)         
    549560        if doc_authors['authors'] in [DO_BADC, DO_NEODC]: 
    550             doc_authors = findAuthorsInResource(self._dataEntityMigration) 
    551             whereAreAuthors = self._dataEntityMigration  
     561            doc_authors = findAuthorsInResource(self._data_entity_migration) 
     562            whereAreAuthors = self._data_entity_migration  
    552563                 
    553564        ind_names = [] 
     
    618629         
    619630        #Is a first time process? 
    620         if not hasMOBeenProcessed(self._deploymentMigration): 
     631        if not hasMOBeenProcessed(self._deployment_migration): 
    621632            ceda_observation.publicationState = getCLValue(MM_ObservationPublicationStateValue.cl_working)           
    622             docHash = getAtomDocumentHashByMO(self._dataEntityMigration) 
     633            docHash = getAtomDocumentHashByMO(self._data_entity_migration) 
    623634            self.epbRepo.moles3EPB.persistInstance(ceda_observation)         
    624             self.epbRepo.migrationEPB.updateMigrationObject(self._deploymentMigration, \ 
     635            self.epbRepo.migrationEPB.updateMigrationObject(self._deployment_migration, \ 
    625636                {'ceda_observation_id': ceda_observation.id, 
    626637                 'doc_hash': docHash})                 
     
    629640        if self.epbRepo.moles3EPB.retrieveGUIDFromInstance(ceda_observation) is None:        
    630641            ceda_guid = CedaGUID() 
    631             ceda_guid.id = calculateHash(self._deploymentMigration.depl_id) 
     642            ceda_guid.id = calculateHash(self._deployment_migration.depl_id) 
    632643            ceda_guid.ceda_observation = ceda_observation.id 
    633644            self.epbRepo.moles3EPB.persistInstance(ceda_guid) 
     
    635646 
    636647        if not self._deploymentHasBeenProcessed:                 
    637             deploymentDataProcessor = DeploymentDataProcessor(self._deploymentMigration, self.epbRepo)                 
     648            deploymentDataProcessor = DeploymentDataProcessor(self._deployment_migration, self.epbRepo)                 
    638649            procedure = deploymentDataProcessor.createProcess() 
    639650            project = deploymentDataProcessor.createProject()  
     
    650661        ceda_observation = None 
    651662        #Moles3 object exists...  
    652         if self._deploymentMigration.ceda_observation_id: 
    653             ceda_observation = self.epbRepo.moles3EPB.search(CEDA_Observation, self._deploymentMigration.ceda_observation_id) 
     663        if self._deployment_migration.ceda_observation_id: 
     664            ceda_observation = self.epbRepo.moles3EPB.search(CEDA_Observation, self._deployment_migration.ceda_observation_id) 
    654665        else: 
    655666            #... does not exist so create it 
Note: See TracChangeset for help on using the changeset viewer.