diff --git a/pom.xml b/pom.xml index 9a041fd..e74a9dc 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.gcube.portlets.admin rmp-common-library - 2.8.2-SNAPSHOT + 2.8.3-SNAPSHOT Resource Management Library gCube Resource Management Library is a common library containing shared code for Information System Operations diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getResourceByID.xq b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getResourceByID.xq index 9a394d6..6590a52 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getResourceByID.xq +++ b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getResourceByID.xq @@ -1,4 +1,7 @@ declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry'; -for $resource in collection('/db/Profiles/')//Document/Data/ic:Profile/Resource -where $resource/ID/string() eq '' -return $resource \ No newline at end of file +let $_res_type := '' +let $_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 \ No newline at end of file diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getResourcesDetails.xq b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getResourcesDetails.xq index b732bc4..e6ad876 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getResourcesDetails.xq +++ b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getResourcesDetails.xq @@ -4,25 +4,26 @@ # RES_TYPE the main type of the resource # This query is used by forms -for $profiles in collection('/db/Profiles/')//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/')//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 diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getResourcesDetailsSubtype.xq b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getResourcesDetailsSubtype.xq index 3ce789f..75e2dae 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getResourcesDetailsSubtype.xq +++ b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getResourcesDetailsSubtype.xq @@ -4,25 +4,26 @@ # RES_TYPE the main type of the resource # This query is used by forms -for $profiles in collection('/db/Profiles/')//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/'))//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 '' diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getSubTypes.xq b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getSubTypes.xq index 640f883..208cbcc 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getSubTypes.xq +++ b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/getSubTypes.xq @@ -1,21 +1,22 @@ +declare namespace ic = 'http://gcube-system.org/namespaces/informationsystem/registry'; let $type := '' let $subtypes := - for $_profiles in collection('/db/Profiles/')//Resource + for $_profiles in collection('/db/Profiles/')//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 diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/Collection.xq b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/Collection.xq index 2b8c939..8711b27 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/Collection.xq +++ b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/Collection.xq @@ -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' return diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/GHN.xq b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/GHN.xq index 8214a21..90692d9 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/GHN.xq +++ b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/GHN.xq @@ -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() return diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_GHN.xq b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_GHN.xq index b86ec60..6b2e7a3 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_GHN.xq +++ b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_GHN.xq @@ -1,17 +1,17 @@ - {$profiles//Resource/ID} - {$profiles//Resource/Type/text()} + {$profiles/ID} + {$profiles/Type/text()} {$subtype} - {$profiles//Resource/Profile/GHNDescription/Status/text()} - {$profiles//Resource/Profile/GHNDescription/Name/text()} - {$profiles//Resource/Profile/GHNDescription/Uptime/text()} - {$profiles//Resource/Profile/GHNDescription/LastUpdate/text()} - {$profiles//Resource/Profile/GHNDescription/LocalAvailableSpace/text()} - {$profiles//Resource/Profile/GHNDescription/MainMemory/string(@VirtualSize)} - {$profiles//Resource/Profile/GHNDescription/MainMemory/string(@VirtualAvailable)} - {$profiles//Resource/Profile/GHNDescription/Load/string(@Last1Min)} - {$profiles//Resource/Profile/GHNDescription/Load/string(@Last5Min)} - {$profiles//Resource/Profile/GHNDescription/Load/string(@Last15Min)} + {$profiles/Profile/GHNDescription/Status/text()} + {$profiles/Profile/GHNDescription/Name/text()} + {$profiles/Profile/GHNDescription/Uptime/text()} + {$profiles/Profile/GHNDescription/LastUpdate/text()} + {$profiles/Profile/GHNDescription/LocalAvailableSpace/text()} + {$profiles/Profile/GHNDescription/MainMemory/string(@VirtualSize)} + {$profiles/Profile/GHNDescription/MainMemory/string(@VirtualAvailable)} + {$profiles/Profile/GHNDescription/Load/string(@Last1Min)} + {$profiles/Profile/GHNDescription/Load/string(@Last5Min)} + {$profiles/Profile/GHNDescription/Load/string(@Last15Min)} {$gcf-version} {$ghn-version} {$scopes} diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_GenericResource.xq b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_GenericResource.xq index e7862a4..9095376 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_GenericResource.xq +++ b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_GenericResource.xq @@ -1,8 +1,8 @@ - {$profiles//Resource/ID} + {$profiles/ID} {$profiles//Resource/Type/text()} {$subtype} {$scopes} - {$profiles//Resource/Profile/Name/text()} - {$profiles//Resource/Profile/Description/text()} + {$profiles/Profile/Name/text()} + {$profiles/Profile/Description/text()} \ No newline at end of file diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_RuntimeResource.xq b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_RuntimeResource.xq index a9296d1..acf762d 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_RuntimeResource.xq +++ b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_RuntimeResource.xq @@ -1,8 +1,8 @@ - {$profiles//Resource/ID} - {$profiles//Resource/Type/text()} + {$profiles/ID} + {$profiles/Type/text()} {$subtype} {$scopes} - {$profiles//Resource/Profile/Name/text()} - {$profiles//Resource/Profile/RunTime/HostedOn/text()} + {$profiles/Profile/Name/text()} + {$profiles/Profile/RunTime/HostedOn/text()} \ No newline at end of file diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_Service.xq b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_Service.xq index 42f770f..45da8ea 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_Service.xq +++ b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RETURN_Service.xq @@ -1,10 +1,10 @@ - {$profiles//Resource/ID} - {$profiles//Resource/Type/text()} + {$profiles/ID} + {$profiles/Type/text()} {$subtype} {$scopes} - {$profiles//Resource/Profile/Class/text()} - {$profiles//Resource/Profile/Name/text()} - {$profiles//Resource/Profile/Packages/Software[1]/Version/text()} - {$profiles//Resource/Profile/Packages/Software/Shareable/string(@level)} + {$profiles/Profile/Class/text()} + {$profiles/Profile/Name/text()} + {$profiles/Profile/Packages/Software[1]/Version/text()} + {$profiles/Profile/Packages/Software/Shareable/string(@level)} \ No newline at end of file diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RunningInstance.xq b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RunningInstance.xq index 0fbceb3..9472b70 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RunningInstance.xq +++ b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RunningInstance.xq @@ -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() diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RuntimeResource.xq b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RuntimeResource.xq index 8dba6fc..005e015 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RuntimeResource.xq +++ b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/RuntimeResource.xq @@ -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() return diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/Service.xq b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/Service.xq index e08ff29..24ecf71 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/Service.xq +++ b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/Service.xq @@ -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() return \ No newline at end of file