Changeset 2466 for TI07-MOLES/trunk


Ignore:
Timestamp:
11/05/07 11:35:00 (12 years ago)
Author:
ko23
Message:

Updated XQueries for BADC 'worst cases so far'

Location:
TI07-MOLES/trunk/StubB/XQuery
Files:
4 edited

Legend:

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

    r2367 r2466  
    99import module namespace stubblib='http://ndg.nerc.ac.uk/xquery/lib/stubb' at 'xmldb:exist:///db/xqueryLib/StubB/stubb_xquery_lib.xquery'; 
    1010:) 
     11declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
     12declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     13declare variable $localIdentifier as xs:string {'activity_11680365144712080'}; 
     14(: replacable parameters 
    1115declare variable $targetCollection as xs:string {'TargetCollection'}; 
    1216declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
    1317declare variable $localIdentifier as xs:string {'LocalID'}; 
     18:) 
    1419 
    1520declare function f:return-stub-activity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()  
     
    1722(: Security not implemented here yet :) 
    1823{ 
    19 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    20             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    21             and moles:dgMetadataID/moles:localIdentifier=$locid]) 
    22 return   
    23     if ($found = 0) then  
    24         element {$out-element-name} { 
    25             element error {'not found'}, 
    26             element repositoryIdentifier {$repid}, 
    27             element localIdentifier {$locid} 
    28         }  
    29     else ( 
    30         for $SRAct in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    31             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    32             and moles:dgMetadataID/moles:localIdentifier=$locid]  
    33         return  
    34             element  {$out-element-name} {  
    35                 ($SRAct/moles:dgMetadataID), 
    36                 ($SRAct/moles:dgMetadataDescription), 
    37                 ($SRAct/moles:name), 
    38                 ($SRAct/moles:abbreviation), 
    39                 element dgActivity { 
    40                     if (exists($SRAct/*/moles:dgActivityDataCollection)) then  
    41                         ($SRAct/*/moles:dgActivityDataCollection) 
    42                     else if (exists($SRAct/*/moles:dgActivityDataProject)) then  
    43                         ($SRAct/*/moles:dgActivityDataProject) 
    44                     else if (exists($SRAct/*/dgActivityDataCampaign)) then 
    45                         ($SRAct/moles:dgActivity/moles:dgActivityDataCampaign) 
    46                     else  
    47                         ($SRAct/moles:dgActivity/moles:dgActivityDataInvestigation),  
    48                     ($SRAct/moles:dgActivity/moles:dgActivityCoverage), 
    49                     ($SRAct/moles:dgActivity/moles:dgActivityDuration) 
    50                 } (: </dgActivity> :)  
    51             } (: </activity> :)  
    52     ) 
    53 } ; 
    54  
    55 declare function f:return-stub-dataentity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()  
     24let $SRAct := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     25moles:dgMetadataID/moles:localIdentifier=$locid 
     26and moles:dgMetadataID/moles:repositoryIdentifier=$repid ]  
     27return  
     28element  {$out-element-name} {  
     29($SRAct/moles:dgMetadataID), 
     30($SRAct/moles:dgMetadataDescription), 
     31($SRAct/moles:name), 
     32($SRAct/moles:abbreviation), 
     33($SRAct/moles:logos), 
     34element dgActivity { 
     35if (exists($SRAct/moles:dgActivity/moles:dgActivityDataCollection)) then  
     36($SRAct/*/moles:dgActivityDataCollection) 
     37else if (exists($SRAct/moles:dgActivity/moles:dgActivityDataProject)) then  
     38($SRAct/*/moles:dgActivityDataProject) 
     39else if (exists($SRAct/moles:dgActivity/moles:dgActivityDataCampaign)) then 
     40($SRAct/moles:dgActivity/moles:dgActivityDataCampaign) 
     41else  
     42($SRAct/moles:dgActivity/moles:dgActivityDataInvestigation),  
     43($SRAct/moles:dgActivity/moles:dgActivityCoverage), 
     44($SRAct/moles:dgActivity/moles:dgActivityDuration) 
     45} (: </dgActivity> :)  
     46} (: </activity> :)  
     47} ; 
     48 
     49declare function f:return-stub-dataentity($out-element-name as xs:string, $DE as element()) as element()  
    5650(: Returns a 'stubB' style observation station record to expand an data entity record :) 
    5751(: Security not implemented yet :) 
    5852{ 
    59 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    60         moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    61         and moles:dgMetadataID/moles:localIdentifier=$locid]) 
     53let $SRDE := $DE 
    6254return   
    63     if ($found = 0) then  
    64         element {$out-element-name} { 
    65             element error {'not found'}, 
    66             element repositoryIdentifier {$repid}, 
    67             element localIdentifier {$locid} 
    68         }  
    69     else ( 
    70         for $SRDE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    71             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    72             and moles:dgMetadataID/moles:localIdentifier=$locid]  
    73         return   
    74             element {$out-element-name} { 
    75                 ($SRDE/moles:dgMetadataID), 
    76                 ($SRDE/moles:dgMetadataDescription), 
    77                 ($SRDE/moles:name), 
    78                 ($SRDE/moles:abbreviation), 
    79                 element dgDataEntity { 
    80                     ($SRDE/moles:dgDataEntity/moles:dgDataSetType), 
    81                     ($SRDE/moles:dgDataEntity/moles:dgDataGranule), 
    82                     ($SRDE/moles:dgDataEntity/moles:dgDataSummary) 
    83                 } (: </dgDataEntity> :)         
    84             } 
    85     ) 
     55element {$out-element-name} { 
     56($SRDE/moles:dgMetadataID), 
     57($SRDE/moles:dgMetadataDescription), 
     58($SRDE/moles:name), 
     59($SRDE/moles:abbreviation), 
     60($SRDE/moles:abbreviation), 
     61element dgDataEntity { 
     62($SRDE/moles:dgDataEntity/moles:dgDataSetType), 
     63($SRDE/moles:dgDataEntity/moles:dgDataGranule), 
     64($SRDE/moles:dgDataEntity/moles:dgDataSummary) 
     65} (: </dgDataEntity> :)         
     66} 
    8667} ; 
    8768 
     
    9071(: Security not implemented yet :) 
    9172{ 
    92 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    93         moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    94         and moles:dgMetadataID/moles:localIdentifier=$locid]) 
     73let $SRDPT := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     74moles:dgMetadataID/moles:localIdentifier=$locid 
     75and 
     76moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     77] 
    9578return   
    96     if ($found = 0) then  
    97         element {$out-element-name} { 
    98             element error {'not found'}, 
    99             element repositoryIdentifier {$repid}, 
    100             element localIdentifier {$locid} 
    101         }  
    102     else ( 
    103         for $SRDPT in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    104                 moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    105                 and moles:dgMetadataID/moles:localIdentifier=$locid] 
    106         return   
    107             element {$out-element-name} { 
    108                 $SRDPT/moles:dgMetadataID, 
    109                 $SRDPT/moles:dgMetadataDescription, 
    110                 $SRDPT/moles:name, 
    111                 $SRDPT/moles:abbreviation, 
    112                 $SRDPT/moles:logos, 
    113                 element dgDataProductionTool { 
    114                     $SRDPT/moles:dgDataProductionTool/moles:contactDetails, 
    115                     if (exists($SRDPT/moles:dgDataProductionTool/moles:dgModel)) then 
    116                         $SRDPT/moles:dgDataProductionTool/moles:dgModel 
    117                     else (), 
    118                     if (exists($SRDPT/moles:dgDataProductionTool/moles:dgInstrument)) then 
    119                         $SRDPT/moles:dgDataProductionTool/moles:dgInstrument 
    120                     else () 
    121                     } (: </dgDataProductionTool> :) 
    122                 } (: </dataproductiontool> :) 
    123     ) 
     79element {$out-element-name} { 
     80$SRDPT/moles:dgMetadataID, 
     81$SRDPT/moles:dgMetadataDescription, 
     82$SRDPT/moles:name, 
     83$SRDPT/moles:abbreviation, 
     84$SRDPT/moles:logos, 
     85element dgDataProductionTool { 
     86$SRDPT/moles:dgDataProductionTool/moles:contactDetails, 
     87if (exists($SRDPT/moles:dgDataProductionTool/moles:dgModel)) then 
     88$SRDPT/moles:dgDataProductionTool/moles:dgModel 
     89else (), 
     90if (exists($SRDPT/moles:dgDataProductionTool/moles:dgInstrument)) then 
     91$SRDPT/moles:dgDataProductionTool/moles:dgInstrument 
     92else () 
     93} (: </dgDataProductionTool> :) 
     94} (: </dataproductiontool> :) 
    12495} ; 
    12596 
     
    12899(: Security not implemented here yet;  :) 
    129100{ 
    130 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    131             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    132             and moles:dgMetadataID/moles:localIdentifier=$locid]) 
    133 return   
    134     if ($found = 0) then  
    135         element {$out-element-name} { 
    136             element error {'not found'}, 
    137             element repositoryIdentifier {$repid}, 
    138             element localIdentifier {$locid} 
    139         }  
    140     else ( 
    141         for $SRObsStn in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    142             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    143             and moles:dgMetadataID/moles:localIdentifier=$locid]  
    144         return 
    145             element {$out-element-name} { 
    146                 ($SRObsStn/moles:dgMetadataID), 
    147                 ($SRObsStn/moles:dgMetadataDescription), 
    148                 ($SRObsStn/moles:name), 
    149                 ($SRObsStn/moles:abbreviation), 
    150                 element dgObservationStation { 
    151                     ($SRObsStn/moles:dgObservationStation/moles:contactDetails), 
    152                     if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform)) then 
    153                         element dgStationaryPlatform { 
    154                             $SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:position, 
    155                             if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgLandStation)) then element dgLandStation {''} 
    156                             else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgMooring)) then element dgMooring {''} 
    157                             else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgStationGroup)) then element dgStationGroup {''} 
    158                             else () 
    159                             } 
    160                     else if (exists($SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform)) then  
    161                         $SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform 
    162                     else () 
    163                 } (: </dgObservationStation> :) 
    164             } 
    165     ) 
     101let $SRObsStn := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     102moles:dgMetadataID/moles:localIdentifier=$locid 
     103and 
     104moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     105]  
     106return 
     107element {$out-element-name} { 
     108($SRObsStn/moles:dgMetadataID), 
     109($SRObsStn/moles:dgMetadataDescription), 
     110($SRObsStn/moles:name), 
     111($SRObsStn/moles:abbreviation), 
     112($SRObsStn/moles:logos), 
     113element dgObservationStation { 
     114($SRObsStn/moles:dgObservationStation/moles:contactDetails), 
     115if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform)) then 
     116element dgStationaryPlatform { 
     117$SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:position, 
     118if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgLandStation)) then element dgLandStation {''} 
     119else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgMooring)) then element dgMooring {''} 
     120else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgStationGroup)) then element dgStationGroup {''} 
     121else () 
     122} 
     123else if (exists($SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform)) then  
     124$SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform 
     125else () 
     126} (: </dgObservationStation> :) 
     127} 
    166128} ; 
    167129 
     
    170132(: Security not implemented yet :) 
    171133{ 
    172 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgPerson[ 
    173             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    174             and moles:dgMetadataID/moles:localIdentifier=$locid]) 
    175 return   
    176     if ($found = 0) then  
    177         element {$out-element-name} { 
    178             element error {'not found'}, 
    179             element repositoryIdentifier {$repid}, 
    180             element localIdentifier {$locid} 
    181         }  
    182     else ( 
    183     for $person in collection($targetCollection)/moles:dgMetadata/moles:dgPerson[ 
    184         moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    185         and moles:dgMetadataID/moles:localIdentifier=$locid]  
    186     return  
    187         element  {$out-element-name}  
    188         { 
    189             ($person/moles:name), 
    190             ($person/moles:contactDetails), 
    191             ($person/moles:dgMetadataID) 
    192         } 
    193     ) 
     134let $person := collection($targetCollection)/moles:dgMetadata/moles:dgPerson[ 
     135moles:dgMetadataID/moles:localIdentifier=$locid 
     136and 
     137moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     138]  
     139return  
     140element  {$out-element-name}  
     141{ 
     142($person/moles:name), 
     143($person/moles:contactDetails), 
     144($person/moles:dgMetadataID) 
     145} 
    194146} ; 
    195147 
     
    198150(: Security not implemented yet :) 
    199151{ 
    200     let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation[ 
    201                 moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    202                 and moles:dgMetadataID/moles:localIdentifier=$locid]) 
    203     return   
    204         if ($found = 0) then  
    205             element {$out-element-name} { 
    206                 element error {'not found'}, 
    207                 element repositoryIdentifier {$repid}, 
    208                 element localIdentifier {$locid} 
    209             }  
    210         else ( 
    211             for $org in collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation[ 
    212                 moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    213                 and moles:dgMetadataID/moles:localIdentifier=$locid]  
    214             return  
    215                 element  {$out-element-name} { 
    216                     $org/moles:dgMetadataID, 
    217                     $org/moles:name, 
    218                     $org/moles:abbreviation, 
    219                     $org/moles:contactDetails, 
    220                     $org/moles:logos 
    221                 } 
    222         ) 
     152let $org := collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation[ 
     153moles:dgMetadataID/moles:localIdentifier=$locid 
     154and 
     155moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     156]  
     157return  
     158element  {$out-element-name} { 
     159$org/moles:dgMetadataID, 
     160$org/moles:name, 
     161$org/moles:abbreviation, 
     162$org/moles:contactDetails, 
     163$org/moles:logos 
     164} 
    223165} ; 
    224166 
     
    365307            f:return-stub-dpt('dataproductiontool', data($RelDep/moles:DataProductionToolID/moles:repositoryIdentifier), data($RelDep/moles:DataProductionToolID/moles:localIdentifier)), 
    366308            f:return-stub-obsstn('observationstation', data($RelDep/moles:ObservationStationID/moles:repositoryIdentifier), data($RelDep/moles:ObservationStationID/moles:localIdentifier)), 
    367             for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord 
    368                 where $DE/moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier 
    369                         and $DE/moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier 
    370             return 
    371                 f:return-stub-dataentity('dataentity', data($DE/moles:dgMetadataID/moles:repositoryIdentifier), data($DE/moles:dgMetadataID/moles:localIdentifier)) 
     309                for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier 
     310and moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier] 
     311return 
     312f:return-stub-dataentity('dataentity', $DE) 
    372313        }, (: </ActivityDeployment> :) 
    373314        if (exists($Act/dgActivityCoverage)) then 
  • TI07-MOLES/trunk/StubB/XQuery/NDG-DEStubB.xquery

    r2464 r2466  
    1111declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
    1212declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
    13 declare variable $localIdentifier as xs:string {'dataent_chablis'}; 
     13declare variable $localIdentifier as xs:string {'dataent_11738907158217423'}; 
    1414(: replacable parameters 
    1515declare variable $targetCollection as xs:string {'TargetCollection'}; 
     
    2222(: Security not implemented here yet :) 
    2323{ 
    24         for $SRAct in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    25             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    26             and moles:dgMetadataID/moles:localIdentifier=$locid]  
    27         return  
    28             element  {$out-element-name} {  
    29                 ($SRAct/moles:dgMetadataID), 
    30                 ($SRAct/moles:dgMetadataDescription), 
    31                 ($SRAct/moles:name), 
    32                 ($SRAct/moles:abbreviation), 
    33                 element dgActivity { 
    34                     if (exists($SRAct/*/moles:dgActivityDataCollection)) then  
    35                         ($SRAct/*/moles:dgActivityDataCollection) 
    36                     else if (exists($SRAct/*/moles:dgActivityDataProject)) then  
    37                         ($SRAct/*/moles:dgActivityDataProject) 
    38                     else if (exists($SRAct/*/dgActivityDataCampaign)) then 
    39                         ($SRAct/moles:dgActivity/moles:dgActivityDataCampaign) 
    40                     else  
    41                         ($SRAct/moles:dgActivity/moles:dgActivityDataInvestigation),  
    42                     ($SRAct/moles:dgActivity/moles:dgActivityCoverage), 
    43                     ($SRAct/moles:dgActivity/moles:dgActivityDuration) 
    44                 } (: </dgActivity> :)  
    45             } (: </activity> :)  
    46 } ; 
    47  
    48 declare function f:return-stub-dataentity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()  
     24let $SRAct := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     25moles:dgMetadataID/moles:localIdentifier=$locid 
     26and moles:dgMetadataID/moles:repositoryIdentifier=$repid ]  
     27return  
     28element  {$out-element-name} {  
     29($SRAct/moles:dgMetadataID), 
     30($SRAct/moles:dgMetadataDescription), 
     31($SRAct/moles:name), 
     32($SRAct/moles:abbreviation), 
     33($SRAct/moles:logos), 
     34element dgActivity { 
     35if (exists($SRAct/moles:dgActivity/moles:dgActivityDataCollection)) then  
     36($SRAct/*/moles:dgActivityDataCollection) 
     37else if (exists($SRAct/moles:dgActivity/moles:dgActivityDataProject)) then  
     38($SRAct/*/moles:dgActivityDataProject) 
     39else if (exists($SRAct/moles:dgActivity/moles:dgActivityDataCampaign)) then 
     40($SRAct/moles:dgActivity/moles:dgActivityDataCampaign) 
     41else  
     42($SRAct/moles:dgActivity/moles:dgActivityDataInvestigation),  
     43($SRAct/moles:dgActivity/moles:dgActivityCoverage), 
     44($SRAct/moles:dgActivity/moles:dgActivityDuration) 
     45} (: </dgActivity> :)  
     46} (: </activity> :)  
     47} ; 
     48 
     49declare function f:return-stub-dataentity($out-element-name as xs:string, $DE as element()) as element()  
    4950(: Returns a 'stubB' style observation station record to expand an data entity record :) 
    5051(: Security not implemented yet :) 
    5152{ 
    52         for $SRDE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    53             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    54             and moles:dgMetadataID/moles:localIdentifier=$locid]  
    55         return   
    56             element {$out-element-name} { 
    57                 ($SRDE/moles:dgMetadataID), 
    58                 ($SRDE/moles:dgMetadataDescription), 
    59                 ($SRDE/moles:name), 
    60                 ($SRDE/moles:abbreviation), 
    61                 element dgDataEntity { 
    62                     ($SRDE/moles:dgDataEntity/moles:dgDataSetType), 
    63                     ($SRDE/moles:dgDataEntity/moles:dgDataGranule), 
    64                     ($SRDE/moles:dgDataEntity/moles:dgDataSummary) 
    65                 } (: </dgDataEntity> :)         
    66             } 
     53let $SRDE := $DE 
     54return   
     55element {$out-element-name} { 
     56($SRDE/moles:dgMetadataID), 
     57($SRDE/moles:dgMetadataDescription), 
     58($SRDE/moles:name), 
     59($SRDE/moles:abbreviation), 
     60($SRDE/moles:abbreviation), 
     61element dgDataEntity { 
     62($SRDE/moles:dgDataEntity/moles:dgDataSetType), 
     63($SRDE/moles:dgDataEntity/moles:dgDataGranule), 
     64($SRDE/moles:dgDataEntity/moles:dgDataSummary) 
     65} (: </dgDataEntity> :)         
     66} 
    6767} ; 
    6868 
     
    7171(: Security not implemented yet :) 
    7272{ 
    73         for $SRDPT in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    74                 moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    75                 and moles:dgMetadataID/moles:localIdentifier=$locid] 
    76         return   
    77             element {$out-element-name} { 
    78                 $SRDPT/moles:dgMetadataID, 
    79                 $SRDPT/moles:dgMetadataDescription, 
    80                 $SRDPT/moles:name, 
    81                 $SRDPT/moles:abbreviation, 
    82                 $SRDPT/moles:logos, 
    83                 element dgDataProductionTool { 
    84                     $SRDPT/moles:dgDataProductionTool/moles:contactDetails, 
    85                     if (exists($SRDPT/moles:dgDataProductionTool/moles:dgModel)) then 
    86                         $SRDPT/moles:dgDataProductionTool/moles:dgModel 
    87                     else (), 
    88                     if (exists($SRDPT/moles:dgDataProductionTool/moles:dgInstrument)) then 
    89                         $SRDPT/moles:dgDataProductionTool/moles:dgInstrument 
    90                     else () 
    91                     } (: </dgDataProductionTool> :) 
    92                 } (: </dataproductiontool> :) 
     73let $SRDPT := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     74moles:dgMetadataID/moles:localIdentifier=$locid 
     75and 
     76moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     77] 
     78return   
     79element {$out-element-name} { 
     80$SRDPT/moles:dgMetadataID, 
     81$SRDPT/moles:dgMetadataDescription, 
     82$SRDPT/moles:name, 
     83$SRDPT/moles:abbreviation, 
     84$SRDPT/moles:logos, 
     85element dgDataProductionTool { 
     86$SRDPT/moles:dgDataProductionTool/moles:contactDetails, 
     87if (exists($SRDPT/moles:dgDataProductionTool/moles:dgModel)) then 
     88$SRDPT/moles:dgDataProductionTool/moles:dgModel 
     89else (), 
     90if (exists($SRDPT/moles:dgDataProductionTool/moles:dgInstrument)) then 
     91$SRDPT/moles:dgDataProductionTool/moles:dgInstrument 
     92else () 
     93} (: </dgDataProductionTool> :) 
     94} (: </dataproductiontool> :) 
    9395} ; 
    9496 
     
    9799(: Security not implemented here yet;  :) 
    98100{ 
    99         for $SRObsStn in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    100             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    101             and moles:dgMetadataID/moles:localIdentifier=$locid]  
    102         return 
    103             element {$out-element-name} { 
    104                 ($SRObsStn/moles:dgMetadataID), 
    105                 ($SRObsStn/moles:dgMetadataDescription), 
    106                 ($SRObsStn/moles:name), 
    107                 ($SRObsStn/moles:abbreviation), 
    108                 element dgObservationStation { 
    109                     ($SRObsStn/moles:dgObservationStation/moles:contactDetails), 
    110                     if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform)) then 
    111                         element dgStationaryPlatform { 
    112                             $SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:position, 
    113                             if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgLandStation)) then element dgLandStation {''} 
    114                             else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgMooring)) then element dgMooring {''} 
    115                             else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgStationGroup)) then element dgStationGroup {''} 
    116                             else () 
    117                             } 
    118                     else if (exists($SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform)) then  
    119                         $SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform 
    120                     else () 
    121                 } (: </dgObservationStation> :) 
    122             } 
     101let $SRObsStn := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     102moles:dgMetadataID/moles:localIdentifier=$locid 
     103and 
     104moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     105]  
     106return 
     107element {$out-element-name} { 
     108($SRObsStn/moles:dgMetadataID), 
     109($SRObsStn/moles:dgMetadataDescription), 
     110($SRObsStn/moles:name), 
     111($SRObsStn/moles:abbreviation), 
     112($SRObsStn/moles:logos), 
     113element dgObservationStation { 
     114($SRObsStn/moles:dgObservationStation/moles:contactDetails), 
     115if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform)) then 
     116element dgStationaryPlatform { 
     117$SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:position, 
     118if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgLandStation)) then element dgLandStation {''} 
     119else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgMooring)) then element dgMooring {''} 
     120else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgStationGroup)) then element dgStationGroup {''} 
     121else () 
     122} 
     123else if (exists($SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform)) then  
     124$SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform 
     125else () 
     126} (: </dgObservationStation> :) 
     127} 
    123128} ; 
    124129 
     
    127132(: Security not implemented yet :) 
    128133{ 
    129     for $person in collection($targetCollection)/moles:dgMetadata/moles:dgPerson[ 
    130         moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    131         and moles:dgMetadataID/moles:localIdentifier=$locid]  
    132     return  
    133         element  {$out-element-name}  
    134         { 
    135             ($person/moles:name), 
    136             ($person/moles:contactDetails), 
    137             ($person/moles:dgMetadataID) 
    138         } 
     134let $person := collection($targetCollection)/moles:dgMetadata/moles:dgPerson[ 
     135moles:dgMetadataID/moles:localIdentifier=$locid 
     136and 
     137moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     138]  
     139return  
     140element  {$out-element-name}  
     141{ 
     142($person/moles:name), 
     143($person/moles:contactDetails), 
     144($person/moles:dgMetadataID) 
     145} 
    139146} ; 
    140147 
     
    143150(: Security not implemented yet :) 
    144151{ 
    145             for $org in collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation[ 
    146                 moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    147                 and moles:dgMetadataID/moles:localIdentifier=$locid]  
    148             return  
    149                 element  {$out-element-name} { 
    150                     $org/moles:dgMetadataID, 
    151                     $org/moles:name, 
    152                     $org/moles:abbreviation, 
    153                     $org/moles:contactDetails, 
    154                     $org/moles:logos 
    155                 } 
     152let $org := collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation[ 
     153moles:dgMetadataID/moles:localIdentifier=$locid 
     154and 
     155moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     156]  
     157return  
     158element  {$out-element-name} { 
     159$org/moles:dgMetadataID, 
     160$org/moles:name, 
     161$org/moles:abbreviation, 
     162$org/moles:contactDetails, 
     163$org/moles:logos 
     164} 
    156165} ; 
    157166 
     
    261270                    $RelatedDataEntity/moles:RelationID/moles:dgValidTermID 
    262271                }, (: </relation> :) 
    263                 f:return-stub-dataentity('dataentity', data($RelatedDataEntity/(moles:RelatedDataEntityID | moles:RelatedDataGranuleID)/moles:repositoryIdentifier), data($RelatedDataEntity/(moles:RelatedDataEntityID | moles:RelatedDataGranuleID)/moles:localIdentifier)) 
    264                 } (: </relateddataentity> :) 
    265     } (: </dgDataEntity> :), 
     272                let $DE := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelatedDataEntity/moles:RelatedDataEntityID/moles:repositoryIdentifier 
     273                      and moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelatedDataEntity/moles:RelatedDataEntityID/moles:localIdentifier] 
     274                 return 
     275                    f:return-stub-dataentity('dataentity', $DE) 
     276                } 
     277} (: </dgDataEntity> :), 
    266278    for $strkwrd in $DE/moles:dgStructuredKeyword return $strkwrd, 
    267279    if (exists($DE/moles:dgMetadataProvenance)) then $DE/moles:dgMetadataProvenance else (), 
  • TI07-MOLES/trunk/StubB/XQuery/NDG-DPTStubB.xquery

    r2367 r2466  
    99declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
    1010 
     11declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
     12declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
     13declare variable $localIdentifier as xs:string {'dpt_116291244849226'}; 
     14(: replacable parameters 
    1115declare variable $targetCollection as xs:string {'TargetCollection'}; 
    1216declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
    1317declare variable $localIdentifier as xs:string {'LocalID'}; 
     18:) 
    1419 
    1520declare function f:return-stub-activity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()  
     
    1722(: Security not implemented here yet :) 
    1823{ 
    19 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    20             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    21             and moles:dgMetadataID/moles:localIdentifier=$locid]) 
     24let $SRAct := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     25moles:dgMetadataID/moles:localIdentifier=$locid 
     26and moles:dgMetadataID/moles:repositoryIdentifier=$repid ]  
     27return  
     28element  {$out-element-name} {  
     29($SRAct/moles:dgMetadataID), 
     30($SRAct/moles:dgMetadataDescription), 
     31($SRAct/moles:name), 
     32($SRAct/moles:abbreviation), 
     33($SRAct/moles:logos), 
     34element dgActivity { 
     35if (exists($SRAct/moles:dgActivity/moles:dgActivityDataCollection)) then  
     36($SRAct/*/moles:dgActivityDataCollection) 
     37else if (exists($SRAct/moles:dgActivity/moles:dgActivityDataProject)) then  
     38($SRAct/*/moles:dgActivityDataProject) 
     39else if (exists($SRAct/moles:dgActivity/moles:dgActivityDataCampaign)) then 
     40($SRAct/moles:dgActivity/moles:dgActivityDataCampaign) 
     41else  
     42($SRAct/moles:dgActivity/moles:dgActivityDataInvestigation),  
     43($SRAct/moles:dgActivity/moles:dgActivityCoverage), 
     44($SRAct/moles:dgActivity/moles:dgActivityDuration) 
     45} (: </dgActivity> :)  
     46} (: </activity> :)  
     47} ; 
     48 
     49declare function f:return-stub-dataentity($out-element-name as xs:string, $DE as element()) as element()  
     50(: Returns a 'stubB' style observation station record to expand an data entity record :) 
     51(: Security not implemented yet :) 
     52{ 
     53let $SRDE := $DE 
    2254return   
    23     if ($found = 0) then  
    24         element {$out-element-name} { 
    25             element error {'not found'}, 
    26             element repositoryIdentifier {$repid}, 
    27             element localIdentifier {$locid} 
    28         }  
    29     else ( 
    30         for $SRAct in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    31             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    32             and moles:dgMetadataID/moles:localIdentifier=$locid]  
    33         return  
    34             element  {$out-element-name} {  
    35                 ($SRAct/moles:dgMetadataID), 
    36                 ($SRAct/moles:dgMetadataDescription), 
    37                 ($SRAct/moles:name), 
    38                 ($SRAct/moles:abbreviation), 
    39                 element dgActivity { 
    40                     if (exists($SRAct/*/moles:dgActivityDataCollection)) then  
    41                         ($SRAct/*/moles:dgActivityDataCollection) 
    42                     else if (exists($SRAct/*/moles:dgActivityDataProject)) then  
    43                         ($SRAct/*/moles:dgActivityDataProject) 
    44                     else if (exists($SRAct/*/dgActivityDataCampaign)) then 
    45                         ($SRAct/moles:dgActivity/moles:dgActivityDataCampaign) 
    46                     else  
    47                         ($SRAct/moles:dgActivity/moles:dgActivityDataInvestigation),  
    48                     ($SRAct/moles:dgActivity/moles:dgActivityCoverage), 
    49                     ($SRAct/moles:dgActivity/moles:dgActivityDuration) 
    50                 } (: </dgActivity> :)  
    51             } (: </activity> :)  
    52     ) 
    53 } ; 
    54  
    55 declare function f:return-stub-dataentity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()  
    56 (: Returns a 'stubB' style observation station record to expand an data entity record :) 
    57 (: Security not implemented yet :) 
    58 { 
    59 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    60         moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    61         and moles:dgMetadataID/moles:localIdentifier=$locid]) 
    62 return   
    63     if ($found = 0) then  
    64         element {$out-element-name} { 
    65             element error {'not found'}, 
    66             element repositoryIdentifier {$repid}, 
    67             element localIdentifier {$locid} 
    68         }  
    69     else ( 
    70         for $SRDE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    71             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    72             and moles:dgMetadataID/moles:localIdentifier=$locid]  
    73         return   
    74             element {$out-element-name} { 
    75                 ($SRDE/moles:dgMetadataID), 
    76                 ($SRDE/moles:dgMetadataDescription), 
    77                 ($SRDE/moles:name), 
    78                 ($SRDE/moles:abbreviation), 
    79                 element dgDataEntity { 
    80                     ($SRDE/moles:dgDataEntity/moles:dgDataSetType), 
    81                     ($SRDE/moles:dgDataEntity/moles:dgDataGranule), 
    82                     ($SRDE/moles:dgDataEntity/moles:dgDataSummary) 
    83                 } (: </dgDataEntity> :)         
    84             } 
    85     ) 
     55element {$out-element-name} { 
     56($SRDE/moles:dgMetadataID), 
     57($SRDE/moles:dgMetadataDescription), 
     58($SRDE/moles:name), 
     59($SRDE/moles:abbreviation), 
     60($SRDE/moles:abbreviation), 
     61element dgDataEntity { 
     62($SRDE/moles:dgDataEntity/moles:dgDataSetType), 
     63($SRDE/moles:dgDataEntity/moles:dgDataGranule), 
     64($SRDE/moles:dgDataEntity/moles:dgDataSummary) 
     65} (: </dgDataEntity> :)         
     66} 
    8667} ; 
    8768 
     
    9071(: Security not implemented yet :) 
    9172{ 
    92 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    93         moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    94         and moles:dgMetadataID/moles:localIdentifier=$locid]) 
     73let $SRDPT := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     74moles:dgMetadataID/moles:localIdentifier=$locid 
     75and 
     76moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     77] 
    9578return   
    96     if ($found = 0) then  
    97         element {$out-element-name} { 
    98             element error {'not found'}, 
    99             element repositoryIdentifier {$repid}, 
    100             element localIdentifier {$locid} 
    101         }  
    102     else ( 
    103         for $SRDPT in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    104                 moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    105                 and moles:dgMetadataID/moles:localIdentifier=$locid] 
    106         return   
    107             element {$out-element-name} { 
    108                 $SRDPT/moles:dgMetadataID, 
    109                 $SRDPT/moles:dgMetadataDescription, 
    110                 $SRDPT/moles:name, 
    111                 $SRDPT/moles:abbreviation, 
    112                 $SRDPT/moles:logos, 
    113                 element dgDataProductionTool { 
    114                     $SRDPT/moles:dgDataProductionTool/moles:contactDetails, 
    115                     if (exists($SRDPT/moles:dgDataProductionTool/moles:dgModel)) then 
    116                         $SRDPT/moles:dgDataProductionTool/moles:dgModel 
    117                     else (), 
    118                     if (exists($SRDPT/moles:dgDataProductionTool/moles:dgInstrument)) then 
    119                         $SRDPT/moles:dgDataProductionTool/moles:dgInstrument 
    120                     else () 
    121                     } (: </dgDataProductionTool> :) 
    122                 } (: </dataproductiontool> :) 
    123     ) 
     79element {$out-element-name} { 
     80$SRDPT/moles:dgMetadataID, 
     81$SRDPT/moles:dgMetadataDescription, 
     82$SRDPT/moles:name, 
     83$SRDPT/moles:abbreviation, 
     84$SRDPT/moles:logos, 
     85element dgDataProductionTool { 
     86$SRDPT/moles:dgDataProductionTool/moles:contactDetails, 
     87if (exists($SRDPT/moles:dgDataProductionTool/moles:dgModel)) then 
     88$SRDPT/moles:dgDataProductionTool/moles:dgModel 
     89else (), 
     90if (exists($SRDPT/moles:dgDataProductionTool/moles:dgInstrument)) then 
     91$SRDPT/moles:dgDataProductionTool/moles:dgInstrument 
     92else () 
     93} (: </dgDataProductionTool> :) 
     94} (: </dataproductiontool> :) 
    12495} ; 
    12596 
     
    12899(: Security not implemented here yet;  :) 
    129100{ 
    130 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    131             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    132             and moles:dgMetadataID/moles:localIdentifier=$locid]) 
    133 return   
    134     if ($found = 0) then  
    135         element {$out-element-name} { 
    136             element error {'not found'}, 
    137             element repositoryIdentifier {$repid}, 
    138             element localIdentifier {$locid} 
    139         }  
    140     else ( 
    141         for $SRObsStn in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    142             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    143             and moles:dgMetadataID/moles:localIdentifier=$locid]  
    144         return 
    145             element {$out-element-name} { 
    146                 ($SRObsStn/moles:dgMetadataID), 
    147                 ($SRObsStn/moles:dgMetadataDescription), 
    148                 ($SRObsStn/moles:name), 
    149                 ($SRObsStn/moles:abbreviation), 
    150                 element dgObservationStation { 
    151                     ($SRObsStn/moles:dgObservationStation/moles:contactDetails), 
    152                     if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform)) then 
    153                         element dgStationaryPlatform { 
    154                             $SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:position, 
    155                             if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgLandStation)) then element dgLandStation {''} 
    156                             else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgMooring)) then element dgMooring {''} 
    157                             else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgStationGroup)) then element dgStationGroup {''} 
    158                             else () 
    159                             } 
    160                     else if (exists($SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform)) then  
    161                         $SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform 
    162                     else () 
    163                 } (: </dgObservationStation> :) 
    164             } 
    165     ) 
     101let $SRObsStn := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     102moles:dgMetadataID/moles:localIdentifier=$locid 
     103and 
     104moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     105]  
     106return 
     107element {$out-element-name} { 
     108($SRObsStn/moles:dgMetadataID), 
     109($SRObsStn/moles:dgMetadataDescription), 
     110($SRObsStn/moles:name), 
     111($SRObsStn/moles:abbreviation), 
     112($SRObsStn/moles:logos), 
     113element dgObservationStation { 
     114($SRObsStn/moles:dgObservationStation/moles:contactDetails), 
     115if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform)) then 
     116element dgStationaryPlatform { 
     117$SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:position, 
     118if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgLandStation)) then element dgLandStation {''} 
     119else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgMooring)) then element dgMooring {''} 
     120else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgStationGroup)) then element dgStationGroup {''} 
     121else () 
     122} 
     123else if (exists($SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform)) then  
     124$SRObsStn/moles:dgObservationStation/moles:dgMovingPlatform 
     125else () 
     126} (: </dgObservationStation> :) 
     127} 
    166128} ; 
    167129 
     
    170132(: Security not implemented yet :) 
    171133{ 
    172 let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgPerson[ 
    173             moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    174             and moles:dgMetadataID/moles:localIdentifier=$locid]) 
    175 return   
    176     if ($found = 0) then  
    177         element {$out-element-name} { 
    178             element error {'not found'}, 
    179             element repositoryIdentifier {$repid}, 
    180             element localIdentifier {$locid} 
    181         }  
    182     else ( 
    183     for $person in collection($targetCollection)/moles:dgMetadata/moles:dgPerson[ 
    184         moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    185         and moles:dgMetadataID/moles:localIdentifier=$locid]  
    186     return  
    187         element  {$out-element-name}  
    188         { 
    189             ($person/moles:name), 
    190             ($person/moles:contactDetails), 
    191             ($person/moles:dgMetadataID) 
    192         } 
    193     ) 
     134let $person := collection($targetCollection)/moles:dgMetadata/moles:dgPerson[ 
     135moles:dgMetadataID/moles:localIdentifier=$locid 
     136and 
     137moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     138]  
     139return  
     140element  {$out-element-name}  
     141{ 
     142($person/moles:name), 
     143($person/moles:contactDetails), 
     144($person/moles:dgMetadataID) 
     145} 
    194146} ; 
    195147 
     
    198150(: Security not implemented yet :) 
    199151{ 
    200     let $found := count(collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation[ 
    201                 moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    202                 and moles:dgMetadataID/moles:localIdentifier=$locid]) 
    203     return   
    204         if ($found = 0) then  
    205             element {$out-element-name} { 
    206                 element error {'not found'}, 
    207                 element repositoryIdentifier {$repid}, 
    208                 element localIdentifier {$locid} 
    209             }  
    210         else ( 
    211             for $org in collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation[ 
    212                 moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    213                 and moles:dgMetadataID/moles:localIdentifier=$locid]  
    214             return  
    215                 element  {$out-element-name} { 
    216                     $org/moles:dgMetadataID, 
    217                     $org/moles:name, 
    218                     $org/moles:abbreviation, 
    219                     $org/moles:contactDetails, 
    220                     $org/moles:logos 
    221                 } 
    222         ) 
     152let $org := collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation[ 
     153moles:dgMetadataID/moles:localIdentifier=$locid 
     154and 
     155moles:dgMetadataID/moles:repositoryIdentifier=$repid  
     156]  
     157return  
     158element  {$out-element-name} { 
     159$org/moles:dgMetadataID, 
     160$org/moles:name, 
     161$org/moles:abbreviation, 
     162$org/moles:contactDetails, 
     163$org/moles:logos 
     164} 
    223165} ; 
    224166 
     
    256198            f:return-stub-activity('activity', data($RelDep/moles:ActivityID/moles:repositoryIdentifier), data($RelDep/moles:ActivityID/moles:localIdentifier)), 
    257199            f:return-stub-obsstn('observationstation', data($RelDep/moles:ObservationStationID/moles:repositoryIdentifier), data($RelDep/moles:ObservationStationID/moles:localIdentifier)), 
    258             for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord 
    259                 where $DE/moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier 
    260                         and $DE/moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier 
    261             return 
    262                 f:return-stub-dataentity('dataentity', data($DE/moles:dgMetadataID/moles:repositoryIdentifier), data($DE/moles:dgMetadataID/moles:localIdentifier)), 
     200                for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier 
     201and moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier] 
     202return 
     203f:return-stub-dataentity('dataentity', $DE), 
    263204            $RelDep/moles:Coverage 
    264205        } (: </DPTDeployment> :)  
  • TI07-MOLES/trunk/StubB/XQuery/NDG-ObsStnStubB.xquery

    r2464 r2466  
    2121(: Security not implemented here yet :) 
    2222{ 
    23 for $SRAct in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     23let $SRAct := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    2424moles:dgMetadataID/moles:localIdentifier=$locid 
    2525and moles:dgMetadataID/moles:repositoryIdentifier=$repid ]  
     
    3030($SRAct/moles:name), 
    3131($SRAct/moles:abbreviation), 
     32($SRAct/moles:logos), 
    3233element dgActivity { 
    33 if (exists($SRAct/*/moles:dgActivityDataCollection)) then  
     34if (exists($SRAct/moles:dgActivity/moles:dgActivityDataCollection)) then  
    3435($SRAct/*/moles:dgActivityDataCollection) 
    35 else if (exists($SRAct/*/moles:dgActivityDataProject)) then  
     36else if (exists($SRAct/moles:dgActivity/moles:dgActivityDataProject)) then  
    3637($SRAct/*/moles:dgActivityDataProject) 
    37 else if (exists($SRAct/*/dgActivityDataCampaign)) then 
     38else if (exists($SRAct/moles:dgActivity/moles:dgActivityDataCampaign)) then 
    3839($SRAct/moles:dgActivity/moles:dgActivityDataCampaign) 
    3940else  
     
    4546} ; 
    4647 
    47 declare function f:return-stub-dataentity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()  
     48declare function f:return-stub-dataentity($out-element-name as xs:string, $DE as element()) as element()  
    4849(: Returns a 'stubB' style observation station record to expand an data entity record :) 
    4950(: Security not implemented yet :) 
    5051{ 
    51 for $SRDE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    52 moles:dgMetadataID/moles:localIdentifier=$locid 
    53 and 
    54 moles:dgMetadataID/moles:repositoryIdentifier=$repid  
    55 ]  
     52let $SRDE := $DE 
    5653return   
    5754element {$out-element-name} { 
     
    6057($SRDE/moles:name), 
    6158($SRDE/moles:abbreviation), 
     59($SRDE/moles:abbreviation), 
    6260element dgDataEntity { 
    6361($SRDE/moles:dgDataEntity/moles:dgDataSetType), 
     
    7270(: Security not implemented yet :) 
    7371{ 
    74 for $SRDPT in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     72let $SRDPT := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    7573moles:dgMetadataID/moles:localIdentifier=$locid 
    7674and 
     
    10098(: Security not implemented here yet;  :) 
    10199{ 
    102 for $SRObsStn in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     100let $SRObsStn := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    103101moles:dgMetadataID/moles:localIdentifier=$locid 
    104102and 
     
    111109($SRObsStn/moles:name), 
    112110($SRObsStn/moles:abbreviation), 
     111($SRObsStn/moles:logos), 
    113112element dgObservationStation { 
    114113($SRObsStn/moles:dgObservationStation/moles:contactDetails), 
     
    116115element dgStationaryPlatform { 
    117116$SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:position, 
    118 if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgLandStation)) then element dgLandStation {''} 
    119 else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgMooring)) then element dgMooring {''} 
    120 else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/dgStationGroup)) then element dgStationGroup {''} 
     117if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgLandStation)) then element dgLandStation {''} 
     118else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgMooring)) then element dgMooring {''} 
     119else if (exists($SRObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgStationGroup)) then element dgStationGroup {''} 
    121120else () 
    122121} 
     
    132131(: Security not implemented yet :) 
    133132{ 
    134 for $person in collection($targetCollection)/moles:dgMetadata/moles:dgPerson[ 
     133let $person := collection($targetCollection)/moles:dgMetadata/moles:dgPerson[ 
    135134moles:dgMetadataID/moles:localIdentifier=$locid 
    136135and 
     
    150149(: Security not implemented yet :) 
    151150{ 
    152 for $org in collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation[ 
     151let $org := collection($targetCollection)/moles:dgMetadata/moles:dgOrganisation[ 
    153152moles:dgMetadataID/moles:localIdentifier=$locid 
    154153and 
     
    165164} ; 
    166165 
    167 for $ObsStn in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
     166let $ObsStn := collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ 
    168167moles:dgObservationStation!=''  
    169168and moles:dgMetadataID[ 
     
    197196for $StationGrouping in $ObsStn/moles:dgObservationStation/moles:dgStationaryPlatform/moles:dgMooring/dgStationGrouping  
    198197return   
    199 f:return-stub-obsstn('stationgrouping', data($StationGrouping/moles:dgMetadataID/moles:repositoryIdentifier), data($StationGrouping/moles:dgMetadataID/moles:localIdentifier)) 
     198f:return-stub-obsstn('dgStationGrouping', data($StationGrouping/moles:dgMetadataID/moles:repositoryIdentifier), data($StationGrouping/moles:dgMetadataID/moles:localIdentifier)) 
    200199else () 
    201200} (: End </dgMooring> :)   
     
    220219f:return-stub-activity('activity', data($RelDep/moles:ActivityID/moles:repositoryIdentifier), data($RelDep/moles:ActivityID/moles:localIdentifier)), 
    221220f:return-stub-dpt('dataproductiontool', data($RelDep/moles:DataProductionToolID/moles:repositoryIdentifier), data($RelDep/moles:DataProductionToolID/moles:localIdentifier)),  
    222 for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord 
    223 where $DE/moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier 
    224 and $DE/moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier 
     221for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:repositoryIdentifier=$RelDep/moles:dgMetadataID/moles:repositoryIdentifier 
     222and moles:dgDataEntity/moles:RelatedDeployment/moles:dgMetadataID/moles:localIdentifier=$RelDep/moles:dgMetadataID/moles:localIdentifier] 
    225223return 
    226 f:return-stub-dataentity('dataentity', data($DE/moles:dgMetadataID/moles:repositoryIdentifier), data($DE/moles:dgMetadataID/moles:localIdentifier)), 
     224f:return-stub-dataentity('dataentity', $DE), 
    227225$RelDep/moles:Coverage 
    228226} (: </RelatedDeployment> :)  
Note: See TracChangeset for help on using the changeset viewer.