Changeset 8538


Ignore:
Timestamp:
17/08/12 14:10:49 (7 years ago)
Author:
mnagni
Message:

Incomplete - # 22528: Migration of FAtCat Open Search link for HPFeld
 http://team.ceda.ac.uk/trac/ceda/ticket/22528

Location:
mauRepo/MolesManager/trunk/cedaMoles
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/forms/date.py

    r8488 r8538  
    44@author: mnagni 
    55''' 
    6 from cedaMoles.MolesManager.forms.formsFactory import createFieldInstance 
     6from cedaMoles.MolesManager.forms.formsFactory import create_field_instance 
    77from django.forms.forms import Form 
    88from sqlalchemy.orm.properties import ColumnProperty, RelationshipProperty 
     
    6262            columns = getattr(clazz_property, 'columns') 
    6363            if len(columns) > 0: 
    64                 self._coreFields[clazz_property.key] = createFieldInstance(columns[0].type, clazz_property.key, instance)                     
     64                self._coreFields[clazz_property.key] = create_field_instance(columns[0].type, clazz_property.key, instance)                     
    6565  
    6666    def _manageRelationshipProperty(self, relationship_property, instance): 
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/forms/formsFactory.py

    r8488 r8538  
    55''' 
    66from django.db import models 
    7 from django.forms.fields import CharField, DecimalField, IntegerField,\ 
     7from django.forms.fields import CharField, DecimalField, IntegerField, \ 
    88    ChoiceField 
    99from ascore.asenumeration import EnumSymbol, ASEnumType 
     
    1414 
    1515 
    16 _fieldFactory = {  
     16_FIELD_FACTORY = {  
    1717       'Text': CharField, 
    1818       'TEXT': CharField, 
     
    2222     }     
    2323 
    24 def createASEnumField(clazz, **kwargs): 
     24def create_as_enumfield(clazz, **kwargs): 
    2525    sel = [] 
    2626    for attrName in clazz.enum.__dict__: 
     
    3333 
    3434 
    35 def getTypeName(clazz):     
     35def get_type_name(clazz):     
    3636    return type(clazz).__name__ 
    3737 
    38 def createField(name): 
    39     return _fieldFactory.get(name) 
     38def create_field(name): 
     39    return _FIELD_FACTORY.get(name) 
    4040 
    41 def _extractValue(self, property_name, instance): 
     41def _extract_value(self, property_name, instance): 
    4242    kwargs = {} 
    4343    if self._instance: 
     
    4646    return kwargs  
    4747 
    48 def createFieldInstance(clazz, fieldName, iinstance): 
    49     name = getTypeName(clazz) 
     48def create_field_instance(clazz, fieldName, iinstance): 
     49    name = get_type_name(clazz) 
    5050    if (name == 'ASEnumType'): 
    51         return createASEnumField(clazz) 
     51        return create_as_enumfield(clazz) 
    5252    elif (name == 'ARRAY'): 
    53         return formset_factory(createField(getTypeName(clazz.item_type)))     
    54     elif _fieldFactory.has_key(name): 
    55         kwargs = _extractValue(fieldName, iinstance) 
    56         return createField(name)(**kwargs) 
     53        return formset_factory(create_field(get_type_name(clazz.item_type)))     
     54    elif _FIELD_FACTORY.has_key(name): 
     55        kwargs = _extract_value(fieldName, iinstance) 
     56        return create_field(name)(**kwargs) 
    5757 
    58 def createField_(field, kwargs = None): 
     58def create_field_(field, kwargs = None): 
    5959    if not kwargs: 
    6060        return field() 
     
    6363 
    6464def extractInteger(column, kwargs = None): 
    65     return createField_(IntegerField, kwargs) 
     65    return create_field_(IntegerField, kwargs) 
    6666     
    67 def extractChar(column, kwargs = None): 
    68     return createField_(CharField, kwargs)       
     67def extract_char(column, kwargs = None): 
     68    return create_field_(CharField, kwargs)       
    6969 
    70 def extractEnum(column, kwargs = None): 
     70def extract_enum(column, kwargs = None): 
    7171    if not kwargs: 
    7272        kwargs = {} 
    7373    kwargs['choices'] = [(value, value) for value in column.enums] 
    74     return createField_(ChoiceField, kwargs) #ChoiceField(choices=values) 
     74    return create_field_(ChoiceField, kwargs) #ChoiceField(choices=values) 
    7575     
    7676def convertColumnToFormField(columnToConvert): 
     
    8989        formField = extractInteger(column) 
    9090    elif (issubclass(ctype, ASEnumType)): 
    91         formField = extractEnum(column.type.impl)                 
     91        formField = extract_enum(column.type.impl)                 
    9292    elif (issubclass(ctype, String)): 
    9393        if (issubclass(ctype, Enum)): 
    94             formField = extractEnum(column) 
     94            formField = extract_enum(column) 
    9595        else: 
    96             formField = extractChar(column) 
     96            formField = extract_char(column) 
    9797    if not formField: 
    98         print "Have not way to convert %s type" % (getTypeName(column.type)) 
     98        print "Have not way to convert %s type" % (get_type_name(column.type)) 
    9999        return None 
    100100         
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/moles3epb.py

    r8537 r8538  
    6969         
    7070    def _associate_ceda_guid(self): 
    71         guid_table = Table('ceda_guid', self._db_manager.metadata, \ 
    72                            Column('id', String, primary_key=True), \ 
    73                            Column('ceda_observationcollection', \ 
     71        guid_table = Table('ceda_guid', self._db_manager.metadata,  
     72                           Column('id', String, primary_key=True),  
     73                           Column('ceda_observationcollection',  
    7474                                  Integer, ForeignKey('ceda_observationcollection.id')),  
    75                            Column('ceda_observation', \ 
     75                           Column('ceda_observation',  
    7676                                  Integer, ForeignKey('ceda_observation.id')), 
    77                            Column('ceda_project', \ 
     77                           Column('ceda_project',  
    7878                                  Integer, ForeignKey('ceda_project.id'))) 
    7979        mapper(CedaGUID, guid_table) 
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/views/cedaObservationView.py

    r8536 r8538  
    3131@author: mnagni 
    3232''' 
    33 from django.shortcuts import render_to_response 
    34 from django.core.context_processors import csrf 
    3533from cedaMoles.MolesManager.djencoder import encodeToJSON 
    3634from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
     
    6664 
    6765def _getCedaObservation(request, obs_id):     
    68     eagerloadthese = ['identifier.authority', 'resultTime.position.dateTime8601.month', \ 
    69                       'resultAccumulation', 'relatedParty.party', \ 
    70                       'result.source.function', 'permission', \ 
    71                       'geographicExtent', 'phenomenonTime.*', 'keywords', 'description', \ 
     66    eagerloadthese = ['identifier.authority', 'resultTime.position.dateTime8601.month',  
     67                      'resultAccumulation', 'relatedParty.party',  
     68                      'result.source.function', 'permission',  
     69                      'geographicExtent', 'phenomenonTime.*', 'keywords', 'description',  
    7270                      'inSupportOf.abstract', 'dataLineage'] 
    7371    return request.moles3EPB.searchSelectiveLoad(CEDA_Observation, obs_id, eagerloadthese) 
  • mauRepo/MolesManager/trunk/cedaMoles/libs/migration/MigrationEPB.py

    r8513 r8538  
    44@author: mnagni 
    55''' 
    6 from cedaMoles.libs.migration.db.classes import DeploymentDataMigration, DataEntityMigration,\ 
    7     DeploymentsMigration, MigrationObject 
     6from cedaMoles.libs.migration.db.classes import DeploymentDataMigration, \ 
     7    DataEntityMigration, DeploymentsMigration 
    88from sqlalchemy.sql.expression import asc 
    99from cedaMoles.libs.epb import EPB 
     
    4242        return self._session.query(mo_type).filter(*[EPB.buildFilter('doc_name', doc_name)]).first() 
    4343 
    44     def _getMigrationObjectByName(self, mo_type, migrationObject, doc_name): 
    45         return self._getMigrationObject(mo_type, migrationObject.doc_status, migrationObject.doc_owner, doc_name)              
     44    def _getMigrationObjectByName(self, mo_type, migration_object, doc_name): 
     45        return self._getMigrationObject(mo_type, migration_object.doc_status, migration_object.doc_owner, doc_name)              
    4646 
    47     def getDeploymentsMigrationByName(self, migrationObject, doc_name): 
    48         if migrationObject is None: 
     47    def get_deployment_data_migration_by_name(self, migration_object, doc_name): 
     48        if migration_object is None: 
    4949            raise Exception("migrationObject is None") 
    50         return self._getMigrationObjectByName(DeploymentsMigration, migrationObject, doc_name)         
     50        return self._getMigrationObjectByName(DeploymentDataMigration, migration_object, doc_name) 
    5151 
    52     def getDeploymentDataMigrationByName(self, migrationObject, doc_name): 
    53         if migrationObject is None: 
    54             raise Exception("migrationObject is None") 
    55         return self._getMigrationObjectByName(DeploymentDataMigration, migrationObject, doc_name) 
    56  
    57     def getDataEntityMigrationbyPath(self, migrationObject): 
     52    def getDataEntityMigrationbyPath(self, migration_object): 
    5853        """ 
    5954            Returns the DataEntityMigration associated with the given path 
    60             @param migrationObject: the migration object to look for. If None returns all the DataEntityMigration items 
     55            @param migration_object: the migration object to look for. If None returns all the DataEntityMigration items 
    6156        """ 
    6257        ret = [] 
    63         if migrationObject: 
    64             ret.append(self._session.query(DataEntityMigration).filter(*[EPB.buildFilter('doc_name', migrationObject.doc_name)]).first())                
     58        if migration_object: 
     59            ret.append(self._session.query(DataEntityMigration).filter(*[EPB.buildFilter('doc_name', migration_object.doc_name)]).first())                
    6560        else: #then process all the DataEntities 
    6661            res = self._session.query(DataEntityMigration).all() 
  • mauRepo/MolesManager/trunk/cedaMoles/libs/migration/processor/deployment.py

    r8522 r8538  
    461461                obsList = [] 
    462462                for obs in links['OBS']: 
    463                     observationStation = self.epbRepo.migrationEPB.getDeploymentDataMigrationByName(self._deployment_migration, obs + '.atom') 
     463                    observationStation = self.epbRepo.migrationEPB.get_deployment_data_migration_by_name(self._deployment_migration, obs + '.atom') 
    464464                    obsList.append((extract_title(observationStation), find_subtype_in_dpt(observationStation))) 
    465465                 
     
    477477            if links.has_key('ACTIVITY'):              
    478478                for link in links['ACTIVITY']: 
    479                     activity = self.epbRepo.migrationEPB.getDeploymentDataMigrationByName(self._deployment_migration, link + '.atom')                     
     479                    activity = self.epbRepo.migrationEPB.get_deployment_data_migration_by_name(self._deployment_migration, link + '.atom')                     
    480480      
    481481                    projSubType = find_subtype_in_dpt(activity) 
  • mauRepo/MolesManager/trunk/cedaMoles/libs/migration/processor/deployment_data.py

    r8496 r8538  
    3131@author: Maurizio Nagni 
    3232''' 
    33 from cedaMoles.libs.migration.processor.commons import find_subtype_in_dpt,\ 
    34     create_ceda_processing, create_ceda_instrument, create_ceda_project,\ 
    35     find_summary, find_documentation_in_migration_document, create_ci_citation,\ 
    36     create_mo_online_resource, find_links_in_deployment, has_mo_been_processed,\ 
     33from cedaMoles.libs.migration.processor.commons import find_subtype_in_dpt, \ 
     34    create_ceda_processing, create_ceda_instrument, create_ceda_project, \ 
     35    find_summary, find_documentation_in_migration_document, create_ci_citation, \ 
     36    create_mo_online_resource, find_links_in_deployment, has_mo_been_processed, \ 
    3737    get_atom_document_hash_by_mo, calculate_hash, has_mo_same_hash 
    38 from ea_model.moles3_4.utilities.ceda_publicationstatevalue import CEDA_PublicationStateValue 
     38from ea_model.moles3_4.utilities.ceda_publicationstatevalue \ 
     39    import CEDA_PublicationStateValue 
    3940from cedaMoles.MolesManager.codelist import getCLValue 
    4041from cedaMoles.MolesManager.ceda_guid import CedaGUID 
     
    5657        self._links = find_links_in_deployment(self._deploymentMigration) 
    5758         
    58     def _commitDeploymentMigration(self, associateWithCedaObservation, dataProductionTool, dataProductionToolField): 
     59    def _commitDeploymentMigration(self, associateWithCedaObservation, \ 
     60                                   dataProductionTool, dataProductionToolField): 
    5961        self.epbRepo.moles3EPB.persistInstance(associateWithCedaObservation) 
    60         self.epbRepo.migrationEPB.updateMigrationObject(dataProductionTool, {dataProductionToolField: associateWithCedaObservation.id}) 
     62        self.epbRepo.migrationEPB.\ 
     63            updateMigrationObject(dataProductionTool, \ 
     64                            {dataProductionToolField: associateWithCedaObservation.id}) 
    6165                                    
    6266    def _createProject(self, activity):         
     
    6872            i_documentation = create_ci_citation("Documentation resource") 
    6973            i_resource = create_mo_online_resource(doc_link[0]['href']) 
    70         project = create_ceda_project(abstract=i_abstract, publication_state=getCLValue(CEDA_PublicationStateValue.cl_working), \ 
    71                                      documentation=i_documentation, project_resource=i_resource) 
     74        project = create_ceda_project(abstract=i_abstract, \ 
     75                    publication_state=getCLValue(CEDA_PublicationStateValue.cl_working), \ 
     76                    documentation=i_documentation, project_resource=i_resource) 
    7277        self._commitDeploymentMigration(project, activity, 'ceda_project_id') 
    7378        return project 
     
    7782        if self._links.has_key('ACTIVITY'): 
    7883            for link in self._links['ACTIVITY']: 
    79                 activity = self.epbRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, link + '.atom') 
     84                activity = self.epbRepo.migrationEPB.\ 
     85                    get_deployment_data_migration_by_name(self._deploymentMigration, \ 
     86                                                     link + '.atom') 
    8087                deploymentDataHasSameHash = has_mo_same_hash(activity)     
    8188                deploymentDataHasBeenProcessed = has_mo_been_processed(activity)                
     
    8390                    if activity.ceda_project_id is not None: 
    8491                        #obsColl = self.epbRepo.moles3EPB.search(CEDA_ObservationCollection, self._dataEntityMigration.ceda_observation_coll_id)  
    85                         project = self.epbRepo.moles3EPB.search(CEDA_Project, activity.ceda_project_id) 
     92                        project = self.epbRepo.moles3EPB.search(CEDA_Project,  
     93                                                                activity.ceda_project_id) 
    8694                    else: 
    8795                        project = self._createProject(activity) 
     
    120128        hasCedaAcquisition = False 
    121129        for dpt in self._links['DPT']: 
    122             dataProductionTool = self.epbRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, dpt + '.atom') 
     130            dataProductionTool = self.epbRepo.migrationEPB.\ 
     131                get_deployment_data_migration_by_name(self._deploymentMigration, \ 
     132                                                      dpt + '.atom') 
    123133             
    124134            #has the document changed?             
     
    134144                if dataProductionTool.ceda_processing_id is None: 
    135145                    associateWithCedaObservation = create_ceda_processing() 
    136                     self._commitDeploymentMigration(associateWithCedaObservation, dataProductionTool, 'ceda_processing_id') 
     146                    self._commitDeploymentMigration(associateWithCedaObservation,  
     147                                                    dataProductionTool,  
     148                                                    'ceda_processing_id') 
    137149                    if not (hasCedaComposite or hasCedaProcessing): 
    138150                        hasCedaProcessing = True 
     
    154166        #if not a DPT.subType == 'model' then.... 
    155167        for obs in self._links['OBS']: 
    156             observationStation = self.epbRepo.migrationEPB.getDeploymentDataMigrationByName(self._deploymentMigration, obs + '.atom') 
     168            observationStation = self.epbRepo.migrationEPB.get_deployment_data_migration_by_name(self._deploymentMigration, obs + '.atom') 
    157169  
    158170            #has the document changed?             
  • mauRepo/MolesManager/trunk/cedaMoles/libs/migration/processor/loadResources.py

    r8496 r8538  
    3131@author: Maurizio Nagni 
    3232''' 
    33 from cedaMoles.libs.migration.processor.commons import DOC_STATUS, get_collection_refs,\ 
    34     find_moles_creation_date, find_id, stringToTimestamp, build_exist_type_path,\ 
    35     build_exist_doc_path, DT_DATA_ENTITIES, DT_DEPLOYMENTS, DT_DEPLOYMENT_DATA,\ 
     33from cedaMoles.libs.migration.processor.commons import DOC_STATUS, get_collection_refs, \ 
     34    find_moles_creation_date, find_id, stringToTimestamp, build_exist_type_path, \ 
     35    build_exist_doc_path, DT_DATA_ENTITIES, DT_DEPLOYMENTS, DT_DEPLOYMENT_DATA, \ 
    3636    get_owner_refs, get_atom_document_as_elementtree 
    3737from cedaMoles.libs.migration.exception.exceptions import NoCreationDate, NoDocumentID 
    38 from cedaMoles.libs.migration.db.classes import DeploymentDataMigration,\ 
     38from cedaMoles.libs.migration.db.classes import DeploymentDataMigration, \ 
    3939    DeploymentsMigration, DataEntityMigration 
    4040 
  • mauRepo/MolesManager/trunk/cedaMoles/tests/migration/test_utils.py

    r8496 r8538  
    44@author: mnagni 
    55''' 
    6 from ea_model.ceda_metadatamodel.ceda_observationcollection.ceda_observationcollection import CEDA_ObservationCollection 
    7 from cedaMoles.libs.migration.processor.commons import create_ci_citation,\ 
     6from ea_model.ceda_metadatamodel.ceda_observationcollection.ceda_observationcollection \ 
     7        import CEDA_ObservationCollection 
     8from cedaMoles.libs.migration.processor.commons import create_ci_citation, \ 
    89    create_md_identifier 
    910from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
     
    1617        oc.identifier[0].authority.title = 'test_title' 
    1718    ''' 
    18     observationCollection = CEDA_ObservationCollection() 
     19    observation_collection = CEDA_ObservationCollection() 
    1920    auth = create_ci_citation('test_title') 
    2021    i_identifier = create_md_identifier(code = 'test_code', authority=auth) 
    21     observationCollection.identifier.append(i_identifier)       
    22     return observationCollection 
     22    observation_collection.identifier.append(i_identifier)       
     23    return observation_collection 
    2324 
    2425def createObservation(): 
  • mauRepo/MolesManager/trunk/cedaMoles/tests/moles2gui/ceda/observation.py

    r8517 r8538  
    3333import unittest 
    3434from json import loads, dumps 
    35 from cedaMoles.MolesManager.views.moles2gui import encodeCedaMoles2Json,\ 
     35from cedaMoles.MolesManager.views.moles2gui import encodeCedaMoles2Json, \ 
    3636    decodeJson2CedaMoles, getData 
    3737from cedaMoles.tests.moles2gui.creationFactory import assembleObservation 
  • mauRepo/MolesManager/trunk/cedaMoles/tests/moles2gui/om/instant.py

    r8510 r8538  
    3333import unittest 
    3434from json import loads, dumps 
    35 from cedaMoles.MolesManager.views.moles2gui import encodeCedaMoles2Json,\ 
     35from cedaMoles.MolesManager.views.moles2gui import encodeCedaMoles2Json, \ 
    3636    decodeJson2CedaMoles, getData 
    3737from cedaMoles.tests.moles2gui.creationFactory import assembleTM_Instant 
Note: See TracChangeset for help on using the changeset viewer.