updated queries (SVN branch) as the porting to git ported the old ones

This commit is contained in:
Massimiliano Assante 2020-09-25 12:39:08 +02:00
parent f75abfeadd
commit 628ba14f41
14 changed files with 96 additions and 87 deletions

View File

@ -11,7 +11,7 @@
<groupId>org.gcube.portlets.admin</groupId>
<artifactId>rmp-common-library</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
<name>Resource Management Library</name>
<description>
gCube Resource Management Library is a common library containing shared code for Information System Operations

View File

@ -1,4 +1,7 @@
declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry';
for $resource in collection('/db/Profiles/<RES_TYPE ISdefault ='' />')//Document/Data/ic:Profile/Resource
where $resource/ID/string() eq '<RES_ID/>'
return $resource
let $_res_type := '<RES_TYPE ISdefault ='' />'
let $_res_id := '<RES_ID/>'
let $res_type := if (empty($_res_type)) then $_res_id else concat($_res_type, '/', $_res_id )
let $res_docname := concat('/db/Profiles/',$res_type)
let $res := doc($res_docname)//Document/Data/ic:Profile/Resource
return $res

View File

@ -4,25 +4,26 @@
# RES_TYPE the main type of the resource
# This query is used by forms
for $profiles in collection('/db/Profiles/<RES_TYPE ISdefault ='GHN' />')//Resource
let $ghn-name := $profiles//Resource/Profile/GHN/@UniqueID/string()
let $gcf-version := $profiles//Resource/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'gCF-version']/Value/text()
let $ghn-version := $profiles//Resource/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'GHN-distribution-version']/Value/text()
let $scopes := string-join( $profiles//Resource/Scopes//Scope/text(), ';')
declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry';
for $profiles in collection('/db/Profiles/<RES_TYPE ISdefault ='GHN' />')//Document/Data/ic:Profile/Resource
let $ghn-name := $profiles/Profile/GHN/@UniqueID/string()
let $gcf-version := $profiles/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'gCF-version']/Value/text()
let $ghn-version := $profiles/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'GHN-distribution-version']/Value/text()
let $scopes := string-join( $profiles/Scopes//Scope/text(), ';')
let $subtype :=
if ($profiles//Resource/Type eq "Service")
then $profiles//Resource/Profile/Class/text()
else if ($profiles//Resource/Type eq "RunningInstance")
then $profiles//Resource/Profile/ServiceClass/text()
else if ($profiles//Resource/Type eq "GenericResource")
then $profiles//Resource/Profile/SecondaryType/text()
else if ($profiles//Resource/Type eq "GHN")
then $profiles//Resource/Profile/Site/Domain/text()
else if ($profiles//Resource/Type eq "MetadataCollection")
then $profiles//Resource/Profile/MetadataFormat/Name/text()
else if ($profiles//Resource/Type eq "Collection" and ($profiles//Resource/Profile/IsUserCollection/string(@value) eq 'true'))
if ($profiles/Type eq "Service")
then $profiles/Profile/Class/text()
else if ($profiles/Type eq "RunningInstance")
then $profiles/Profile/ServiceClass/text()
else if ($profiles/Type eq "GenericResource")
then $profiles/Profile/SecondaryType/text()
else if ($profiles/Type eq "GHN")
then $profiles/Profile/Site/Domain/text()
else if ($profiles/Type eq "MetadataCollection")
then $profiles/Profile/MetadataFormat/Name/text()
else if ($profiles/Type eq "Collection" and ($profiles/Profile/IsUserCollection/string(@value) eq 'true'))
then "User"
else if ($profiles//Resource/Type eq "Collection" and ($profiles//Resource/Profile/IsUserCollection/string(@value) eq 'false'))
else if ($profiles/Type eq "Collection" and ($profiles/Profile/IsUserCollection/string(@value) eq 'false'))
then "System"
else ""
return

View File

@ -4,25 +4,26 @@
# RES_TYPE the main type of the resource
# This query is used by forms
for $profiles in collection('/db/Profiles/<RES_TYPE ISdefault ='GHN' />')//Resource
let $ghn-name := $profiles//Resource/Profile/GHN/@UniqueID/string()
let $gcf-version := $profiles//Resource/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'gCF-version']/Value/text()
let $ghn-version := $profiles//Resource/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'GHN-distribution-version']/Value/text()
let $scopes := string-join( $profiles//Resource/Scopes//Scope/text(), ';')
declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry';
for $profiles in collection('/db/Profiles/<RES_TYPE ISdefault ='GHN' />'))//Document/Data/ic:Profile/Resource
let $ghn-name := $profiles/Profile/GHN/@UniqueID/string()
let $gcf-version := $profiles/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'gCF-version']/Value/text()
let $ghn-version := $profiles/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'GHN-distribution-version']/Value/text()
let $scopes := string-join( $profiles/Scopes//Scope/text(), ';')
let $subtype :=
if ($profiles//Resource/Type eq "Service")
then $profiles//Resource/Profile/Class/text()
else if ($profiles//Resource/Type eq "RunningInstance")
then $profiles//Resource/Profile/ServiceClass/text()
else if ($profiles//Resource/Type eq "GenericResource")
then $profiles//Resource/Profile/SecondaryType/text()
else if ($profiles//Resource/Type eq "GHN")
then $profiles//Resource/Profile/Site/Domain/text()
else if ($profiles//Resource/Type eq "MetadataCollection")
then $profiles//Resource/Profile/MetadataFormat/Name/text()
else if ($profiles//Resource/Type eq "Collection" and ($profiles//Resource/Profile/IsUserCollection/string(@value) eq 'true'))
if ($profiles/Type eq "Service")
then $profiles/Profile/Class/text()
else if ($profiles/Type eq "RunningInstance")
then $profiles/Profile/ServiceClass/text()
else if ($profiles/Type eq "GenericResource")
then $profiles/Profile/SecondaryType/text()
else if ($profiles/Type eq "GHN")
then $profiles/Profile/Site/Domain/text()
else if ($profiles/Type eq "MetadataCollection")
then $profiles/Profile/MetadataFormat/Name/text()
else if ($profiles/Type eq "Collection" and ($profiles/Profile/IsUserCollection/string(@value) eq 'true'))
then "User"
else if ($profiles//Resource/Type eq "Collection" and ($profiles//Resource/Profile/IsUserCollection/string(@value) eq 'false'))
else if ($profiles/Type eq "Collection" and ($profiles/Profile/IsUserCollection/string(@value) eq 'false'))
then "System"
else ""
where $subtype eq '<RES_SUBTYPE ISdefault='isti.cnr.it'/>'

View File

@ -1,21 +1,22 @@
declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry';
let $type := '<RES_TYPE ISdefault ='MetadataCollection'/>'
let $subtypes :=
for $_profiles in collection('/db/Profiles/<RES_TYPE ISdefault ='MetadataCollection'/>')//Resource
for $_profiles in collection('/db/Profiles/<RES_TYPE ISdefault ='MetadataCollection'/>')//Document/Data/ic:Profile/Resource
let $elem := if ($type eq "Service")
then $_profiles//Resource/Profile/Class
then $_profiles/Profile/Class
else if ($type eq "RunningInstance")
then $_profiles//Resource/Profile/ServiceClass
then $_profiles/Profile/ServiceClass
else if ($type eq "GenericResource")
then $_profiles//Resource/Profile/SecondaryType
then $_profiles/Profile/SecondaryType
else if ($type eq "GHN")
then $_profiles//Resource/Profile/Site/Domain
then $_profiles/Profile/Site/Domain
else if ($type eq "MetadataCollection")
then $_profiles//Resource/Profile/MetadataFormat/Name
then $_profiles/Profile/MetadataFormat/Name
else if ($type eq "RuntimeResource")
then $_profiles//Resource/Profile/Category
else if ($type eq "Collection" and ($_profiles//Resource/Profile/IsUserCollection/string(@value) eq 'true'))
then $_profiles/Profile/Category
else if ($type eq "Collection" and ($_profiles/Profile/IsUserCollection/string(@value) eq 'true'))
then "User"
else if ($type eq "Collection" and ($_profiles//Resource/Profile/IsUserCollection/string(@value) eq 'false'))
else if ($type eq "Collection" and ($_profiles/Profile/IsUserCollection/string(@value) eq 'false'))
then "System"
else ""
return $elem

View File

@ -1,7 +1,8 @@
for $profiles in collection('/db/Profiles/GenericResource')//Resource, $wsresource in collection('/db/Properties')//Document
declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry';
for $profiles in collection('/db/Profiles/GenericResource')//Document/Data/ic:Profile/Resource, $wsresource in collection('/db/Properties')//Document
let $scopes := string-join( $profiles/Scopes//Scope/text(), ';')
let $subtype := $profiles//Resource/Profile/SecondaryType/text()
where $subtype = "DataSource" and $profiles//Resource/ID eq $wsresource/SourceKey and $wsresource/Data//child::*[local-name()='ServiceName']/string() eq 'tree-manager-service'
where $subtype = "DataSource" and $profiles/ID eq $wsresource/SourceKey and $wsresource/Data//child::*[local-name()='ServiceName']/string() eq 'tree-manager-service'
<RES_SUBTYPE ISdefault =''/>
return
<RESOURCE/>

View File

@ -1,8 +1,9 @@
for $profiles in collection('/db/Profiles/GHN')//Resource
let $gcf-version := $profiles//Resource/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'gCF-version']/Value/text() | $profiles//Resource/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'SmartGears']/Value/text()
let $ghn-version := $profiles//Resource/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'GHN-distribution-version']/Value/text() | $profiles//Resource/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'SmartGearsDistribution']/Value/text()
declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry';
for $profiles in collection('/db/Profiles/GHN')//Document/Data/ic:Profile/Resource
let $gcf-version := $profiles/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'gCF-version']/Value/text() | $profiles/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'SmartGears']/Value/text()
let $ghn-version := $profiles/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'GHN-distribution-version']/Value/text() | $profiles/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'SmartGearsDistribution']/Value/text()
let $scopes := string-join( $profiles/Scopes//Scope/text(), ';')
let $subtype := $profiles//Resource/Profile/Site/Domain/text()
let $subtype := $profiles/Profile/Site/Domain/text()
<RES_SUBTYPE ISdefault =''/>
return
<RESOURCE/>

View File

@ -1,17 +1,17 @@
<Resource>
{$profiles//Resource/ID}
<Type>{$profiles//Resource/Type/text()}</Type>
{$profiles/ID}
<Type>{$profiles/Type/text()}</Type>
<SubType>{$subtype}</SubType>
<Status>{$profiles//Resource/Profile/GHNDescription/Status/text()}</Status>
<Name>{$profiles//Resource/Profile/GHNDescription/Name/text()}</Name>
<Uptime>{$profiles//Resource/Profile/GHNDescription/Uptime/text()}</Uptime>
<LastUpdate>{$profiles//Resource/Profile/GHNDescription/LastUpdate/text()}</LastUpdate>
<LocalAvailableSpace>{$profiles//Resource/Profile/GHNDescription/LocalAvailableSpace/text()}</LocalAvailableSpace>
<VirtualSize>{$profiles//Resource/Profile/GHNDescription/MainMemory/string(@VirtualSize)}</VirtualSize>
<VirtualAvailable>{$profiles//Resource/Profile/GHNDescription/MainMemory/string(@VirtualAvailable)}</VirtualAvailable>
<LoadLast1Min>{$profiles//Resource/Profile/GHNDescription/Load/string(@Last1Min)}</LoadLast1Min>
<LoadLast5Min>{$profiles//Resource/Profile/GHNDescription/Load/string(@Last5Min)}</LoadLast5Min>
<LoadLast15Min>{$profiles//Resource/Profile/GHNDescription/Load/string(@Last15Min)}</LoadLast15Min>
<Status>{$profiles/Profile/GHNDescription/Status/text()}</Status>
<Name>{$profiles/Profile/GHNDescription/Name/text()}</Name>
<Uptime>{$profiles/Profile/GHNDescription/Uptime/text()}</Uptime>
<LastUpdate>{$profiles/Profile/GHNDescription/LastUpdate/text()}</LastUpdate>
<LocalAvailableSpace>{$profiles/Profile/GHNDescription/LocalAvailableSpace/text()}</LocalAvailableSpace>
<VirtualSize>{$profiles/Profile/GHNDescription/MainMemory/string(@VirtualSize)}</VirtualSize>
<VirtualAvailable>{$profiles/Profile/GHNDescription/MainMemory/string(@VirtualAvailable)}</VirtualAvailable>
<LoadLast1Min>{$profiles/Profile/GHNDescription/Load/string(@Last1Min)}</LoadLast1Min>
<LoadLast5Min>{$profiles/Profile/GHNDescription/Load/string(@Last5Min)}</LoadLast5Min>
<LoadLast15Min>{$profiles/Profile/GHNDescription/Load/string(@Last15Min)}</LoadLast15Min>
<gcf-version>{$gcf-version}</gcf-version>
<ghn-version>{$ghn-version}</ghn-version>
<Scopes>{$scopes}</Scopes>

View File

@ -1,8 +1,8 @@
<Resource>
{$profiles//Resource/ID}
{$profiles/ID}
<Type>{$profiles//Resource/Type/text()}</Type>
<SubType>{$subtype}</SubType>
<Scopes>{$scopes}</Scopes>
<Name>{$profiles//Resource/Profile/Name/text()}</Name>
<Description>{$profiles//Resource/Profile/Description/text()}</Description>
<Name>{$profiles/Profile/Name/text()}</Name>
<Description>{$profiles/Profile/Description/text()}</Description>
</Resource>

View File

@ -1,8 +1,8 @@
<Resource>
{$profiles//Resource/ID}
<Type>{$profiles//Resource/Type/text()}</Type>
{$profiles/ID}
<Type>{$profiles/Type/text()}</Type>
<SubType>{$subtype}</SubType>
<Scopes>{$scopes}</Scopes>
<Name>{$profiles//Resource/Profile/Name/text()}</Name>
<Host>{$profiles//Resource/Profile/RunTime/HostedOn/text()}</Host>
<Name>{$profiles/Profile/Name/text()}</Name>
<Host>{$profiles/Profile/RunTime/HostedOn/text()}</Host>
</Resource>

View File

@ -1,10 +1,10 @@
<Resource>
{$profiles//Resource/ID}
<Type>{$profiles//Resource/Type/text()}</Type>
{$profiles/ID}
<Type>{$profiles/Type/text()}</Type>
<SubType>{$subtype}</SubType>
<Scopes>{$scopes}</Scopes>
<ServiceClass>{$profiles//Resource/Profile/Class/text()}</ServiceClass>
<ServiceName>{$profiles//Resource/Profile/Name/text()}</ServiceName>
<Version>{$profiles//Resource/Profile/Packages/Software[1]/Version/text()}</Version>
<Shareable>{$profiles//Resource/Profile/Packages/Software/Shareable/string(@level)}</Shareable>
<ServiceClass>{$profiles/Profile/Class/text()}</ServiceClass>
<ServiceName>{$profiles/Profile/Name/text()}</ServiceName>
<Version>{$profiles/Profile/Packages/Software[1]/Version/text()}</Version>
<Shareable>{$profiles/Profile/Packages/Software/Shareable/string(@level)}</Shareable>
</Resource>

View File

@ -1,8 +1,7 @@
for $profiles in collection('/db/Profiles/RunningInstance')//Resource
let $ghns := collection('/db/Profiles/GHN')//Resource
let $_ghn-name := for $ghn in $ghns
where $ghn/ID/string() eq $profiles/Profile/GHN/@UniqueID/string()
return $ghn/Profile/GHNDescription/Name/string()
declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry';
for $profiles in collection('/db/Profiles/RunningInstance')//Document/Data/ic:Profile/Resource
let $docname := concat('/db/Profiles/GHN/',$profiles/Profile/GHN/@UniqueID/string())
let $_ghn-name := doc($docname)//Document/Data/ic:Profile/Resource/Profile/GHNDescription/Name/string()
let $ghn-name := if (empty($_ghn-name)) then $profiles/Profile/GHN/@UniqueID/string() else $_ghn-name
let $scopes := string-join( $profiles/Scopes//Scope/text(), ';')
let $subtype := $profiles/Profile/ServiceClass/text()

View File

@ -1,6 +1,7 @@
for $profiles in collection('/db/Profiles/RuntimeResource')//Resource
declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry';
for $profiles in collection('/db/Profiles/RuntimeResource')//Document/Data/ic:Profile/Resource
let $scopes := string-join( $profiles/Scopes//Scope/text(), ';')
let $subtype := $profiles//Resource/Profile/Category/text()
let $subtype := $profiles/Profile/Category/text()
<RES_SUBTYPE ISdefault =''/>
return
<RESOURCE/>

View File

@ -1,6 +1,7 @@
for $profiles in collection('/db/Profiles/Service')//Resource
declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry';
for $profiles in collection('/db/Profiles/Service')//Document/Data/ic:Profile/Resource
let $scopes := string-join( $profiles/Scopes//Scope/text(), ';')
let $subtype := $profiles//Resource/Profile/Class/text()
let $subtype := $profiles/Profile/Class/text()
<RES_SUBTYPE ISdefault =''/>
return
<RESOURCE/>