Changeset 2553 for TI07-MOLES


Ignore:
Timestamp:
07/06/07 13:52:30 (11 years ago)
Author:
ko23
Message:

Update of ndg_xqueries.py to include time-out capability

Location:
TI07-MOLES/trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • TI07-MOLES/trunk/DIF/XQuery/NDG-DIF.xquery

    r2464 r2553  
    1313declare variable $localIdentifier as xs:string {'dataent_chablis'}; 
    1414 
    15 for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     15let $DE := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    1616        exists('moles:dgDataEntity')  
    17         and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0'  
    1817        and moles:dgMetadataID/moles:repositoryIdentifier=$repositoryIdentifier 
    1918        and moles:dgMetadataID/moles:localIdentifier=$localIdentifier] 
     
    2625            for $DataCreatorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCreator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''][1] 
    2726                return  
    28                     for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/*[(moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' 
    29                                and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/*/moles:repositoryIdentifier 
    30                                and moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/*/moles:localIdentifier)] 
     27                    for $DataCreatorRoleHolder in collection($targetCollection)/moles:dgMetadata/*[( 
     28                               moles:dgMetadataID/moles:localIdentifier=$DataCreatorRole/*/moles:repositoryIdentifier 
     29                               and moles:dgMetadataID/moles:repositoryIdentifier=$DataCreatorRole/*/moles:localIdentifier)] 
    3130                        return  
    3231                            element Dataset_Creator { 
     
    4342                    element Parameters { 
    4443                        element Category {string($StructuredKeyword/*/moles:dgValidTerm)}, 
    45                         if (exists($StructuredKeyword//moles:dgValidSubterm)  
    46                                 and $StructuredKeyword//moles:dgValidSubterm != ''  
    47                                 and $StructuredKeyword//moles:dgValidSubterm != ' ') then  
     44                        if (exists($StructuredKeyword/*/moles:dgValidSubterm)  
     45                                and $StructuredKeyword/*/moles:dgValidSubterm != ''  
     46                                and $StructuredKeyword/*/moles:dgValidSubterm != ' ') then  
    4847                        for $Subterm in $StructuredKeyword//moles:dgValidSubterm[exists(moles:dgValidTerm)] 
    4948                            where exists($Subterm/moles:dgValidSubterm) 
     
    5453                                        else if ($Subterm/moles:ListLevel=3) then element Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
    5554                                        else if ($Subterm/moles:ListLevel=4) then element Detailed_Variable {string($Subterm/moles:dgValidSubterm/moles:dgValidTerm)}  
    56                                         else element GCMD_Science_Valid {$Subterm/moles:ListLevel,($Subterm/moles:dgValidSubterm/moles:dgValidTerm)} 
     55                                        else element GCMD_Science_Valid {data($Subterm/moles:dgValidSubterm/moles:dgValidTerm)} 
    5756                        else() 
    5857                    } 
    5958                else(), 
    60         for $StructuredKeyword in ($DE//(moles:dgStructuredKeyword | moles:dgDataEntity/moles:dgDataSummary/moles:dgParameterSummary/moles:dgStdParameterMeasured)[voclib:spot-vocab($voclib:gcmd_science_valids, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_correct, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_deprecated, moles:dgValidTermID/moles:ParentListID) and (not(exists(moles:ListLevel)) or moles:ListLevel=0)]) 
     59        for $StructuredKeyword in ($DE/(moles:dgStructuredKeyword | moles:dgDataEntity/moles:dgDataSummary/moles:dgParameterSummary/moles:dgStdParameterMeasured)[voclib:spot-vocab($voclib:gcmd_science_valids, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_correct, moles:dgValidTermID/moles:ParentListID) or voclib:spot-vocab($voclib:gcmd_science_valids_deprecated, moles:dgValidTermID/moles:ParentListID) and (not(exists(moles:ListLevel)) or moles:ListLevel=0)]) 
    6160        return 
    6261                element Parameters {data($StructuredKeyword/moles:dgValidTerm)}, 
     
    6463            return  
    6564                element ISO_Topic_Category {string($ISOTopicCategory/moles:dgValidTerm)}, 
    66         for $Keyword in distinct-values($DE//moles:dgStructuredKeyword[ 
     65        for $Keyword in distinct-values($DE/moles:dgStructuredKeyword[ 
    6766        not (voclib:spot-vocab($voclib:iso_topic_list, moles:dgValidTermID/moles:ParentListID) 
    6867        or voclib:spot-vocab($voclib:gcmd_science_valids, moles:dgValidTermID/moles:ParentListID) 
    6968        or voclib:spot-vocab($voclib:gcmd_science_valids_correct, moles:dgValidTermID/moles:ParentListID) 
     69        or voclib:spot-vocab($voclib:iso_topic_list, moles:dgValidTermID/moles:ParentListID) 
    7070        )]/moles:dgValidTerm) 
    7171        return element Keyword {string($Keyword)},  
    72         for $DepDPT in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID 
    73         return  
    74             element Sensor_Name { 
    75                 for $DepDPTAbbrev in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPT/moles:repositoryIdentifier and moles:localIdentifier=$DepDPT/moles:localIdentifier]]/moles:abbreviation)) 
    76                     return element Short_Name {data($DepDPTAbbrev)}, 
    77                 for $DepDPTName in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPT/moles:repositoryIdentifier and moles:localIdentifier=$DepDPT/moles:localIdentifier]]/moles:name)) 
    78                     return element Long_Name {data($DepDPTName)} 
     72        for $DepDPTRepository in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID/moles:repositoryIdentifier 
     73        for $DepDPTLocal in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID[moles:repositoryIdentifier=$DepDPTRepository]/moles:localIdentifier)  
     74        let $DepDPTRecord := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepDPTRepository  and moles:localIdentifier=$DepDPTLocal]] 
     75                    return 
     76                            element Sensor_Name { 
     77                    element Short_Name {data($DepDPTRecord/moles:abbreviation)}, 
     78                    element Long_Name {data($DepDPTRecord/moles:name)} 
    7979                }, 
    80         for $DepObsStn in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID) 
    81         return  
    82             element Source_Name { 
    83                 for $DepObsStnAbbrev in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepObsStn/moles:repositoryIdentifier and moles:localIdentifier=$DepObsStn/moles:localIdentifier]]/moles:abbreviation)) 
    84                     return element Short_Name {data($DepObsStnAbbrev)}, 
    85                 for $DepObsStnName in ((collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepObsStn/moles:repositoryIdentifier and moles:localIdentifier=$DepObsStn/moles:localIdentifier]]/moles:name)) 
    86                     return element Long_Name {data($DepObsStnName)} 
     80        for $DepObsStnRepository in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID/moles:repositoryIdentifier) 
     81        for $DepObsStnLocal in distinct-values(($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID[moles:repositoryIdentifier=$DepObsStnRepository]/moles:localIdentifier)) 
     82        let $DepObsStnRecord := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:repositoryIdentifier=$DepObsStnRepository  and moles:localIdentifier=$DepObsStnLocal]] 
     83                    return element Source_Name { 
     84                    element Short_Name {data($DepObsStnRecord/moles:abbreviation)}, 
     85                    element Long_Name {data($DepObsStnRecord/moles:name)} 
    8786                }, 
    88         for $TemporalRange in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:DateRange) 
     87        for $TemporalRange in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage/moles:dgTemporalCoverage/moles:DateRange) 
    8988                return  
    9089                    element Temporal_Coverage 
     
    9392                        element End_Date {data($TemporalRange/moles:DateRangeEnd)} 
    9493                        }, 
    95         for $TemporalTerm in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea[voclib:spot-vocab($voclib:gcmd_chronostratigraphic_valids, moles:dgValidTermID/moles:ParentListID)]/moles:dgValidTerm) 
     94        for $TemporalTerm in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage/moles:dgTemporalCoverage/moles:dgChronostratigraphicTerm[voclib:spot-vocab($voclib:gcmd_chronostratigraphic_valids, moles:dgValidTermID/moles:ParentListID)]/moles:dgValidTerm) 
    9695                return element Paleo_Temporal_Coverage {element Chronostratigraphic_Unit {data($TemporalTerm)}},  
    9796        for $Data_Set_Progress in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataStatus/moles:dgDatasetClosure) 
    9897                return element Data_Set_Progress {data($Data_Set_Progress)}, 
    99         for $BoundingBox in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:BoundingBox) 
     98        for $BoundingBox in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage/moles:dgSpatialCoverage/moles:BoundingBox) 
    10099        return  
    101100            element Spatial_Coverage { 
     
    105104                    element Easternmost_Longitude {data($BoundingBox/moles:LimitEast)} 
    106105                }, 
    107         for $Location in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea[voclib:spot-vocab($voclib:gcmd_location_valids, moles:dgValidTermID/moles:ParentListID)]) 
     106        for $Location in ($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage/moles:dgSpatialCoverage/moles:dgArea[voclib:spot-vocab($voclib:gcmd_location_valids, moles:dgValidTermID/moles:ParentListID)]) 
    108107                return element Location {data($Location/moles:dgValidTerm)},  
    109         for $DepAct in ($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID) 
     108        for $DepActRepository in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID/moles:repositoryIdentifer) 
     109        for $DepActLocal in  distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ActivityID[moles:repositoryIdentifer=$DepActRepository]/moles:localIdentifer)   
     110        let $DepActRecord := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:repositoryIdentifier=$DepActRepository and moles:localIdentifier=$DepActLocal]] 
    110111        return  
    111112            element Project { 
    112                 for $DepActAbbrev in (collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepAct/moles:repositoryIdentifier and moles:localIdentifier=$DepAct/moles:localIdentifier]]/moles:abbreviation) 
    113                     return  
    114                         element Short_Name {data($DepActAbbrev)}, 
    115                 for $DepActName in (collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgMetadataID[moles:schemeIdentifier='NDG-B0' and moles:repositoryIdentifier=$DepAct/moles:repositoryIdentifier and moles:localIdentifier=$DepAct/moles:localIdentifier]]/moles:name) 
    116                     return  
    117                         element Long_Name {data($DepActName)} 
     113                        element Short_Name {data($DepActRecord/abbreviation)}, 
     114                        element Long_Name {data($DepActRecord/name)} 
    118115                }, 
    119116        if (exists($DE/moles:dgDataEntity/moles:dgDataGranule/moles:accessControlPolicy)) then  
  • TI07-MOLES/trunk/PythonCode/wsgi/ndg_xqueries.py

    r2487 r2553  
    1515declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions'; 
    1616declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
    17  
     17declare option exist:timeout '24500';  
    1818import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
    1919import module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities' at 'xmldb:exist:///db/xqueryLib/Utilities/utility_xquery_lib.xquery'; 
     
    258258declare namespace f='http://ndg.nerc.ac.uk/moles/localfunctions'; 
    259259declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
     260declare option exist:timeout '24500';  
    260261 
    261262import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
     
    548549import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
    549550import module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities' at 'xmldb:exist:///db/xqueryLib/Utilities/utility_xquery_lib.xquery'; 
     551declare option exist:timeout '24500';  
    550552(:  
    551553Will return when scope problem sussed... ;( 
     
    720722import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; 
    721723import module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities' at 'xmldb:exist:///db/xqueryLib/Utilities/utility_xquery_lib.xquery'; 
     724declare option exist:timeout '24500';  
    722725(:  
    723726Will return when scope problem sussed... ;( 
     
    921924declare namespace xlink='http://www.w3.org/1999/xlink';  
    922925declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';  
     926declare option exist:timeout '24500';  
    923927 
    924928declare variable $targetCollection as xs:string {'TargetCollection'}; 
     
    11291133declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance';  
    11301134declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
     1135declare option exist:timeout '24500';  
    11311136 
    11321137declare variable $targetCollection as xs:string {'TargetCollection'}; 
  • TI07-MOLES/trunk/StubB/XQuery/DeploymentCount.xquery

    r2512 r2553  
    22element html { 
    33element table { 
     4element tr { 
     5element td {'localIdentifier'},  
     6element td {'Name'}, 
     7element td {'Deployment'}, 
     8element td {'Data Entities'} 
     9}, 
    410for $Act in collection('/db/ndg_B_metadata/badc.nerc.ac.uk')/dgMetadata/dgMetadataRecord 
    511[exists(dgActivity/ActivityDeployment)] 
     
    1117element td {data($Act/name)}, 
    1218element td {data(count($Act/dgActivity/ActivityDeployment))} 
     19, 
     20let $DEDepl := count(collection('/db/ndg_B_metadata/badc.nerc.ac.uk')/dgMetadata/dgMetadataRecord/dgDataEntity/RelatedDeployment[ActivityID[localIdentifier=$Act/dgMetadataID/localIdentifier and repositoryIdentifier=$Act/dgMetadataID/repositoryIdentifier]]) 
     21return  
     22element td {data( 
     23$DEDepl 
     24)} 
    1325} 
    1426}, 
    1527element table { 
     28element tr { 
     29element td {'localIdentifier'},  
     30element td {'Name'}, 
     31element td {'Deployment'}, 
     32element td {'Data Entities'} 
     33}, 
    1634for $DPT in collection('/db/ndg_B_metadata/badc.nerc.ac.uk')/dgMetadata/dgMetadataRecord 
    1735[exists(dgDataProductionTool/DPTDeployment)] 
     
    2240,  
    2341element td {data($DPT/name)}, 
    24 element td {data(count($DPT/dgDataProductionTool/DPTDeployment))} 
     42element td {data(count($DPT/dgDataProductionTool/DPTDeployment))}, 
     43let $DEDepl := count(collection('/db/ndg_B_metadata/badc.nerc.ac.uk')/dgMetadata/dgMetadataRecord/dgDataEntity/RelatedDeployment[DataProductionToolID[localIdentifier=$DPT/dgMetadataID/localIdentifier and repositoryIdentifier=$DPT/dgMetadataID/repositoryIdentifier]]) 
     44return  
     45element td {data( 
     46$DEDepl 
     47)} 
    2548} 
    2649}, 
    2750element table { 
     51element tr { 
     52element td {'localIdentifier'},  
     53element td {'Name'}, 
     54element td {'Deployment'}, 
     55element td {'Data Entities'} 
     56}, 
    2857for $ObsStn in collection('/db/ndg_B_metadata/badc.nerc.ac.uk')/dgMetadata/dgMetadataRecord 
    2958[exists(dgObservationStation/ObsStationDeployment)] 
     
    3564element td {data($ObsStn/name)}, 
    3665element td {data(count($ObsStn/dgObservationStation/ObsStationDeployment))} 
     66, 
     67let $DEDepl := count(collection('/db/ndg_B_metadata/badc.nerc.ac.uk')/dgMetadata/dgMetadataRecord/dgDataEntity/RelatedDeployment[ObservationStationID[localIdentifier=$ObsStn/dgMetadataID/localIdentifier and repositoryIdentifier=$ObsStn/dgMetadataID/repositoryIdentifier]]) 
     68return  
     69element td {data( 
     70$DEDepl 
     71)} 
    3772} 
    3873}, 
     
    5085} 
    5186} 
    52  
  • TI07-MOLES/trunk/StubB/XQuery/NDG-ObsStnStubB.xquery

    r2511 r2553  
    166166moles:dgObservationStation!=''  
    167167and moles:dgMetadataID[ 
    168 moles:schemeIdentifier='NDG-B0'  
    169 and moles:repositoryIdentifier=$repositoryIdentifier 
     168moles:repositoryIdentifier=$repositoryIdentifier 
    170169and moles:localIdentifier=$localIdentifier]] 
    171170return 
     
    218217f:return-stub-activity('activity', data($RelDep/moles:ActivityID/moles:repositoryIdentifier), data($RelDep/moles:ActivityID/moles:localIdentifier)), 
    219218f:return-stub-dpt('dataproductiontool', data($RelDep/moles:DataProductionToolID/moles:repositoryIdentifier), data($RelDep/moles:DataProductionToolID/moles:localIdentifier)),  
    220 for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier 
    221 and moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier] 
     219for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     220moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier 
     221and 
     222moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier] 
    222223return 
    223224f:return-stub-dataentity('dataentity', $DE), 
Note: See TracChangeset for help on using the changeset viewer.