Massimiliano Assante 11 years ago
parent 7efab18307
commit 146c7a2cba

@ -0,0 +1,73 @@
/****************************************************************************
* This software is part of the gCube Project.
* Site: http://www.gcube-system.org/
****************************************************************************
* The gCube/gCore software is licensed as Free Open Source software
* conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
* The software and documentation is provided by its authors/distributors
* "as is" and no expressed or
* implied warranty is given for its use, quality or fitness for a
* particular case.
****************************************************************************
* Filename: QueryLoader.java
****************************************************************************
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
***************************************************************************/
package org.gcube.resourcemanagement.support.server.gcube.queries;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import org.gcube.resourcemanagement.support.server.utils.ServerConsole;
/**
* Resource_support utility to load at runtime the customized queries to submit to
* the IS.
* @author Daniele Strollo
* @author Massimiliano Assante (ISTI-CNR)
*/
public class QueryLoader {
private static final HashMap<QueryLocation, String> cachedQueries = new HashMap<QueryLocation, String>();
private static final String LOG_PREFIX = "[QUERY-LOADER]";
/**
* @param query the location of query file to load
* @return the string consisting of the xquery to submit to the server
* @throws Exception
*/
public static String getQuery(final QueryLocation query) throws Exception {
if (query == null) {
throw new Exception("Invalid query parameter. Null not allowed.");
}
ServerConsole.trace(LOG_PREFIX, "loading " + query.name());
if (query != null && cachedQueries.containsKey(query)) {
return cachedQueries.get(query);
}
BufferedReader in = new BufferedReader(new InputStreamReader(query.getFileName()));
StringBuilder retval = new StringBuilder();
String currLine = null;
while ((currLine = in.readLine()) != null) {
// a comment
if (currLine.trim().length() > 0 && currLine.trim().startsWith("#")) {
continue;
}
if (currLine.trim().length() == 0) { continue; }
retval.append(currLine + System.getProperty("line.separator"));
}
in.close();
String tmp = retval.toString();
if (cachedQueries != null) {
cachedQueries.put(query, tmp);
}
return tmp;
}
}

@ -0,0 +1,79 @@
/****************************************************************************
* This software is part of the gCube Project.
* Site: http://www.gcube-system.org/
****************************************************************************
* The gCube/gCore software is licensed as Free Open Source software
* conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
* The software and documentation is provided by its authors/distributors
* "as is" and no expressed or
* implied warranty is given for its use, quality or fitness for a
* particular case.
****************************************************************************
* Filename: QueryLocator.java
****************************************************************************
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
***************************************************************************/
package org.gcube.resourcemanagement.support.server.gcube.queries;
import java.io.InputStream;
/**
* Keeps the association between an xquery and the path
* on which it can be retrieved.
* @author Daniele Strollo
* @author Massimiliano Assante (ISTI-CNR)
*/
public enum QueryLocation {
// These two queries are needed to build the tree of resource types and subtypes
// for resources different from wsresources.
GET_TREE_TYPES("getTypes.xq"),
GET_TREE_SUBTYPES("getSubTypes.xq"),
// Customized queries to retrieve the relevant data from resources
// according to their type
LIST_GHN("resources/GHN.xq"),
LIST_Collection("resources/Collection.xq"),
LIST_VIEW("resources/VIEW.xq"),
LIST_Service("resources/Service.xq"),
LIST_GenericResource("resources/GenericResource.xq"),
LIST_RunningInstance("resources/RunningInstance.xq"),
LIST_RuntimeResource("resources/RuntimeResource.xq"),
// To retrieve the list of generic resources publishing plugins
// to deploy activation records
GET_GENERIC_RESOURCE_PLUGINS("getPlugins.xq"),
// to deploy activation records for Tree manager
GET_GENERIC_RESOURCE_TREE_MANAGER_PLUGINS("getTreeManagerPlugins.xq"),
// Related resources
LIST_RELATED_GHN("related/GHN.xq"),
LIST_RELATED_RunningInstance("related/RunningInstance.xq"),
LIST_RELATED_Service("related/Service.xq"),
// Queries for sweeper
SWEEPER_EXPIRED_GHN("sweeper/expiredGhns.xq"),
SWEEPER_DEAD_GHN("sweeper/deadGhns.xq"),
SWEEPER_ORPHAN_RI("sweeper/orphanRI.xq"),
// Used to build the gwt model representation inside dialogs.
// see getResourceModels inside ISClientRequester.
GET_RES_DETAILS_BYTYPE("getResourcesDetails.xq"),
GET_RES_DETAILS_BYSUBTYPE("getResourcesDetailsSubtype.xq"),
GET_RESOURCE_BYID("getResourceByID.xq"),
GET_WSRES_TYPES("getWSResourcesTypes.xq"),
GET_WSRES_DETAILS_BYTYPE("getWSResourcesDetails.xq"),
GET_WSRES_DETAILS_BYSUBTYPE("getWSResourcesDetailsSubType.xq"),
GET_WSRESOURCE_BYID("getWSResourceByID.xq");
private final String path = "org/gcube/resourcemanagement/support/server/gcube/queries/xquery/";
private String filename = null;
QueryLocation(final String filename) {
this.filename = filename;
}
public InputStream getFileName() {
return this.getClass().getClassLoader().getResourceAsStream(this.path + this.filename);
}
}

