perfsonar-dev - r1934 - in branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig: . queryGenerator
Subject: perfsonar development work
List archive
r1934 - in branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig: . queryGenerator
Chronological Thread
- From:
- To:
- Subject: r1934 - in branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig: . queryGenerator
- Date: Thu, 18 Jan 2007 06:17:16 -0500
Author: roman
Date: 2007-01-18 06:17:15 -0500 (Thu, 18 Jan 2007)
New Revision: 1934
Modified:
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/Transformations.java
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/L2PathStatusQueryGenerator.java
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/UtilizationQueryGenerator.java
Log:
- Xquery statements (for searching in the metadata configuration) improved
- log messages improved
Modified:
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
===================================================================
---
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
2007-01-18 11:11:53 UTC (rev 1933)
+++
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
2007-01-18 11:17:15 UTC (rev 1934)
@@ -133,7 +133,7 @@
throw new SystemException(
"error.ma.query",
"MetadataConfigurationStorageManager.fetch: "
- + "Empty query to get data from rrd metadata
configuration file");
+ + "Empty query to get data from the metadata
configuration");
Object object = null;
@@ -165,14 +165,14 @@
throw new SystemException(
"warning.ma.metadata_configuration",
"MetadataConfigurationStorageManager.fetch: "
- + "No metadata in rrd metadata configuration file");
+ + "No metadata in the metadata configuration");
if (xmlResults.length == 1)
if (xmlResults[0].trim().equals(""))
throw new SystemException(
"warning.ma.metadata_configuration",
"MetadataConfigurationStorageManager.fetch: "
- + "No metadata in rrd metadata configuration file");
+ + "No metadata in the metadata configuration");
for (int i = 0; i < xmlResults.length; i++) {
Modified:
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/Transformations.java
===================================================================
---
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/Transformations.java
2007-01-18 11:11:53 UTC (rev 1933)
+++
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/Transformations.java
2007-01-18 11:17:15 UTC (rev 1934)
@@ -15,6 +15,7 @@
import
org.perfsonar.commons.auxiliary.components.configuration.ConfigurationComponent;
import org.perfsonar.service.commons.exceptions.SystemException;
+import org.perfsonar.service.commons.exceptions.PerfSONARException;
import org.perfsonar.service.commons.exceptions.RequestException;
import org.ggf.ns.nmwg.base.v2_0.Element;
@@ -142,8 +143,32 @@
// genarate correct metadata query
MetadataQueryGenerator metadataQueryGenerator =
MetadataQueryGeneratorFactory.getMetadataQueryGenerator(eventType);
- String mq = metadataQueryGenerator.getMetadataQuery(query);
+ String mq = "";
+ try {
+
+ mq = metadataQueryGenerator.getMetadataQuery(query);
+
+ } catch (PerfSONARException pex) {
+
+ throw new SystemException(pex.getResultCode(),
pex.getMessage());
+
+ } catch (Exception ex) {
+
+ logger.error("Transformations.getMetadataQuery: "
+ + "Unable to generate xquery statement "
+ + "for the metadata configuration "
+ + "from the request metadata. "
+ + ex.toString());
+ throw new RequestException(
+ "error.ma.query",
+ "Unable to generate xquery statement "
+ + "for the metadata configuration "
+ + "from the request metadata. "
+ + ex.toString());
+
+ }
+
return mq;
}
Modified:
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/L2PathStatusQueryGenerator.java
===================================================================
---
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/L2PathStatusQueryGenerator.java
2007-01-18 11:11:53 UTC (rev 1933)
+++
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/L2PathStatusQueryGenerator.java
2007-01-18 11:17:15 UTC (rev 1934)
@@ -128,7 +128,7 @@
+ " for $k in $metaids
\n"
+ " let $d :=
\n"
+ " for $l in //nmwg:data
\n"
- + " where $l/@metadataIdRef = $k
\n"
+ + " where fn:data($l/@metadataIdRef) = $k
\n"
+ " return $l
\n"
+ " return $d
\n"
+ "
\n"
@@ -175,8 +175,8 @@
+ " let $nodeMetadata :=
\n"
+ " if ($linkMetadata != '') then
\n"
+ " for $n in //nmwg:metadata
\n"
- + " where $n/nmwg:subject/nmwgtopo3:node/@id =
\n"
- + "
$linkMetadata/nmwg:subject/nmtl2:link/nmwgtopo3:node/@nodeIdRef
\n"
+ + " where
fn:data($n/nmwg:subject/nmwgtopo3:node/@id) =
\n"
+ + "
fn:data($linkMetadata/nmwg:subject/nmtl2:link/nmwgtopo3:node/@nodeIdRef)
\n"
+ " return $n
\n"
+ " else
\n"
+ " ''
\n"
@@ -189,7 +189,7 @@
+ " for $k in $metaids
\n"
+ " let $d :=
\n"
+ " for $l in //nmwg:data
\n"
- + " where $l/@metadataIdRef = $k
\n"
+ + " where fn:data($l/@metadataIdRef) = $k
\n"
+ " return $l
\n"
+ " return $d
\n"
+ "
\n"
@@ -199,124 +199,203 @@
Node[] nodeArray = (Node[]) link.getNodeArray();
- if (nodeArray == null)
- return "";
+ if (nodeArray == null) {
+ logger.error(
+ "L2PathStatusQueryGenerator.getMetadataQuery: "
+ + "No node element(s) in the request metadata");
+ throw new RequestException(
+ "error.ma.query",
+ "L2PathStatusQueryGenerator.getMetadataQuery: "
+ + "No node element(s) in the request metadata");
+ }
+ if (nodeArray.length > 2 || nodeArray.length == 0) {
+ logger.error(
+ "L2PathStatusQueryGenerator.getMetadataQuery: "
+ + "0 or more than 2 node element(s) in the request
metadata");
+ throw new RequestException(
+ "error.ma.query",
+ "L2PathStatusQueryGenerator.getMetadataQuery: "
+ + "0 or more than 2 node element(s) in the request
metadata");
+ }
- String node1Name = "";
- String node1Country = "";
- String node1City = "";
- String node1Institution = "";
+ if (nodeArray.length == 2) {
- if (nodeArray.length > 0) {
+ String node1Name = "";
+ String node1Country = "";
+ String node1City = "";
+ String node1Institution = "";
+
try { node1Name =
nodeArray[0].getNameElement().getName(); } catch (Exception ex)
{;}
try { node1Country =
nodeArray[0].getCountryElement().getCountry(); } catch (Exception ex)
{;}
try { node1City =
nodeArray[0].getCityElement().getCity(); } catch (Exception ex)
{;}
try { node1Institution =
nodeArray[0].getInstitutionElement().getInstitution(); } catch (Exception ex)
{;}
- }
- String node2Name = "";
- String node2Country = "";
- String node2City = "";
- String node2Institution = "";
- if (nodeArray.length > 1) {
+ String node2Name = "";
+ String node2Country = "";
+ String node2City = "";
+ String node2Institution = "";
+
try { node2Name =
nodeArray[1].getNameElement().getName(); } catch (Exception ex)
{;}
try { node2Country =
nodeArray[1].getCountryElement().getCountry(); } catch (Exception ex)
{;}
try { node2City =
nodeArray[1].getCityElement().getCity(); } catch (Exception ex)
{;}
try { node2Institution =
nodeArray[1].getInstitutionElement().getInstitution(); } catch (Exception ex)
{;}
- }
- String node1 = null;
- if (node1Name == "" && node1Country == "" && node1City == "" &&
node1Institution == "")
- node1 = " let $node1_metadata := '' \n"
- + " let $node1_id := '' ";
- else
- node1 = " let $node1_metadata :=
\n"
- + " for $i in //nmwg:metadata
\n"
- + " where 1
\n"
- + (node1Name != "" ? " and
fn:lower-case($i/nmwg:subject/nmwgtopo3:node/nmwgtopo3:name) =
fn:lower-case('" + node1Name + "') \n" : "")
- + (node1Country != "" ? " and
fn:lower-case($i/nmwg:subject/nmwgtopo3:node/nmwgtopo3:country) =
fn:lower-case('" + node1Country + "') \n" : "")
- + (node1City != "" ? " and
fn:lower-case($i/nmwg:subject/nmwgtopo3:node/nmwgtopo3:city) =
fn:lower-case('" + node1City + "') \n" : "")
- + (node1Institution != "" ? " and
fn:lower-case($i/nmwg:subject/nmwgtopo3:node/nmwgtopo3:institution) =
fn:lower-case('" + node1Institution + "') \n" : "")
- + " return $i
\n"
- + "
\n"
- + " let $node1_id :=
\n"
- + " if ($node1_metadata) then
\n"
- + "
$node1_metadata/nmwg:subject/nmwgtopo3:node/@id \n"
- + " else
\n"
- + " ''
\n";
+ String node1 = null;
+ if (node1Name == "" && node1Country == "" && node1City == ""
&& node1Institution == "")
+ node1 = " let $node1_metadata := '' \n"
+ + " let $node1_id := '' ";
+ else
+ node1 = " let $node1_metadata :=
\n"
+ + " for $i in //nmwg:metadata
\n"
+ + " where 1
\n"
+ + (node1Name != "" ? " and
fn:lower-case($i/nmwg:subject/nmwgtopo3:node/nmwgtopo3:name) =
fn:lower-case('" + node1Name + "') \n" : "")
+ + (node1Country != "" ? " and
fn:lower-case($i/nmwg:subject/nmwgtopo3:node/nmwgtopo3:country) =
fn:lower-case('" + node1Country + "') \n" : "")
+ + (node1City != "" ? " and
fn:lower-case($i/nmwg:subject/nmwgtopo3:node/nmwgtopo3:city) =
fn:lower-case('" + node1City + "') \n" : "")
+ + (node1Institution != "" ? " and
fn:lower-case($i/nmwg:subject/nmwgtopo3:node/nmwgtopo3:institution) =
fn:lower-case('" + node1Institution + "') \n" : "")
+ + " return $i
\n"
+ + "
\n"
+ + " let $node1_id :=
\n"
+ + " if ($node1_metadata) then
\n"
+ + "
fn:data($node1_metadata/nmwg:subject/nmwgtopo3:node/@id) \n"
+ + " else
\n"
+ + " ''
\n";
- String node2 = null;
- if (node2Name == "" && node2Country == "" && node2City == "" &&
node2Institution == "")
- node2 = " let $node2_metadata := '' \n"
- + " let $node2_id := '' ";
- else
- node2 = " let $node2_metadata :=
\n"
- + " for $j in //nmwg:metadata
\n"
- + " where 1
\n"
- + (node2Name != "" ? " and
fn:lower-case($j/nmwg:subject/nmwgtopo3:node/nmwgtopo3:name) =
fn:lower-case('" + node2Name + "') \n" : "")
- + (node2Country != "" ? " and
fn:lower-case($j/nmwg:subject/nmwgtopo3:node/nmwgtopo3:country) =
fn:lower-case('" + node2Country + "') \n" : "")
- + (node2City != "" ? " and
fn:lower-case($j/nmwg:subject/nmwgtopo3:node/nmwgtopo3:city) =
fn:lower-case('" + node2City + "') \n" : "")
- + (node2Institution != "" ? " and
fn:lower-case($j/nmwg:subject/nmwgtopo3:node/nmwgtopo3:institution) =
fn:lower-case('" + node2Institution + "') \n" : "")
- + " return $j
\n"
- + "
\n"
- + " let $node2_id :=
\n"
- + " if ($node2_metadata) then
\n"
- + "
$node2_metadata/nmwg:subject/nmwgtopo3:node/@id \n"
- + " else
\n"
- + " ''
\n";
+ String node2 = null;
+ if (node2Name == "" && node2Country == "" && node2City == ""
&& node2Institution == "")
+ node2 = " let $node2_metadata := '' \n"
+ + " let $node2_id := '' ";
+ else
+ node2 = " let $node2_metadata :=
\n"
+ + " for $j in //nmwg:metadata
\n"
+ + " where 1
\n"
+ + (node2Name != "" ? " and
fn:lower-case($j/nmwg:subject/nmwgtopo3:node/nmwgtopo3:name) =
fn:lower-case('" + node2Name + "') \n" : "")
+ + (node2Country != "" ? " and
fn:lower-case($j/nmwg:subject/nmwgtopo3:node/nmwgtopo3:country) =
fn:lower-case('" + node2Country + "') \n" : "")
+ + (node2City != "" ? " and
fn:lower-case($j/nmwg:subject/nmwgtopo3:node/nmwgtopo3:city) =
fn:lower-case('" + node2City + "') \n" : "")
+ + (node2Institution != "" ? " and
fn:lower-case($j/nmwg:subject/nmwgtopo3:node/nmwgtopo3:institution) =
fn:lower-case('" + node2Institution + "') \n" : "")
+ + " return $j
\n"
+ + "
\n"
+ + " let $node2_id :=
\n"
+ + " if ($node2_metadata) then
\n"
+ + "
fn:data($node2_metadata/nmwg:subject/nmwgtopo3:node/@id) \n"
+ + " else
\n"
+ + " ''
\n";
- xQuery = "
\n "
- + "
\n "
- + node1
- + node2
- + "
\n"
- + " let $linkMetadata :=
\n"
- + " if ($node1_id != '' and $node2_id != '') then
\n"
- + " for $k in //nmwg:metadata
\n"
- + " where
$k/nmwg:subject/nmtl2:link/nmwgtopo3:node/@nodeIdRef = $node1_id
\n"
- + " and
$k/nmwg:subject/nmtl2:link/nmwgtopo3:node/@nodeIdRef = $node2_id
\n"
- + " and
$k/nmwg:parameters/nmwg:parameter[(text()='Path.Status' and
@name='supportedEventType') \n"
- + " or
(@value='Path.Status' and @name='supportedEventType')] \n"
- + " return $k
\n"
- + " else if ($node1_id != '' and $node2_id = '') then
\n"
- + " for $k in //nmwg:metadata
\n"
- + " where
$k/nmwg:subject/nmtl2:link/nmwgtopo3:node/@nodeIdRef = $node1_id
\n"
- + " and
$k/nmwg:parameters/nmwg:parameter[(text()='Path.Status' and
@name='supportedEventType') \n"
- + " or
(@value='Path.Status' and @name='supportedEventType')] \n"
- + " return $k
\n"
- + " else if ($node1_id = '' and $node2_id != '') then
\n"
- + " for $k in //nmwg:metadata
\n"
- + " where
$k/nmwg:subject/nmtl2:link/nmwgtopo3:node/@nodeIdRef = $node2_id
\n"
- + " and
$k/nmwg:parameters/nmwg:parameter[(text()='Path.Status' and
@name='supportedEventType') \n"
- + " or
(@value='Path.Status' and @name='supportedEventType')] \n"
- + " return $k
\n"
- + " else
\n"
- + " ''
\n"
- + "
\n"
- + " let $metaids :=
\n"
- + " for $j in $linkMetadata
\n"
- + " return fn:data($j/@id)
\n"
- + "
\n"
- + " let $datas :=
\n"
- + " for $k in $metaids
\n"
- + " let $d :=
\n"
- + " for $l in //nmwg:data
\n"
- + " where $l/@metadataIdRef = $k
\n"
- + " return $l
\n"
- + " return $d
\n"
- + "
\n"
- + " return
\n"
- + " if ($linkMetadata != '') then
\n"
- + " ($node1_metadata, $node2_metadata,
$linkMetadata, $datas) \n"
- + " else
\n"
- + " ''
";
+ xQuery = "
\n "
+ + "
\n "
+ + node1
+ + node2
+ + "
\n"
+ + " let $linkMetadata :=
\n"
+ + " if ($node1_id != '' and $node2_id != '') then
\n"
+ + " for $k in //nmwg:metadata
\n"
+ + " where
fn:data($k/nmwg:subject/nmtl2:link/nmwgtopo3:node/@nodeIdRef) = $node1_id
\n"
+ + " and
fn:data($k/nmwg:subject/nmtl2:link/nmwgtopo3:node/@nodeIdRef) = $node2_id
\n"
+ + " and
$k/nmwg:parameters/nmwg:parameter[(text()='Path.Status' and
@name='supportedEventType') \n"
+ + " or
(@value='Path.Status' and @name='supportedEventType')] \n"
+ + " return $k
\n"
+ + " else
\n"
+ + " ''
\n"
+ + "
\n"
+ + " let $metaids :=
\n"
+ + " if ($linkMetadata != '') then
\n"
+ + " for $j in $linkMetadata
\n"
+ + " return fn:data($j/@id)
\n"
+ + " else
\n"
+ + " ''
\n"
+ + "
\n"
+ + " let $datas :=
\n"
+ + " if ($metaids != '') then
\n"
+ + " for $k in $metaids
\n"
+ + " let $d :=
\n"
+ + " for $l in //nmwg:data
\n"
+ + " where fn:data($l/@metadataIdRef) =
$k \n"
+ + " return $l
\n"
+ + " return $d
\n"
+ + " else
\n"
+ + " ''
\n"
+ + "
\n"
+ + " return
\n"
+ + " if ($linkMetadata != '') then
\n"
+ + " ($node1_metadata, $node2_metadata,
$linkMetadata, $datas) \n"
+ + " else
\n"
+ + " ''
";
+ } else if (nodeArray.length == 1){
+ String nodeName = "";
+ String nodeCountry = "";
+ String nodeCity = "";
+ String nodeInstitution = "";
+
+ try { nodeName =
nodeArray[0].getNameElement().getName(); } catch (Exception ex)
{;}
+ try { nodeCountry =
nodeArray[0].getCountryElement().getCountry(); } catch (Exception ex)
{;}
+ try { nodeCity =
nodeArray[0].getCityElement().getCity(); } catch (Exception ex)
{;}
+ try { nodeInstitution =
nodeArray[0].getInstitutionElement().getInstitution(); } catch (Exception ex)
{;}
+
+ String node = null;
+ if (nodeName == "" && nodeCountry == "" && nodeCity == "" &&
nodeInstitution == "")
+ node = " let $node_metadata := '' \n"
+ + " let $node_id := '' ";
+ else
+ node = " let $node_metadata :=
\n"
+ + " for $i in //nmwg:metadata
\n"
+ + " where 1
\n"
+ + (nodeName != "" ? " and
fn:lower-case($i/nmwg:subject/nmwgtopo3:node/nmwgtopo3:name) =
fn:lower-case('" + nodeName + "') \n" : "")
+ + (nodeCountry != "" ? " and
fn:lower-case($i/nmwg:subject/nmwgtopo3:node/nmwgtopo3:country) =
fn:lower-case('" + nodeCountry + "') \n" : "")
+ + (nodeCity != "" ? " and
fn:lower-case($i/nmwg:subject/nmwgtopo3:node/nmwgtopo3:city) =
fn:lower-case('" + nodeCity + "') \n" : "")
+ + (nodeInstitution != "" ? " and
fn:lower-case($i/nmwg:subject/nmwgtopo3:node/nmwgtopo3:institution) =
fn:lower-case('" + nodeInstitution + "') \n" : "")
+ + " return $i
\n"
+ + "
\n"
+ + " let $node_id :=
\n"
+ + " if ($node_metadata) then
\n"
+ + "
fn:data($node_metadata/nmwg:subject/nmwgtopo3:node/@id) \n"
+ + " else
\n"
+ + " ''
\n";
+ xQuery = "
\n "
+ + "
\n "
+ + node
+ + "
\n"
+ + " let $linkMetadata :=
\n"
+ + " if ($node_id != '') then
\n"
+ + " for $k in //nmwg:metadata
\n"
+ + " where
fn:data($k/nmwg:subject/nmtl2:link/nmwgtopo3:node/@nodeIdRef) = $node_id
\n"
+ + " and
$k/nmwg:parameters/nmwg:parameter[(text()='Path.Status' and
@name='supportedEventType') \n"
+ + " or
(@value='Path.Status' and @name='supportedEventType')] \n"
+ + " return $k
\n"
+ + " else
\n"
+ + " ''
\n"
+ + "
\n"
+ + " let $metaids :=
\n"
+ + " if ($linkMetadata != '') then
\n"
+ + " for $j in $linkMetadata
\n"
+ + " return fn:data($j/@id)
\n"
+ + " else
\n"
+ + " ''
\n"
+ + "
\n"
+ + " let $datas :=
\n"
+ + " if ($metaids != '') then
\n"
+ + " for $k in $metaids
\n"
+ + " let $d :=
\n"
+ + " for $l in //nmwg:data
\n"
+ + " where fn:data($l/@metadataIdRef) =
$k \n"
+ + " return $l
\n"
+ + " return $d
\n"
+ + " else
\n"
+ + " ''
\n"
+ + "
\n"
+ + " return
\n"
+ + " if ($linkMetadata != '') then
\n"
+ + " ($node_metadata, $linkMetadata, $datas)
\n"
+ + " else
\n"
+ + " ''
";
+
+ }
+
}
xQuery = ns + xQuery;
Modified:
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/UtilizationQueryGenerator.java
===================================================================
---
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/UtilizationQueryGenerator.java
2007-01-18 11:11:53 UTC (rev 1933)
+++
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/UtilizationQueryGenerator.java
2007-01-18 11:17:15 UTC (rev 1934)
@@ -184,21 +184,21 @@
xQuery += "\n"
- + " return $i \n"
- + " \n"
- + " let $metaids := \n"
- + " for $j in $res \n"
- + " return fn:data($j/@id) \n"
- + " \n"
- + " let $datas := \n"
- + " for $k in $metaids \n"
- + " let $d := \n"
- + " for $l in //nmwg:data \n"
- + " where $l/@metadataIdRef = $k \n"
- + " return $l \n"
- + " return $d \n"
- + " \n"
- + " return ($res, $datas) \n";
+ + " return $i \n"
+ + " \n"
+ + " let $metaids := \n"
+ + " for $j in $res \n"
+ + " return fn:data($j/@id) \n"
+ + " \n"
+ + " let $datas := \n"
+ + " for $k in $metaids \n"
+ + " let $d := \n"
+ + " for $l in //nmwg:data \n"
+ + " where fn:data($l/@metadataIdRef) = $k \n"
+ + " return $l \n"
+ + " return $d \n"
+ + " \n"
+ + " return ($res, $datas) \n";
//logger.debug(
- r1934 - in branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/metadataConfig: . queryGenerator, svnlog, 01/18/2007
Archive powered by MHonArc 2.6.16.