Skip to Content.
Sympa Menu

perfsonar-dev - r1931 - trunk/perfsonar/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator

Subject: perfsonar development work

List archive

r1931 - trunk/perfsonar/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator


Chronological Thread 
  • From:
  • To:
  • Subject: r1931 - trunk/perfsonar/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator
  • Date: Thu, 18 Jan 2007 04:50:35 -0500

Author: roman
Date: 2007-01-18 04:50:33 -0500 (Thu, 18 Jan 2007)
New Revision: 1931

Modified:

trunk/perfsonar/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/L2PathStatusQueryGenerator.java
Log:
Xquery statements have been improved. They are more reliable for exceptional
situations (wrong format of message).

Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/L2PathStatusQueryGenerator.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/L2PathStatusQueryGenerator.java
2007-01-17 15:28:39 UTC (rev 1930)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/L2PathStatusQueryGenerator.java
2007-01-18 09:50:33 UTC (rev 1931)
@@ -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"
- + "
fn:data($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"
- + "
fn:data($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
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 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
$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
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"
- + " 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 fn:data($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;



  • r1931 - trunk/perfsonar/src/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator, svnlog, 01/18/2007

Archive powered by MHonArc 2.6.16.

Top of Page