@ -0,0 +1,33 @@
for $_outer in collection("/db/Properties")//Document
where ($_outer//Document/Data/child::*[local-name()='ServiceClass']/text() = 'ContentManagement'
and exists($_outer/Data/child::*[local-name()='Plugin']/name))
return
<CMPlugins>
{
for $plugin in $_outer/Data/child::*[local-name()='Plugin']
return
<Plugin>
{
for $elem in $plugin/parameters/child::*
return
<Entry>
{$plugin/name}
{$plugin/description}
<namespace>{namespace-uri($elem)}</namespace>
<Type>{local-name($elem)}</Type>
<Params>
{
for $p in $elem/child::*
return
<param>
<param-name>{$p/name()}</param-name>
<param-definition>{$p/text()}</param-definition>
</param>
}
</Params>
</Entry>
}
</Plugin>
}
</CMPlugins>

@ -0,0 +1,8 @@
#
# Params: RES_ID the ID of looked up resource
# RES_TYPE (option) the type of searched resource
for $resource in collection('/db/Profiles/<RES_TYPE ISdefault =''>')//Resource
where $resource/ID/string() eq '<RES_ID/>'
return $resource

@ -0,0 +1,36 @@
# Given a couple of (type, subtype) retrieves
# the list of all resources contained in such category.
# Parameters:
# 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(), ';')
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'))
then "User"
else if ($profiles//Resource/Type eq "Collection" and ($profiles//Resource/Profile/IsUserCollection/string(@value) eq 'false'))
then "System"
else ""
return
<Resource>
{$profiles//Resource/child::*}
<SubType>{$subtype}</SubType>
<gcf-version>{$gcf-version}</gcf-version>
<ghn-version>{$ghn-version}</ghn-version>
<scopes>{$scopes}</scopes>
<ghn-name>{$ghn-name}</ghn-name>
</Resource>

@ -0,0 +1,37 @@
# Given a couple of (type, subtype) retrieves
# the list of all resources contained in such category.
# Parameters:
# 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(), ';')
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'))
then "User"
else if ($profiles//Resource/Type eq "Collection" and ($profiles//Resource/Profile/IsUserCollection/string(@value) eq 'false'))
then "System"
else ""
where $subtype eq '<RES_SUBTYPE ISdefault='isti.cnr.it'/>'
return
<Resource>
{$profiles//Resource/child::*}
<SubType>{$subtype}</SubType>
<gcf-version>{$gcf-version}</gcf-version>
<ghn-version>{$ghn-version}</ghn-version>
<scopes>{$scopes}</scopes>
<ghn-name>{$ghn-name}</ghn-name>
</Resource>

@ -0,0 +1,27 @@
let $type := '<RES_TYPE ISdefault ='MetadataCollection'/>'
let $subtypes :=
for $_profiles in collection('/db/Profiles/<RES_TYPE ISdefault ='MetadataCollection'/>')//Resource
let $elem := if ($type eq "Service")
then $_profiles//Resource/Profile/Class
else if ($type eq "RunningInstance")
then $_profiles//Resource/Profile/ServiceClass
else if ($type eq "GenericResource")
then $_profiles//Resource/Profile/SecondaryType
else if ($type eq "GHN")
then $_profiles//Resource/Profile/Site/Domain
else if ($type eq "MetadataCollection")
then $_profiles//Resource/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 "User"
else if ($type eq "Collection" and ($_profiles//Resource/Profile/IsUserCollection/string(@value) eq 'false'))
then "System"
else ""
return $elem
<!--
return $elem
-->
for $subtype in distinct-values($subtypes)
return
<subtype>{$subtype}</subtype>

@ -0,0 +1,29 @@
for $_outer in collection("/db/Properties")//Document
where ($_outer//Document/Data/child::*[local-name()='ServiceClass']/text() = 'DataAccess'
and exists($_outer/Data/child::*[local-name()='Plugin']/name))
return
<TMPlugins>
{
for $plugin in $_outer/Data/child::*[local-name()='Plugin']
return
<Plugin>
<Entry>
{$plugin/name}
{$plugin/description}
<namespace>{namespace-uri($plugin)}</namespace>
<Type>treeManagerPlugin</Type>
<Params>
{
for $elem in $plugin/child::*[local-name()='property']
return
<param>
<param-name>{$elem/name/text()}</param-name>
<param-definition>{$elem/value/text()}</param-definition>
</param>
}
</Params>
</Entry>
</Plugin>
}
</TMPlugins>

@ -0,0 +1,4 @@
let $entry0ValueAuth := collection("/db/Profiles")//Resource
for $types in distinct-values($entry0ValueAuth//Resource/Type/text())
return <type>{$types}</type>

@ -0,0 +1,4 @@
for $resource in collection("/db/Properties")//Document
where $resource/ID/string() eq '<RES_ID/>'
return $resource

@ -0,0 +1,16 @@
for $_outer in collection("/db/Properties")//Document
let $_scopes := string-join( $_outer//Document/Data/child::*[local-name()='Scope']/text(), ';')
return
<WSResource>
{$_outer//Document/ID}
{$_outer//Document/Source}
{$_outer//Document/SourceKey}
<ServiceClass>{$_outer//Document/Data/child::*[local-name()='ServiceClass']/text()}</ServiceClass>
<ServiceName>{$_outer//Document/Data/child::*[local-name()='ServiceName']/text()}</ServiceName>
<SubType>{$_outer//Document/Data/child::*[local-name()='ServiceClass']/text()}</SubType>
{$_outer//Document/TerminationTimeHuman}
{$_outer//Document/LastUpdateHuman}
<RI>{$_outer//Document/Data/child::*[local-name()='RI']/text()}</RI>
<Type>WSResource</Type>
<scopes>{$_scopes}</scopes>
</WSResource>

@ -0,0 +1,17 @@
for $outer in collection("/db/Properties")//Document
let $scopes := string-join( $outer//Document/Data/child::*[local-name()='Scope']/text(), ';')
where $outer//Document/Data/child::*[local-name()='ServiceClass']/text() eq '<RES_SUBTYPE/>'
return
<WSResource>
{$outer//Document/ID}
{$outer//Document/Source}
{$outer//Document/SourceKey}
<ServiceClass>{$outer//Document/Data/child::*[local-name()='ServiceClass']/text()}</ServiceClass>
<ServiceName>{$outer//Document/Data/child::*[local-name()='ServiceName']/text()}</ServiceName>
<SubType>{$outer//Document/Data/child::*[local-name()='ServiceClass']/text()}</SubType>
{$outer//Document/TerminationTimeHuman}
{$outer//Document/LastUpdateHuman}
<RI>{$outer//Document/Data/child::*[local-name()='RI']/text()}</RI>
<Type>WSResource</Type>
<scopes>{$scopes}</scopes>
</WSResource>

@ -0,0 +1,5 @@
let $tempcollection := for $outer in collection("/db/Properties")//Document
return $outer//Document/Data/child::*[local-name()='ServiceClass']
for $elem in distinct-values($tempcollection)
return $elem

@ -0,0 +1,25 @@
<!--
Retrieves the list of RunningInstances on a GHN.
Params:
RES_ID - the GHN id on which lookup the RIs
Result sample:
<Resource>
<ID>8ced4e40-ecf1-11df-95dd-c203e806a114</ID>
<ServiceName>ResourceManager</ServiceName>
<ServiceClass>VREManagement</ServiceClass>
<ServiceVersion>1.0.1</ServiceVersion>
<MainVersion>2.00.00</MainVersion>
<Status>ready</Status>
</Resource>
-->
for $ris in collection('/db/Profiles/RunningInstance')//Resource
where $ris//Resource/Profile/GHN/@UniqueID/string() eq '<RES_ID/>'
return
<Resource>
{$ris/ID}
{$ris/Profile/ServiceName}
{$ris/Profile/ServiceClass}
<ServiceVersion>{$ris//Resource/@version/string()}</ServiceVersion>
<MainVersion>{$ris/Profile/Version/text()}</MainVersion>
<Status>{$ris/Profile/DeploymentData/Status/text()}</Status>
</Resource>

@ -0,0 +1,55 @@
<!--
Notice: the <Resources> node must be removed in using the resource grid factory.
-->
let $profiles := collection('/db/Profiles/<RES_TYPE ISdefault ='RunningInstance'>')//Resource[ID/string() eq '<RES_ID/>']
let $relatedghn := collection('/db/Profiles/GHN')//Resource[ID/string() eq $profiles/Profile/GHN/@UniqueID/string()]
let $ghn-name := if (empty($relatedghn/Profile/GHNDescription/Name/string()))
then $profiles/Profile/GHN/@UniqueID/string()
else $relatedghn/Profile/GHNDescription/Name/string()
for $ri in $profiles
return
<Resources>
<Resource>
<Key>ID</Key>
<Value>{$ri//Resource/ID/string()}</Value>
</Resource>
<Resource>
<Key>ServiceStatus</Key>
<Value>{$ri/Profile/DeploymentData/Status/string()}</Value>
</Resource>
<Resource>
<Key>ActivationTime</Key>
<Value>{$ri/Profile/DeploymentData/ActivationTime/@value/string()}</Value>
</Resource>
<Resource>
<Key>GHNName</Key>
<Value>{$ghn-name}</Value>
</Resource>
<Resource>
<Key>GHNSite</Key>
<Value>{$relatedghn/Profile/Site/Domain/string()}</Value>
</Resource>
<Resource>
<Key>GHNStatus</Key>
<Value>{$relatedghn/Profile/GHNDescription/Status/string()}</Value>
</Resource>
<Resource>
<Key>GHNActivationTime</Key>
<Value>{$relatedghn/Profile/GHNDescription/ActivationTime/string()}</Value>
</Resource>
<Resource>
<Key>GHNLastUpdate</Key>
<Value>{$relatedghn/Profile/GHNDescription/LastUpdate/string()}</Value>
</Resource>
<Resource>
<Key>GHNLoad15Min</Key>
<Value>{$relatedghn/Profile/GHNDescription/Load/@Last15Min/string()}</Value>
</Resource>
<Resource>
<Key>GHNLoad5Min</Key>
<Value>{$relatedghn/Profile/GHNDescription/Load/@Last5Min/string()}</Value>
</Resource><Resource>
<Key>GHNLoad1Min</Key>
<Value>{$relatedghn/Profile/GHNDescription/Load/@Last1Min/string()}</Value>
</Resource>
</Resources>

@ -0,0 +1,36 @@
<!--
PARAMETS:
RES_ID the ID of the Service
-->
let $service := collection('/db/Profiles/Service')//Resource//Resource[ID/text() eq '<RES_ID/>']
let $ServiceClass := $service/Profile/Class
let $ServiceName := $service/Profile/Name
let $ServiceVersion := $service/Profile/Version
let $riloop := collection('/db/Profiles/RunningInstance')//Resource[Profile/ServiceClass/string() eq $ServiceClass and Profile/ServiceName/string() eq $ServiceName]
let $relatedris :=
for $ri in $riloop
let $ghn-id := $ri/Profile/GHN/@UniqueID/string()
let $ghn := collection('/db/Profiles/GHN')//Resource[ID/string() eq $ghn-id]
<!-- and $ri//Profile/Version/string() eq $ServiceVersion -->
return
<Resource>
<!-- INFORMATION ABOUT THE RI -->
<RIID>{$ri/ID/string()}</RIID>
<ServiceStatus>{$ri/Profile/DeploymentData/Status/string()}</ServiceStatus>
<ActivationTime>{$ri/Profile/DeploymentData/ActivationTime/@value/string()}</ActivationTime>
<RIVersion>{$ri/Profile/Version/string()}</RIVersion>
<!-- INFORMATION about GHN -->
<GHNID>{$ghn-id}</GHNID>
<GHNName>{$ghn/Profile/GHNDescription/Name/string()}</GHNName>
<GHNSite>{$ghn/Profile/Site/Domain/string()}</GHNSite>
<GHNStatus>{$ghn/Profile/GHNDescription/Status/string()}</GHNStatus>
<GHNLoad15Min>{$ghn/Profile/GHNDescription/Load/@Last15Min/string()}</GHNLoad15Min>
<GHNLoad5Min>{$ghn/Profile/GHNDescription/Load/@Last15Min/string()}</GHNLoad5Min>
<GHNLoad1Min>{$ghn/Profile/GHNDescription/Load/@Last15Min/string()}</GHNLoad1Min>
<GHNActivationTime>{$ghn/Profile/GHNDescription/ActivationTime/string()}</GHNActivationTime>
<GHNLastUpdate>{$ghn/Profile/GHNDescription/LastUpdate/string()}</GHNLastUpdate>
</Resource>
return
<Resources>
{$relatedris}
</Resources>

@ -0,0 +1,22 @@
<!--
RES_SUBTYPE subtype parameters can be passed by expressing:
where $subtype = "TheSubType" and $wsresource/Data//child::*[local-name()='Type'][0]/string() eq 'gDocRead'
-->
for $profiles in collection('/db/Profiles/GenericResource')//Resource, $wsresource in collection('/db/Properties')//Document
let $scopes := string-join( $profiles/Scopes//Scope/text(), ';')
let $subtype := $profiles//Resource/Profile/SecondaryType/text()
where $subtype = "GCUBECollection" and $profiles//Resource/ID eq $wsresource/SourceKey and $wsresource/Data//child::*[local-name()='Type']/string() eq 'gDocRead'
<RES_SUBTYPE ISdefault =''/>
return
<Resource>
{$profiles//Resource/ID}
<Type>{$profiles//Resource/Type/text()}</Type>
<SubType>{$subtype}</SubType>
<Scopes>{$scopes}</Scopes>
<Name>{$profiles//Resource/Profile/Name/text()}</Name>
<CreationTime>{$profiles//Resource/Profile/Body/CollectionInfo/creationTime/text()}</CreationTime>
<LastUpdateTime>{$wsresource/LastUpdateHuman/text()}</LastUpdateTime>
<NumberOfMembers>{$wsresource//child::*[local-name()='Cardinality']/text()}</NumberOfMembers>
</Resource>

@ -0,0 +1,30 @@
<!--
gets the compressed description of all GHNs published in a scope
-->
for $profiles in collection('/db/Profiles/GHN')//Resource
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/Scopes//Scope/text(), ';')
let $subtype := $profiles//Resource/Profile/Site/Domain/text()
<RES_SUBTYPE ISdefault =''/>
return
<Resource>
{$profiles//Resource/ID}
<Type>{$profiles//Resource/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>
<gcf-version>{$gcf-version}</gcf-version>
<ghn-version>{$ghn-version}</ghn-version>
<Scopes>{$scopes}</Scopes>
</Resource>

@ -0,0 +1,15 @@
for $profiles in collection('/db/Profiles/GenericResource')//Resource
let $scopes := string-join( $profiles/Scopes//Scope/text(), ';')
let $subtype := $profiles//Resource/Profile/SecondaryType/text()
<RES_SUBTYPE ISdefault =''/>
return
<Resource>
{$profiles//Resource/ID}
<Type>{$profiles//Resource/Type/text()}</Type>
<SubType>{$subtype}</SubType>
<Scopes>{$scopes}</Scopes>
<Name>{$profiles//Resource/Profile/Name/text()}</Name>
</Resource>

@ -0,0 +1,26 @@
for $profiles in collection('/db/Profiles/RunningInstance')//Resource
<!--
let $ghn-name := $profiles/Profile/GHN/@UniqueID/string()
-->
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()
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()
<RES_SUBTYPE ISdefault =''/>
return
<Resource>
{$profiles/ID}
<Type>{$profiles/Type/text()}</Type>
<SubType>{$subtype}</SubType>
<Scopes>{$scopes}</Scopes>
<ServiceClass>{$profiles/Profile/ServiceClass/text()}</ServiceClass>
<ServiceName>{$profiles/Profile/ServiceName/text()}</ServiceName>
<Version>{$profiles/Profile/Version/text()}</Version>
<Status>{$profiles/Profile/DeploymentData/Status/text()}</Status>
<ghn-name>{$ghn-name}</ghn-name>
</Resource>

@ -0,0 +1,12 @@
for $profiles in collection('/db/Profiles/RuntimeResource')//Resource
let $scopes := string-join( $profiles/Scopes//Scope/text(), ';')
let $subtype := $profiles//Resource/Profile/Category/text()
<RES_SUBTYPE ISdefault =''/>
return
<Resource>
{$profiles//Resource/ID}
<Type>{$profiles//Resource/Type/text()}</Type>
<SubType>{$subtype}</SubType>
<Scopes>{$scopes}</Scopes>
<Name>{$profiles//Resource/Profile/Name/text()}</Name>
</Resource>

@ -0,0 +1,18 @@
for $profiles in collection('/db/Profiles/Service')//Resource
let $scopes := string-join( $profiles/Scopes//Scope/text(), ';')
let $subtype := $profiles//Resource/Profile/Class/text()
<RES_SUBTYPE ISdefault =''/>
return
<Resource>
{$profiles//Resource/ID}
<Type>{$profiles//Resource/Type/text()}</Type>
<SubType>{$subtype}</SubType>
<Scopes>{$scopes}</Scopes>
<ServiceClass>{$profiles//Resource/Profile/Class/text()}</ServiceClass>
<ServiceName>{$profiles//Resource/Profile/Name/text()}</ServiceName>
<!-- if many software defined takes the version of the first one -->
<Version>{$profiles//Resource/Profile/Packages/Software[1]/Version/text()}</Version>
<Shareable>{$profiles//Resource/Profile/Packages/Software/Shareable/string(@level)}</Shareable>
</Resource>

@ -0,0 +1,21 @@
declare namespace gc = 'http://gcube-system.org/namespaces/common/core/porttypes/GCUBEProvider';
declare namespace wmns= 'http://gcube-system.org/namespaces/contentmanagement/viewmanager';
for $outer in collection("/db/Properties")//Document, $res in $outer/Data where $res/gc:ServiceClass/string() eq 'ContentManagement'
and count($res//wmns:View)>0 and $res/gc:ServiceName/string() eq 'ViewManager'
return
<Resource>
{$outer//Document/ID}
{$outer//Document/Source}
{$outer//Document/SourceKey}
<ViewName>{$outer//Document/Data/child::*[local-name()='View']/child::*[local-name()='property']/child::*[local-name()='name' and text()='name']/../child::*[local-name()='value']/text()}</ViewName>
<Cardinality>{$outer//Document/Data/child::*[local-name()='View']/child::*[local-name()='cardinality']/text()}</Cardinality>
<ViewType>{$outer//Document/Data/child::*[local-name()='View']/child::*[local-name()='type']/text()}</ViewType>
<RelatedCollectionId>{$outer//Document/Data/child::*[local-name()='View']/child::*[local-name()='collectionID']/text()}</RelatedCollectionId>
<ServiceClass>{$outer//Document/Data/child::*[local-name()='ServiceClass']/text()}</ServiceClass>
<ServiceName>{$outer//Document/Data/child::*[local-name()='ServiceName']/text()}</ServiceName>
<SubType>{$outer//Document/Data/child::*[local-name()='ServiceClass']/text()}</SubType>
{$outer//Document/TerminationTimeHuman} {$outer//Document/LastUpdateHuman}
<RI>{$outer//Document/Data/child::*[local-name()='RI']/text()}</RI>
<Type>WSResource</Type>
<scopes>{$outer//Document/Data/child::*[local-name()='Scope']/text()}</scopes>
</Resource>

@ -0,0 +1,29 @@
<!--
These are the GHNs that are declared certified and must be passed to
down status.
The choice is done by minutes elapsed from last update.
-->
let $RIs := collection("/db/Profiles/RunningInstance")//Document/Data/child::*[local-name()='Profile']/Resource
for $GHNs in collection("/db/Profiles/GHN")//Document/Data/child::*[local-name()='Profile']/Resource
let $totalminutes := hours-from-dateTime($GHNs/Profile/GHNDescription/LastUpdate/text())
let $RIinstalled := $RIs[Profile/GHN/string(@UniqueID)=$GHNs/ID]
let $scopes := string-join( $GHNs/Scopes//Scope/text(), ';')
where ($GHNs/Profile/GHNDescription/Status/string() eq 'down' or $GHNs/Profile/GHNDescription/Status/string() eq 'unreachable')
return
<Resource>
{$GHNs/ID}
{$GHNs/Profile/GHNDescription/Name}
{$GHNs/Profile/GHNDescription/Status}
{$GHNs/Profile/GHNDescription/Type}
{$GHNs/Profile/Site/Location}
{$GHNs/Profile/Site/Domain}
<IPAddress>{$GHNs/Profile/GHNDescription/NetworkAdapter/@IPAddress/string()}</IPAddress>
<!--
Other info
-->
<Scopes>{$scopes}</Scopes>
<AllocatedRI>{count($RIinstalled)}</AllocatedRI>
{$GHNs/Profile/GHNDescription/LastUpdate}
<UpdateMinutesElapsed>{$totalminutes}</UpdateMinutesElapsed>
<Actions><ACTION ISdefault ='APPLY_GHN_DELETE'/></Actions>
</Resource>

@ -0,0 +1,27 @@
<!--
These are the GHNs that are declared certified and must be passed to
down status.
The choice is done by minutes elapsed from last update.
-->
let $RIs := collection("/db/Profiles/RunningInstance")//Document/Data/child::*[local-name()='Profile']/Resource
for $GHNs in collection("/db/Profiles/GHN")//Document/Data/child::*[local-name()='Profile']/Resource
let $RIinstalled := $RIs[Profile/GHN/string(@UniqueID)=$GHNs/ID]
let $scopes := string-join( $GHNs/Scopes//Scope/text(), ';')
where $GHNs/Profile/GHNDescription/Status/string() != 'down' and $GHNs/Profile/GHNDescription/Status/string() != 'unreachable'
return
<Resource>
{$GHNs/ID}
{$GHNs/Profile/GHNDescription/Name}
{$GHNs/Profile/GHNDescription/Status}
{$GHNs/Profile/GHNDescription/Type}
{$GHNs/Profile/Site/Location}
{$GHNs/Profile/Site/Domain}
<IPAddress>{$GHNs/Profile/GHNDescription/NetworkAdapter/@IPAddress/string()}</IPAddress>
<!--
Other info
-->
<Scopes>{$scopes}</Scopes>
<AllocatedRI>{count($RIinstalled)}</AllocatedRI>
{$GHNs/Profile/GHNDescription/LastUpdate}
<Actions><ACTION ISdefault ='APPLY_GHN_MOVE_TO_UNREACHABLE'/></Actions>
</Resource>

@ -0,0 +1,19 @@
let $ghns := collection('/db/Profiles/GHN')//Resource/ID
let $ris := collection('/db/Profiles/RunningInstance')//Resource
for $ri in $ris
let $counter := index-of(($ghns//ID/string()), $ri/Profile/GHN/@UniqueID/string())
where empty($counter)
return
<Resource>
<ID>{$ri//Resource/ID/string()}</ID>
<ServiceStatus>{$ri/Profile/DeploymentData/Status/string()}</ServiceStatus>
<ActivationTime>{$ri/Profile/DeploymentData/ActivationTime/@value/string()}</ActivationTime>
<ghnid>{$ri/Profile/GHN/@UniqueID/string()}</ghnid>
<ServiceClass>{$ri/Profile/ServiceClass/string()}</ServiceClass>
<ServiceName>{$ri/Profile/ServiceName/string()}</ServiceName>
<!-- <tmp>{$ghns//ID}</tmp> -->
<!--
The actions must be declared inside the SweeperAction enum declaration.
-->
<Actions><ACTION ISdefault ='APPLY_RI_DELETE'/></Actions>
</Resource>
Loading…
Cancel
Save