Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r3979 - in trunk/perfsonar_base: ant src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator

Subject: perfsonar development work

List archive

perfsonar: r3979 - in trunk/perfsonar_base: ant src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r3979 - in trunk/perfsonar_base: ant src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator
  • Date: Mon, 9 Jun 2008 10:20:59 -0400

Author: roman
Date: 2008-06-09 10:20:58 -0400 (Mon, 09 Jun 2008)
New Revision: 3979

Modified:
trunk/perfsonar_base/ant/const.properties

trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/UtilizationQueryGenerator.java
Log:

Xquery to fetch utilization metadata elements updated. It supports the
parameter keyword inside metadata

example:

<nmwg:parameters>
<nmwg:parameter name="keyword"
type="project">http://geant2.net</nmwg:parameter>
</nmwg:parameters>




Modified: trunk/perfsonar_base/ant/const.properties
===================================================================
--- trunk/perfsonar_base/ant/const.properties 2008-06-09 14:02:41 UTC (rev
3978)
+++ trunk/perfsonar_base/ant/const.properties 2008-06-09 14:20:58 UTC (rev
3979)
@@ -13,4 +13,4 @@
# name of jar file to be created
jarfilename=perfsonar-base
# version of the product (will be included in the final name of jar file)
-version=1.0.20080416
+version=1.0.20080609

Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/UtilizationQueryGenerator.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/UtilizationQueryGenerator.java
2008-06-09 14:02:41 UTC (rev 3978)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/UtilizationQueryGenerator.java
2008-06-09 14:20:58 UTC (rev 3979)
@@ -7,6 +7,7 @@

import org.ggf.ns.nmwg.base.v2_0.Message;
import org.ggf.ns.nmwg.base.v2_0.Metadata;
+import org.ggf.ns.nmwg.base.v2_0.Parameter;
import org.ggf.ns.nmwg.characteristic.utilization.v2_0.Subject;
import org.ggf.ns.nmwg.topology.v2_0.Interface;
import org.perfsonar.base.auxiliary.AuxiliaryComponentManager;
@@ -74,6 +75,9 @@
// + "start getMetadataQuery");

String eventType = null;
+ String keyword = null;
+ String keywordType = null;
+
String ipAddress = null;
String hostName = null;
String ifName = null;
@@ -104,6 +108,20 @@


eventType = metadata.getEventType().getEventType().trim();
+
+ Parameter keywordParameter = metadata.getParameterByName("keyword");
+ String keywordQueryPart = "";
+ if (keywordParameter != null) {
+
+ keyword = keywordParameter.getParameterValue();
+ keywordType = keywordParameter.getParameterType();
+
+ if (!keyword.trim().equals("") && !keywordType.trim().equals(""))
+ keywordQueryPart = " and
$i/nmwg:parameters/nmwg:parameter[(functx:trim(text())='"+ keyword +"' and
functx:trim(@name)='keyword' and functx:trim(@type)='" + keywordType + "') or
(functx:trim(@value)='" + keyword + "' and functx:trim(@name)='keyword' and
functx:trim(@type)='" + keywordType + "')] ";
+ else if (!keyword.trim().equals("") &&
keywordType.trim().equals(""))
+ keywordQueryPart = " and
$i/nmwg:parameters/nmwg:parameter[(functx:trim(text())='"+ keyword +"' and
functx:trim(@name)='keyword') or (functx:trim(@value)='" + keyword + "' and
functx:trim(@name)='keyword')] ";
+ }
+
Subject subject = (Subject) metadata.getSubject();
if (subject != null) {
Interface interf = subject.getInterface();
@@ -123,16 +141,16 @@
try {
ifAddressType =
(!interf.getIfAddressElement().getType().trim().equals("") ?
interf.getIfAddressElement().getType().trim(): null);
} catch (Exception ex) {
- ifAddressType = null;
+ ifAddressType = null;
}
} else {
- throw new PerfSONARException(
+ throw new PerfSONARException(
"error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: "
+ "no interface element in metadata element");
}
} else {
- throw new PerfSONARException(
+ throw new PerfSONARException(
"error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: "
+ "no subject element in metadata element");
@@ -144,11 +162,11 @@
+ "declare namespace
nmwgt='http://ggf.org/ns/nmwg/topology/2.0/'; \n\n";

xQuery +=
- "declare namespace functx = 'http://www.functx.com';\n"
- + "declare function functx:trim \n"
- + " ( $arg as xs:string? ) as xs:string { \n"
- + " replace(replace($arg,'\\s+$',''),'^\\s+','') \n"
- + "}; \n\n";
+ "declare namespace functx = 'http://www.functx.com';\n"
+ + "declare function functx:trim \n"
+ + " ( $arg as xs:string? ) as xs:string { \n"
+ + " replace(replace($arg,'\\s+$',''),'^\\s+','') \n"
+ + "}; \n\n";


if (ipAddress == null &&
@@ -165,14 +183,16 @@

// getting all metadata

- xQuery +=
+ xQuery +=
"let $res :=
\n"
+ " for $i in //nmwg:metadata
\n"
+ " where
\n"
- + "
$i/nmwg:parameters/nmwg:parameter[(functx:trim(text())='" + eventType + "'
and functx:trim(@name)='supportedEventType') \n"
+ + " 1 and \n"
+ + "
($i/nmwg:parameters/nmwg:parameter[(functx:trim(text())='" + eventType + "'
and functx:trim(@name)='supportedEventType') \n"
+ " or (functx:trim(@value)='" + eventType + "' and
functx:trim(@name)='supportedEventType')] \n"
+ " or
\n"
- + " $i/nmwg:eventType[functx:trim(text())='" +
eventType + "']
\n"
+ + " $i/nmwg:eventType[functx:trim(text())='" +
eventType + "'])
\n"
+ + keywordQueryPart
+ " return $i
\n"
+ "\n"
+ "let $datas :=
\n"
@@ -180,12 +200,12 @@
+ "\n"
+ "return ($res, $datas) \n";

- return xQuery;
+ return xQuery;

}


- xQuery +=
+ xQuery +=
" let $res := \n"
+ " for $i in //nmwg:metadata \n"
+ " where 1 \n";
@@ -200,23 +220,24 @@
+ "or
(functx:trim(@value)='" + eventType + "' and
functx:trim(@name)='supportedEventType')]) "
+ "or "
+ "($i/nmwg:eventType[functx:trim(text())='" +
eventType + "'])"
- + ") ";
+ + ") "
+ + keywordQueryPart;

if (ipAddress != null) {
if (ipAddress.equals(""))
- throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong ipAddress");
+ throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong ipAddress");
xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:ipAddress[functx:trim(text())='" +
ipAddress + "'] ";
}

if (hostName != null) {
if (hostName.equals(""))
- throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong hostName");
- xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:hostName[functx:trim(text())='" +
hostName + "'] ";
+ throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong hostName");
+ xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:hostName[functx:trim(text())='" +
hostName + "'] ";
}

if (ifName != null) {
if (ifName.equals(""))
- throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong ifName");
+ throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong ifName");
xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:ifName[functx:trim(text())='" +
ifName + "'] ";
}

@@ -228,49 +249,49 @@

if (ifAddress != null) {
if (ifAddress.equals("") && ifAddressType == null)
- throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong ifAddress");
+ throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong ifAddress");
if (!ifAddress.equals(""))
xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:ifAddress[functx:trim(text())='" +
ifAddress + "'] ";
}

if (ifIndex != null) {
if (ifIndex.equals(""))
- throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong ifIndex");
+ throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong ifIndex");
xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:ifIndex[functx:trim(text())='" +
ifIndex + "'] ";
}

if (type != null) {
if (type.equals(""))
- throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong type");
+ throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong type");
xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:type[functx:trim(text())='" + type +
"'] ";
}

if (direction != null) {
if (direction.equals(""))
- throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong direction");
+ throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong direction");
xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:direction[functx:trim(text())='" +
direction + "'] ";
}

if (authRealm != null) {
if (authRealm.equals(""))
- throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong authRealm");
+ throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong authRealm");
xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:authRealm[functx:trim(text())='" +
authRealm + "'] ";
}

if (classOfService != null) {
if (classOfService.equals(""))
- throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong classOfService");
+ throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong classOfService");
xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:classOfService[functx:trim(text())='"
+ classOfService + "'] ";
}

if (capacity != null) {
if (capacity.equals(""))
- throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong capacity");
+ throw new PerfSONARException("error.ma.query",
"UtilizationQueryGenerator.getMetadataQuery: wrong capacity");
xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:capacity[functx:trim(text())='" +
capacity + "'] ";
}

if (ifAddressType != null) {
- xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:ifAddress[functx:trim(@type)='" +
ifAddressType + "'] ";
+ xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:ifAddress[functx:trim(@type)='" +
ifAddressType + "'] ";
}





  • perfsonar: r3979 - in trunk/perfsonar_base: ant src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator, svnlog, 06/09/2008

Archive powered by MHonArc 2.6.16.

Top of Page