summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrei Aiordachioaie <a.aiordachioaie@jacobs-university.de>2009-05-25 10:23:43 +0200
committerAndrei Aiordachioaie <andrei@kahlua.eecs.jacobs-university.de>2009-07-07 10:50:05 +0200
commit256aa4ff66f4bcd87e9c9b3ae5fcd4455a65f67f (patch)
treecc4c83035d4b61f58f661463e9ad8845c37672ad /src
parentfcf40c09879355d0b1860cf5545ac26ac0aca681 (diff)
Updated WCPS source code to match spec WCPS 1.0.0
Diffstat (limited to 'src')
-rw-r--r--src/wcps/server/cli/WCPService.java126
-rw-r--r--src/wcps/server/cli/grammar.java53
-rw-r--r--src/wcps/server/cli/xml.java163
-rw-r--r--src/wcps/server/core/AxisNameType.java57
-rw-r--r--src/wcps/server/core/BinaryOperationCoverageExprType.java275
-rw-r--r--src/wcps/server/core/BooleanScalarExprType.java179
-rw-r--r--src/wcps/server/core/CachedMetadataSource.java205
-rw-r--r--src/wcps/server/core/CellDomainElement.java163
-rw-r--r--src/wcps/server/core/CombineRangeCoverageExprType.java36
-rw-r--r--src/wcps/server/core/ComplexConstantType.java60
-rw-r--r--src/wcps/server/core/CondenseScalarExprType.java40
-rw-r--r--src/wcps/server/core/ConstantCoverageExprType.java46
-rw-r--r--src/wcps/server/core/ConstructCoverageExprType.java46
-rw-r--r--src/wcps/server/core/CoordinateType.java49
-rw-r--r--src/wcps/server/core/CoverageExprPairType.java109
-rw-r--r--src/wcps/server/core/CoverageExprType.java319
-rw-r--r--src/wcps/server/core/CoverageInfo.java315
-rw-r--r--src/wcps/server/core/CoverageIterator.java182
-rw-r--r--src/wcps/server/core/CrsNameType.java54
-rw-r--r--src/wcps/server/core/CrsTransformCoverageExprType.java82
-rw-r--r--src/wcps/server/core/DbMetadataSource.java748
-rw-r--r--src/wcps/server/core/DimensionIntervalElement.java191
-rw-r--r--src/wcps/server/core/DimensionIntervalList.java86
-rw-r--r--src/wcps/server/core/DimensionPointElement.java142
-rw-r--r--src/wcps/server/core/DimensionPointElementType.java74
-rw-r--r--src/wcps/server/core/DomainElement.java368
-rw-r--r--src/wcps/server/core/DomainMetadataExprType.java151
-rw-r--r--src/wcps/server/core/EncodeDataExprType.java189
-rw-r--r--src/wcps/server/core/ExtendCoverageExprType.java264
-rw-r--r--src/wcps/server/core/FieldNameType.java62
-rw-r--r--src/wcps/server/core/ICoverageInfo.java57
-rw-r--r--src/wcps/server/core/IRasNode.java56
-rw-r--r--src/wcps/server/core/InducedOperationCoverageExprType.java105
-rw-r--r--src/wcps/server/core/InterpolationMethod.java170
-rw-r--r--src/wcps/server/core/InvalidMetadataException.java74
-rw-r--r--src/wcps/server/core/InvalidRequestException.java86
-rw-r--r--src/wcps/server/core/Metadata.java1440
-rw-r--r--src/wcps/server/core/MetadataScalarExprType.java41
-rw-r--r--src/wcps/server/core/MetadataSource.java72
-rw-r--r--src/wcps/server/core/NumericScalarExprType.java139
-rw-r--r--src/wcps/server/core/ProcessCoverageRequest.java196
-rw-r--r--src/wcps/server/core/ProcessCoveragesRequest.java305
-rw-r--r--src/wcps/server/core/ProcessOneCoverage.java114
-rw-r--r--src/wcps/server/core/RangeCoverageExprType.java90
-rw-r--r--src/wcps/server/core/RangeElement.java330
-rw-r--r--src/wcps/server/core/RangeElementType.java94
-rw-r--r--src/wcps/server/core/RangeFieldType.java63
-rw-r--r--src/wcps/server/core/ReduceScalarExprType.java119
-rw-r--r--src/wcps/server/core/ResourceException.java84
-rw-r--r--src/wcps/server/core/SDU.java385
-rw-r--r--src/wcps/server/core/ScalarExprType.java239
-rw-r--r--src/wcps/server/core/ScaleCoverageExprType.java46
-rw-r--r--src/wcps/server/core/SetMetadataCoverageExprType.java46
-rw-r--r--src/wcps/server/core/SliceCoverageExprType.java255
-rw-r--r--src/wcps/server/core/StringScalarExprType.java69
-rw-r--r--src/wcps/server/core/SubsetOperationCoverageExprType.java80
-rw-r--r--src/wcps/server/core/TrimCoverageExprType.java272
-rw-r--r--src/wcps/server/core/UnaryOperationCoverageExprType.java308
-rw-r--r--src/wcps/server/core/WCPS.java336
-rw-r--r--src/wcps/server/core/WCPSException.java83
-rw-r--r--src/wcps/server/core/XmlQuery.java141
-rw-r--r--src/wcps/server/servlet/WCPSServlet.java323
-rw-r--r--src/wcps/server/servlet/WCPService.java267
63 files changed, 7272 insertions, 4047 deletions
diff --git a/src/wcps/server/cli/WCPService.java b/src/wcps/server/cli/WCPService.java
deleted file mode 100644
index 2090109..0000000
--- a/src/wcps/server/cli/WCPService.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.cli;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import wcps.server.core.CachedMetadataSource;
-import wcps.server.core.DbMetadataSource;
-import wcps.server.core.ProcessCoverageRequest;
-import wcps.server.core.WCPS;
-
-// This is a small application around the WCPS core. It takes XML requests as files and runs them through WCPS. The resulting radaman queries are displayed, but not executed. This is very useful for testing whether your metadata is valid.
-
-public class WCPService {
-
- private static WCPS wcps;
-
- public static void main( String[] args ) {
-
- if( args.length != 1 ) {
- System.err.println( "WCPS: no input files" );
- System.exit( 1 );
- }
-
- String pcSchemaFileName = ".." + File.separator + "xml" + File.separator + "ogc" + File.separator + "wcps" + File.separator + "1.0.0" + File.separator + "wcpsProcessCoverage.xsd";
- File pcSchemaFile = new File( pcSchemaFileName );
- if( !pcSchemaFile.exists() ) {
- System.err.println( "WCPS: could not find the WCPS ProcessCoverage schema (" + pcSchemaFileName + ")" );
- System.exit( 1 );
- }
-
- DbMetadataSource metadataSource = null;
- try {
- Properties dbParams = new Properties();
- dbParams.load( new FileInputStream( ".." + File.separator + "dbparams.properties" ) );
- metadataSource = new DbMetadataSource( dbParams.getProperty( "metadata_driver" ), dbParams.getProperty( "metadata_url" ), dbParams.getProperty( "metadata_user" ), dbParams.getProperty( "metadata_pass" ), false );
- wcps = new WCPS( pcSchemaFile, new CachedMetadataSource( metadataSource ) );
- }
- catch( Exception e ) {
- System.err.println( "WCPS: could not initialize WCPS:" );
- e.printStackTrace( System.err );
- System.exit( 1 );
- }
-
- for( int i = 0; i < args.length; i++ ) {
- File fileIn = null;
- try {
- fileIn = new File( args[i] );
- }
- catch( Exception fnfe ) {
- System.err.println( "WCPS: " + args[i] + ": no such file or directory" + fnfe );
- System.exit( 1 );
- }
- boolean ok = processCoverage( fileIn, i );
- if( !ok ) {
- System.err.println( "WCPS: " + args[i] + " failed" );
- System.exit( 1 );
- }
- }
-
- metadataSource.close();
- System.exit( 0 );
-
- }
-
- // TODO: Here's a fun idea: make this function multithreaded! ;)
- private static boolean processCoverage( File in, int i ) {
-
- try {
-
- ProcessCoverageRequest r = wcps.pcPrepare("http://kahlua.eecs.jacobs-university.de:7001", "RASSERVICE", in );
-
- System.err.println( "Request " + i );
-
- System.out.println( r.getQuery() );
-
-
-/* Iterator<byte[]> results = r.execute().iterator();
-
- int j = 0;
- while( results.hasNext() ) {
- String outFileName = "WCPS-" + i + "-" + j++;
- FileOutputStream out = new FileOutputStream( outFileName );
- out.write( results.next() );
- out.close();
- System.out.println( "WCPS: " + outFileName + " written" );
- }*/
-
- }
- catch( Exception e ) {
- System.err.println( "WCPS: request " + i + " failed with the following exception:" );
- e.printStackTrace( System.err );
- }
-
- return true;
-
- }
-
-}
diff --git a/src/wcps/server/cli/grammar.java b/src/wcps/server/cli/grammar.java
new file mode 100644
index 0000000..879b814
--- /dev/null
+++ b/src/wcps/server/cli/grammar.java
@@ -0,0 +1,53 @@
+package wcps.server.cli;
+
+import grammar.*;
+import grammar.wcpsParser.*;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import org.antlr.runtime.ANTLRInputStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.antlr.runtime.RecognitionException;
+
+/** Test the WCPS grammar parser (generated by ANTLR).
+ * Input a Abstract Syntax query.
+ * Outputs the corresponding XML tree.
+ *
+ * @author Andrei Aiordachioaie
+ */
+public class grammar {
+
+ static String query;
+
+ public static void main(String[] args) throws RecognitionException, IOException
+ {
+ if (args.length != 1)
+ {
+ System.err.println("AbstractGrammarGen: no query as parameter !");
+ // What is the meaning of AxisIterator variable and axis type? Query 15, 16
+ // Query 4: cast should not be this greedy! (float)a + b != (float) (a+b)
+ query = "for s in ( rgb, rgb, rgb ), r in ( rgb ) return count( ((s.0-s.1)/(s.0+s.1) > 0.6) * r )";
+ }
+ else
+ query = args[0];
+
+ System.out.println("Running with the following query: " + query);
+
+ InputStream stream = new ByteArrayInputStream(query.getBytes()); // defaults to ISO-1
+ ANTLRInputStream inputStream = new ANTLRInputStream(stream);
+// wcpsLexer lexer = new wcpsLexer( inputStream );
+ wcpsLexer lexer = new wcpsLexer( inputStream );
+
+ CommonTokenStream tokenStream = new CommonTokenStream(lexer);
+// wcpsParser parser = new wcpsParser(tokenStream);
+ wcpsParser parser = new wcpsParser(tokenStream);
+
+ wcpsRequest_return rrequest = parser.wcpsRequest();
+ WCPSRequest request = rrequest.value;
+ System.out.println("Output XML: \n****************\n" + request.toXML());
+
+ System.exit(0);
+
+ }
+
+}
diff --git a/src/wcps/server/cli/xml.java b/src/wcps/server/cli/xml.java
new file mode 100644
index 0000000..725a878
--- /dev/null
+++ b/src/wcps/server/cli/xml.java
@@ -0,0 +1,163 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.cli;
+
+import wcps.server.core.CachedMetadataSource;
+import wcps.server.core.DbMetadataSource;
+import wcps.server.core.ProcessCoveragesRequest;
+import wcps.server.core.WCPS;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import java.util.Properties;
+
+/**
+ * This is a small application around the WCPS core. It takes XML requests as files and runs them
+ * through WCPS. The resulting radaman queries are displayed, but not executed. This is very useful
+ * for testing whether your metadata is valid.
+ */
+
+
+public class xml
+{
+ private static WCPS wcps;
+
+ public static void main(String[] args)
+ {
+ if (args.length < 1)
+ {
+ System.err.println("WCPS CLI: no input files");
+
+ System.err.println("\nWCPS CLI Usage: java wcps.server.cli.xml input.xml");
+ System.err.println("Where input.xml contains a ProcessCoverages Request ");
+ System.exit(1);
+
+ args = new String[1];
+ args[0] = "old_testing/testcases/1.test.xml";
+ }
+ if (args.length > 1)
+ {
+ System.err.println("WCPS: no input files");
+ System.exit(1);
+ }
+
+ String pcSchemaFileName = "src" + File.separator + "conf" + File.separator + "xml"
+ + File.separator + "wcps"
+ + File.separator + "1.0.0" + File.separator + "wcpsProcessCoverages.xsd";
+ File pcSchemaFile = new File(pcSchemaFileName);
+
+ if (!pcSchemaFile.exists())
+ {
+ System.err.println("WCPS: could not find the WCPS ProcessCoverage schema ("
+ + pcSchemaFileName + ")");
+ System.exit(1);
+ }
+
+ DbMetadataSource metadataSource = null;
+
+ try
+ {
+ Properties dbParams = new Properties();
+
+ dbParams.load(new FileInputStream("dbparams.properties"));
+ metadataSource =
+ new DbMetadataSource(dbParams.getProperty("metadata_driver"),
+ dbParams.getProperty("metadata_url"),
+ dbParams.getProperty("metadata_user"),
+ dbParams.getProperty("metadata_pass"), false);
+ wcps = new WCPS(pcSchemaFile, new CachedMetadataSource(metadataSource));
+ }
+ catch (Exception e)
+ {
+ System.err.println("WCPS: could not initialize WCPS:");
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+
+ for (int i = 0; i < args.length; i++)
+ {
+ File fileIn = null;
+
+ try
+ {
+ fileIn = new File(args[i]);
+ }
+ catch (Exception fnfe)
+ {
+ System.err.println("WCPS: " + args[i]
+ + ": no such file or directory" + fnfe);
+ System.exit(1);
+ }
+
+ boolean ok = processCoverage(fileIn, i);
+
+ if (!ok)
+ {
+ System.err.println("WCPS: " + args[i] + " failed");
+ System.exit(1);
+ }
+ }
+
+ metadataSource.close();
+ System.exit(0);
+
+ }
+
+ private static boolean processCoverage(File in, int i)
+ {
+ try
+ {
+
+ ProcessCoveragesRequest r =
+ wcps.pcPrepare("http://kahlua.eecs.jacobs-university.de:7001",
+ "RASSERVICE", in);
+
+ System.err.println("Request " + i);
+
+ System.out.println(r.getRasqlQuery());
+
+
+/* Iterator<byte[]> results = r.execute().iterator();
+
+ int j = 0;
+ while( results.hasNext() ) {
+ String outFileName = "WCPS-" + i + "-" + j++;
+ FileOutputStream out = new FileOutputStream( outFileName );
+ out.write( results.next() );
+ out.close();
+ System.out.println( "WCPS: " + outFileName + " written" );
+ }*/
+ }
+ catch (Exception e)
+ {
+ System.err.println("WCPS: request " + i
+ + " failed with the following exception:");
+ e.printStackTrace(System.err);
+ }
+
+ return true;
+
+ }
+}
diff --git a/src/wcps/server/core/AxisNameType.java b/src/wcps/server/core/AxisNameType.java
new file mode 100644
index 0000000..bc2af50
--- /dev/null
+++ b/src/wcps/server/core/AxisNameType.java
@@ -0,0 +1,57 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class AxisNameType implements IRasNode
+{
+ private String name;
+
+ public AxisNameType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ System.err.println("Trying axis node: " + node.getNodeName());
+
+ while ((node != null) && node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ }
+
+ if (node != null && node.getNodeName().equals("axis"))
+ {
+ String axis = node.getTextContent();
+ if (axis.length() == 1 && "xyzt".contains(axis))
+ this.name = axis;
+ else
+ throw new WCPSException("Unknown axis name " + axis);
+ }
+ else
+ throw new WCPSException("Could not find an axis node !");
+ }
+
+ public String toRasQL()
+ {
+ return name;
+ }
+}
diff --git a/src/wcps/server/core/BinaryOperationCoverageExprType.java b/src/wcps/server/core/BinaryOperationCoverageExprType.java
index 308e742..4bba7f4 100644
--- a/src/wcps/server/core/BinaryOperationCoverageExprType.java
+++ b/src/wcps/server/core/BinaryOperationCoverageExprType.java
@@ -1,133 +1,142 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-
-public class BinaryOperationCoverageExprType implements IRasNode, ICoverageInfo {
-
- private IRasNode first, second;
- private String operation;
- private CoverageInfo info;
-
- public BinaryOperationCoverageExprType(Node node, ProcessCoverageRequest pcr) throws WCPSException {
- String nodeName = node.getNodeName();
- System.err.println("Trying to parse binary operation: " + nodeName);
- boolean okay = false; // will be true if the node is recognized
- if (nodeName.equals("plus")) {
- operation = "+";
- okay = true;
- }
- if (nodeName.equals("minus")) {
- operation = "-";
- okay = true;
- }
- if (nodeName.equals("mult")) {
- operation = "*";
- okay = true;
- }
- if (nodeName.equals("div")) {
- operation = "/";
- okay = true;
- }
-
- if (nodeName.equals("and") || nodeName.equals("or") || nodeName.equals("xor")) {
- operation = nodeName;
- okay = true;
- }
-
- if (nodeName.equals("equals")) {
- operation = "=";
- okay = true;
- }
- if (nodeName.equals("lessThan")) {
- operation = "<";
- okay = true;
- }
- if (nodeName.equals("greaterThan")) {
- operation = ">";
- okay = true;
- }
- if (nodeName.equals("lessOrEqual")) {
- operation = "<=";
- okay = true;
- }
- if (nodeName.equals("greaterOrEqual")) {
- operation = ">=";
- okay = true;
- }
- if (nodeName.equals("notEqual")) {
- operation = "!=";
- okay = true;
- }
- if (nodeName.equals("overlay")) {
- operation = "overlay";
- okay = true;
- }
-
- if (!okay)
- throw new WCPSException("Unexpected binary operation : " + nodeName);
-
- Node operand = node.getFirstChild();
- while (operand.getNodeName().equals("#text")) operand = operand.getNextSibling();
- try {
- first = new ScalarExprType(operand, pcr);
- System.err.println("Matched scalar expression in binary operation " + nodeName + ": " + operand.getNodeName());
-
- } catch (WCPSException e) {
- System.err.println("Failed to match scalar expression in binary operation " + nodeName + ": " + operand.getNodeName());
- }
- if (first == null) {
- first = new CoverageExprType(operand, pcr);
- info = new CoverageInfo(((ICoverageInfo)first).getCoverageInfo());
- operand = operand.getNextSibling();
- while (operand.getNodeName().equals("#text"))
- operand = operand.getNextSibling();
- try {
- second = new ScalarExprType(operand, pcr);
- System.err.println("Matched scalar expression in binary operation " + nodeName + ": " + operand.getNodeName());
- } catch (WCPSException e) {
- System.err.println("Failed to match scalar expression in binary operation " + nodeName + ": " + operand.getNodeName());
- }
- if (second == null) {
- second = new CoverageExprType(operand, pcr);
- if (!((ICoverageInfo)first).getCoverageInfo().isCompatible(((ICoverageInfo)second).getCoverageInfo()))
- throw new WCPSException("Coverages are not compatible");
- }
- } else {
- operand = operand.getNextSibling();
- while (operand.getNodeName().equals("#text")) operand = operand.getNextSibling();
- second = new CoverageExprType(operand, pcr);
- info = new CoverageInfo(((ICoverageInfo)second).getCoverageInfo());
- }
- }
-
- public CoverageInfo getCoverageInfo() {
- return info;
- }
-
- public String toRasQL() {
- return "(" + first.toRasQL() + ")" + operation + "(" + second.toRasQL() + ")";
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class BinaryOperationCoverageExprType implements IRasNode, ICoverageInfo
+{
+ private IRasNode first, second;
+ private CoverageExprPairType pair;
+ private CoverageInfo info;
+ private String operation;
+
+ public BinaryOperationCoverageExprType(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+ String nodeName = node.getNodeName();
+
+ System.err.println("Trying to parse binary operation: " + nodeName);
+ boolean okay = false; // will be true if the node is recognized
+
+ if (nodeName.equals("plus"))
+ {
+ operation = "+";
+ okay = true;
+ }
+
+ if (nodeName.equals("minus"))
+ {
+ operation = "-";
+ okay = true;
+ }
+
+ if (nodeName.equals("mult"))
+ {
+ operation = "*";
+ okay = true;
+ }
+
+ if (nodeName.equals("div"))
+ {
+ operation = "/";
+ okay = true;
+ }
+
+ if (nodeName.equals("and") || nodeName.equals("or") || nodeName.equals("xor"))
+ {
+ operation = nodeName;
+ okay = true;
+ }
+
+ if (nodeName.equals("equals"))
+ {
+ operation = "=";
+ okay = true;
+ }
+
+ if (nodeName.equals("lessThan"))
+ {
+ operation = "<";
+ okay = true;
+ }
+
+ if (nodeName.equals("greaterThan"))
+ {
+ operation = ">";
+ okay = true;
+ }
+
+ if (nodeName.equals("lessOrEqual"))
+ {
+ operation = "<=";
+ okay = true;
+ }
+
+ if (nodeName.equals("greaterOrEqual"))
+ {
+ operation = ">=";
+ okay = true;
+ }
+
+ if (nodeName.equals("notEqual"))
+ {
+ operation = "!=";
+ okay = true;
+ }
+
+ if (nodeName.equals("overlay"))
+ {
+ operation = "overlay";
+ okay = true;
+ }
+
+ if (!okay)
+ {
+ throw new WCPSException("Unexpected binary operation : " + nodeName);
+ }
+
+ Node operand = node.getFirstChild();
+
+ while (operand.getNodeName().equals("#text"))
+ {
+ operand = operand.getNextSibling();
+ }
+
+ pair = new CoverageExprPairType(operand, pcr);
+ info = new CoverageInfo(((ICoverageInfo) pair).getCoverageInfo());
+ first = pair.getFirst();
+ second = pair.getSecond();
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return info;
+ }
+
+ public String toRasQL()
+ {
+ return "(" + first.toRasQL() + ")" + operation + "(" + second.toRasQL() + ")";
+ }
+}
diff --git a/src/wcps/server/core/BooleanScalarExprType.java b/src/wcps/server/core/BooleanScalarExprType.java
index 9b965d8..e44dca4 100644
--- a/src/wcps/server/core/BooleanScalarExprType.java
+++ b/src/wcps/server/core/BooleanScalarExprType.java
@@ -1,58 +1,121 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-
-public class BooleanScalarExprType implements IRasNode {
- private boolean simple; // true if the expression is just a value
- private String value;
- private String op;
- private BooleanScalarExprType first, second;
-
- public BooleanScalarExprType(Node node, ProcessCoverageRequest pcr) throws WCPSException {
- String nodeName = node.getNodeName();
- simple = false;
- if (nodeName.equals("boolean")) {
- simple = true;
- value = node.getFirstChild().getNodeValue();
- } else if (nodeName.equals("scalarAnd") || nodeName.equals("scalarOr") || nodeName.equals("scalarXor")) {
- if (nodeName.equals("scalarAnd")) op = "and";
- if (nodeName.equals("scalarOr")) op = "or";
- if (nodeName.equals("scalarXor")) op = "xor";
- Node child = node.getFirstChild();
- first = new BooleanScalarExprType(child, pcr);
- child = child.getNextSibling();
- second = new BooleanScalarExprType(child, pcr);
- } else if (nodeName.equals("scalarNot")) {
- op = "not";
- first = new BooleanScalarExprType(node.getFirstChild(), pcr);
- } else throw new WCPSException("Unexpected Binary Expression node : " + node.getNodeName());
- }
-
- public String toRasQL() {
- if (simple) return value;
- if (op.equals("not")) return "not(" + first.toRasQL() + ")";
- return "(" + first.toRasQL() + ")" + op + "(" + second.toRasQL() + ")";
- }
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class BooleanScalarExprType implements IRasNode
+{
+ private BooleanScalarExprType first, second;
+ private String op;
+ private boolean simple; // true if the expression is just a value
+ private String value;
+
+ public BooleanScalarExprType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ if (node == null)
+ throw new WCPSException("Unexpected null node !");
+
+ String nodeName = node.getNodeName();
+
+ simple = false;
+
+ System.out.println("Parsing boolean scalar operation ...");
+
+ if (nodeName.equals("booleanConstant"))
+ {
+ simple = true;
+ value = node.getFirstChild().getNodeValue();
+ }
+ else if (nodeName.equals("booleanAnd")
+ || nodeName.equals("booleanOr")
+ || nodeName.equals("booleanXor")
+ || nodeName.equals("booleanLessThan")
+ || nodeName.equals("booleanLessOrEqual")
+ || nodeName.equals("booleanGreaterThan")
+ || nodeName.equals("booleanGreaterOrEqual")
+ || nodeName.equals("booleanEqualNumeric")
+ || nodeName.equals("booleanNotEqualNumeric")
+ || nodeName.equals("booleanEqualString")
+ || nodeName.equals("booleanNotEqualString"))
+ {
+ // Logical operations
+ if (nodeName.equals("booleanAnd")
+ || nodeName.equals("booleanOr")
+ || nodeName.equals("booleanXor"))
+ {
+ // Remove the "boolean" in front
+ op = nodeName.substring(7).toLowerCase();
+ }
+ else
+ // Boolean Comparison operations
+ {
+ if (nodeName.equals("booleanLessThan"))
+ op = "<";
+ if (nodeName.equals("booleanLessOrEqual"))
+ op = "<=";
+ if (nodeName.equals("booleanGreaterThan"))
+ op = ">";
+ if (nodeName.equals("booleanGreaterOrEqual"))
+ op = ">=";
+ if (nodeName.equals("booleanEqualNumeric") || nodeName.equals("booleanEqualString"))
+ op = "=";
+ if (nodeName.equals("booleanNotEqualNumeric") || nodeName.equals("booleanNotEqualString"))
+ op = "!=";
+ }
+
+ Node child = node.getFirstChild();
+
+ first = new BooleanScalarExprType(child, pcr);
+ child = child.getNextSibling();
+ second = new BooleanScalarExprType(child, pcr);
+ }
+ else if (nodeName.equals("booleanNot"))
+ {
+ op = "not";
+ first = new BooleanScalarExprType(node.getFirstChild(), pcr);
+ }
+ else
+ {
+ throw new WCPSException("Unexpected Binary Expression node : "
+ + node.getNodeName());
+ }
+ System.err.println("*** Boolean Scalar Expr SUCCESS: " + node.getNodeName());
+ }
+
+ public String toRasQL()
+ {
+ if (simple)
+ {
+ return value;
+ }
+
+ if (op.equals("not"))
+ {
+ return "not(" + first.toRasQL() + ")";
+ }
+
+ return "(" + first.toRasQL() + ")" + op + "(" + second.toRasQL() + ")";
+ }
+}
diff --git a/src/wcps/server/core/CachedMetadataSource.java b/src/wcps/server/core/CachedMetadataSource.java
index ebf4456..08cc68d 100644
--- a/src/wcps/server/core/CachedMetadataSource.java
+++ b/src/wcps/server/core/CachedMetadataSource.java
@@ -1,95 +1,110 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-// A MetadataSource that caches reads from another MetadataSource. It reads and caches all coverages at startup, in order to make reads faster and so that WCPS will continue to work once it initializes correctly, even if the database cannot be accessed, or metadata is changed into an invalid state.
-
-public class CachedMetadataSource implements MetadataSource {
-
- private Set<String> coverageNames;
- private MetadataSource metadataSource;
- private Map<String,Metadata> metadata;
- private Map<String,String> supportedFormats;
-
- public CachedMetadataSource( MetadataSource metadataSource ) throws ResourceException, InvalidMetadataException {
-
- this.metadataSource = metadataSource;
-
- coverageNames = metadataSource.coverages();
- metadata = new HashMap<String,Metadata>( coverageNames.size() );
- supportedFormats = new HashMap<String,String>();
- Iterator<String> i = coverageNames.iterator();
- try {
- while( i.hasNext() ) {
- String coverage = i.next();
- metadata.put( coverage, metadataSource.read( coverage ) );
- }
- }
- catch( InvalidRequestException ire ) {
- throw (InvalidMetadataException) ire.getCause();
- }
-
- }
-
- public Set<String> coverages() {
-
- return coverageNames;
-
- }
-
- public String mimetype( String format ) {
-
- if( supportedFormats.containsKey( format ) ) {
- return supportedFormats.get( format );
- }
- else {
- String mimetype = metadataSource.mimetype( format );
- synchronized( this ) {
- supportedFormats.put( format, mimetype );
- }
- return mimetype;
- }
-
- }
-
- public Metadata read( String coverageName ) throws InvalidRequestException {
-
- if( coverageName == null || coverageName.equals( "" ) ) {
- throw new InvalidRequestException( "Cannot retrieve coverage with null or empty name" );
- }
-
- if( !coverageNames.contains( coverageName ) ) {
- throw new InvalidRequestException( "Coverage '" + coverageName + "' is not served by this server" );
- }
-
- return metadata.get( coverageName ).clone();
-
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+//A MetadataSource that caches reads from another MetadataSource. It reads and caches all coverages at startup, in order to make reads faster and so that WCPS will continue to work once it initializes correctly, even if the database cannot be accessed, or metadata is changed into an invalid state.
+
+public class CachedMetadataSource implements MetadataSource
+{
+ private Set<String> coverageNames;
+ private Map<String, Metadata> metadata;
+ private MetadataSource metadataSource;
+ private Map<String, String> supportedFormats;
+
+ public CachedMetadataSource(MetadataSource metadataSource)
+ throws ResourceException, InvalidMetadataException
+ {
+ this.metadataSource = metadataSource;
+
+ coverageNames = metadataSource.coverages();
+ metadata = new HashMap<String, Metadata>(coverageNames.size());
+ supportedFormats = new HashMap<String, String>();
+ Iterator<String> i = coverageNames.iterator();
+
+ try
+ {
+ while (i.hasNext())
+ {
+ String coverage = i.next();
+
+ metadata.put(coverage, metadataSource.read(coverage));
+ }
+ }
+ catch (InvalidRequestException ire)
+ {
+ throw(InvalidMetadataException) ire.getCause();
+ }
+
+ }
+
+ public Set<String> coverages()
+ {
+ return coverageNames;
+
+ }
+
+ public String mimetype(String format)
+ {
+ if (supportedFormats.containsKey(format))
+ {
+ return supportedFormats.get(format);
+ }
+ else
+ {
+ String mimetype = metadataSource.mimetype(format);
+
+ synchronized (this)
+ {
+ supportedFormats.put(format, mimetype);
+ }
+
+ return mimetype;
+ }
+
+ }
+
+ public Metadata read(String coverageName) throws InvalidRequestException
+ {
+ if ((coverageName == null) || coverageName.equals(""))
+ {
+ throw new InvalidRequestException(
+ "Cannot retrieve coverage with null or empty name");
+ }
+
+ if (!coverageNames.contains(coverageName))
+ {
+ throw new InvalidRequestException("Coverage '" + coverageName
+ + "' is not served by this server");
+ }
+
+ return metadata.get(coverageName).clone();
+
+ }
+}
diff --git a/src/wcps/server/core/CellDomainElement.java b/src/wcps/server/core/CellDomainElement.java
index fe29155..f5c69dc 100644
--- a/src/wcps/server/core/CellDomainElement.java
+++ b/src/wcps/server/core/CellDomainElement.java
@@ -1,76 +1,87 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import java.math.BigInteger;
-
-// A coverage axis in pixel coordinates. See the WCPS standard.
-
-class CellDomainElement implements Cloneable {
-
- private BigInteger hi;
- private BigInteger lo;
-
- public CellDomainElement( BigInteger lo, BigInteger hi ) throws InvalidMetadataException {
-
- if( lo == null || hi == null ) {
- throw new InvalidMetadataException( "Invalid cell domain element: Bounds may not be null" );
- }
- if( lo.compareTo( hi ) == 1 ) {
- throw new InvalidMetadataException( "Invalid cell domain element: Lower bound cannot be larger than upper bound" );
- }
- this.lo = lo;
- this.hi = hi;
-
- }
-
- public CellDomainElement clone() {
-
- try {
- return new CellDomainElement( BigInteger.ZERO.add( lo ), BigInteger.ZERO.add( hi ) );
- }
- catch( InvalidMetadataException ime ) {
- throw new RuntimeException( "Invalid metadata while cloning CellDomainElement. This is a software bug in WCPS.", ime );
- }
-
- }
-
- public boolean equals( CellDomainElement cde ) {
-
- return lo.equals( cde.lo ) && hi.equals( cde.hi );
-
- }
-
- public BigInteger getHi() {
-
- return hi;
-
- }
-
- public BigInteger getLo() {
-
- return lo;
-
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import java.math.BigInteger;
+
+//A coverage axis in pixel coordinates. See the WCPS standard.
+
+class CellDomainElement implements Cloneable
+{
+ private BigInteger hi;
+ private BigInteger lo;
+
+ public CellDomainElement(BigInteger lo, BigInteger hi) throws InvalidMetadataException
+ {
+ if ((lo == null) || (hi == null))
+ {
+ throw new InvalidMetadataException(
+ "Invalid cell domain element: Bounds may not be null");
+ }
+
+ if (lo.compareTo(hi) == 1)
+ {
+ throw new InvalidMetadataException(
+ "Invalid cell domain element: Lower bound cannot be larger than upper bound");
+ }
+
+ this.lo = lo;
+ this.hi = hi;
+
+ }
+
+ public CellDomainElement clone()
+ {
+ try
+ {
+ return new CellDomainElement(BigInteger.ZERO.add(lo),
+ BigInteger.ZERO.add(hi));
+ }
+ catch (InvalidMetadataException ime)
+ {
+ throw new RuntimeException(
+ "Invalid metadata while cloning CellDomainElement. This is a software bug in WCPS.",
+ ime);
+ }
+
+ }
+
+ public boolean equals(CellDomainElement cde)
+ {
+ return lo.equals(cde.lo) && hi.equals(cde.hi);
+
+ }
+
+ public BigInteger getHi()
+ {
+ return hi;
+
+ }
+
+ public BigInteger getLo()
+ {
+ return lo;
+
+ }
+}
diff --git a/src/wcps/server/core/CombineRangeCoverageExprType.java b/src/wcps/server/core/CombineRangeCoverageExprType.java
deleted file mode 100644
index a0562f2..0000000
--- a/src/wcps/server/core/CombineRangeCoverageExprType.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-
-// TODO(smsorin): how do we do combine this ?
-public class CombineRangeCoverageExprType implements IRasNode, ICoverageInfo {
-
- public CombineRangeCoverageExprType(Node node, ProcessCoverageRequest pcr) throws WCPSException{
- throw new WCPSException("Method not implemented");
- }
-
- public String toRasQL() { return ""; }
- public CoverageInfo getCoverageInfo() { return null; }
-}
diff --git a/src/wcps/server/core/ComplexConstantType.java b/src/wcps/server/core/ComplexConstantType.java
new file mode 100644
index 0000000..da353ef
--- /dev/null
+++ b/src/wcps/server/core/ComplexConstantType.java
@@ -0,0 +1,60 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class ComplexConstantType implements IRasNode
+{
+ private String re, im;
+
+ public ComplexConstantType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ System.err.println("Parsing complex constant: " + node.getNodeName());
+
+ while ((node != null) && node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ }
+
+ while (node != null)
+ {
+ String name = node.getNodeName();
+ if (name.equals("re"))
+ re = node.getNodeValue();
+ else
+ if (name.equals("im"))
+ im = node.getNodeValue();
+ else
+ throw new WCPSException("Unknown node while processing complex constant: " + name);
+
+ node = node.getNextSibling();
+ }
+ }
+
+ public String toRasQL()
+ {
+ return "complex ( " + re + ", " + im + " ) ";
+ }
+}
diff --git a/src/wcps/server/core/CondenseScalarExprType.java b/src/wcps/server/core/CondenseScalarExprType.java
new file mode 100644
index 0000000..67f0220
--- /dev/null
+++ b/src/wcps/server/core/CondenseScalarExprType.java
@@ -0,0 +1,40 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+// TODO: implement CondenseScalarExprType
+public class CondenseScalarExprType implements IRasNode
+{
+ public CondenseScalarExprType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ throw new WCPSException("Method not implemented");
+ }
+
+ public String toRasQL()
+ {
+ return "";
+ }
+}
diff --git a/src/wcps/server/core/ConstantCoverageExprType.java b/src/wcps/server/core/ConstantCoverageExprType.java
new file mode 100644
index 0000000..c5de6c9
--- /dev/null
+++ b/src/wcps/server/core/ConstantCoverageExprType.java
@@ -0,0 +1,46 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+// TODO: implement class ConstantCoverageExprType
+public class ConstantCoverageExprType implements IRasNode, ICoverageInfo
+{
+ public ConstantCoverageExprType(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+ throw new WCPSException("Method not implemented");
+ }
+
+ public String toRasQL()
+ {
+ return "";
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return null;
+ }
+}
diff --git a/src/wcps/server/core/ConstructCoverageExprType.java b/src/wcps/server/core/ConstructCoverageExprType.java
new file mode 100644
index 0000000..2a127e4
--- /dev/null
+++ b/src/wcps/server/core/ConstructCoverageExprType.java
@@ -0,0 +1,46 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+// TODO: implement class ConstructCoverageExprType
+public class ConstructCoverageExprType implements IRasNode, ICoverageInfo
+{
+ public ConstructCoverageExprType(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+ throw new WCPSException("Method not implemented");
+ }
+
+ public String toRasQL()
+ {
+ return "";
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return null;
+ }
+}
diff --git a/src/wcps/server/core/CoordinateType.java b/src/wcps/server/core/CoordinateType.java
deleted file mode 100644
index 72ff1d1..0000000
--- a/src/wcps/server/core/CoordinateType.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-import java.util.List;
-import java.util.Iterator;
-
-public class CoordinateType implements IRasNode {
- private int value;
-
- public CoordinateType(Node node) throws WCPSException {
- if (!node.getNodeName().equals("cellCoord") &&
- !node.getNodeName().equals("domainCoord"))
- throw new WCPSException("Expected cellCoord or domainCoord, found " + node.getNodeName());
-
- System.out.println("CoordinateType: node name: " + node.getNodeName());
- System.out.println("CoordinateType: node child 1: " + node.getFirstChild().getNodeName());
- value = Integer.parseInt(node.getFirstChild().getNodeValue());
- }
-
- public int getValue() {
- return value;
- }
-
- public String toRasQL() {
- return ""+value;
- }
-};
diff --git a/src/wcps/server/core/CoverageExprPairType.java b/src/wcps/server/core/CoverageExprPairType.java
new file mode 100644
index 0000000..eac6cc9
--- /dev/null
+++ b/src/wcps/server/core/CoverageExprPairType.java
@@ -0,0 +1,109 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class CoverageExprPairType implements IRasNode, ICoverageInfo
+{
+ private IRasNode first, second;
+ private CoverageInfo info;
+ private boolean ok = false;
+
+ public CoverageExprPairType(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+ String nodeName = node.getNodeName();
+
+ System.err.println("Trying to parse a coverage expression pair ... Starting at node "
+ + nodeName);
+
+ // Combination 1: CoverageExprType + CoverageExprType
+ try
+ {
+ first = new CoverageExprType(node, pcr);
+ second = new CoverageExprType(node.getNextSibling(), pcr);
+ info = new CoverageInfo(((ICoverageInfo) first).getCoverageInfo());
+ ok = true;
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to parse a CoverageExprType + CoverageExprType!");
+ }
+
+ // Combination 2: CoverageExprType + ScalarExprType
+ if (ok == false)
+ try
+ {
+ first = new CoverageExprType(node, pcr);
+ second = new ScalarExprType(node.getNextSibling(), pcr);
+ info = new CoverageInfo(((ICoverageInfo) first).getCoverageInfo());
+ ok = true;
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to parse CoverageExprType + ScalarExprType!");
+ }
+
+ // Combination 3: ScalarExprType + CoverageExprType
+ if (ok == false)
+ try
+ {
+ first = new ScalarExprType(node, pcr);
+ second = new CoverageExprType(node.getNextSibling(), pcr);
+ info = new CoverageInfo(((ICoverageInfo) second).getCoverageInfo());
+ ok = true;
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to parse ScalarExprType + CoverageExprType!");
+ }
+
+ if (ok == false)
+ throw new WCPSException("Could not parse a coverage expression pair !");
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return info;
+ }
+
+ public String toRasQL()
+ {
+ if (ok == true)
+ return first.toRasQL() + second.toRasQL();
+ else
+ return " error ";
+ }
+
+ public IRasNode getFirst()
+ {
+ return first;
+ }
+
+ public IRasNode getSecond()
+ {
+ return second;
+ }
+}
diff --git a/src/wcps/server/core/CoverageExprType.java b/src/wcps/server/core/CoverageExprType.java
index 15a042f..8d407e0 100644
--- a/src/wcps/server/core/CoverageExprType.java
+++ b/src/wcps/server/core/CoverageExprType.java
@@ -1,131 +1,188 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-import java.util.Iterator;
-
-public class CoverageExprType implements IRasNode, ICoverageInfo {
-
- private boolean simpleCoverage; // True is the coverage is just a string
- private IRasNode child;
- private String childInfo;
- private CoverageInfo info;
-
- public CoverageInfo getCoverageInfo() {
- return info;
- }
-
- public CoverageExprType (Node node, ProcessCoverageRequest pcr) throws WCPSException {
- while (node != null && node.getNodeName().equals("#text")) {
- node = node.getNextSibling();
- }
-
- if (node == null) throw new WCPSException("CoverageExprType parsing error!");
- String nodeName = node.getNodeName();
- simpleCoverage = false;
- System.err.println("CoverageExprType: node " + nodeName);
-
- if (nodeName.equals("coverage")) {
- simpleCoverage = true;
- childInfo = node.getFirstChild().getNodeValue();
- if (!pcr.isIteratorDefined(childInfo))
- throw new WCPSException("Iterator " + childInfo + " not defined!");
-
- Iterator<String> coverages = pcr.getCoverages(childInfo);
-
- info = new CoverageInfo(pcr.getMetadataSource().read(coverages.next()));
-
- while (coverages.hasNext()) { // Check if all the coverages are compatible
- CoverageInfo tmp = new CoverageInfo(pcr.getMetadataSource().read(coverages.next()));
- if (!tmp.isCompatible(info))
- throw new WCPSException("Incompatible coverages within the same iterator");
- }
- System.err.println("Found simple coverage definition: " + childInfo + ", " + info.toString());
- } else if (nodeName.equals("trim")) {
- child = new TrimCoverageExprType(node, pcr);
- } else if (nodeName.equals("extend")) {
- //child = new ExtendCoverageExprType(node, pcr);
- // TODO: add the class and remove this
- throw new WCPSException("Feature not yet implemented");
- } else if (nodeName.equals("slice")) {
- child = new SliceCoverageExprType(node, pcr);
- } else if (nodeName.equals("scale")) {
- //child = new ScaleCoverageExprType(node, pcr);
- // TODO: add the class and remove this
- throw new WCPSException("Feature not yet implemented");
- } else if (nodeName.equals("combine")) {
- child = new CombineRangeCoverageExprType(node, pcr);
- } else if (nodeName.equals("crsTransform")) {
- child = new CrsTransformCoverageExprType(node, pcr);
- } else if (nodeName.equals("construct")) {
- //child = new ConstructcoverageExprType(node, pcr);
- // TODO: add the class and remove this
- throw new WCPSException("Feature not yet implemented");
-
- } else { // Try one of the groups
- try {
- child = new UnaryOperationCoverageExprType(node, pcr);
- System.err.println("Matched unary operation.");
- } catch (WCPSException e) {
- System.err.println("Failed to match Unary operation: " + e.toString() + "\nRetrying");
- child = null;
- }
-
- if (child == null) {
- try {
- child = new BinaryOperationCoverageExprType(node, pcr);
- System.err.println("Matched binary operation.");
- } catch (WCPSException e) {
- System.err.println("Failed to match binary operation: " + e.toString() + "\nRetrying");
- child = null;
- }
- }
-
- // TODO: implement the class and remove this
- /* if (child == null) {
- try {
- child = new SetMetadataCoverageExprType(node, pcr);
- } catch (WCPSException e) {
- child = null;
- }
- }*/
-
- }
- if (!simpleCoverage && child == null) {
- throw new WCPSException("Invalid coverage Expression, next node: " + node.getNodeName());
- }
- if (info == null) {
- System.err.println(node.getNodeName());
- info = new CoverageInfo(((ICoverageInfo)child).getCoverageInfo());
- }
- }
-
- public String toRasQL() {
- if (simpleCoverage)
- return childInfo;
- else
- return child.toRasQL();
- }
-
-};
+ /*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+import java.util.Iterator;
+
+public class CoverageExprType implements IRasNode, ICoverageInfo
+{
+ private IRasNode child;
+ private String childInfo;
+ private CoverageInfo info;
+ private boolean simpleCoverage; // True is the coverage is just a string
+
+ public CoverageExprType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ while ((node != null) && node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ }
+
+ if (node == null)
+ {
+ throw new WCPSException("CoverageExprType parsing error!");
+ }
+
+ String nodeName = node.getNodeName();
+
+ simpleCoverage = false;
+ System.err.println("CoverageExprType: node " + nodeName);
+
+ if (nodeName.equals("coverage"))
+ {
+ simpleCoverage = true;
+ childInfo = node.getFirstChild().getNodeValue();
+
+ if (!pcr.isIteratorDefined(childInfo))
+ {
+ throw new WCPSException("Iterator " + childInfo + " not defined!");
+ }
+
+ Iterator<String> coverages = pcr.getCoverages(childInfo);
+
+ info = new CoverageInfo(pcr.getMetadataSource().read(coverages.next()));
+
+ while (coverages.hasNext())
+ { // Check if all the coverages are compatible
+ CoverageInfo tmp = new CoverageInfo(
+ pcr.getMetadataSource().read(
+ coverages.next()));
+
+ if (!tmp.isCompatible(info))
+ {
+ throw new WCPSException(
+ "Incompatible coverages within the same iterator");
+ }
+ }
+
+ System.err.println("Found simple coverage definition: " + childInfo + ", "
+ + info.toString());
+ }
+ else if (nodeName.equals("crsTransform"))
+ {
+ // TODO: implement CrsTransform class
+ child = new CrsTransformCoverageExprType(node, pcr);
+ }
+ else if (nodeName.equals("scale"))
+ {
+ // TODO: implement class ScaleCoverageExprType
+ child = new ScaleCoverageExprType(node, pcr);
+ }
+ else if (nodeName.equals("construct"))
+ {
+ // TODO: implement ConstructCoverageExprType class
+ child = new ConstructCoverageExprType(node, pcr);
+ }
+ else if (nodeName.equals("const"))
+ {
+ child = new ConstantCoverageExprType(node, pcr);
+ }
+ else
+ { // Try one of the groups
+ child = null;
+
+ if (child == null)
+ {
+ try
+ {
+ child = new SetMetadataCoverageExprType(node, pcr);
+ System.err.println("Matched set metadata operation.");
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to match set metadata operation: "
+ + e.toString() + "\nRetrying");
+ child = null;
+ }
+ }
+
+ if (child == null)
+ {
+ try
+ {
+ child = new InducedOperationCoverageExprType(node, pcr);
+ System.err.println("Matched induced coverage expression operation.");
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to match induced coverage expression operation: "
+ + e.toString() + "\nRetrying");
+ child = null;
+ if (e.getMessage().equals("Method not implemented"))
+ throw e;
+ }
+ }
+
+ if (child == null)
+ {
+ try
+ {
+ child = new SubsetOperationCoverageExprType(node, pcr);
+ System.err.println("Matched subset operation.");
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to match subset operation: "
+ + "\nRetrying");
+ child = null;
+ }
+ }
+
+ }
+
+ if (!simpleCoverage && (child == null))
+ {
+ throw new WCPSException("Invalid coverage Expression, next node: "
+ + node.getNodeName());
+ }
+
+ if (info == null)
+ {
+ System.err.println(node.getNodeName());
+ info = new CoverageInfo(((ICoverageInfo) child).getCoverageInfo());
+ }
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return info;
+ }
+
+ public String toRasQL()
+ {
+ if (simpleCoverage)
+ {
+ return childInfo;
+ }
+ else
+ {
+ return child.toRasQL();
+ }
+ }
+}
+
+
+;
diff --git a/src/wcps/server/core/CoverageInfo.java b/src/wcps/server/core/CoverageInfo.java
index 3cba44d..dfa3b4e 100644
--- a/src/wcps/server/core/CoverageInfo.java
+++ b/src/wcps/server/core/CoverageInfo.java
@@ -1,138 +1,177 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Iterator;
-
-public class CoverageInfo {
-
- private List<CellDomainElement> cellDomains;
- private List<DomainElement> domains;
-
-
- public CoverageInfo(CoverageInfo other) {
- cellDomains = new ArrayList<CellDomainElement>();
- domains = new ArrayList<DomainElement>();
- int N = other.getNumDimensions();
- for (int i = 0; i < N; ++i) {
- cellDomains.add(other.getCellDomainElement(i));
- domains.add(other.getDomainElement(i));
- }
- }
-
- public CoverageInfo(Metadata m) {
- cellDomains = new ArrayList<CellDomainElement>();
- domains = new ArrayList<DomainElement>();
- Iterator<CellDomainElement> itcde = m.getCellDomainIterator();
-
- while (itcde.hasNext())
- cellDomains.add (itcde.next());
-
- Iterator<DomainElement> itde = m.getDomainIterator();
- while (itde.hasNext())
- domains.add(itde.next());
- }
-
- public boolean isCompatible(CoverageInfo other) {
- if (getNumDimensions() != other.getNumDimensions()) {
- System.err.println("The number of dimensions doesn't match");
- return false;
- }
- {
- Iterator<CellDomainElement> it = cellDomains.iterator();
- int index = 0;
- while (it.hasNext()) {
- CellDomainElement me, you;
- me = it.next();
- you = other.getCellDomainElement(index ++);
- if (!me.getHi().equals(you.getHi())) {
- System.err.println("High values don't match: " + me.getHi().toString() + ", " + you.getHi().toString());
- return false;
- }
- if (!me.getLo().equals(you.getLo())) {
- System.err.println("Low values don't match: " + me.getLo().toString() + ", " + you.getLo().toString());
- return false;
- }
- }
- }
- {
- Iterator<DomainElement> it = domains.iterator();
- int index = 0;
- while (it.hasNext()) {
- DomainElement me, you;
- me = it.next();
- you = other.getDomainElement(index ++);
- if (!me.getName().equals(you.getName())) {
- System.err.println("Domain element names don't match: '" + me.getName() + "' and '"+
- you.getName() + "'.");
- return false;
- }
- //if (me.getName() != you.getName()) return false;
- }
- }
- return true;
- }
-
-
-
- int getNumDimensions() {
- return cellDomains.size();
- }
-
- public CellDomainElement getCellDomainElement(int dim) {
- return cellDomains.get(dim);
- }
-
- public DomainElement getDomainElement(int dim) {
- return domains.get(dim);
- }
-
- public void removeDimension(int dim) {
- cellDomains.remove(dim);
- domains.remove(dim);
- }
-
- public void setDimension(int dim,CellDomainElement cde, DomainElement de) {
- cellDomains.set(dim, cde);
- domains.set(dim, de);
- }
-
- public void setCellDimension(int dim, CellDomainElement cde) {
- cellDomains.set(dim, cde);
- }
-
- public int getDomainIndexByName(String name) throws WCPSException {
- Iterator<DomainElement> it = domains.iterator();
- int index = 0;
- while (it.hasNext() ) {
- if (name.equals(it.next().getName())) {
- return index;
- }
- index ++;
- }
- throw new WCPSException("Domain name not found :" + name);
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class CoverageInfo
+{
+ private List<CellDomainElement> cellDomains;
+ private List<DomainElement> domains;
+
+ public CoverageInfo(CoverageInfo other)
+ {
+ cellDomains = new ArrayList<CellDomainElement>();
+ domains = new ArrayList<DomainElement>();
+ int N = other.getNumDimensions();
+
+ for (int i = 0; i < N; ++i)
+ {
+ cellDomains.add(other.getCellDomainElement(i));
+ domains.add(other.getDomainElement(i));
+ }
+ }
+
+ public CoverageInfo(Metadata m)
+ {
+ cellDomains = new ArrayList<CellDomainElement>();
+ domains = new ArrayList<DomainElement>();
+ Iterator<CellDomainElement> itcde = m.getCellDomainIterator();
+
+ while (itcde.hasNext())
+ {
+ cellDomains.add(itcde.next());
+ }
+
+ Iterator<DomainElement> itde = m.getDomainIterator();
+
+ while (itde.hasNext())
+ {
+ domains.add(itde.next());
+ }
+ }
+
+ public boolean isCompatible(CoverageInfo other)
+ {
+ if (getNumDimensions() != other.getNumDimensions())
+ {
+ System.err.println("The number of dimensions doesn't match");
+ return false;
+ }
+
+ {
+ Iterator<CellDomainElement> it = cellDomains.iterator();
+ int index = 0;
+
+ while (it.hasNext())
+ {
+ CellDomainElement me, you;
+
+ me = it.next();
+ you = other.getCellDomainElement(index++);
+
+ if (!me.getHi().equals(you.getHi()))
+ {
+ System.err.println("High values don't match: "
+ + me.getHi().toString() + ", "
+ + you.getHi().toString());
+ return false;
+ }
+
+ if (!me.getLo().equals(you.getLo()))
+ {
+ System.err.println("Low values don't match: "
+ + me.getLo().toString() + ", "
+ + you.getLo().toString());
+ return false;
+ }
+ }
+ }
+ {
+ Iterator<DomainElement> it = domains.iterator();
+ int index = 0;
+
+ while (it.hasNext())
+ {
+ DomainElement me, you;
+
+ me = it.next();
+ you = other.getDomainElement(index++);
+
+ if (!me.getName().equals(you.getName()))
+ {
+ System.err.println("Domain element names don't match: '"
+ + me.getName() + "' and '"
+ + you.getName() + "'.");
+ return false;
+ }
+
+ // if (me.getName() != you.getName()) return false;
+ }
+ }
+ return true;
+ }
+
+ int getNumDimensions()
+ {
+ return cellDomains.size();
+ }
+
+ public CellDomainElement getCellDomainElement(int dim)
+ {
+ return cellDomains.get(dim);
+ }
+
+ public DomainElement getDomainElement(int dim)
+ {
+ return domains.get(dim);
+ }
+
+ public void removeDimension(int dim)
+ {
+ cellDomains.remove(dim);
+ domains.remove(dim);
+ }
+
+ public void setDimension(int dim, CellDomainElement cde, DomainElement de)
+ {
+ cellDomains.set(dim, cde);
+ domains.set(dim, de);
+ }
+
+ public void setCellDimension(int dim, CellDomainElement cde)
+ {
+ cellDomains.set(dim, cde);
+ }
+
+ public int getDomainIndexByName(String name) throws WCPSException
+ {
+ Iterator<DomainElement> it = domains.iterator();
+ int index = 0;
+
+ while (it.hasNext())
+ {
+ if (name.equals(it.next().getName()))
+ {
+ return index;
+ }
+
+ index++;
+ }
+
+ throw new WCPSException("Domain name not found :" + name);
+ }
+}
diff --git a/src/wcps/server/core/CoverageIterator.java b/src/wcps/server/core/CoverageIterator.java
index 81eef59..dd94a7b 100644
--- a/src/wcps/server/core/CoverageIterator.java
+++ b/src/wcps/server/core/CoverageIterator.java
@@ -1,77 +1,105 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-public class CoverageIterator implements IRasNode {
-
- private String iteratorName;
-
- private List<String> coverageNames;
-
- public CoverageIterator(Node x, ProcessCoverageRequest pcr) throws WCPSException {
- MetadataSource source = pcr.getMetadataSource();
- coverageNames = new ArrayList<String>();
- if (x.getNodeName() != "coverageIterator")
- throw new WCPSException("Invalid cast form " + x.getNodeName() + " XML node to CoverageIterator class");
- Node it = x.getFirstChild();
- while(it != null) {
- if (it.getNodeName().equals("#text")) {
- it = it.getNextSibling();
- continue;
- }
- if (it.getNodeName().equals("iteratorVar")) {
- iteratorName = it.getFirstChild().getNodeValue();
- System.err.println("Found iterator name : " + iteratorName);
- } else if (it.getNodeName().equals("coverageName")) {
- String cn = it.getFirstChild().getNodeValue();
- System.err.println("Found coverage reference : " + cn);
- try {
- if (!source.coverages().contains(cn))
- throw new WCPSException("Unknown coverage " + cn);
- } catch (ResourceException e) {
- throw new WCPSException("Cannot load coverage information!", e);
- }
- coverageNames.add(cn);
- }
- it = it.getNextSibling();
- }
- }
-
- public Iterator<String> getCoverages() {
- return coverageNames.iterator();
- }
-
- public String getIteratorName() {
- return iteratorName;
- }
-
- public String toRasQL() {
- // TODO(smsorin) : How to translate multiple coverages?
- return coverageNames.get(0) + " AS " + iteratorName;
- }
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class CoverageIterator implements IRasNode
+{
+ private List<String> coverageNames;
+ private String iteratorName;
+
+ public CoverageIterator(Node x, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ MetadataSource source = pcr.getMetadataSource();
+
+ coverageNames = new ArrayList<String>();
+
+ if (! x.getNodeName().equals("coverageIterator"))
+ {
+ throw new WCPSException("Invalid cast form " + x.getNodeName()
+ + " XML node to CoverageIterator class");
+ }
+
+ Node it = x.getFirstChild();
+
+ while (it != null)
+ {
+ if (it.getNodeName().equals("#text"))
+ {
+ it = it.getNextSibling();
+ continue;
+ }
+
+ if (it.getNodeName().equals("iteratorVar"))
+ {
+ iteratorName = it.getFirstChild().getNodeValue();
+ System.err.println("*** Iterator variable : " + iteratorName);
+ }
+ else if (it.getNodeName().equals("coverageName"))
+ {
+ String cn = it.getFirstChild().getNodeValue();
+
+ System.err.println("*** Coverage reference : " + cn);
+
+ try
+ {
+ if (!source.coverages().contains(cn))
+ {
+ throw new WCPSException("Unknown coverage " + cn);
+ }
+ }
+ catch (ResourceException e)
+ {
+ throw new WCPSException(
+ "Cannot load coverage information!", e);
+ }
+
+ coverageNames.add(cn);
+ }
+
+ it = it.getNextSibling();
+ }
+ }
+
+ public Iterator<String> getCoverages()
+ {
+ return coverageNames.iterator();
+ }
+
+ public String getIteratorName()
+ {
+ return iteratorName;
+ }
+
+ public String toRasQL()
+ {
+ // TODO(smsorin) : How to translate multiple coverages?
+ return coverageNames.get(0) + " AS " + iteratorName;
+ }
+}
diff --git a/src/wcps/server/core/CrsNameType.java b/src/wcps/server/core/CrsNameType.java
new file mode 100644
index 0000000..6bf71c0
--- /dev/null
+++ b/src/wcps/server/core/CrsNameType.java
@@ -0,0 +1,54 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class CrsNameType implements IRasNode
+{
+ private String crs;
+
+ public CrsNameType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ System.err.println("Parsing crs name ...");
+
+ while ((node != null) && node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ }
+
+ if (node != null && node.getNodeName().equals("srsName"))
+ {
+ String val = node.getNodeValue();
+ this.crs = val;
+ }
+ else
+ throw new WCPSException("Could not a 'srsName' node !");
+ }
+
+ public String toRasQL()
+ {
+ return crs;
+ }
+}
diff --git a/src/wcps/server/core/CrsTransformCoverageExprType.java b/src/wcps/server/core/CrsTransformCoverageExprType.java
index 7c42580..d1cc9ec 100644
--- a/src/wcps/server/core/CrsTransformCoverageExprType.java
+++ b/src/wcps/server/core/CrsTransformCoverageExprType.java
@@ -1,36 +1,46 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-
-// TODO(smsorin): how do we do combine this ?
-public class CrsTransformCoverageExprType implements IRasNode, ICoverageInfo {
-
- public CrsTransformCoverageExprType(Node node, ProcessCoverageRequest pcr) throws WCPSException{
- throw new WCPSException("Method not implemented");
- }
-
- public String toRasQL() { return ""; }
- public CoverageInfo getCoverageInfo() { return null; }
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+//TODO(smsorin): how do we do combine this ?
+public class CrsTransformCoverageExprType implements IRasNode, ICoverageInfo
+{
+ public CrsTransformCoverageExprType(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+ throw new WCPSException("Method not implemented");
+ }
+
+ public String toRasQL()
+ {
+ return "";
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return null;
+ }
+}
diff --git a/src/wcps/server/core/DbMetadataSource.java b/src/wcps/server/core/DbMetadataSource.java
index c687e29..3667251 100644
--- a/src/wcps/server/core/DbMetadataSource.java
+++ b/src/wcps/server/core/DbMetadataSource.java
@@ -1,313 +1,435 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import java.math.BigInteger;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-// The DbMetadataSource is a MetadataSource that uses a relational database. It keeps a global connection which is reused on future requests, as well as between threads. Before each read, the connection is verified to be valid, and recreated if necessary. This MetadataSource is not particularly efficient, because it accesses the database at least once for every read. To increase efficiency, wrap a CachedMetadataSource around this one.
-
-public class DbMetadataSource implements MetadataSource {
-
- private static final int CONNECTION_TIMEOUT = 4;
-
- private Map<Integer,String> axisTypes;
- private boolean checkAtInit;
- private Connection connection;
- private Map<Integer,String> crss;
- private Map<Integer,String> dataTypes;
- private String driver;
- private boolean initializing;
- private Map<Integer,String> interpolationTypes;
- private Map<Integer,String> nullResistances;
- private String pass;
- private Map<String,String> supportedFormats;
- private String url;
- private String user;
-
- public DbMetadataSource( String driver, String url, String user, String pass ) throws ResourceException, InvalidMetadataException {
-
- this( driver, url, user, pass, true );
-
- }
-
- public DbMetadataSource( String driver, String url, String user, String pass, boolean checkAtInit ) throws ResourceException, InvalidMetadataException {
-
- try {
- Class.forName( driver ).newInstance();
- }
- catch( ClassNotFoundException e ) {
- throw new ResourceException( "Metadata database error: Could not find JDBC driver: " + driver, e );
- }
- catch( InstantiationException e ) {
- throw new ResourceException( "Metadata database error: Could not instantiate JDBC driver: " + driver, e );
- }
- catch( IllegalAccessException e ) {
- throw new ResourceException( "Metadata database error: Access denied to JDBC driver: " + driver, e );
- }
- this.driver = driver;
- this.url = url;
- this.user = user;
- this.pass = pass;
- Statement s = null;
-
- try {
- ensureConnection();
-
- axisTypes = new HashMap<Integer,String>( 5 );
- s = connection.createStatement();
- ResultSet r = s.executeQuery( "SELECT id, axisType FROM WCPS_AxisType" );
- while( r.next() ) {
- axisTypes.put( r.getInt( "id" ), r.getString( "axisType" ) );
- }
-
- dataTypes = new HashMap<Integer,String>( 13 );
- r = s.executeQuery( "SELECT id, dataType FROM WCPS_Datatype" );
- while( r.next() ) {
- dataTypes.put( r.getInt( "id" ), r.getString( "dataType" ) );
- }
-
- interpolationTypes = new HashMap<Integer,String>( 5 );
- r = s.executeQuery( "SELECT id, interpolationType FROM WCPS_InterpolationType" );
- while( r.next() ) {
- interpolationTypes.put( r.getInt( "id" ), r.getString( "interpolationType" ) );
- }
-
- nullResistances = new HashMap<Integer,String>( 4 );
- r = s.executeQuery( "SELECT id, nullResistance FROM WCPS_NullResistance" );
- while( r.next() ) {
- nullResistances.put( r.getInt( "id" ), r.getString( "nullResistance" ) );
- }
-
- crss = new HashMap<Integer,String>();
- r = s.executeQuery( "SELECT id, name FROM WCPS_Crs" );
- while( r.next() ) {
- crss.put( r.getInt( "id" ), r.getString( "name" ) );
- }
-
- supportedFormats = new HashMap<String,String>( 6 );
- r = s.executeQuery( "SELECT name, mimetype FROM WCPS_Format" );
- while( r.next() ) {
- supportedFormats.put( r.getString( "name" ), r.getString( "mimetype" ) );
- }
-
- s.close();
-
- this.checkAtInit = checkAtInit;
- if( checkAtInit ) {
- initializing = true;
- boolean coveragesOk = false;
- while( !coveragesOk ) {
- try {
- Iterator<String> coverages = coverages().iterator();
- while( coverages.hasNext() ) {
- read( coverages.next() );
- }
- }
- catch( InvalidRequestException ire ) {
- throw (InvalidMetadataException) ire.getCause();
- }
- coveragesOk = true;
- }
- initializing = false;
- }
- }
- catch( SQLException sqle ) {
- if( s != null ) {
- try {
- s.close();
- }
- catch( SQLException e ) {}
- }
- close();
- throw new ResourceException( "Metadata database error", sqle );
- }
-
- }
-
- public void close() {
-
- synchronized( this ) {
- if( connection != null ) {
- try {
- connection.close();
- }
- catch( SQLException sqle ) {}
- }
- }
-
- }
-
- public Set<String> coverages() throws ResourceException {
-
- Statement s = null;
- Set<String> coverages;
-
- try {
- ensureConnection();
- s = connection.createStatement();
-
- ResultSet r = s.executeQuery( "SELECT name FROM WCPS_Coverage" );
- coverages = new HashSet<String>( r.getFetchSize() );
- while( r.next() ) {
- coverages.add( r.getString( "name" ) );
- }
-
- s.close();
- return coverages;
- }
- catch( SQLException sqle ) {
- if( s != null ) {
- try {
- s.close();
- }
- catch( SQLException f ) {}
- }
- close();
- throw new ResourceException( "Metadata database error", sqle );
- }
-
- }
-
- public String mimetype( String format ) {
-
- return supportedFormats.get( format );
-
- }
-
- public Metadata read( String coverageName ) throws InvalidRequestException, ResourceException {
-
- System.err.println( "DB: " + coverageName );
-
- if( coverageName == null || coverageName.equals( "" ) ) {
- throw new InvalidRequestException( "Cannot retrieve coverage with null or empty name" );
- }
- Statement s = null;
-
- try {
- ensureConnection();
- s = connection.createStatement();
-
- ResultSet r = s.executeQuery( "SELECT id, nullDefault, interpolationTypeDefault, nullResistanceDefault FROM WCPS_Coverage WHERE name = '" + coverageName + "'" );
- if( !r.next() ) {
- throw new InvalidRequestException( "Coverage '" + coverageName + "' is not served by this server" );
- }
- int coverage = r.getInt( "id" );
- String nullDefault = r.getString( "nullDefault" );
- String interpolationTypeDefault = interpolationTypes.get( r.getInt( "interpolationTypeDefault" ) );
- String nullResistanceDefault = nullResistances.get( r.getInt( "nullResistanceDefault" ) );
-
- r = s.executeQuery( "SELECT lo, hi FROM WCPS_CellDomain WHERE coverage = '" + coverage + "' ORDER BY i ASC" );
- List<CellDomainElement> cellDomain = new ArrayList<CellDomainElement>( r.getFetchSize() );
- while( r.next() ) {
- cellDomain.add( new CellDomainElement( BigInteger.valueOf( r.getInt( "lo" ) ), BigInteger.valueOf( r.getInt( "hi" ) ) ) );
- }
-
- r = s.executeQuery( "SELECT name, type FROM WCPS_Range WHERE coverage = '" + coverage + "' ORDER BY i ASC" );
- List<RangeElement> range = new ArrayList<RangeElement>( r.getFetchSize() );
- while( r.next() ) {
- range.add( new RangeElement( r.getString( "name" ), dataTypes.get( r.getInt( "type" ) ) ) );
- }
-
- r = s.executeQuery( "SELECT interpolationType, nullResistance FROM WCPS_InterpolationSet WHERE coverage = '" + coverage + "'" );
- Set<InterpolationMethod> interpolationSet = new HashSet<InterpolationMethod>( r.getFetchSize() );
- while( r.next() ) {
- interpolationSet.add( new InterpolationMethod( interpolationTypes.get( r.getInt( "interpolationType" ) ), nullResistances.get( r.getInt( "nullResistance" ) ) ) );
- }
-
- r = s.executeQuery( "SELECT nullValue FROM WCPS_NullSet WHERE coverage = '" + coverage + "'" );
- Set<String> nullSet = new HashSet<String>( r.getFetchSize() );
- while( r.next() ) {
- nullSet.add( r.getString( "nullValue" ) );
- }
-
- r = s.executeQuery( "SELECT id, name, type, numLo, numHi, strLo, strHi FROM WCPS_Domain WHERE coverage = '" + coverage + "' ORDER BY i ASC" );
- List<DomainElement> domain = new ArrayList<DomainElement>( r.getFetchSize() );
- Statement ss = connection.createStatement();
- while( r.next() ) {
- Double numLo = r.getDouble( "numLo" );
- if( r.wasNull() ) {
- numLo = null;
- }
- Double numHi = r.getDouble( "numHi" );
- if( r.wasNull() ) {
- numHi = null;
- }
- ResultSet rr = ss.executeQuery( "SELECT crs FROM WCPS_CrsSet WHERE axis = '" + r.getInt( "id" ) + "'" );
- Set<String> crsSet = new HashSet<String>( rr.getFetchSize() );
- while( rr.next() ) {
- crsSet.add( crss.get( rr.getInt( "crs" ) ) );
- }
- crsSet.add( DomainElement.IMAGE_CRS );
- domain.add( new DomainElement( r.getString( "name" ), axisTypes.get( r.getInt( "type" ) ), numLo, numHi, r.getString( "strLo" ), r.getString( "strHi" ), crsSet ) );
- }
-
- s.close();
-
- return new Metadata( cellDomain, range, nullSet, nullDefault, interpolationSet, new InterpolationMethod( interpolationTypeDefault, nullResistanceDefault ), coverageName, domain );
- }
- catch( InvalidMetadataException ime ) {
- if( checkAtInit && !initializing ) {
- throw new ResourceException( "Previously valid metadata is now invalid. The metadata for coverage '" + coverageName + "' has been modified incorrectly.", ime );
- }
- else {
- throw new InvalidRequestException( "Coverage '" + coverageName + "' has invalid metadata", ime );
- }
- }
- catch( SQLException sqle ) {
- if( s != null ) {
- try {
- s.close();
- }
- catch( SQLException f ) {}
- }
- close();
- throw new ResourceException( "Metadata database error", sqle );
- }
-
- }
-
- private void ensureConnection() throws SQLException {
-
- synchronized (this) {
-// if( connection == null || !connection.isValid( CONNECTION_TIMEOUT ) ) { // Not implemented by PostgreSQL yet.
- if( connection == null || !connection.isClosed() ) {
- close();
- connection = DriverManager.getConnection( url, user, pass );
- }
- }
-
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import java.math.BigInteger;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+//The DbMetadataSource is a MetadataSource that uses a relational database. It keeps a global connection which is reused on future requests, as well as between threads. Before each read, the connection is verified to be valid, and recreated if necessary. This MetadataSource is not particularly efficient, because it accesses the database at least once for every read. To increase efficiency, wrap a CachedMetadataSource around this one.
+
+public class DbMetadataSource implements MetadataSource
+{
+ private static final int CONNECTION_TIMEOUT = 4;
+ private Map<Integer, String> axisTypes;
+ private boolean checkAtInit;
+ private Connection connection;
+ private Map<Integer, String> crss;
+ private Map<Integer, String> dataTypes;
+ private String driver;
+ private boolean initializing;
+ private Map<Integer, String> interpolationTypes;
+ private Map<Integer, String> nullResistances;
+ private String pass;
+ private Map<String, String> supportedFormats;
+ private String url;
+ private String user;
+
+ public DbMetadataSource(String driver, String url, String user, String pass)
+ throws ResourceException, InvalidMetadataException
+ {
+ this(driver, url, user, pass, true);
+
+ }
+
+ public DbMetadataSource(String driver, String url, String user, String pass,
+ boolean checkAtInit)
+ throws ResourceException, InvalidMetadataException
+ {
+ try
+ {
+ Class.forName(driver).newInstance();
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new ResourceException(
+ "Metadata database error: Could not find JDBC driver: " + driver, e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new ResourceException(
+ "Metadata database error: Could not instantiate JDBC driver: "
+ + driver, e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new ResourceException(
+ "Metadata database error: Access denied to JDBC driver: " + driver, e);
+ }
+
+ this.driver = driver;
+ this.url = url;
+ this.user = user;
+ this.pass = pass;
+ Statement s = null;
+
+ try
+ {
+ ensureConnection();
+
+ axisTypes = new HashMap<Integer, String>(5);
+ s = connection.createStatement();
+ ResultSet r = s.executeQuery("SELECT id, axisType FROM WCPS_AxisType");
+
+ while (r.next())
+ {
+ axisTypes.put(r.getInt("id"), r.getString("axisType"));
+ }
+
+ dataTypes = new HashMap<Integer, String>(13);
+ r = s.executeQuery("SELECT id, dataType FROM WCPS_Datatype");
+
+ while (r.next())
+ {
+ dataTypes.put(r.getInt("id"), r.getString("dataType"));
+ }
+
+ interpolationTypes = new HashMap<Integer, String>(5);
+ r = s.executeQuery(
+ "SELECT id, interpolationType FROM WCPS_InterpolationType");
+
+ while (r.next())
+ {
+ interpolationTypes.put(r.getInt("id"),
+ r.getString("interpolationType"));
+ }
+
+ nullResistances = new HashMap<Integer, String>(4);
+ r = s.executeQuery(
+ "SELECT id, nullResistance FROM WCPS_NullResistance");
+
+ while (r.next())
+ {
+ nullResistances.put(r.getInt("id"), r.getString("nullResistance"));
+ }
+
+ crss = new HashMap<Integer, String>();
+ r = s.executeQuery("SELECT id, name FROM WCPS_Crs");
+
+ while (r.next())
+ {
+ crss.put(r.getInt("id"), r.getString("name"));
+ }
+
+ supportedFormats = new HashMap<String, String>(6);
+ r = s.executeQuery("SELECT name, mimetype FROM WCPS_Format");
+
+ while (r.next())
+ {
+ supportedFormats.put(r.getString("name"), r.getString("mimetype"));
+ }
+
+ s.close();
+
+ this.checkAtInit = checkAtInit;
+
+ if (checkAtInit)
+ {
+ initializing = true;
+ boolean coveragesOk = false;
+
+ while (!coveragesOk)
+ {
+ try
+ {
+ Iterator<String> coverages = coverages().iterator();
+
+ while (coverages.hasNext())
+ {
+ read(coverages.next());
+ }
+ }
+ catch (InvalidRequestException ire)
+ {
+ throw(InvalidMetadataException) ire.getCause();
+ }
+
+ coveragesOk = true;
+ }
+
+ initializing = false;
+ }
+ }
+ catch (SQLException sqle)
+ {
+ if (s != null)
+ {
+ try
+ {
+ s.close();
+ }
+ catch (SQLException e) {}
+ }
+
+ close();
+ throw new ResourceException("Metadata database error", sqle);
+ }
+
+ }
+
+ public void close()
+ {
+ synchronized (this)
+ {
+ if (connection != null)
+ {
+ try
+ {
+ connection.close();
+ }
+ catch (SQLException sqle) {}
+ }
+ }
+
+ }
+
+ public Set<String> coverages() throws ResourceException
+ {
+ Statement s = null;
+ Set<String> coverages;
+
+ try
+ {
+ ensureConnection();
+ s = connection.createStatement();
+
+ ResultSet r = s.executeQuery("SELECT name FROM WCPS_Coverage");
+
+ coverages = new HashSet<String>(r.getFetchSize());
+
+ while (r.next())
+ {
+ coverages.add(r.getString("name"));
+ }
+
+ s.close();
+ return coverages;
+ }
+ catch (SQLException sqle)
+ {
+ if (s != null)
+ {
+ try
+ {
+ s.close();
+ }
+ catch (SQLException f) {}
+ }
+
+ close();
+ throw new ResourceException("Metadata database error", sqle);
+ }
+
+ }
+
+ public String mimetype(String format)
+ {
+ return supportedFormats.get(format);
+
+ }
+
+ public Metadata read(String coverageName) throws InvalidRequestException, ResourceException
+ {
+ System.err.println("DB: " + coverageName);
+
+ if ((coverageName == null) || coverageName.equals(""))
+ {
+ throw new InvalidRequestException(
+ "Cannot retrieve coverage with null or empty name");
+ }
+
+ Statement s = null;
+
+ try
+ {
+ ensureConnection();
+ s = connection.createStatement();
+
+ ResultSet r =
+ s.executeQuery(
+ "SELECT id, nullDefault, interpolationTypeDefault, nullResistanceDefault FROM WCPS_Coverage WHERE name = '"
+ + coverageName + "'");
+
+ if (!r.next())
+ {
+ throw new InvalidRequestException(
+ "Coverage '" + coverageName + "' is not served by this server");
+ }
+
+ int coverage = r.getInt("id");
+ String nullDefault = r.getString("nullDefault");
+ String interpolationTypeDefault =
+ interpolationTypes.get(r.getInt("interpolationTypeDefault"));
+ String nullResistanceDefault =
+ nullResistances.get(r.getInt("nullResistanceDefault"));
+
+ r = s.executeQuery("SELECT lo, hi FROM WCPS_CellDomain WHERE coverage = '"
+ + coverage + "' ORDER BY i ASC");
+ List<CellDomainElement> cellDomain =
+ new ArrayList<CellDomainElement>(r.getFetchSize());
+
+ while (r.next())
+ {
+ cellDomain.add(
+ new CellDomainElement(
+ BigInteger.valueOf(r.getInt("lo")),
+ BigInteger.valueOf(r.getInt("hi"))));
+ }
+
+ r = s.executeQuery("SELECT name, type FROM WCPS_Range WHERE coverage = '"
+ + coverage + "' ORDER BY i ASC");
+ List<RangeElement> range = new ArrayList<RangeElement>(r.getFetchSize());
+
+ while (r.next())
+ {
+ range.add(new RangeElement(r.getString("name"),
+ dataTypes.get(r.getInt("type"))));
+ }
+
+ r = s.executeQuery(
+ "SELECT interpolationType, nullResistance FROM WCPS_InterpolationSet WHERE coverage = '"
+ + coverage + "'");
+ Set<InterpolationMethod> interpolationSet =
+ new HashSet<InterpolationMethod>(r.getFetchSize());
+
+ while (r.next())
+ {
+ interpolationSet.add(
+ new InterpolationMethod(
+ interpolationTypes.get(r.getInt("interpolationType")),
+ nullResistances.get(r.getInt("nullResistance"))));
+ }
+
+ r = s.executeQuery("SELECT nullValue FROM WCPS_NullSet WHERE coverage = '"
+ + coverage + "'");
+ Set<String> nullSet = new HashSet<String>(r.getFetchSize());
+
+ while (r.next())
+ {
+ nullSet.add(r.getString("nullValue"));
+ }
+
+ r = s.executeQuery(
+ "SELECT id, name, type, numLo, numHi, strLo, strHi FROM WCPS_Domain WHERE coverage = '"
+ + coverage + "' ORDER BY i ASC");
+ List<DomainElement> domain = new ArrayList<DomainElement>(r.getFetchSize());
+ Statement ss = connection.createStatement();
+
+ while (r.next())
+ {
+ Double numLo = r.getDouble("numLo");
+
+ if (r.wasNull())
+ {
+ numLo = null;
+ }
+
+ Double numHi = r.getDouble("numHi");
+
+ if (r.wasNull())
+ {
+ numHi = null;
+ }
+
+ ResultSet rr = ss.executeQuery(
+ "SELECT crs FROM WCPS_CrsSet WHERE axis = '"
+ + r.getInt("id") + "'");
+ Set<String> crsSet = new HashSet<String>(rr.getFetchSize());
+
+ while (rr.next())
+ {
+ crsSet.add(crss.get(rr.getInt("crs")));
+ }
+
+ crsSet.add(DomainElement.IMAGE_CRS);
+ domain.add(new DomainElement(r.getString("name"),
+ axisTypes.get(r.getInt("type")),
+ numLo, numHi, r.getString("strLo"),
+ r.getString("strHi"), crsSet));
+ }
+
+ s.close();
+
+ return new Metadata(cellDomain, range, nullSet, nullDefault,
+ interpolationSet,
+ new InterpolationMethod(interpolationTypeDefault,
+ nullResistanceDefault), coverageName, domain);
+ }
+ catch (InvalidMetadataException ime)
+ {
+ if (checkAtInit && !initializing)
+ {
+ throw new ResourceException(
+ "Previously valid metadata is now invalid. The metadata for coverage '"
+ + coverageName + "' has been modified incorrectly.", ime);
+ }
+ else
+ {
+ throw new InvalidRequestException("Coverage '" + coverageName
+ + "' has invalid metadata", ime);
+ }
+ }
+ catch (SQLException sqle)
+ {
+ if (s != null)
+ {
+ try
+ {
+ s.close();
+ }
+ catch (SQLException f) {}
+ }
+
+ close();
+ throw new ResourceException("Metadata database error", sqle);
+ }
+
+ }
+
+ private void ensureConnection() throws SQLException
+ {
+ synchronized (this)
+ {
+// if( connection == null || !connection.isValid( CONNECTION_TIMEOUT ) ) { // Not implemented by PostgreSQL yet.
+ if ((connection == null) || !connection.isClosed())
+ {
+ close();
+ connection = DriverManager.getConnection(url, user, pass);
+ }
+ }
+
+ }
+}
diff --git a/src/wcps/server/core/DimensionIntervalElement.java b/src/wcps/server/core/DimensionIntervalElement.java
new file mode 100644
index 0000000..b4b3504
--- /dev/null
+++ b/src/wcps/server/core/DimensionIntervalElement.java
@@ -0,0 +1,191 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class DimensionIntervalElement implements IRasNode, ICoverageInfo
+{
+ private IRasNode child;
+ private CoverageInfo info = null;
+ private AxisNameType axis;
+ private CrsNameType crs;
+ private IRasNode domain1, domain2; // lower and upper bound, or "DomainMetadataExprType" and null
+ private int counter = 0; // counter for the domain vars
+ private boolean finished = false;
+ private Node nextNode;
+
+ public DimensionIntervalElement(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+ /*
+ while ((node != null) && node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ }
+
+ if (node == null)
+ {
+ throw new WCPSException("SubsetOperationCoverageExpr parsing error!");
+ }
+
+ String nodeName = node.getNodeName();
+
+ System.err.println("SubsetOperationCoverageExpr: node " + nodeName);
+
+ if (nodeName.equals("trim"))
+ {
+ child = new TrimCoverageExprType(node, pcr);
+ }
+ else if (nodeName.equals("extend"))
+ child = new ExtendCoverageExprType(node, pcr);
+ else if (nodeName.equals("slice"))
+ child = new SliceCoverageExprType(node, pcr);
+ * */
+
+ System.err.println("Trying to parse DimensionIntervalElement expression...");
+ String name;
+
+ while ((node != null) && node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ }
+
+ while (node != null && finished == false)
+ {
+ if (node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ continue;
+ }
+
+ name = node.getNodeName();
+ System.err.println("Current node is " + name);
+
+ // Try Axis
+ try
+ {
+ axis = new AxisNameType(node, pcr);
+ node = node.getNextSibling();
+ continue;
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to parse an axis!");
+ }
+
+ // Try CRS name
+ try
+ {
+ crs = new CrsNameType(node, pcr);
+ node = node.getNextSibling();
+ if (axis == null)
+ throw new WCPSException("Expected Axis node before CRS !");
+ continue;
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to parse a crs!");
+ }
+
+ // TODO: how to implement DomainMetadataExpr ?
+
+// // Try last thing
+// try
+// {
+// domain1 = new DomainMetadataExprType(node, pcr);
+// counter = 1;
+// continue;
+// }
+// catch (WCPSException e)
+// {
+// System.err.println("Failed to parse domain metadata!");
+// }
+
+ // Then it must be a pair of nodes "lowerBound" + "upperBound"
+ if (node.getNodeName().equals("lowerBound"))
+ {
+ counter = 2;
+ domain1 = new ScalarExprType(node.getFirstChild(), pcr);
+ if (axis == null)
+ throw new WCPSException("Expected <axis> node before <lowerBound> !");
+ }
+ else
+ if (node.getNodeName().equals("upperBound"))
+ {
+ counter = 2;
+ domain2 = new ScalarExprType(node.getFirstChild(), pcr);
+ if (axis == null)
+ throw new WCPSException("Expected <lowerBound> node before <upperBound> !");
+ }
+ else
+ throw new WCPSException("Unexpected node: " + node.getFirstChild().getNodeName());
+
+ if (axis != null && counter == 1 && domain1 != null)
+ finished = true;
+ if (axis != null && counter == 2 && domain1 != null && domain2 != null)
+ finished = true;
+
+ if (finished == true)
+ nextNode = node.getNextSibling();
+
+ node = node.getNextSibling();
+ }
+ }
+
+ public String toRasQL()
+ {
+ return child.toRasQL();
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return info;
+ }
+
+ public Node getNextNode()
+ {
+ return nextNode;
+ }
+
+ public String getAxisName()
+ {
+ return this.axis.toRasQL();
+ }
+
+ public String getAxisCoords()
+ {
+ return this.domain1.toRasQL() + " : " + this.domain2.toRasQL();
+ }
+
+ public String getLowCoord()
+ {
+ return this.domain1.toRasQL();
+ }
+
+ public String getHighCoord()
+ {
+ return this.domain2.toRasQL();
+ }
+}
diff --git a/src/wcps/server/core/DimensionIntervalList.java b/src/wcps/server/core/DimensionIntervalList.java
new file mode 100644
index 0000000..7569252
--- /dev/null
+++ b/src/wcps/server/core/DimensionIntervalList.java
@@ -0,0 +1,86 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.w3c.dom.*;
+
+public class DimensionIntervalList
+{
+ private ArrayList<IRasNode> list;
+
+ public DimensionIntervalList(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+ /*
+ while ((node != null) && node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ }
+
+ if (node == null)
+ {
+ throw new WCPSException("SubsetOperationCoverageExpr parsing error!");
+ }
+
+ String nodeName = node.getNodeName();
+
+ System.err.println("SubsetOperationCoverageExpr: node " + nodeName);
+
+ if (nodeName.equals("trim"))
+ {
+ child = new TrimCoverageExprType(node, pcr);
+ }
+ else if (nodeName.equals("extend"))
+ child = new ExtendCoverageExprType(node, pcr);
+ else if (nodeName.equals("slice"))
+ child = new SliceCoverageExprType(node, pcr);
+ * */
+
+ System.err.println("Parsing a Dimension Interval List ...");
+
+ while (node != null)
+ {
+ list = new ArrayList<IRasNode>();
+ try
+ {
+ System.err.println("Parsing one dimension interval element ...");
+ DimensionIntervalElement elem = new DimensionIntervalElement(node, pcr);
+ node = elem.getNextNode();
+ list.add(elem);
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to parse this dimension interval element !");
+ System.err.println("Current node: " + node);
+ }
+ }
+ }
+
+ public List getAxisList()
+ {
+ return list;
+ }
+}
diff --git a/src/wcps/server/core/DimensionPointElement.java b/src/wcps/server/core/DimensionPointElement.java
new file mode 100644
index 0000000..cd017ce
--- /dev/null
+++ b/src/wcps/server/core/DimensionPointElement.java
@@ -0,0 +1,142 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class DimensionPointElement implements IRasNode
+{
+ private IRasNode domain, child;
+ private AxisNameType axis;
+ private CrsNameType crs;
+ private boolean finished = false;
+ private Node nextNode;
+
+ public DimensionPointElement(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+ System.err.println("Trying to parse DimensionPointElement expression...");
+ String name;
+
+ while ((node != null) && node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ }
+
+ while (node != null && finished == false)
+ {
+ if (node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ continue;
+ }
+
+ name = node.getNodeName();
+ System.err.println("Current node is " + name);
+
+ // Try Axis
+ try
+ {
+ axis = new AxisNameType(node, pcr);
+ node = node.getNextSibling();
+ continue;
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to parse an axis!");
+ }
+
+ // Try CRS name
+ try
+ {
+ crs = new CrsNameType(node, pcr);
+ node = node.getNextSibling();
+ if (axis == null)
+ throw new WCPSException("Expected Axis node before CRS !");
+ continue;
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to parse a crs!");
+ }
+
+ // TODO: how to implement DomainMetadataExpr ?
+
+// // Try last thing
+// try
+// {
+// domain1 = new DomainMetadataExprType(node, pcr);
+// counter = 1;
+// continue;
+// }
+// catch (WCPSException e)
+// {
+// System.err.println("Failed to parse domain metadata!");
+// }
+
+ // Then it must be a pair of nodes "lowerBound" + "upperBound"
+ if (node.getNodeName().equals("slicingPosition"))
+ {
+ domain = new ScalarExprType(node.getFirstChild(), pcr);
+ if (axis == null)
+ throw new WCPSException("Expected <axis> node before <slicingPosition> !");
+ }
+ else
+ throw new WCPSException("Unexpected node: " + node.getFirstChild().getNodeName());
+
+ if (axis != null && domain != null)
+ finished = true;
+
+ if (finished == true)
+ nextNode = node.getNextSibling();
+
+ node = node.getNextSibling();
+ }
+ }
+
+ public String toRasQL()
+ {
+ return child.toRasQL();
+ }
+
+ public Node getNextNode()
+ {
+ return nextNode;
+ }
+
+ public String getAxisName()
+ {
+ return this.axis.toRasQL();
+ }
+
+ public String getCrsName()
+ {
+ return this.crs.toRasQL();
+ }
+
+ public String getSlicingPosition()
+ {
+ return this.domain.toRasQL();
+ }
+}
diff --git a/src/wcps/server/core/DimensionPointElementType.java b/src/wcps/server/core/DimensionPointElementType.java
new file mode 100644
index 0000000..424e952
--- /dev/null
+++ b/src/wcps/server/core/DimensionPointElementType.java
@@ -0,0 +1,74 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+// TODO: Implement class DimensionPointElementType
+public class DimensionPointElementType implements IRasNode, ICoverageInfo
+{
+ private IRasNode child;
+ private CoverageInfo info = null;
+
+ public DimensionPointElementType(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+ /*
+ while ((node != null) && node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ }
+
+ if (node == null)
+ {
+ throw new WCPSException("SubsetOperationCoverageExpr parsing error!");
+ }
+
+ String nodeName = node.getNodeName();
+
+ System.err.println("SubsetOperationCoverageExpr: node " + nodeName);
+
+ if (nodeName.equals("trim"))
+ {
+ child = new TrimCoverageExprType(node, pcr);
+ }
+ else if (nodeName.equals("extend"))
+ child = new ExtendCoverageExprType(node, pcr);
+ else if (nodeName.equals("slice"))
+ child = new SliceCoverageExprType(node, pcr);
+ * */
+
+ throw new WCPSException("Method not implemented");
+ }
+
+ public String toRasQL()
+ {
+ return child.toRasQL();
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return info;
+ }
+}
diff --git a/src/wcps/server/core/DomainElement.java b/src/wcps/server/core/DomainElement.java
index da51251..1c71687 100644
--- a/src/wcps/server/core/DomainElement.java
+++ b/src/wcps/server/core/DomainElement.java
@@ -1,160 +1,208 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-// This is an axis i geographic coordinates. See the WCPS standard.
-
-class DomainElement implements Cloneable {
-
- public static final String IMAGE_CRS = "CRS:1";
-
- private Set<String> crss;
- private String name;
- private Double numHi;
- private Double numLo;
- private String strHi;
- private String strLo;
- private String type;
-
- public DomainElement( String name, String type, Double numLo, Double numHi, String strLo, String strHi, Set<String> crss ) throws InvalidMetadataException {
-
- if( name == null || type == null ) {
- throw new InvalidMetadataException( "Invalid domain element: Element name and type cannot be null" );
- }
- if( name.equals( "" ) ) {
- throw new InvalidMetadataException( "Invalid domain element: Element name cannot be empty" );
- }
-
- if( !( type.equals( "x" ) || type.equals( "y" ) || type.equals( "temporal" ) || type.equals( "elevation" ) || type.equals( "other" )) ) {
- throw new InvalidMetadataException( "Invalid domain element: Invlaid element type: " + type );
- }
-
- if( numLo != null && numHi != null && strLo == null && strHi == null ) {
- if( numLo.compareTo( numHi ) == 1 ) {
- throw new InvalidMetadataException( "Invalid domain element: Lower integer bound cannot be larger than upper integer bound" );
- }
- this.numLo = numLo;
- this.numHi = numHi;
- }
- else if( strLo != null && numHi != null && numLo == null && numHi == null ) {
- if( strLo.equals( "" ) || strHi.equals( "" ) ) {
- throw new InvalidMetadataException( "Invalid domain element: String bounds cannot be empty" );
- }
- this.strLo = strLo;
- this.strHi = strHi;
- }
- else {
- throw new InvalidMetadataException( "Invalid domain element: Integer bounds must both be non-null if string bounds are null, and vice versa at " + name + ":" + type );
- }
- if( (type.equals( "x" ) || type.equals( "y" )) && numLo == null ) {
- throw new InvalidMetadataException( "Invalid domain element: A spatial axis must have integer extent" );
- }
- else if( type.equals( "temporal" ) && strLo == null ) {
- throw new InvalidMetadataException( "Invalid domain element: A temporal axis must have string extent" );
- }
-
- this.name = name;
- this.type = type;
-
- if( crss == null || !crss.contains( IMAGE_CRS ) ) {
- throw new InvalidMetadataException( "Invalid domain element: CRS set does not contain image CRS '" + IMAGE_CRS + "'" );
- }
- this.crss = crss;
-
- }
-
- public DomainElement clone() {
-
- Set<String> c = new HashSet<String>( crss.size() );
- Iterator<String> i = crss.iterator();
- while( i.hasNext() ) {
- c.add( new String( i.next() ) );
- }
-
- try {
- if( numLo != null ) {
- return new DomainElement( new String( name ), new String( type ), new Double( numLo ), new Double( numHi ), null, null, c );
- }
- else {
- return new DomainElement( new String( name ), new String( type ), null, null, new String( strLo ), new String( strHi ), c );
- }
- }
- catch( InvalidMetadataException ime ) {
- throw new RuntimeException( "Invalid metadata while cloning DomainElement. This is a software bug in WCPS.", ime );
- }
-
- }
-
- public boolean equals( DomainElement de ) {
-
- if( numLo == null && de.numLo == null ) {
- return strLo.equals( de.strLo ) && strHi.equals( strHi ) && name.equals( de.name ) && type.equals( de.type );
- }
- else if( strLo == null && de.strLo == null ) {
- return numLo.equals( de.numLo ) && numHi.equals( numHi ) && name.equals( de.name ) && type.equals( de.type );
- }
- else return false;
-
- }
-
- public String getName() {
-
- return name;
-
- }
-
- public Double getNumHi() {
-
- return numHi;
-
- }
-
- public Double getNumLo() {
-
- return numLo;
-
- }
-
- public String getStrHi() {
-
- return strHi;
-
- }
-
- public String getStrLo() {
-
- return strLo;
-
- }
-
- public String getType() {
-
- return type;
-
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+//This is an axis i geographic coordinates. See the WCPS standard.
+
+class DomainElement implements Cloneable
+{
+ public static final String IMAGE_CRS = "CRS:1";
+ private Set<String> crss;
+ private String name;
+ private Double numHi;
+ private Double numLo;
+ private String strHi;
+ private String strLo;
+ private String type;
+
+ public DomainElement(String name, String type, Double numLo, Double numHi, String strLo,
+ String strHi, Set<String> crss)
+ throws InvalidMetadataException
+ {
+ if ((name == null) || (type == null))
+ {
+ throw new InvalidMetadataException(
+ "Invalid domain element: Element name and type cannot be null");
+ }
+
+ if (name.equals(""))
+ {
+ throw new InvalidMetadataException(
+ "Invalid domain element: Element name cannot be empty");
+ }
+
+ if (!(type.equals("x") || type.equals("y") || type.equals("temporal")
+ || type.equals("elevation") || type.equals("other")))
+ {
+ throw new InvalidMetadataException(
+ "Invalid domain element: Invlaid element type: " + type);
+ }
+
+ if ((numLo != null) && (numHi != null) && (strLo == null) && (strHi == null))
+ {
+ if (numLo.compareTo(numHi) == 1)
+ {
+ throw new InvalidMetadataException(
+ "Invalid domain element: Lower integer bound cannot be larger than upper integer bound");
+ }
+
+ this.numLo = numLo;
+ this.numHi = numHi;
+ }
+ else if ((strLo != null) && (numHi != null) && (numLo == null) && (numHi == null))
+ {
+ if (strLo.equals("") || strHi.equals(""))
+ {
+ throw new InvalidMetadataException(
+ "Invalid domain element: String bounds cannot be empty");
+ }
+
+ this.strLo = strLo;
+ this.strHi = strHi;
+ }
+ else
+ {
+ throw new InvalidMetadataException(
+ "Invalid domain element: Integer bounds must both be non-null if string bounds are null, and vice versa at "
+ + name + ":" + type);
+ }
+
+ if ((type.equals("x") || type.equals("y")) && (numLo == null))
+ {
+ throw new InvalidMetadataException(
+ "Invalid domain element: A spatial axis must have integer extent");
+ }
+ else if (type.equals("temporal") && (strLo == null))
+ {
+ throw new InvalidMetadataException(
+ "Invalid domain element: A temporal axis must have string extent");
+ }
+
+ this.name = name;
+ this.type = type;
+
+ if ((crss == null) || !crss.contains(IMAGE_CRS))
+ {
+ throw new InvalidMetadataException(
+ "Invalid domain element: CRS set does not contain image CRS '"
+ + IMAGE_CRS + "'");
+ }
+
+ this.crss = crss;
+
+ }
+
+ public DomainElement clone()
+ {
+ Set<String> c = new HashSet<String>(crss.size());
+ Iterator<String> i = crss.iterator();
+
+ while (i.hasNext())
+ {
+ c.add(new String(i.next()));
+ }
+
+ try
+ {
+ if (numLo != null)
+ {
+ return new DomainElement(new String(name), new String(type),
+ new Double(numLo), new Double(numHi),
+ null, null, c);
+ }
+ else
+ {
+ return new DomainElement(new String(name), new String(type), null,
+ null, new String(strLo),
+ new String(strHi), c);
+ }
+ }
+ catch (InvalidMetadataException ime)
+ {
+ throw new RuntimeException(
+ "Invalid metadata while cloning DomainElement. This is a software bug in WCPS.",
+ ime);
+ }
+
+ }
+
+ public boolean equals(DomainElement de)
+ {
+ if ((numLo == null) && (de.numLo == null))
+ {
+ return strLo.equals(de.strLo) && strHi.equals(strHi)
+ && name.equals(de.name) && type.equals(de.type);
+ }
+ else if ((strLo == null) && (de.strLo == null))
+ {
+ return numLo.equals(de.numLo) && numHi.equals(numHi)
+ && name.equals(de.name) && type.equals(de.type);
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+
+ public String getName()
+ {
+ return name;
+
+ }
+
+ public Double getNumHi()
+ {
+ return numHi;
+
+ }
+
+ public Double getNumLo()
+ {
+ return numLo;
+
+ }
+
+ public String getStrHi()
+ {
+ return strHi;
+
+ }
+
+ public String getStrLo()
+ {
+ return strLo;
+
+ }
+
+ public String getType()
+ {
+ return type;
+
+ }
+}
diff --git a/src/wcps/server/core/DomainMetadataExprType.java b/src/wcps/server/core/DomainMetadataExprType.java
new file mode 100644
index 0000000..f738191
--- /dev/null
+++ b/src/wcps/server/core/DomainMetadataExprType.java
@@ -0,0 +1,151 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class DomainMetadataExprType implements IRasNode, ICoverageInfo
+{
+ private IRasNode child;
+ private CoverageInfo info = null;
+ private AxisNameType axis;
+ private CrsNameType crs;
+ private IRasNode domain1, domain2; // lower and upper bound, or "DomainMetadataExprType" and null
+ private int counter = 0; // counter for the domain vars
+
+ public DomainMetadataExprType(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+ /*
+ while ((node != null) && node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ }
+
+ if (node == null)
+ {
+ throw new WCPSException("SubsetOperationCoverageExpr parsing error!");
+ }
+
+ String nodeName = node.getNodeName();
+
+ System.err.println("SubsetOperationCoverageExpr: node " + nodeName);
+
+ if (nodeName.equals("trim"))
+ {
+ child = new TrimCoverageExprType(node, pcr);
+ }
+ else if (nodeName.equals("extend"))
+ child = new ExtendCoverageExprType(node, pcr);
+ else if (nodeName.equals("slice"))
+ child = new SliceCoverageExprType(node, pcr);
+ * */
+
+ System.err.println("Trying to parse DimensionIntervalElement expression...");
+
+ throw new WCPSException("Method not implemented");
+
+// while ((node != null) && node.getNodeName().equals("#text"))
+// {
+// node = node.getNextSibling();
+// }
+//
+// while (node != null)
+// {
+// if (node.getNodeName().equals("#text"))
+// {
+// node = node.getNextSibling();
+// continue;
+// }
+//
+// String name = node.getNodeName();
+// System.err.println("Current node is " + name);
+//
+// // Try Axis
+// try
+// {
+// axis = new AxisNameType(node, pcr);
+// continue;
+// }
+// catch (WCPSException e)
+// {
+// System.err.println("Failed to parse an axis!");
+// }
+//
+// // Try CRS name
+// try
+// {
+// crs = new CrsNameType(node, pcr);
+// continue;
+// }
+// catch (WCPSException e)
+// {
+// System.err.println("Failed to parse a crs!");
+// }
+//
+// // Try last thing
+// try
+// {
+// domain1 = new DomainMetadataExprType(node, pcr);
+// counter = 1;
+// continue;
+// }
+// catch (WCPSException e)
+// {
+// System.err.println("Failed to parse domain metadata!");
+// }
+//
+// // Then it must be a pair of nodes "lowerBound" + "upperBound"
+// if (node.getNodeName().equals("lowerBound"))
+// {
+// counter ++;
+// if (counter == 1)
+// domain1 = new ScalarExprType(node, pcr);
+// else
+// throw new WCPSException("Too many *Bounds nodes !!!");
+// }
+// else
+// if (node.getNodeName().equals("upperBound"))
+// {
+// counter ++;
+// if (counter == 2)
+// domain2 = new ScalarExprType(node, pcr);
+// else
+// throw new WCPSException("Too many *Bounds nodes !!!");
+// }
+// else
+// throw new WCPSException("Unexpected node: " + node.getNodeName());
+// }
+ }
+
+ public String toRasQL()
+ {
+ return child.toRasQL();
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return info;
+ }
+}
diff --git a/src/wcps/server/core/EncodeDataExprType.java b/src/wcps/server/core/EncodeDataExprType.java
index 955e4ec..130ab3b 100644
--- a/src/wcps/server/core/EncodeDataExprType.java
+++ b/src/wcps/server/core/EncodeDataExprType.java
@@ -1,82 +1,107 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-
-public class EncodeDataExprType implements IRasNode{
-
- private String format;
- private String extraParams;
- private IRasNode coverageExprType;
- private Boolean store;
- private String mime;
-
- public EncodeDataExprType (Node node, ProcessCoverageRequest request) throws WCPSException {
- Node child;
- String nodeName;
-
- for (child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- nodeName = child.getNodeName();
-
- if (nodeName.equals("#text")) continue;
- System.err.println("Encode : node : " + child.getNodeName());
-
- if (nodeName.equals("format")) {
- format = child.getFirstChild().getNodeValue();
- mime = request.getMetadataSource().mimetype(format);
- continue;
- }
-
- if (nodeName.equals("extraParameters")) {
- extraParams = child.getFirstChild().getNodeValue();
- continue;
- }
-
- coverageExprType = new CoverageExprType(child, request);
- }
-
- Node _store = node.getAttributes().getNamedItem("store");
- if (_store != null)
- store = _store.getNodeValue().equals("true");
- }
-
- public String getMime() {
- return mime;
- }
-
- public String toRasQL() {
- // TODO: cjucovschi - implement store
-
- String result;
- if (format.equals("raw"))
- result = coverageExprType.toRasQL();
- else {
- result = format + "(" + coverageExprType.toRasQL();
- if (extraParams != null)
- result = result + ", " + extraParams;
- result = result + ")";
- }
- return result;
- }
-};
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+// This is the equivalent of the "ProcessingExprType" complex XML type.
+public class EncodeDataExprType implements IRasNode
+{
+ private IRasNode coverageExprType;
+ private String extraParams;
+ private String format;
+ private String mime;
+ private Boolean store;
+
+ public EncodeDataExprType(Node node, ProcessCoveragesRequest request) throws WCPSException
+ {
+ Node child;
+ String nodeName;
+
+ for (child = node.getFirstChild(); child != null; child = child.getNextSibling())
+ {
+ nodeName = child.getNodeName();
+
+ if (nodeName.equals("#text"))
+ {
+ continue;
+ }
+
+ System.err.println("Encode : node : " + child.getNodeName());
+
+ if (nodeName.equals("format"))
+ {
+ format = child.getFirstChild().getNodeValue();
+ mime = request.getMetadataSource().mimetype(format);
+ continue;
+ }
+
+ if (nodeName.equals("extraParameters"))
+ {
+ extraParams = child.getFirstChild().getNodeValue();
+ continue;
+ }
+
+ coverageExprType = new CoverageExprType(child, request);
+ }
+
+ Node _store = node.getAttributes().getNamedItem("store");
+
+ if (_store != null)
+ {
+ store = _store.getNodeValue().equals("true");
+ }
+ }
+
+ public String getMime()
+ {
+ return mime;
+ }
+
+ public String toRasQL()
+ {
+ // TODO: cjucovschi - implement store
+
+ String result;
+
+ if (format.equals("raw"))
+ {
+ result = coverageExprType.toRasQL();
+ }
+ else
+ {
+ result = format + "(" + coverageExprType.toRasQL();
+
+ if (extraParams != null)
+ {
+ result = result + ", " + extraParams;
+ }
+
+ result = result + ")";
+ }
+
+ System.err.println("Returning EncodeExpression:" + result);
+ return result;
+ }
+} \ No newline at end of file
diff --git a/src/wcps/server/core/ExtendCoverageExprType.java b/src/wcps/server/core/ExtendCoverageExprType.java
index 0b0506c..43bd9a9 100644
--- a/src/wcps/server/core/ExtendCoverageExprType.java
+++ b/src/wcps/server/core/ExtendCoverageExprType.java
@@ -1,116 +1,148 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.math.BigInteger;
-
-
-public class ExtendCoverageExprType implements IRasNode, ICoverageInfo {
-
- private class axisSpec {
- public String axisName;
- public String crs;
- public List<Integer> coords = new ArrayList<Integer> ();
- };
-
- private List <axisSpec> axisList;
- private CoverageExprType coverageExprType;
- private CoverageInfo coverageInfo;
- private int dims;
- private String [] dim;
-
- public CoverageInfo getCoverageInfo() {
- return coverageInfo;
- }
-
- public ExtendCoverageExprType (Node node, ProcessCoverageRequest source) throws WCPSException{
- Node child, axisNode;
- String nodeName;
- axisList = new ArrayList<axisSpec> ();
-
- for (child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- nodeName = child.getNodeName();
- if (nodeName.equals("#text")) continue;
-
- if (nodeName.equals("extendAxisSpec")) {
- axisSpec axis = new axisSpec();
- String childName;
- for (axisNode = child.getFirstChild(); axisNode != null; axisNode = axisNode.getNextSibling()) {
- childName = axisNode.getNodeName();
- if (childName.equals("axis")) {
- axis.axisName = axisNode.getFirstChild().getNodeValue();
- continue;
- }
- if (childName.equals("crs")) {
- axis.crs = axisNode.getFirstChild().getNodeValue();
- continue;
- }
- if (childName.equals("coord")) {
- CoordinateType coord = new CoordinateType(axisNode);
- axis.coords.add(coord.getValue());
- }
- }
- axisList.add(axis);
- continue;
- }
-
- // else is a coverage expression type
- coverageExprType = new CoverageExprType(child, source);
- coverageInfo = coverageExprType.getCoverageInfo();
- }
-
- dims = coverageInfo.getNumDimensions();
- dim = new String[dims];
- for (int j=0; j<dims; ++j)
- dim[j]="*:*";
-
-
- Iterator <axisSpec> i = axisList.iterator();
- axisSpec axis;
- int axisId;
- int axisLo, axisHi;
- while (i.hasNext()) {
- axis = i.next();
- axisId = coverageInfo.getDomainIndexByName(axis.axisName);
- axisLo = axis.coords.get(0);
- axisHi = axis.coords.get(1);
- dim[axisId]=axisLo+":"+axisHi;
- coverageInfo.setCellDimension(axisId, new CellDomainElement(BigInteger.valueOf(axisLo), BigInteger.valueOf(axisHi)));
- }
- }
-
- public String toRasQL() {
- String result = "extend("+coverageExprType.toRasQL()+",[";
- for (int j=0; j<dims; ++j) {
- if (j>0)
- result += ",";
- result += dim[j];
- }
- result += "])";
- return result;
- }
-};
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.w3c.dom.*;
+
+
+public class ExtendCoverageExprType implements IRasNode, ICoverageInfo
+{
+ private List<DimensionIntervalElement> axisList;
+ private CoverageExprType coverageExprType;
+ private CoverageInfo coverageInfo;
+ private String[] dim;
+ private int dims;
+ private DimensionIntervalElement elem;
+
+ public ExtendCoverageExprType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+
+ Node child, axisNode;
+ String nodeName;
+
+ axisList = new ArrayList<DimensionIntervalElement>();
+
+ child = node.getFirstChild();
+ while (child != null)
+ {
+ nodeName = child.getNodeName();
+
+ if (nodeName.equals("#text"))
+ {
+ child = child.getNextSibling();
+ continue;
+ }
+
+ try
+ {
+ System.err.println("Trying out an CoverageExprType group...");
+ coverageExprType = new CoverageExprType(node, pcr);
+ coverageInfo = coverageExprType.getCoverageInfo();
+ child = child.getNextSibling();
+ continue;
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("This was no CoverageExprType: " + nodeName);
+ }
+
+ try
+ {
+ // Start a new axis and save it
+ elem = new DimensionIntervalElement(node, pcr);
+ axisList.add(elem);
+ child = elem.getNextNode();
+ continue;
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("This was no Dimension Interval ELement: " + child.getNodeName());
+ }
+
+ // else unknown element
+ throw new WCPSException("Unknown node for ExtendCoverage expression:" + child.getNodeName());
+ }
+
+ dims = coverageInfo.getNumDimensions();
+ dim = new String[dims];
+
+ for (int j = 0; j < dims; ++j)
+ {
+ dim[j] = "*:*";
+ }
+
+
+ Iterator<DimensionIntervalElement> i = axisList.iterator();
+ DimensionIntervalElement axis;
+ int axisId;
+ int axisLo, axisHi;
+
+ while (i.hasNext())
+ {
+ axis = i.next();
+ axisId = coverageInfo.getDomainIndexByName(axis.getAxisName());
+ System.out.println("Axis ID: " + axisId);
+ System.out.println("Axis name: " + axis.getAxisName());
+ System.out.print("Axis coords: ");
+
+ axisLo = Integer.parseInt(axis.getLowCoord());
+ axisHi = Integer.parseInt(axis.getHighCoord());
+ dim[axisId] = axisLo + ":" + axisHi;
+ coverageInfo.setCellDimension(
+ axisId,
+ new CellDomainElement(
+ BigInteger.valueOf(axisLo), BigInteger.valueOf(axisHi)));
+ }
+
+
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return coverageInfo;
+ }
+
+ public String toRasQL()
+ {
+ String result = "extend(" + coverageExprType.toRasQL() + ",[";
+
+ for (int j = 0; j < dims; ++j)
+ {
+ if (j > 0)
+ {
+ result += ",";
+ }
+
+ result += dim[j];
+ }
+
+ result += "])";
+
+ return result;
+ }
+} \ No newline at end of file
diff --git a/src/wcps/server/core/FieldNameType.java b/src/wcps/server/core/FieldNameType.java
new file mode 100644
index 0000000..00d5be6
--- /dev/null
+++ b/src/wcps/server/core/FieldNameType.java
@@ -0,0 +1,62 @@
+ /*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+
+public class FieldNameType implements IRasNode
+{
+ private String name;
+
+ public FieldNameType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ while ((node != null) && node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ }
+
+ if (node == null)
+ {
+ throw new WCPSException("FieldNameType parsing error!");
+ }
+
+ String nodeName = node.getNodeName();
+
+ if (nodeName.equals("name"))
+ {
+ this.name = node.getTextContent();
+
+ System.err.println("Found field name: " + name);
+ }
+ }
+
+ public String toRasQL()
+ {
+ return this.name;
+ }
+}
+
+
+;
diff --git a/src/wcps/server/core/ICoverageInfo.java b/src/wcps/server/core/ICoverageInfo.java
index ff393cc..df33362 100644
--- a/src/wcps/server/core/ICoverageInfo.java
+++ b/src/wcps/server/core/ICoverageInfo.java
@@ -1,28 +1,29 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-interface ICoverageInfo {
- public CoverageInfo getCoverageInfo();
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+interface ICoverageInfo
+{
+ public CoverageInfo getCoverageInfo();
+}
diff --git a/src/wcps/server/core/IRasNode.java b/src/wcps/server/core/IRasNode.java
index 67197b8..073742b 100644
--- a/src/wcps/server/core/IRasNode.java
+++ b/src/wcps/server/core/IRasNode.java
@@ -1,27 +1,29 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-interface IRasNode {
- public String toRasQL();
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+interface IRasNode
+{
+ public String toRasQL();
+}
diff --git a/src/wcps/server/core/InducedOperationCoverageExprType.java b/src/wcps/server/core/InducedOperationCoverageExprType.java
new file mode 100644
index 0000000..3732c95
--- /dev/null
+++ b/src/wcps/server/core/InducedOperationCoverageExprType.java
@@ -0,0 +1,105 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class InducedOperationCoverageExprType implements IRasNode, ICoverageInfo
+{
+ private IRasNode child;
+ private CoverageInfo info;
+ private String operation = "";
+
+ public InducedOperationCoverageExprType(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+ String nodeName = node.getNodeName();
+
+ System.err.println("Trying induced operation: " + nodeName);
+ boolean okay = false; // will be true if the node is recognized
+
+ if (nodeName.equals("rangeConstructor"))
+ {
+ operation = nodeName;
+ child = new RangeCoverageExprType(node, pcr);
+ info = new CoverageInfo((((ICoverageInfo)child).getCoverageInfo()));
+ }
+ else
+ { // Try one of the groups
+ child = null;
+
+ if (child == null)
+ {
+ try
+ {
+ child = new UnaryOperationCoverageExprType(node, pcr);
+ info = new CoverageInfo((((ICoverageInfo)child).getCoverageInfo()));
+ System.err.println("*** Induced Operation SUCCESS: " + node.getNodeName());
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("InducedOperation failed: " + node.getNodeName());
+ child = null;
+ if (e.getMessage().equals("Method not implemented"))
+ throw e;
+ }
+ }
+
+ if (child == null)
+ {
+ try
+ {
+ child = new BinaryOperationCoverageExprType(node, pcr);
+ info = new CoverageInfo((((ICoverageInfo)child).getCoverageInfo()));
+ System.err.println("*** Binary Operation SUCCESS: " + node.getNodeName());
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Binary operation failed: " + node.getNodeName()) ;
+ child = null;
+ }
+ }
+
+ if (child == null)
+ {
+ throw new WCPSException("Invalid induced coverage expression, next node: "
+ + node.getNodeName());
+ }
+ }
+
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return info;
+ }
+
+ public String toRasQL()
+ {
+ if (operation.equals("rangeConstructor"))
+ return "<rangeConstructor>" + child.toRasQL() + "</rangeConstructor>";
+ // else: groups
+ return child.toRasQL();
+ }
+}
diff --git a/src/wcps/server/core/InterpolationMethod.java b/src/wcps/server/core/InterpolationMethod.java
index f95bd9c..3e79a32 100644
--- a/src/wcps/server/core/InterpolationMethod.java
+++ b/src/wcps/server/core/InterpolationMethod.java
@@ -1,75 +1,95 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-// A pair of an interpolation type and a null resistance. See the WCPS standard for an explanation of these.
-
-class InterpolationMethod implements Cloneable {
-
- private String interpolationType;
- private String nullResistance;
-
- public InterpolationMethod( String interpolationType, String nullResistance ) throws InvalidMetadataException {
-
- if( interpolationType == null || !(interpolationType.equals( "nearest" ) || interpolationType.equals( "linear" ) || interpolationType.equals( "cubic" ) || interpolationType.equals( "quadratic" ) || interpolationType.equals( "none" )) ) {
- throw new InvalidMetadataException( "Invalid interpolation method: " + interpolationType + " is not a legal interpolation type" );
- }
- this.interpolationType = interpolationType;
-
- if( nullResistance == null || !(nullResistance.equals( "full" ) || nullResistance.equals( "none" ) || nullResistance.equals( "half" ) || nullResistance.equals( "other" )) ) {
- throw new InvalidMetadataException( "Invalid interpolation method: " + nullResistance + " is not a legal null resistance" );
- }
- this.nullResistance = nullResistance;
-
- }
-
- public InterpolationMethod clone() {
-
- try {
- return new InterpolationMethod( interpolationType, nullResistance );
- }
- catch( InvalidMetadataException ime ) {
- throw new RuntimeException( "Invalid metadata while cloning InterpolationMethod. This is a software bug in WCPS.", ime );
- }
-
- }
-
- public boolean equals( InterpolationMethod im ) {
-
- return interpolationType.equals( im.interpolationType ) && nullResistance.equals( im.nullResistance );
-
- }
-
- public String getInterpolationType() {
-
- return interpolationType;
-
- }
-
- public String getNullResistance() {
-
- return nullResistance;
-
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+//A pair of an interpolation type and a null resistance. See the WCPS standard for an explanation of these.
+
+class InterpolationMethod implements Cloneable
+{
+ private String interpolationType;
+ private String nullResistance;
+
+ public InterpolationMethod(String interpolationType, String nullResistance)
+ throws InvalidMetadataException
+ {
+ if ((interpolationType == null)
+ || !(interpolationType.equals("nearest") || interpolationType.equals("linear")
+ || interpolationType.equals("cubic")
+ || interpolationType.equals("quadratic")
+ || interpolationType.equals("none")))
+ {
+ throw new InvalidMetadataException("Invalid interpolation method: "
+ + interpolationType
+ + " is not a legal interpolation type");
+ }
+
+ this.interpolationType = interpolationType;
+
+ if ((nullResistance == null)
+ || !(nullResistance.equals("full") || nullResistance.equals("none")
+ || nullResistance.equals("half") || nullResistance.equals("other")))
+ {
+ throw new InvalidMetadataException("Invalid interpolation method: "
+ + nullResistance
+ + " is not a legal null resistance");
+ }
+
+ this.nullResistance = nullResistance;
+
+ }
+
+ public InterpolationMethod clone()
+ {
+ try
+ {
+ return new InterpolationMethod(interpolationType, nullResistance);
+ }
+ catch (InvalidMetadataException ime)
+ {
+ throw new RuntimeException(
+ "Invalid metadata while cloning InterpolationMethod. This is a software bug in WCPS.",
+ ime);
+ }
+
+ }
+
+ public boolean equals(InterpolationMethod im)
+ {
+ return interpolationType.equals(im.interpolationType)
+ && nullResistance.equals(im.nullResistance);
+
+ }
+
+ public String getInterpolationType()
+ {
+ return interpolationType;
+
+ }
+
+ public String getNullResistance()
+ {
+ return nullResistance;
+
+ }
+}
diff --git a/src/wcps/server/core/InvalidMetadataException.java b/src/wcps/server/core/InvalidMetadataException.java
index 92bc754..dc8ce77 100644
--- a/src/wcps/server/core/InvalidMetadataException.java
+++ b/src/wcps/server/core/InvalidMetadataException.java
@@ -1,37 +1,37 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-// Thrown when WCPS received a request, but could not evaluate it because the metadata for some coverage does not conform to the WCPS standard.
-
-public class InvalidMetadataException extends WCPSException {
-
- private static final long serialVersionUID = 48924938L;
-
- public InvalidMetadataException( String message ) {
-
- super( message, null );
-
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+//Thrown when WCPS received a request, but could not evaluate it because the metadata for some coverage does not conform to the WCPS standard.
+
+public class InvalidMetadataException extends WCPSException
+{
+ private static final long serialVersionUID = 48924938L;
+
+ public InvalidMetadataException(String message)
+ {
+ super(message, null);
+
+ }
+}
diff --git a/src/wcps/server/core/InvalidRequestException.java b/src/wcps/server/core/InvalidRequestException.java
index da0b759..56fdc94 100644
--- a/src/wcps/server/core/InvalidRequestException.java
+++ b/src/wcps/server/core/InvalidRequestException.java
@@ -1,43 +1,43 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-// This exception is throws whenever a user submits a request that is not valid in some way.
-
-public class InvalidRequestException extends WCPSException {
-
- private static final long serialVersionUID = 65492846L;
-
- public InvalidRequestException( String message ) {
-
- super( message, null );
-
- }
-
- public InvalidRequestException( String message, Throwable cause ) {
-
- super( message, cause );
-
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+//This exception is throws whenever a user submits a request that is not valid in some way.
+
+public class InvalidRequestException extends WCPSException
+{
+ private static final long serialVersionUID = 65492846L;
+
+ public InvalidRequestException(String message)
+ {
+ super(message, null);
+
+ }
+
+ public InvalidRequestException(String message, Throwable cause)
+ {
+ super(message, cause);
+
+ }
+}
diff --git a/src/wcps/server/core/Metadata.java b/src/wcps/server/core/Metadata.java
index 92dbc96..9370a00 100644
--- a/src/wcps/server/core/Metadata.java
+++ b/src/wcps/server/core/Metadata.java
@@ -1,639 +1,801 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import java.math.BigInteger;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-// This class implements WCPS metadata. For information on what each field means, see the WCPS standard. This class provides extensive error cheching and well as various utility functions.
-
-class Metadata implements Cloneable {
-
- private static final DateFormat iso8601 = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss" );
-
- private List<CellDomainElement> cellDomain;
- private String coverageName;
- private List<DomainElement> domain;
- private InterpolationMethod interpolationDefault;
- private Set<InterpolationMethod> interpolationSet;
- private String nullDefault;
- private Set<String> nullSet;
- private List<RangeElement> range;
-
- public Metadata( List<CellDomainElement> cellDomain, List<RangeElement> range, Set<String> nullSet, String nullDefault, Set<InterpolationMethod> interpolationSet, InterpolationMethod interpolationDefault, String coverageName, List<DomainElement> domain ) throws InvalidMetadataException {
-
- if( cellDomain == null || range == null || coverageName == null || nullSet == null || interpolationSet == null ) {
- throw new InvalidMetadataException( "Cell domain, range list, coverage name, null set, and interpolation set cannot be null" );
- }
-
- if( cellDomain.size() == 0 ) {
- throw new InvalidMetadataException( "Invalid cell domain: At least one element is required" );
- }
- this.cellDomain = cellDomain;
-
- if( range.size() == 0 ) {
- throw new InvalidMetadataException( "At least one range element is required" );
- }
- this.range = new ArrayList<RangeElement>( range.size() );
- Iterator<RangeElement> ir = range.iterator();
- while( ir.hasNext() ) {
- RangeElement next = ir.next();
- Iterator<RangeElement> j = this.range.iterator();
- while( j.hasNext() ) {
- if( j.next().getName().equals( next.getName() ) ) {
- throw new InvalidMetadataException( "Duplicate range element name encountered" );
- }
- }
- this.range.add( next );
- }
-
- if( nullSet.size() == 0 ) { // TODO: check with Peter
- throw new InvalidMetadataException( "Invalid null set: At least one null value is required" );
- }
- if( nullDefault == null ) {
- throw new InvalidMetadataException( "Invalid null default: Null default cannot be null" );
- }
- if( !nullSet.contains( nullDefault ) ) {
- throw new InvalidMetadataException( "Invalid null default: Default null value " + nullDefault + " is not part of the null set" );
- }
- Iterator<String> ns = nullSet.iterator();
- while( ns.hasNext() ) {
- String nullVal = ns.next();
- List<String> nulls = SDU.str2string( nullVal );
- if( nulls.size() != range.size() ) {
- throw new InvalidMetadataException( "Invalid null value: " + nullVal + " must have " + range.size() + " axes according to the range specified for coverage " + coverageName );
- }
- Iterator<String> i = nulls.iterator();
- Iterator<RangeElement> j = range.iterator();
- while( j.hasNext() ) {
- RangeElement re = j.next();
- if( re.isBoolean() ) {
- SDU.str2boolean( i.next() );
- }
- else if( re.isIntegral() ) {
- SDU.str2integer( i.next() );
- }
- else if( re.isFloating() ) {
- SDU.str2double( i.next() );
- }
- else if( re.isComplex() ) {
- SDU.str2complex( i.next() );
- }
- }
- }
- this.nullSet = nullSet;
- this.nullDefault = nullDefault;
-
- if( interpolationSet.size() == 0 ) { // TODO: check with Peter
- throw new InvalidMetadataException( "Invalid interpolation set: At least one interpolation method is required" );
- }
- if( interpolationDefault == null ) {
- interpolationDefault = new InterpolationMethod( "none", "none" );
- }
- boolean defaultContainedInSet = false;
- Iterator<InterpolationMethod> is = interpolationSet.iterator();
- while( is.hasNext() ) {
- if( interpolationDefault.equals( is.next() ) ) {
- defaultContainedInSet = true;
- }
- }
- if( !defaultContainedInSet ) {
- throw new InvalidMetadataException( "Ivanlid interpolation default: Default interpolation method (" + interpolationDefault.getInterpolationType() + "," + interpolationDefault.getNullResistance() + ") is not part of the interpolation set" );
- }
- this.interpolationSet = interpolationSet;
- this.interpolationDefault = interpolationDefault;
-
- this.coverageName = coverageName;
-
- if( domain != null ) {
- if( domain.size() != cellDomain.size() ) {
- throw new InvalidMetadataException( "Domain and cell domain must have equal number of elements" );
- }
- this.domain = new ArrayList<DomainElement>( domain.size() );
- Iterator<DomainElement> i = domain.iterator();
- while( i.hasNext() ) {
- DomainElement next = i.next();
- Iterator<DomainElement> j = this.domain.iterator();
- while( j.hasNext() ) {
- DomainElement previous = j.next();
- if( previous.getName().equals( next.getName() ) ) {
- throw new InvalidMetadataException( "Duplicate domain element name encountered" );
- }
- if( previous.getType().equals( "temporal" ) && next.getType().equals( "temporal" ) ) {
- throw new InvalidMetadataException( "Domain can contain at most one temporal axis" );
- }
- if( previous.getType().equals( "elevation" ) && next.getType().equals( "elevation" ) ) {
- throw new InvalidMetadataException( "Domain can contain at most one elevation axis" );
- }
- if( previous.getType().equals( "x" ) && next.getType().equals( "x" ) ) {
- throw new InvalidMetadataException( "Domain can contain at most one x axis" );
- }
- if( previous.getType().equals( "y" ) && next.getType().equals( "y" ) ) {
- throw new InvalidMetadataException( "Domain can contain at most one y axis" );
- }
- if( next.getType().equals( "x" ) ) {
- boolean l = false;
- Iterator<DomainElement> k = domain.iterator();
- while( k.hasNext() ) {
- if( k.next().getType().equals( "y" ) ) {
- l = true;
- }
- }
- if( l == false ) {
- throw new InvalidMetadataException( "If domain contains a x axis, it must contain a y axis as well" );
- }
- }
- else if( next.getType().equals( "y" ) ) {
- boolean l = false;
- Iterator<DomainElement> k = domain.iterator();
- while( k.hasNext() ) {
- if( k.next().getType().equals( "x" ) ) {
- l = true;
- }
- }
- if( l == false ) {
- throw new InvalidMetadataException( "If domain contains a y axis, it must contain a x axis as well" );
- }
- }
- }
- this.domain.add( next );
- }
- }
-
- }
-
- public Metadata clone() {
-
- try {
- List<CellDomainElement> cd = new ArrayList<CellDomainElement>( cellDomain.size() );
- Iterator<CellDomainElement> i = cellDomain.iterator();
- while( i.hasNext() ) {
- cd.add( i.next().clone() );
- }
-
- List<RangeElement> r = new ArrayList<RangeElement>( range.size() );
- Iterator<RangeElement> j = range.iterator();
- while( j.hasNext() ) {
- r.add( j.next().clone() );
- }
-
- List<DomainElement> d = new ArrayList<DomainElement>( domain.size() );
- Iterator<DomainElement> k = domain.iterator();
- while( k.hasNext() ) {
- d.add( k.next().clone() );
- }
-
- Set<String> ns = new HashSet<String>( nullSet.size() );
- Iterator<String> l = nullSet.iterator();
- while( l.hasNext() ) {
- ns.add( new String( l.next() ) );
- }
-
- Set<InterpolationMethod> is = new HashSet<InterpolationMethod>( interpolationSet.size() );
- Iterator<InterpolationMethod> m = interpolationSet.iterator();
- while( m.hasNext() ) {
- is.add( m.next().clone() );
- }
-
- return new Metadata( cd, r, ns, new String( nullDefault ), is, interpolationDefault.clone(), new String( coverageName ), d );
- }
- catch( InvalidMetadataException ime ) {
- throw new RuntimeException( "Invalid metadata while cloning Metadata. This is a software bug in WCPS.", ime );
- }
-
- }
-
-
-// public CellDomainElement getCellDomain( int index ) {
-//
-// return cellDomain.get( index );
-//
-// }
-
- public Iterator<CellDomainElement> getCellDomainIterator() {
-
- return cellDomain.iterator();
-
- }
-
- public Iterator<DomainElement> getDomainIterator() {
- return domain.iterator();
- }
-
- public int getDimension() {
-
- return cellDomain.size();
-
- }
-
-
-// public DomainElement getDomainByType( String type ) {
-//
-// Iterator<DomainElement> i = domain.iterator();
-// DomainElement de;
-// while( i.hasNext() ) {
-// de = i.next();
-// if( de.getType().equals( type ) ) {
-// return de;
-// }
-// }
-// return null;
-//
-// }
-
- public int getDomainIndexByName( String name ) {
-
- Iterator<DomainElement> i = domain.iterator();
- for( int index = 0; i.hasNext(); index++ ) {
- if( i.next().getName().equals( name ) ) {
- return index;
- }
- }
- return -1;
- }
-
-// public int getDomainIndexByType( String type ) {
-//
-// Iterator<DomainElement> i = domain.iterator();
-// for( int index = 0; i.hasNext(); index++ ) {
-// if( i.next().getName().equals( type ) ) {
-// return index;
-// }
-// }
-// return -1;
-//
-// }
-
-// public String getDomainType( int index ) {
-//
-// return domain.get( index ).getType();
-//
-// }
-
- public String getNullDefault() {
-
- return nullDefault;
-
- }
-
- public Set<String> getNullSet() {
-
- return nullSet;
-
- }
-
-// public String getRangeType( int index ) {
-//
-// return range.get( index ).getType();
-//
-// }
-
-// public String getRangeType( String name ) {
-//
-// String type = null;
-// Iterator<RangeElement> i = range.iterator();
-// RangeElement re;
-// while( i.hasNext() ) {
-// re = i.next();
-// if( re.getName().equals( name ) ) {
-// type = re.getType();
-// }
-// }
-// return type;
-//
-// }
-
-// public double getResolution( int i ) {
-//
-// DomainElement de = domain.get( i );
-// Double deLo = de.getNumLo();
-// Double deHi = de.getNumHi();
-// if( deLo == null ) {
-// return -1;
-// }
-//
-// CellDomainElement cde = cellDomain.get( i );
-// BigInteger cdeLo = cde.getLo();
-// BigInteger cdeHi = cde.getHi();
-//
-// return (deHi - deLo) / (cdeHi.subtract( cdeLo ).doubleValue() + 1);
-//
-// }
-
-// public boolean isCellDomainEqualTo( Metadata m ) {
-//
-// if( m == null ) {
-// return false;
-// }
-//
-// Iterator<CellDomainElement> i = cellDomain.iterator();
-// Iterator<CellDomainElement> j = m.cellDomain.iterator();
-// while( i.hasNext() && j.hasNext() ) {
-// if( !i.next().equals( j.next() ) ) {
-// return false;
-// }
-// }
-// if( i.hasNext() || j.hasNext() ) {
-// return false;
-// }
-// return true;
-//
-// }
-
-// public boolean isCrsValid( String crs ) {
-// return crs != null && (crs.equals( "" ) || crs.startsWith( "urn:ogc:def:crs:EPSG::" ));
-// }
-
-// public boolean isDomainEqualTo (Metadata m) {
-//
-// if( m == null ) {
-// return false;
-// }
-//
-// Iterator<DomainElement> i = domain.iterator();
-// Iterator<DomainElement> j = m.domain.iterator();
-// while( i.hasNext() && j.hasNext() ) {
-// if( !i.next().equals( j.next() ) ) {
-// return false;
-// }
-// }
-// if( i.hasNext() || j.hasNext() ) {
-// return false;
-// }
-// return true;
-//
-// }
-
-// public boolean isInterpolationMethodValid( String im ) {
-//
-// return im != null && im.equals( "nearest neighbor" );
-//
-// }
-
- public boolean isRangeBoolean() {
-
- Iterator<RangeElement> i = range.iterator();
- while( i.hasNext() ) {
- if( !i.next().isBoolean() ) {
- return false;
- }
- }
- return true;
-
- }
-
- public boolean isRangeComplex() {
-
- Iterator<RangeElement> i = range.iterator();
- while( i.hasNext() ) {
- if( !i.next().isComplex() ) {
- return false;
- }
- }
- return true;
-
- }
-
- public boolean isRangeIntegral() {
-
- Iterator<RangeElement> i = range.iterator();
- while( i.hasNext() ) {
- if( !i.next().isIntegral() ) {
- return false;
- }
- }
- return true;
-
- }
-
-// public boolean isRangeEqualTo (Metadata m) {
-//
-// if( m == null ) {
-// return false;
-// }
-//
-// Iterator<RangeElement> i = range.iterator();
-// Iterator<RangeElement> j = m.range.iterator();
-// while( i.hasNext() && j.hasNext() ) {
-// if( !i.next().equals( j.next() ) ) {
-// return false;
-// }
-// }
-// if( i.hasNext() || j.hasNext() ) {
-// return false;
-// }
-// return true;
-//
-// }
-
- public boolean isRangeFloating() {
-
- Iterator<RangeElement> i = range.iterator();
- while( i.hasNext() ) {
- if( !i.next().isFloating() ) {
- return false;
- }
- }
- return true;
-
- }
-
- public boolean isRangeNumeric() {
-
- Iterator<RangeElement> i = range.iterator();
- while( i.hasNext() ) {
- if( !i.next().isNumeric() ) {
- return false;
- }
- }
- return true;
-
- }
-
-// public boolean isResolutionEqualTo( Metadata m ) {
-//
-// if( m == null || getDimension() != m.getDimension() ) {
-// return false;
-// }
-//
-// Iterator<CellDomainElement> cdIterator1 = cellDomain.iterator();
-// Iterator<CellDomainElement> cdIterator2 = m.cellDomain.iterator();
-// Iterator<DomainElement> dIterator1 = domain.iterator();
-// Iterator<DomainElement> dIterator2 = m.domain.iterator();
-// double resolution1;
-// double resolution2;
-// CellDomainElement cde;
-// DomainElement de;
-// Double deLo;
-// Double deHi;
-// BigInteger cdeLo;
-// BigInteger cdeHi;
-// while( cdIterator1.hasNext() ) {
-// cde = cdIterator1.next();
-// de = dIterator1.next();
-// deLo = de.getNumLo();
-// deHi = de.getNumHi();
-// if( deLo == null ) {
-// resolution1 = -1;
-// }
-// cdeLo = cde.getLo();
-// cdeHi = cde.getHi();
-// resolution1 = (deHi - deLo) / (cdeHi.subtract( cdeLo ).doubleValue() + 1);
-// cde = cdIterator1.next();
-// de = dIterator1.next();
-// deLo = de.getNumLo();
-// deHi = de.getNumHi();
-// if( deLo == null ) {
-// resolution2 = -1;
-// }
-// cdeLo = cde.getLo();
-// cdeHi = cde.getHi();
-// resolution2 = (deHi - deLo) / (cdeHi.subtract( cdeLo ).doubleValue() + 1);
-// if( resolution1 != resolution2 ) {
-// return false;
-// }
-// }
-// return true;
-//
-// }
-
-// public boolean isTypeValid( String type ) {
-// return type != null && (type.equals( "char" ) || type.equals( "unsigned char" ) || type.equals( "short" ) || type.equals( "unsigned short" ) || type.equals( "int" ) || type.equals( "unsigned int" ) || type.equals( "long" ) || type.equals( "unsigned long" ) || type.equals( "float" ) || type.equals( "double" )); // TODO: fix
-// }
-
-// public void removeFromCellDomain( int index ) throws InvalidMetadataException {
-//
-// cellDomain.remove( index );
-// if( cellDomain.size() == 0 ) {
-// throw new InvalidMetadataException( "Metadata transformation: Cell domain cannot be empty" );
-// }
-//
-// }
-
-// public void removeFromDomain( int index ) throws InvalidMetadataException {
-//
-// domain.remove( index );
-// if( domain.size() == 0 ) {
-// throw new InvalidMetadataException( "Metadata transformation: Domain cannot be empty" );
-// }
-//
-// }
-
- public void setCoverageName( String coverageName ) throws InvalidMetadataException {
-
- if( coverageName == null ) {
- throw new InvalidMetadataException( "Metadata transformation: Coverage name cannot be null" );
- }
- this.coverageName = coverageName;
-
- }
-
-// public void setCrs( String crs ) throws InvalidMetadataException {
-//
-// if( crs == null ) {
-// throw new InvalidMetadataException( "Metadata transformation: CRS cannot be null" );
-// }
-// if( !(crs.equals( "" ) || crs.startsWith( "urn:ogc:def:crs:EPSG::" )) ) {
-// throw new InvalidMetadataException( "Metadata transformation: Invalid CRS" );
-// }
-// this.crs = crs;
-//
-// }
-
-// public void setInterpolationMethodList( List<String> interpolationMethodList ) throws InvalidMetadataException {
-//
-// this.interpolationMethodList = interpolationMethodList;
-// Iterator<String> is = interpolationMethodList.iterator();
-// while( is.hasNext() ) {
-// String next = is.next();
-// if( !(next.equals( "nearest neighbor" ) || next.equals( "bilinear" ) || next.equals( "bicubic" ) || next.equals( "lost area" ) || next.equals( "barycentric" )) ) {
-// throw new InvalidMetadataException( "Metadata transformation: Invalid interpolation method" );
-// }
-// }
-//
-// }
-
-// public void setNullValue( String nullValue ) {
-//
-// this.nullValue = nullValue;
-//
-// }
-
- public void setRangeType( String type ) throws InvalidMetadataException {
-
- Iterator<RangeElement> i = range.iterator();
- while( i.hasNext() ) {
- i.next().setType( type );
- }
-
- }
-
-// public void setRangeType( List<String> types ) throws InvalidMetadataException {
-//
-// if( types.size() != range.size() ) {
-// throw new InvalidMetadataException( "Invalid range type: New type has " + types.size() + " elements, but range has " + range.size() + " elements" );
-// }
-// Iterator<RangeElement> i = range.iterator();
-// Iterator<String> j = types.iterator();
-// while( i.hasNext() ) {
-// i.next().setType( j.next() );
-// }
-//
-// }
-
-// public void updateCellDomain( int index, BigInteger lo, BigInteger hi ) throws InvalidMetadataException {
-//
-// cellDomain.set( index, new CellDomainElement( lo, hi ) );
-//
-// }
-
-// public void updateDomain( int index, Double numLo, Double numHi, String strLo, String strHi ) throws InvalidMetadataException {
-//
-// DomainElement old = domain.get( index );
-// domain.set( index, new DomainElement( old.getName(), old.getType(), numLo, numHi, strLo, strHi ) );
-//
-// }
-
- public void updateNulls( Set<String> nullSet, String nullDefault ) throws InvalidMetadataException {
-
- if( nullSet.size() == 0 ) { // TODO: check with Peter
- throw new InvalidMetadataException( "Invalid null set: At least one null value is required" );
- }
- if( nullDefault == null ) {
- nullDefault = "0"; // TODO: "false" for booleans, but check whether it is supported by rasdaman
- }
- if( !nullSet.contains( nullDefault ) ) {
- throw new InvalidMetadataException( "Invalid null default: Default null value " + nullDefault + " is not part of the null set" );
- }
- this.nullSet = nullSet;
- this.nullDefault = nullDefault;
-
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import java.math.BigInteger;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+//This class implements WCPS metadata. For information on what each field means, see the WCPS standard. This class provides extensive error cheching and well as various utility functions.
+
+class Metadata implements Cloneable
+{
+ private static final DateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+ private List<CellDomainElement> cellDomain;
+ private String coverageName;
+ private List<DomainElement> domain;
+ private InterpolationMethod interpolationDefault;
+ private Set<InterpolationMethod> interpolationSet;
+ private String nullDefault;
+ private Set<String> nullSet;
+ private List<RangeElement> range;
+
+ public Metadata(List<CellDomainElement> cellDomain, List<RangeElement> range,
+ Set<String> nullSet, String nullDefault,
+ Set<InterpolationMethod> interpolationSet,
+ InterpolationMethod interpolationDefault, String coverageName,
+ List<DomainElement> domain)
+ throws InvalidMetadataException
+ {
+ if ((cellDomain == null) || (range == null) || (coverageName == null)
+ || (nullSet == null) || (interpolationSet == null))
+ {
+ throw new InvalidMetadataException(
+ "Cell domain, range list, coverage name, null set, and interpolation set cannot be null");
+ }
+
+ if (cellDomain.size() == 0)
+ {
+ throw new InvalidMetadataException(
+ "Invalid cell domain: At least one element is required");
+ }
+
+ this.cellDomain = cellDomain;
+
+ if (range.size() == 0)
+ {
+ throw new InvalidMetadataException(
+ "At least one range element is required");
+ }
+
+ this.range = new ArrayList<RangeElement>(range.size());
+ Iterator<RangeElement> ir = range.iterator();
+
+ while (ir.hasNext())
+ {
+ RangeElement next = ir.next();
+ Iterator<RangeElement> j = this.range.iterator();
+
+ while (j.hasNext())
+ {
+ if (j.next().getName().equals(next.getName()))
+ {
+ throw new InvalidMetadataException(
+ "Duplicate range element name encountered");
+ }
+ }
+
+ this.range.add(next);
+ }
+
+ if (nullSet.size() == 0)
+ { // TODO: check with Peter
+ throw new InvalidMetadataException(
+ "Invalid null set: At least one null value is required");
+ }
+
+ if (nullDefault == null)
+ {
+ throw new InvalidMetadataException(
+ "Invalid null default: Null default cannot be null");
+ }
+
+ if (!nullSet.contains(nullDefault))
+ {
+ throw new InvalidMetadataException(
+ "Invalid null default: Default null value " + nullDefault
+ + " is not part of the null set");
+ }
+
+ Iterator<String> ns = nullSet.iterator();
+
+ while (ns.hasNext())
+ {
+ String nullVal = ns.next();
+ List<String> nulls = SDU.str2string(nullVal);
+
+ if (nulls.size() != range.size())
+ {
+ throw new InvalidMetadataException(
+ "Invalid null value: " + nullVal + " must have " + range.size()
+ + " axes according to the range specified for coverage "
+ + coverageName);
+ }
+
+ Iterator<String> i = nulls.iterator();
+ Iterator<RangeElement> j = range.iterator();
+
+ while (j.hasNext())
+ {
+ RangeElement re = j.next();
+
+ if (re.isBoolean())
+ {
+ SDU.str2boolean(i.next());
+ }
+ else if (re.isIntegral())
+ {
+ SDU.str2integer(i.next());
+ }
+ else if (re.isFloating())
+ {
+ SDU.str2double(i.next());
+ }
+ else if (re.isComplex())
+ {
+ SDU.str2complex(i.next());
+ }
+ }
+ }
+
+ this.nullSet = nullSet;
+ this.nullDefault = nullDefault;
+
+ if (interpolationSet.size() == 0)
+ { // TODO: check with Peter
+ throw new InvalidMetadataException(
+ "Invalid interpolation set: At least one interpolation method is required");
+ }
+
+ if (interpolationDefault == null)
+ {
+ interpolationDefault = new InterpolationMethod("none", "none");
+ }
+
+ boolean defaultContainedInSet = false;
+ Iterator<InterpolationMethod> is = interpolationSet.iterator();
+
+ while (is.hasNext())
+ {
+ if (interpolationDefault.equals(is.next()))
+ {
+ defaultContainedInSet = true;
+ }
+ }
+
+ if (!defaultContainedInSet)
+ {
+ throw new InvalidMetadataException(
+ "Ivanlid interpolation default: Default interpolation method ("
+ + interpolationDefault.getInterpolationType() + ","
+ + interpolationDefault.getNullResistance()
+ + ") is not part of the interpolation set");
+ }
+
+ this.interpolationSet = interpolationSet;
+ this.interpolationDefault = interpolationDefault;
+
+ this.coverageName = coverageName;
+
+ if (domain != null)
+ {
+ if (domain.size() != cellDomain.size())
+ {
+ throw new InvalidMetadataException(
+ "Domain and cell domain must have equal number of elements");
+ }
+
+ this.domain = new ArrayList<DomainElement>(domain.size());
+ Iterator<DomainElement> i = domain.iterator();
+
+ while (i.hasNext())
+ {
+ DomainElement next = i.next();
+ Iterator<DomainElement> j = this.domain.iterator();
+
+ while (j.hasNext())
+ {
+ DomainElement previous = j.next();
+
+ if (previous.getName().equals(next.getName()))
+ {
+ throw new InvalidMetadataException(
+ "Duplicate domain element name encountered");
+ }
+
+ if (previous.getType().equals("temporal")
+ && next.getType().equals("temporal"))
+ {
+ throw new InvalidMetadataException(
+ "Domain can contain at most one temporal axis");
+ }
+
+ if (previous.getType().equals("elevation")
+ && next.getType().equals("elevation"))
+ {
+ throw new InvalidMetadataException(
+ "Domain can contain at most one elevation axis");
+ }
+
+ if (previous.getType().equals("x")
+ && next.getType().equals("x"))
+ {
+ throw new InvalidMetadataException(
+ "Domain can contain at most one x axis");
+ }
+
+ if (previous.getType().equals("y")
+ && next.getType().equals("y"))
+ {
+ throw new InvalidMetadataException(
+ "Domain can contain at most one y axis");
+ }
+
+ if (next.getType().equals("x"))
+ {
+ boolean l = false;
+ Iterator<DomainElement> k = domain.iterator();
+
+ while (k.hasNext())
+ {
+ if (k.next().getType().equals("y"))
+ {
+ l = true;
+ }
+ }
+
+ if (l == false)
+ {
+ throw new InvalidMetadataException(
+ "If domain contains a x axis, it must contain a y axis as well");
+ }
+ }
+ else if (next.getType().equals("y"))
+ {
+ boolean l = false;
+ Iterator<DomainElement> k = domain.iterator();
+
+ while (k.hasNext())
+ {
+ if (k.next().getType().equals("x"))
+ {
+ l = true;
+ }
+ }
+
+ if (l == false)
+ {
+ throw new InvalidMetadataException(
+ "If domain contains a y axis, it must contain a x axis as well");
+ }
+ }
+ }
+
+ this.domain.add(next);
+ }
+ }
+
+ }
+
+ public Metadata clone()
+ {
+ try
+ {
+ List<CellDomainElement> cd =
+ new ArrayList<CellDomainElement>(cellDomain.size());
+ Iterator<CellDomainElement> i = cellDomain.iterator();
+
+ while (i.hasNext())
+ {
+ cd.add(i.next().clone());
+ }
+
+ List<RangeElement> r = new ArrayList<RangeElement>(range.size());
+ Iterator<RangeElement> j = range.iterator();
+
+ while (j.hasNext())
+ {
+ r.add(j.next().clone());
+ }
+
+ List<DomainElement> d = new ArrayList<DomainElement>(domain.size());
+ Iterator<DomainElement> k = domain.iterator();
+
+ while (k.hasNext())
+ {
+ d.add(k.next().clone());
+ }
+
+ Set<String> ns = new HashSet<String>(nullSet.size());
+ Iterator<String> l = nullSet.iterator();
+
+ while (l.hasNext())
+ {
+ ns.add(new String(l.next()));
+ }
+
+ Set<InterpolationMethod> is =
+ new HashSet<InterpolationMethod>(interpolationSet.size());
+ Iterator<InterpolationMethod> m = interpolationSet.iterator();
+
+ while (m.hasNext())
+ {
+ is.add(m.next().clone());
+ }
+
+ return new Metadata(cd, r, ns, new String(nullDefault), is,
+ interpolationDefault.clone(), new String(coverageName),
+ d);
+ }
+ catch (InvalidMetadataException ime)
+ {
+ throw new RuntimeException(
+ "Invalid metadata while cloning Metadata. This is a software bug in WCPS.",
+ ime);
+ }
+
+ }
+
+// public CellDomainElement getCellDomain( int index ) {
+//
+// return cellDomain.get( index );
+//
+// }
+
+ public Iterator<CellDomainElement> getCellDomainIterator()
+ {
+ return cellDomain.iterator();
+
+ }
+
+ public Iterator<DomainElement> getDomainIterator()
+ {
+ return domain.iterator();
+ }
+
+ public int getDimension()
+ {
+ return cellDomain.size();
+
+ }
+
+// public DomainElement getDomainByType( String type ) {
+//
+// Iterator<DomainElement> i = domain.iterator();
+// DomainElement de;
+// while( i.hasNext() ) {
+// de = i.next();
+// if( de.getType().equals( type ) ) {
+// return de;
+// }
+// }
+// return null;
+//
+// }
+
+ public int getDomainIndexByName(String name)
+ {
+ Iterator<DomainElement> i = domain.iterator();
+
+ for (int index = 0; i.hasNext(); index++)
+ {
+ if (i.next().getName().equals(name))
+ {
+ return index;
+ }
+ }
+
+ return -1;
+ }
+
+// public int getDomainIndexByType( String type ) {
+//
+// Iterator<DomainElement> i = domain.iterator();
+// for( int index = 0; i.hasNext(); index++ ) {
+// if( i.next().getName().equals( type ) ) {
+// return index;
+// }
+// }
+// return -1;
+//
+// }
+
+// public String getDomainType( int index ) {
+//
+// return domain.get( index ).getType();
+//
+// }
+
+ public String getNullDefault()
+ {
+ return nullDefault;
+
+ }
+
+ public Set<String> getNullSet()
+ {
+ return nullSet;
+
+ }
+
+// public String getRangeType( int index ) {
+//
+// return range.get( index ).getType();
+//
+// }
+
+// public String getRangeType( String name ) {
+//
+// String type = null;
+// Iterator<RangeElement> i = range.iterator();
+// RangeElement re;
+// while( i.hasNext() ) {
+// re = i.next();
+// if( re.getName().equals( name ) ) {
+// type = re.getType();
+// }
+// }
+// return type;
+//
+// }
+
+// public double getResolution( int i ) {
+//
+// DomainElement de = domain.get( i );
+// Double deLo = de.getNumLo();
+// Double deHi = de.getNumHi();
+// if( deLo == null ) {
+// return -1;
+// }
+//
+// CellDomainElement cde = cellDomain.get( i );
+// BigInteger cdeLo = cde.getLo();
+// BigInteger cdeHi = cde.getHi();
+//
+// return (deHi - deLo) / (cdeHi.subtract( cdeLo ).doubleValue() + 1);
+//
+// }
+
+// public boolean isCellDomainEqualTo( Metadata m ) {
+//
+// if( m == null ) {
+// return false;
+// }
+//
+// Iterator<CellDomainElement> i = cellDomain.iterator();
+// Iterator<CellDomainElement> j = m.cellDomain.iterator();
+// while( i.hasNext() && j.hasNext() ) {
+// if( !i.next().equals( j.next() ) ) {
+// return false;
+// }
+// }
+// if( i.hasNext() || j.hasNext() ) {
+// return false;
+// }
+// return true;
+//
+// }
+
+// public boolean isCrsValid( String crs ) {
+// return crs != null && (crs.equals( "" ) || crs.startsWith( "urn:ogc:def:crs:EPSG::" ));
+// }
+
+// public boolean isDomainEqualTo (Metadata m) {
+//
+// if( m == null ) {
+// return false;
+// }
+//
+// Iterator<DomainElement> i = domain.iterator();
+// Iterator<DomainElement> j = m.domain.iterator();
+// while( i.hasNext() && j.hasNext() ) {
+// if( !i.next().equals( j.next() ) ) {
+// return false;
+// }
+// }
+// if( i.hasNext() || j.hasNext() ) {
+// return false;
+// }
+// return true;
+//
+// }
+
+// public boolean isInterpolationMethodValid( String im ) {
+//
+// return im != null && im.equals( "nearest neighbor" );
+//
+// }
+
+ public boolean isRangeBoolean()
+ {
+ Iterator<RangeElement> i = range.iterator();
+
+ while (i.hasNext())
+ {
+ if (!i.next().isBoolean())
+ {
+ return false;
+ }
+ }
+
+ return true;
+
+ }
+
+ public boolean isRangeComplex()
+ {
+ Iterator<RangeElement> i = range.iterator();
+
+ while (i.hasNext())
+ {
+ if (!i.next().isComplex())
+ {
+ return false;
+ }
+ }
+
+ return true;
+
+ }
+
+ public boolean isRangeIntegral()
+ {
+ Iterator<RangeElement> i = range.iterator();
+
+ while (i.hasNext())
+ {
+ if (!i.next().isIntegral())
+ {
+ return false;
+ }
+ }
+
+ return true;
+
+ }
+
+// public boolean isRangeEqualTo (Metadata m) {
+//
+// if( m == null ) {
+// return false;
+// }
+//
+// Iterator<RangeElement> i = range.iterator();
+// Iterator<RangeElement> j = m.range.iterator();
+// while( i.hasNext() && j.hasNext() ) {
+// if( !i.next().equals( j.next() ) ) {
+// return false;
+// }
+// }
+// if( i.hasNext() || j.hasNext() ) {
+// return false;
+// }
+// return true;
+//
+// }
+
+ public boolean isRangeFloating()
+ {
+ Iterator<RangeElement> i = range.iterator();
+
+ while (i.hasNext())
+ {
+ if (!i.next().isFloating())
+ {
+ return false;
+ }
+ }
+
+ return true;
+
+ }
+
+ public boolean isRangeNumeric()
+ {
+ Iterator<RangeElement> i = range.iterator();
+
+ while (i.hasNext())
+ {
+ if (!i.next().isNumeric())
+ {
+ return false;
+ }
+ }
+
+ return true;
+
+ }
+
+// public boolean isResolutionEqualTo( Metadata m ) {
+//
+// if( m == null || getDimension() != m.getDimension() ) {
+// return false;
+// }
+//
+// Iterator<CellDomainElement> cdIterator1 = cellDomain.iterator();
+// Iterator<CellDomainElement> cdIterator2 = m.cellDomain.iterator();
+// Iterator<DomainElement> dIterator1 = domain.iterator();
+// Iterator<DomainElement> dIterator2 = m.domain.iterator();
+// double resolution1;
+// double resolution2;
+// CellDomainElement cde;
+// DomainElement de;
+// Double deLo;
+// Double deHi;
+// BigInteger cdeLo;
+// BigInteger cdeHi;
+// while( cdIterator1.hasNext() ) {
+// cde = cdIterator1.next();
+// de = dIterator1.next();
+// deLo = de.getNumLo();
+// deHi = de.getNumHi();
+// if( deLo == null ) {
+// resolution1 = -1;
+// }
+// cdeLo = cde.getLo();
+// cdeHi = cde.getHi();
+// resolution1 = (deHi - deLo) / (cdeHi.subtract( cdeLo ).doubleValue() + 1);
+// cde = cdIterator1.next();
+// de = dIterator1.next();
+// deLo = de.getNumLo();
+// deHi = de.getNumHi();
+// if( deLo == null ) {
+// resolution2 = -1;
+// }
+// cdeLo = cde.getLo();
+// cdeHi = cde.getHi();
+// resolution2 = (deHi - deLo) / (cdeHi.subtract( cdeLo ).doubleValue() + 1);
+// if( resolution1 != resolution2 ) {
+// return false;
+// }
+// }
+// return true;
+//
+// }
+
+// public boolean isTypeValid( String type ) {
+// return type != null && (type.equals( "char" ) || type.equals( "unsigned char" ) || type.equals( "short" ) || type.equals( "unsigned short" ) || type.equals( "int" ) || type.equals( "unsigned int" ) || type.equals( "long" ) || type.equals( "unsigned long" ) || type.equals( "float" ) || type.equals( "double" )); // TODO: fix
+// }
+
+// public void removeFromCellDomain( int index ) throws InvalidMetadataException {
+//
+// cellDomain.remove( index );
+// if( cellDomain.size() == 0 ) {
+// throw new InvalidMetadataException( "Metadata transformation: Cell domain cannot be empty" );
+// }
+//
+// }
+
+// public void removeFromDomain( int index ) throws InvalidMetadataException {
+//
+// domain.remove( index );
+// if( domain.size() == 0 ) {
+// throw new InvalidMetadataException( "Metadata transformation: Domain cannot be empty" );
+// }
+//
+// }
+
+ public void setCoverageName(String coverageName) throws InvalidMetadataException
+ {
+ if (coverageName == null)
+ {
+ throw new InvalidMetadataException(
+ "Metadata transformation: Coverage name cannot be null");
+ }
+
+ this.coverageName = coverageName;
+
+ }
+
+// public void setCrs( String crs ) throws InvalidMetadataException {
+//
+// if( crs == null ) {
+// throw new InvalidMetadataException( "Metadata transformation: CRS cannot be null" );
+// }
+// if( !(crs.equals( "" ) || crs.startsWith( "urn:ogc:def:crs:EPSG::" )) ) {
+// throw new InvalidMetadataException( "Metadata transformation: Invalid CRS" );
+// }
+// this.crs = crs;
+//
+// }
+
+// public void setInterpolationMethodList( List<String> interpolationMethodList ) throws InvalidMetadataException {
+//
+// this.interpolationMethodList = interpolationMethodList;
+// Iterator<String> is = interpolationMethodList.iterator();
+// while( is.hasNext() ) {
+// String next = is.next();
+// if( !(next.equals( "nearest neighbor" ) || next.equals( "bilinear" ) || next.equals( "bicubic" ) || next.equals( "lost area" ) || next.equals( "barycentric" )) ) {
+// throw new InvalidMetadataException( "Metadata transformation: Invalid interpolation method" );
+// }
+// }
+//
+// }
+
+// public void setNullValue( String nullValue ) {
+//
+// this.nullValue = nullValue;
+//
+// }
+
+ public void setRangeType(String type) throws InvalidMetadataException
+ {
+ Iterator<RangeElement> i = range.iterator();
+
+ while (i.hasNext())
+ {
+ i.next().setType(type);
+ }
+
+ }
+
+// public void setRangeType( List<String> types ) throws InvalidMetadataException {
+//
+// if( types.size() != range.size() ) {
+// throw new InvalidMetadataException( "Invalid range type: New type has " + types.size() + " elements, but range has " + range.size() + " elements" );
+// }
+// Iterator<RangeElement> i = range.iterator();
+// Iterator<String> j = types.iterator();
+// while( i.hasNext() ) {
+// i.next().setType( j.next() );
+// }
+//
+// }
+
+// public void updateCellDomain( int index, BigInteger lo, BigInteger hi ) throws InvalidMetadataException {
+//
+// cellDomain.set( index, new CellDomainElement( lo, hi ) );
+//
+// }
+
+// public void updateDomain( int index, Double numLo, Double numHi, String strLo, String strHi ) throws InvalidMetadataException {
+//
+// DomainElement old = domain.get( index );
+// domain.set( index, new DomainElement( old.getName(), old.getType(), numLo, numHi, strLo, strHi ) );
+//
+// }
+
+ public void updateNulls(Set<String> nullSet, String nullDefault)
+ throws InvalidMetadataException
+ {
+ if (nullSet.size() == 0)
+ { // TODO: check with Peter
+ throw new InvalidMetadataException(
+ "Invalid null set: At least one null value is required");
+ }
+
+ if (nullDefault == null)
+ {
+ nullDefault = "0"; // TODO: "false" for booleans, but check whether it is supported by rasdaman
+ }
+
+ if (!nullSet.contains(nullDefault))
+ {
+ throw new InvalidMetadataException(
+ "Invalid null default: Default null value " + nullDefault
+ + " is not part of the null set");
+ }
+
+ this.nullSet = nullSet;
+ this.nullDefault = nullDefault;
+
+ }
+}
diff --git a/src/wcps/server/core/MetadataScalarExprType.java b/src/wcps/server/core/MetadataScalarExprType.java
new file mode 100644
index 0000000..5c46994
--- /dev/null
+++ b/src/wcps/server/core/MetadataScalarExprType.java
@@ -0,0 +1,41 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+// TODO: implement class MetadataScalarExprType
+public class MetadataScalarExprType implements IRasNode
+{
+
+ public MetadataScalarExprType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ throw new WCPSException("Method not yet implemented !");
+ }
+
+ public String toRasQL()
+ {
+ return "";
+ }
+}
diff --git a/src/wcps/server/core/MetadataSource.java b/src/wcps/server/core/MetadataSource.java
index 9df8238..0be5cba 100644
--- a/src/wcps/server/core/MetadataSource.java
+++ b/src/wcps/server/core/MetadataSource.java
@@ -1,35 +1,37 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import java.util.Set;
-
-// A MetadataSource is anything that can read metadata for a given coverage name. It must be able to list all coverages which it knows, return Metadata for each one, and also map a format (e.g. "png") to its mimetype (e.g. "image/png").
-
-public interface MetadataSource {
-
- public Set<String> coverages() throws ResourceException;
- public String mimetype( String format );
- public Metadata read( String coverageName ) throws InvalidRequestException, ResourceException;
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import java.util.Set;
+
+//A MetadataSource is anything that can read metadata for a given coverage name. It must be able to list all coverages which it knows, return Metadata for each one, and also map a format (e.g. "png") to its mimetype (e.g. "image/png").
+
+public interface MetadataSource
+{
+ public Set<String> coverages() throws ResourceException;
+
+ public String mimetype(String format);
+
+ public Metadata read(String coverageName) throws InvalidRequestException, ResourceException;
+}
diff --git a/src/wcps/server/core/NumericScalarExprType.java b/src/wcps/server/core/NumericScalarExprType.java
new file mode 100644
index 0000000..f9b63d7
--- /dev/null
+++ b/src/wcps/server/core/NumericScalarExprType.java
@@ -0,0 +1,139 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class NumericScalarExprType implements IRasNode
+{
+ private IRasNode first, second;
+ private String op, value;
+ private boolean twoChildren;
+
+ public NumericScalarExprType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ twoChildren = false;
+ String nodeName = node.getNodeName();
+
+ op = "";
+
+ System.out.println("Trying to parse numeric scalar expression ...");
+
+ if (nodeName.equals("numericConstant"))
+ {
+ twoChildren = false;
+ op = code(nodeName);
+ value = node.getFirstChild().getNodeValue();
+ try
+ {
+ double dval = Double.parseDouble(value);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new WCPSException("Could not understand constant: " + value);
+ }
+ }
+ else if (nodeName.equals("complexConstant")
+ || nodeName.equals("condense")
+ || nodeName.equals("reduce"))
+ {
+ op = code(nodeName);
+ twoChildren = false;
+ if (nodeName.equals("complexConstant"))
+ first = new ComplexConstantType(node, pcr);
+ if (nodeName.equals("condense"))
+ first = new CondenseScalarExprType(node, pcr);
+ if (nodeName.equals("reduce"))
+ first = new ReduceScalarExprType(node, pcr);
+ }
+ else if (nodeName.equals("numericUnaryMinus"))
+ {
+ op = code(nodeName);
+ twoChildren = false;
+ first = new NumericScalarExprType(node.getFirstChild(), pcr);
+ }
+ else if (nodeName.equals("numericAdd")
+ || nodeName.equals("numericMinus")
+ || nodeName.equals("numericMult")
+ || nodeName.equals("numericDiv"))
+ {
+ try
+ {
+ op = code(nodeName);
+ twoChildren = true;
+ Node child = node.getFirstChild();
+ first = new NumericScalarExprType(child, pcr);
+ second = new NumericScalarExprType(child.getNextSibling(), pcr);
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to parse a numeric expression pair !");
+ }
+ }
+
+ else
+ {
+ throw new WCPSException("Unexpected Numeric Scalar Expression node : "
+ + node.getNodeName());
+ }
+ }
+
+ public String toRasQL()
+ {
+ String result = "";
+ if (op.equals("value"))
+ result = value;
+ else if ((twoChildren==false) && (op.equals("-")))
+ result = "-" + first.toRasQL();
+ else if (op.equals("child"))
+ result = first.toRasQL();
+ else if (twoChildren == true)
+ result = "(" + first.toRasQL() + ")" + op +
+ "(" + second.toRasQL() + ")";
+ else
+ return " error ";
+
+ return result;
+ }
+
+ public String code(String name)
+ {
+ String op = "";
+ if (name.equals("numericConstant"))
+ op = "value";
+ if (name.equals("numericUnaryMinus") || name.equals("numericMinus"))
+ op = "-";
+ if (name.equals("numericAdd"))
+ op = "+";
+ if (name.equals("numericMult"))
+ op = "*";
+ if (name.equals("numericDiv"))
+ op = "/";
+ if (name.equals("condense") || name.equals("reduce")
+ || name.equals("complexConstant"))
+ op = "child";
+
+ return op;
+ }
+} \ No newline at end of file
diff --git a/src/wcps/server/core/ProcessCoverageRequest.java b/src/wcps/server/core/ProcessCoverageRequest.java
deleted file mode 100644
index f85c63d..0000000
--- a/src/wcps/server/core/ProcessCoverageRequest.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.odmg.Database;
-import org.odmg.DBag;
-import org.odmg.Implementation;
-import org.odmg.ODMGException;
-import org.odmg.OQLQuery;
-import org.odmg.QueryException;
-import org.odmg.Transaction;
-import org.xml.sax.SAXException;
-import rasj.RasGMArray;
-import rasj.RasImplementation;
-
-// A ProcessCoverage request is just a list of rasdaman queries.
-
-public class ProcessCoverageRequest {
-
- private ArrayList<CoverageIterator> iterators;
- private IRasNode where;
- private IRasNode coverageExpr;
- private MetadataSource source;
- private String url;
- private String database;
- private String mime;
-
- public ProcessCoverageRequest(String url, String database, Node node, MetadataSource source) throws WCPSException {
- super();
- this.source = source;
- this.url = url;
- this.database = database;
- Node x = node.getFirstChild();
- if (!x.getNodeName().equals("processCoverage"))
- throw new WCPSException("The document contains an unrecognized node : " + x.getNodeName());
- x = x.getFirstChild();
- iterators = new ArrayList<CoverageIterator>();
- while (x != null) {
- if (x.getNodeName().equals("#text")) {
- x = x.getNextSibling();
- continue;
- }
- System.err.println("The current node is: " + x.getNodeName());
- if (x.getNodeName().equals("coverageIterator")) {
- iterators.add(new CoverageIterator(x, this));
- } else if (x.getNodeName().equals("where")) {
- where = new BooleanScalarExprType(x.getFirstChild(), this);
- } else if (x.getNodeName().equals("encode")) {
- EncodeDataExprType encode;
- encode = new EncodeDataExprType(x, this);
- coverageExpr = encode;
- mime = encode.getMime();
- } else {
- // It has to be a scalar Expr Type
- coverageExpr = new ScalarExprType(x, this);
- mime = "text/plain";
- }
- x = x.getNextSibling();
- }
- }
-
-
- public String getMime() {
- return mime;
- }
-
- public MetadataSource getMetadataSource() {
- return source;
- }
-
- public Boolean isIteratorDefined(String iteratorName) {
- Iterator<CoverageIterator> it = iterators.iterator();
- while (it.hasNext()) {
- CoverageIterator tmp = it.next();
- if (iteratorName.equals(tmp.getIteratorName())) {
- return true;
- }
- }
- return false;
- }
-
- public String getQuery() {
- String result = "select " + coverageExpr.toRasQL() + " from ";
- Iterator<CoverageIterator> it = iterators.iterator();
- boolean first = true;
- while (it.hasNext()) {
- if (first) {
- first = false;
- } else {
- result += ", ";
- }
- result += it.next().toRasQL();
- }
- if (where != null)
- result += " where " + where.toRasQL();
- return result;
-
- }
-
- public Iterator<String> getCoverages(String iteratorName) throws WCPSException {
- for (int i = 0; i< iterators.size(); ++i) {
- if (iterators.get(i).getIteratorName().equals(iteratorName)) {
- return iterators.get(i).getCoverages();
- }
- }
- throw new WCPSException("Iterator " + iteratorName + " not defined");
- }
-
- public List<byte[]> execute() throws ResourceException {
- ArrayList<byte[]> results = new ArrayList<byte[]>();
- if (coverageExpr != null) {
- Implementation impl = new RasImplementation( url );
- Database db = impl.newDatabase();
- try {
- db.open( database, Database.OPEN_READ_ONLY );
- } catch( ODMGException odmge ) {
- try {
- db.close();
- }
- catch (ODMGException e) {}
- throw new ResourceException( "Could not connect to rasdaman at " + url + ", database " + database, odmge );
- }
- Transaction tr = impl.newTransaction();
- tr.begin();
- OQLQuery q = impl.newOQLQuery();
- DBag resultSet;
- try {
- q.create( this.getQuery() );
- resultSet = (DBag) q.execute();
- if( resultSet != null ) {
- Iterator resultIterator = resultSet.iterator();
- while( resultIterator.hasNext() ) {
- Object current = resultIterator.next();
- try{
- RasGMArray resultArray = (RasGMArray) current;
- results.add( resultArray.getArray() );
- } catch (ClassCastException e) { // not a RasGMarray
- if (!mime.equals("text/plain"))
- throw new ResourceException("Incompatible mime and data type!");
- System.err.println("result="+current.toString());
- results.add( current.toString().getBytes() );
-
- }
-
-
-/* if (mime.equals("text/plain")) {
- System.err.println("dataType is :" + resultArray.getBaseTypeSchema().toString());
- }*/
-
- }
- }
- } catch (QueryException qe) {
- tr.commit();
- try {
- db.close();
- } catch (ODMGException odmge) {}
- throw new ResourceException ( "Could not evaluate rasdaman query: '" + getQuery() + "'", qe );
- }
- tr.commit();
- try {
- db.close();
- } catch (ODMGException odmge) {}
- }
- if (mime.equals("text/plain")) {
-
- }
- return results;
-
- }
-
-}
diff --git a/src/wcps/server/core/ProcessCoveragesRequest.java b/src/wcps/server/core/ProcessCoveragesRequest.java
new file mode 100644
index 0000000..797d9c9
--- /dev/null
+++ b/src/wcps/server/core/ProcessCoveragesRequest.java
@@ -0,0 +1,305 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+package wcps.server.core;
+
+import grammar.WCPSRequest;
+import grammar.wcpsLexer;
+import grammar.wcpsParser;
+import grammar.wcpsParser.wcpsRequest_return;
+import java.io.IOException;
+import java.io.StringReader;
+import org.antlr.runtime.RecognitionException;
+import org.odmg.DBag;
+import org.odmg.Database;
+import org.odmg.Implementation;
+import org.odmg.ODMGException;
+import org.odmg.OQLQuery;
+import org.odmg.QueryException;
+import org.odmg.Transaction;
+
+import org.w3c.dom.*;
+
+import org.xml.sax.SAXException;
+import rasj.RasGMArray;
+import rasj.RasImplementation;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.xml.sax.InputSource;
+
+/** A ProcessCoveragesRequest request provides a (just one) rasdaman query, that it executes.
+ *
+ * Internally, it relies on XmlRequest, which computes the RasQL query.
+ *
+ */
+public class ProcessCoveragesRequest
+{
+// private IRasNode coverageExpr;
+ private String database;
+// private ArrayList<CoverageIterator> iterators;
+ private MetadataSource source;
+ private String url;
+// private IRasNode where;
+
+ private WCPS wcps;
+ private String rasqlQuery;
+ private String mime;
+ private XmlQuery xmlQuery;
+// public IRasNode covRequest;
+
+ public ProcessCoveragesRequest(String url, String database, Node node, MetadataSource source, WCPS wcps)
+ throws WCPSException, InvalidRequestException, ResourceException, SAXException, IOException
+ {
+ super();
+ this.source = source;
+ this.url = url;
+ this.database = database;
+ this.wcps = wcps;
+ Node child = node.getFirstChild();
+// iterators = new ArrayList<CoverageIterator>();
+ this.rasqlQuery = null;
+
+ System.err.println("Parsing ProcessCoveragesRequest node: " + child.getNodeName());
+
+ if (child.getNodeName().equals("ProcessCoveragesRequest") == false)
+ {
+ throw new WCPSException("The document contains an unrecognized node : "
+ + child.getNodeName());
+ }
+
+ child = child.getFirstChild();
+ while (child.getNodeName().equals("#text"))
+ child = child.getNextSibling();
+
+ if (child.getNodeName().equals("query") == false)
+ throw new WCPSException("Could not find node <query>: " + child.getNodeName());
+
+ // "child" is now the node <query>.
+ Node queryNode = child.getFirstChild();
+ while (queryNode.getNodeName().equals("#text"))
+ queryNode = queryNode.getNextSibling();
+
+ /**
+ * The following code is essential. It handles the two cases:
+ * 1) the xml contains an <xmlSyntax> request
+ * 2) the xml contains an <abstractSyntax> request
+ */
+ if (queryNode.getNodeName().equals("xmlSyntax"))
+ {
+ System.err.println("Found XML Syntax query");
+ this.xmlQuery = new XmlQuery();
+ xmlQuery.startParsing(queryNode, this);
+ }
+ else
+ if (queryNode.getNodeName().equals("abstractSyntax"))
+ {
+ try
+ {
+ String abstractQuery = queryNode.getFirstChild().getNodeValue();
+ System.err.println("Found Abstract Syntax query: " + abstractQuery);
+ String xmlString = abstractQueryToXmlQuery(abstractQuery);
+ InputSource xmlStringSource = new InputSource(new StringReader(xmlString));
+ System.err.println("Coverted the Abstract syntax query to an XML query:");
+ System.err.println("***********************************************");
+ System.err.println(xmlString);
+ System.err.println("***********************************************");
+ ProcessCoveragesRequest newRequest = wcps.pcPrepare(url, database, xmlStringSource);
+ this.xmlQuery = newRequest.getXmlRequestStructure();
+ }
+ catch (RecognitionException e)
+ {
+ throw new WCPSException("Abstract Syntax query is invalid: "
+ + e.getMessage());
+ }
+ }
+ else
+ throw new WCPSException("Error ! Unexpected node: " + queryNode.getNodeName());
+
+ // If everything went well, we now have a proper value for "xmlQuery"
+ this.rasqlQuery = xmlQuery.toRasQL();
+ this.mime = xmlQuery.getMimeType();
+ }
+
+ public static String abstractQueryToXmlQuery(String abstractQuery) throws RecognitionException
+ {
+ CharStream cs = new ANTLRStringStream(abstractQuery);
+ wcpsLexer lexer = new wcpsLexer(cs);
+ CommonTokenStream tokens = new CommonTokenStream();
+ tokens.setTokenSource(lexer);
+ wcpsParser parser = new wcpsParser(tokens);
+ wcpsRequest_return rrequest = parser.wcpsRequest();
+ WCPSRequest request = rrequest.value;
+ String xmlRequest = request.toXML();
+
+ return xmlRequest;
+ }
+
+ /*
+ private IRasNode getProcessOneCoverage()
+ {
+ return covRequest;
+ }
+ */
+
+ public String getMime()
+ {
+ return mime;
+ }
+
+ public MetadataSource getMetadataSource()
+ {
+ return source;
+ }
+
+ private XmlQuery getXmlRequestStructure()
+ {
+ return xmlQuery;
+ }
+
+ public Boolean isIteratorDefined(String iteratorName)
+ {
+ Boolean result = xmlQuery.isIteratorDefined(iteratorName);
+ return result;
+ }
+
+ public String getRasqlQuery()
+ {
+ return this.rasqlQuery;
+ }
+
+ public Iterator<String> getCoverages(String iteratorName) throws WCPSException
+ {
+ Iterator<String> result = xmlQuery.getCoverages(iteratorName);
+ return result;
+ }
+
+ public List<byte[]> execute() throws ResourceException
+ {
+ ArrayList<byte[]> results = new ArrayList<byte[]>();
+
+ if (this.rasqlQuery != null)
+ {
+ Implementation impl = new RasImplementation(url);
+ Database db = impl.newDatabase();
+
+ try
+ {
+ db.open(database, Database.OPEN_READ_ONLY);
+ }
+ catch (ODMGException odmge)
+ {
+ try
+ {
+ db.close();
+ }
+ catch (ODMGException e) {}
+
+ throw new ResourceException("Could not connect to rasdaman at "
+ + url + ", database "
+ + database, odmge);
+ }
+
+ Transaction tr = impl.newTransaction();
+
+ tr.begin();
+ OQLQuery q = impl.newOQLQuery();
+ DBag resultSet;
+
+ try
+ {
+ q.create(this.getRasqlQuery());
+ resultSet = (DBag) q.execute();
+
+ if (resultSet != null)
+ {
+ Iterator resultIterator = resultSet.iterator();
+
+ while (resultIterator.hasNext())
+ {
+ Object current = resultIterator.next();
+
+ try
+ {
+ RasGMArray resultArray =
+ (RasGMArray) current;
+
+ results.add(resultArray.getArray());
+ }
+ catch (ClassCastException e)
+ { // not a RasGMarray
+ if (!mime.equals("text/plain"))
+ {
+ throw new ResourceException(
+ "Incompatible mime and data type!");
+ }
+
+ System.err.println("result="
+ + current.toString());
+ results.add(current.toString().getBytes());
+
+ }
+
+
+ /*
+ * if (mime.equals("text/plain")) {
+ * System.err.println("dataType is :" + resultArray.getBaseTypeSchema().toString());
+ * }
+ */
+
+ }
+ }
+ }
+ catch (QueryException qe)
+ {
+ tr.commit();
+
+ try
+ {
+ db.close();
+ }
+ catch (ODMGException odmge) {}
+
+ throw new ResourceException("Could not evaluate rasdaman query: '"
+ + getRasqlQuery() + "'. Cause: " + qe.getMessage(), qe);
+ }
+
+ tr.commit();
+
+ try
+ {
+ db.close();
+ }
+ catch (ODMGException odmge) {}
+ }
+
+ if (mime.equals("text/plain")) {}
+
+ return results;
+
+ }
+
+}
diff --git a/src/wcps/server/core/ProcessOneCoverage.java b/src/wcps/server/core/ProcessOneCoverage.java
new file mode 100644
index 0000000..6c916ab
--- /dev/null
+++ b/src/wcps/server/core/ProcessOneCoverage.java
@@ -0,0 +1,114 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package wcps.server.core;
+
+import grammar.WCPSRequest;
+import grammar.wcpsLexer;
+import grammar.wcpsParser;
+import grammar.wcpsParser.wcpsRequest_return;
+import java.io.IOException;
+import java.io.StringReader;
+import org.antlr.runtime.RecognitionException;
+import org.odmg.DBag;
+import org.odmg.Database;
+import org.odmg.Implementation;
+import org.odmg.ODMGException;
+import org.odmg.OQLQuery;
+import org.odmg.QueryException;
+import org.odmg.Transaction;
+
+import org.w3c.dom.*;
+
+import org.xml.sax.SAXException;
+import rasj.RasGMArray;
+import rasj.RasImplementation;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.xml.sax.InputSource;
+
+/**
+ *
+ * @author Andrei
+ */
+class ProcessOneCoverage implements IRasNode
+ {
+ private IRasNode query;
+
+ public IRasNode getQuery()
+ {
+ return query;
+ }
+
+ public ProcessOneCoverage(Node parent, ProcessCoveragesRequest pcr, WCPS wcps) throws WCPSException, InvalidRequestException, ResourceException, SAXException, IOException
+ {
+ /*
+ System.err.println("Parsing ProcessOneCoverage: " + parent.getNodeName());
+ Node node = parent.getFirstChild();
+ while (node.getNodeName().equals("#text"))
+ node = node.getNextSibling();
+ System.err.println("Parsing One Coverage request: " + node.getNodeName());
+ if (node.getNodeName().equals("xmlSyntax"))
+ {
+ System.err.println("Found XML Syntax query");
+ query = new XmlQuery(node, pcr);
+ }
+ else
+ if (node.getNodeName().equals("abstractSyntax"))
+ {
+ try
+ {
+ String abstractQuery = node.getFirstChild().getNodeValue();
+ System.err.println("Found Abstract Syntax query: " + abstractQuery);
+ String xmlQuery = abstractToXml(abstractQuery);
+ InputSource source = new InputSource(new StringReader(xmlQuery));
+ System.err.println("Coverted the Abstract syntax query to an XML query:");
+ System.err.println("***********************************************");
+ System.err.println(xmlQuery);
+ System.err.println("***********************************************");
+// ProcessCoveragesRequest newRequest = wcps.pcPrepare(url, database, source);
+// ProcessOneCoverage oneCoverageRequest = (ProcessOneCoverage) newRequest.getProcessOneCoverage();
+// query = oneCoverageRequest.getQuery();
+// rasqlQuery = newRequest.getRasqlQuery();
+// mime = newRequest.getMime();
+ }
+ catch (RecognitionException e)
+ {
+ throw new WCPSException("Abstract Syntax query is invalid: "
+ + e.getMessage());
+ }
+ }
+ else
+ throw new WCPSException("Error ! Unexpected node: " + node.getNodeName());
+ */
+ }
+
+ /*
+ private String abstractToXml(String abstractQuery) throws RecognitionException
+ {
+ CharStream cs = new ANTLRStringStream(abstractQuery);
+ wcpsLexer lexer = new wcpsLexer(cs);
+ CommonTokenStream tokens = new CommonTokenStream();
+ tokens.setTokenSource(lexer);
+ wcpsParser parser = new wcpsParser(tokens);
+ wcpsRequest_return rrequest = parser.wcpsRequest();
+ WCPSRequest request = rrequest.value;
+ String xmlRequest = request.toXML();
+
+ return xmlRequest;
+ }
+
+ */
+ public String toRasQL()
+ {
+ return query.toRasQL();
+ }
+
+ } \ No newline at end of file
diff --git a/src/wcps/server/core/RangeCoverageExprType.java b/src/wcps/server/core/RangeCoverageExprType.java
new file mode 100644
index 0000000..f0904c2
--- /dev/null
+++ b/src/wcps/server/core/RangeCoverageExprType.java
@@ -0,0 +1,90 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.w3c.dom.*;
+
+public class RangeCoverageExprType implements IRasNode, ICoverageInfo
+{
+ private IRasNode child;
+ private CoverageInfo info = null;
+ List<IRasNode> components;
+
+ public RangeCoverageExprType(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+
+ // TODO: Implement RangeCoverageExpr
+ throw new WCPSException("Feature not yet implemented !");
+
+ /*
+ components = new ArrayList<IRasNode>();
+
+ String nodeName = node.getNodeName();
+ System.err.println("Trying to parse a range coverage expression... Starting at node "
+ + nodeName);
+
+ Node it = node.getFirstChild();
+
+ while (it != null)
+ {
+ if (it.getNodeName().equals("#text"))
+ {
+ it = it.getNextSibling();
+ continue;
+ }
+ if (it.getNodeName().equals("component"))
+ {
+ RangeElementType elem = new RangeElementType(it, pcr);
+ components.add(elem);
+ }
+
+ it = it.getNextSibling();
+ }
+ */
+
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return info;
+ }
+
+ public String toRasQL()
+ {
+ String result = "";
+ /*
+ Iterator<IRasNode> i = components.iterator();
+ while (i.hasNext())
+ {
+ result += i.next().toRasQL();
+ }
+ */
+
+ return result;
+ }
+}
diff --git a/src/wcps/server/core/RangeElement.java b/src/wcps/server/core/RangeElement.java
index 6ec864a..de76a61 100644
--- a/src/wcps/server/core/RangeElement.java
+++ b/src/wcps/server/core/RangeElement.java
@@ -1,148 +1,182 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-// A single component of a coverage's range. See the WCPS standard for more information.
-
-class RangeElement implements Cloneable {
-
- private String name;
- private String type;
-
- public RangeElement( String name, String type ) throws InvalidMetadataException {
-
- if( name == null || type == null ) {
- throw new InvalidMetadataException( "Invalid range element: Element name and type cannot be null" );
- }
- if( name.equals( "" ) ) {
- throw new InvalidMetadataException( "Invalid range element: Element name cannot be empty" );
- }
-
- if( !(type.equals( "boolean" ) || type.equals( "char" ) || type.equals( "unsigned char" ) || type.equals( "short" ) || type.equals( "unsigned short" ) || type.equals( "int" ) || type.equals( "unsigned int" ) || type.equals( "long" ) || type.equals( "unsigned long" ) || type.equals( "float" ) || type.equals( "double" ) || type.equals( "complex" ) || type.equals( "complex2" )) ) {
- throw new InvalidMetadataException( "Invalid range element: Invalid element type:" + type );
- }
-
- this.name = name;
- this.type = type;
-
- }
-
- public RangeElement clone() {
-
- try {
- return new RangeElement( new String( name ), new String( type ) );
- }
- catch( InvalidMetadataException ime ) {
- throw new RuntimeException( "Invalid metadata while cloning RangeElement. This is a software bug in WCPS.", ime );
- }
-
- }
-
- public boolean equals( RangeElement re ) {
-
- return name.equals( re.type );
-
- }
-
- public String getName() {
-
- return name;
-
- }
-
- public String getType() {
-
- return type;
-
- }
-
- public boolean isBoolean() {
-
- return type.equals( "boolean" );
-
- }
-
- public static boolean isBoolean( String type ) {
-
- return type.equals( "boolean" );
-
- }
-
- public boolean isComplex() {
-
- return type.equals( "complex" ) || type.equals( "complex2" );
-
- }
-
- public static boolean isComplex( String type ) {
-
- return type.equals( "complex" ) || type.equals( "complex2" );
-
- }
-
- public boolean isIntegral() {
-
- return type.equals( "char" ) || type.equals( "short" ) || type.equals( "unsigned short" ) || type.equals( "int" ) || type.equals( "unsigned int" ) || type.equals( "long" ) || type.equals( "unsigend long" );
-
- }
-
- public static boolean isIntegral( String type ) {
-
- return type.equals( "char" ) || type.equals( "short" ) || type.equals( "unsigned short" ) || type.equals( "int" ) || type.equals( "unsigned int" ) || type.equals( "long" ) || type.equals( "unsigend long" );
-
- }
-
- public boolean isFloating() {
-
- return type.equals( "float" ) || type.equals( "double" );
-
- }
-
- public static boolean isFloating( String type ) {
-
- return type.equals( "float" ) || type.equals( "double" );
-
- }
-
- public boolean isNumeric() {
-
- return type.equals( "char" ) || type.equals( "short" ) || type.equals( "unsigned short" ) || type.equals( "int" ) || type.equals( "unsigned int" ) || type.equals( "long" ) || type.equals( "unsigend long" ) || type.equals( "float" ) || type.equals( "double" ) || type.equals( "complex" ) || type.equals( "complex2" );
-
- }
-
- public static boolean isNumeric( String type ) {
-
- return type.equals( "char" ) || type.equals( "short" ) || type.equals( "unsigned short" ) || type.equals( "int" ) || type.equals( "unsigned int" ) || type.equals( "long" ) || type.equals( "unsigend long" ) || type.equals( "float" ) || type.equals( "double" ) || type.equals( "complex" ) || type.equals( "complex2" );
-
- }
-
- public void setType( String type ) throws InvalidMetadataException {
-
- if( !(type.equals( "boolean" ) || type.equals( "char" ) || type.equals( "unsigned char" ) || type.equals( "short" ) || type.equals( "unsigned short" ) || type.equals( "int" ) || type.equals( "unsigned int" ) || type.equals( "long" ) || type.equals( "unsigned long" ) || type.equals( "float" ) || type.equals( "double" ) || type.equals( "complex" ) || type.equals( "complex2" )) ) {
- throw new InvalidMetadataException( "Invalid range element: Invalid element type:" + type);
- }
- this.type = type;
-
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+//A single component of a coverage's range. See the WCPS standard for more information.
+
+class RangeElement implements Cloneable
+{
+ private String name;
+ private String type;
+
+ public RangeElement(String name, String type) throws InvalidMetadataException
+ {
+ if ((name == null) || (type == null))
+ {
+ throw new InvalidMetadataException(
+ "Invalid range element: Element name and type cannot be null");
+ }
+
+ if (name.equals(""))
+ {
+ throw new InvalidMetadataException(
+ "Invalid range element: Element name cannot be empty");
+ }
+
+ if (!(type.equals("boolean") || type.equals("char") || type.equals("unsigned char")
+ || type.equals("short") || type.equals("unsigned short") || type.equals("int")
+ || type.equals("unsigned int") || type.equals("long")
+ || type.equals("unsigned long") || type.equals("float")
+ || type.equals("double") || type.equals("complex") || type.equals("complex2")))
+ {
+ throw new InvalidMetadataException(
+ "Invalid range element: Invalid element type:" + type);
+ }
+
+ this.name = name;
+ this.type = type;
+
+ }
+
+ public RangeElement clone()
+ {
+ try
+ {
+ return new RangeElement(new String(name), new String(type));
+ }
+ catch (InvalidMetadataException ime)
+ {
+ throw new RuntimeException(
+ "Invalid metadata while cloning RangeElement. This is a software bug in WCPS.",
+ ime);
+ }
+
+ }
+
+ public boolean equals(RangeElement re)
+ {
+ return name.equals(re.type);
+
+ }
+
+ public String getName()
+ {
+ return name;
+
+ }
+
+ public String getType()
+ {
+ return type;
+
+ }
+
+ public boolean isBoolean()
+ {
+ return type.equals("boolean");
+
+ }
+
+ public static boolean isBoolean(String type)
+ {
+ return type.equals("boolean");
+
+ }
+
+ public boolean isComplex()
+ {
+ return type.equals("complex") || type.equals("complex2");
+
+ }
+
+ public static boolean isComplex(String type)
+ {
+ return type.equals("complex") || type.equals("complex2");
+
+ }
+
+ public boolean isIntegral()
+ {
+ return type.equals("char") || type.equals("short") || type.equals("unsigned short")
+ || type.equals("int") || type.equals("unsigned int") || type.equals("long")
+ || type.equals("unsigend long");
+
+ }
+
+ public static boolean isIntegral(String type)
+ {
+ return type.equals("char") || type.equals("short") || type.equals("unsigned short")
+ || type.equals("int") || type.equals("unsigned int") || type.equals("long")
+ || type.equals("unsigend long");
+
+ }
+
+ public boolean isFloating()
+ {
+ return type.equals("float") || type.equals("double");
+
+ }
+
+ public static boolean isFloating(String type)
+ {
+ return type.equals("float") || type.equals("double");
+
+ }
+
+ public boolean isNumeric()
+ {
+ return type.equals("char") || type.equals("short") || type.equals("unsigned short")
+ || type.equals("int") || type.equals("unsigned int") || type.equals("long")
+ || type.equals("unsigend long") || type.equals("float")
+ || type.equals("double") || type.equals("complex")
+ || type.equals("complex2");
+
+ }
+
+ public static boolean isNumeric(String type)
+ {
+ return type.equals("char") || type.equals("short") || type.equals("unsigned short")
+ || type.equals("int") || type.equals("unsigned int") || type.equals("long")
+ || type.equals("unsigend long") || type.equals("float")
+ || type.equals("double") || type.equals("complex")
+ || type.equals("complex2");
+
+ }
+
+ public void setType(String type) throws InvalidMetadataException
+ {
+ if (!(type.equals("boolean") || type.equals("char") || type.equals("unsigned char")
+ || type.equals("short") || type.equals("unsigned short") || type.equals("int")
+ || type.equals("unsigned int") || type.equals("long")
+ || type.equals("unsigned long") || type.equals("float")
+ || type.equals("double") || type.equals("complex") || type.equals("complex2")))
+ {
+ throw new InvalidMetadataException(
+ "Invalid range element: Invalid element type:" + type);
+ }
+
+ this.type = type;
+
+ }
+}
diff --git a/src/wcps/server/core/RangeElementType.java b/src/wcps/server/core/RangeElementType.java
new file mode 100644
index 0000000..53a28e5
--- /dev/null
+++ b/src/wcps/server/core/RangeElementType.java
@@ -0,0 +1,94 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class RangeElementType implements IRasNode, ICoverageInfo
+{
+ private IRasNode child;
+ private CoverageInfo info;
+ private String field;
+
+ public RangeElementType(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+
+ // TODO: Implement RangeCoverageExpr
+ throw new WCPSException("Feature not yet implemented !");
+
+
+ /*
+ String nodeName = node.getNodeName();
+ System.err.println("Trying to parse a range coverage expression... Starting at node "
+ + nodeName);
+
+ Node it = node.getFirstChild();
+
+ while (it != null)
+ {
+ if (it.getNodeName().equals("#text"))
+ {
+ it = it.getNextSibling();
+ continue;
+ }
+ if (it.getNodeName().equals("field"))
+ {
+ field = it.getNodeValue();
+ continue;
+ }
+
+ // Try to read a CoverageExprType
+ try
+ {
+ child = new CoverageExprType(node, pcr);
+ info = new CoverageInfo(((ICoverageInfo) child).getCoverageInfo());
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to parse a CoverageExprType !");
+ child = null;
+ }
+
+ it = it.getNextSibling();
+ }
+
+ if (child == null)
+ throw new WCPSException("Could not parse a CoverageExpr !");
+
+ */
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return info;
+ }
+
+ public String toRasQL()
+ {
+ String result = "";
+
+ return result;
+ }
+}
diff --git a/src/wcps/server/core/RangeFieldType.java b/src/wcps/server/core/RangeFieldType.java
new file mode 100644
index 0000000..2582ddf
--- /dev/null
+++ b/src/wcps/server/core/RangeFieldType.java
@@ -0,0 +1,63 @@
+ /*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+import java.util.Iterator;
+
+public class RangeFieldType implements IRasNode
+{
+ private String type;
+
+ public RangeFieldType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ while ((node != null) && node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ }
+
+ if (node == null)
+ {
+ throw new WCPSException("RangeFieldType parsing error!");
+ }
+
+ String nodeName = node.getNodeName();
+
+ if (nodeName.equals("type"))
+ {
+ this.type = node.getTextContent();
+
+ System.err.println("Found range field type: " + type);
+ }
+ }
+
+ public String toRasQL()
+ {
+ return this.type;
+ }
+}
+
+
+;
diff --git a/src/wcps/server/core/ReduceScalarExprType.java b/src/wcps/server/core/ReduceScalarExprType.java
index ddd25da..8f359a6 100644
--- a/src/wcps/server/core/ReduceScalarExprType.java
+++ b/src/wcps/server/core/ReduceScalarExprType.java
@@ -1,51 +1,68 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-
-public class ReduceScalarExprType implements IRasNode {
-
- CoverageExprType expr;
- String op;
-
- public ReduceScalarExprType(Node node, ProcessCoverageRequest pcr) throws WCPSException {
- String nodeName = node.getNodeName();
- if (nodeName.equals("all") || nodeName.equals("some") || nodeName.equals("count") || nodeName.equals("add") || nodeName.equals("avg") ||
- nodeName.equals("min") || nodeName.equals("max")) {
- op = nodeName;
- if (!op.equals("all") && !op.equals("some"))
- op = op + "_cells";
- node = node.getFirstChild();
- while (node != null && node.getNodeName() == "#text")
- node = node.getNextSibling();
- expr = new CoverageExprType(node, pcr);
- } else
- throw new WCPSException("invalid ReduceScalarExprType node : " + nodeName);
- }
-
- public String toRasQL() {
-
- return op + "(" + expr.toRasQL() +")";
- }
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class ReduceScalarExprType implements IRasNode
+{
+ CoverageExprType expr;
+ String op;
+
+ public ReduceScalarExprType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ System.err.println("Trying to parse ReduceScalarExpr ");
+ String nodeName = node.getNodeName();
+
+ if (nodeName.equals("all") || nodeName.equals("some") || nodeName.equals("count")
+ || nodeName.equals("add") || nodeName.equals("avg") || nodeName.equals("min")
+ || nodeName.equals("max"))
+ {
+ op = nodeName;
+
+ if (!op.equals("all") && !op.equals("some"))
+ {
+ op = op + "_cells";
+ }
+
+ node = node.getFirstChild();
+
+ while ((node != null) && (node.getNodeName().equals("#text")))
+ {
+ node = node.getNextSibling();
+ }
+
+ expr = new CoverageExprType(node, pcr);
+ }
+ else
+ {
+ throw new WCPSException("invalid ReduceScalarExprType node : " + nodeName);
+ }
+ }
+
+ public String toRasQL()
+ {
+ return op + "(" + expr.toRasQL() + ")";
+ }
+}
diff --git a/src/wcps/server/core/ResourceException.java b/src/wcps/server/core/ResourceException.java
index aa06c7c..306ba22 100644
--- a/src/wcps/server/core/ResourceException.java
+++ b/src/wcps/server/core/ResourceException.java
@@ -1,41 +1,43 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-// This exception is thrown whenever some required resource is not available - a database connection, file, whatever.
-
-public class ResourceException extends WCPSException {
-
- private static final long serialVersionUID = 45562458L;
-
- public ResourceException( String message) {
- super (message);
- }
-
- public ResourceException( String message, Throwable cause ) {
-
- super( message, cause );
-
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+//This exception is thrown whenever some required resource is not available - a database connection
+//, file, whatever.
+
+public class ResourceException extends WCPSException
+{
+ private static final long serialVersionUID = 45562458L;
+
+ public ResourceException(String message)
+ {
+ super(message);
+ }
+
+ public ResourceException(String message, Throwable cause)
+ {
+ super(message, cause);
+
+ }
+}
diff --git a/src/wcps/server/core/SDU.java b/src/wcps/server/core/SDU.java
index 30bd1e2..16090a8 100644
--- a/src/wcps/server/core/SDU.java
+++ b/src/wcps/server/core/SDU.java
@@ -1,178 +1,207 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.apache.commons.math.complex.Complex;
-
-// This is a static utility class, which provides encoding and decoding of various datatypes from/to strings. It also handles packing and unpacking of structures.
-
-// TODO: fix complex conversion
-
-class SDU { // String Data Utility
-
- public static String boolean2str( List<Boolean> boolea ) {
-
- List<String> strings = new ArrayList<String>( boolea.size() );
- Iterator<Boolean> i = boolea.iterator();
- while( i.hasNext() ) {
- strings.add( i.next().toString() );
- }
-
- return string2str( strings );
-
- }
-
- public static String complex2str( List<Complex> complex ) {
-
- List<String> strings = new ArrayList<String>( complex.size() );
- Iterator<Complex> i = complex.iterator();
- while( i.hasNext() ) {
- Complex c = i.next();
- strings.add( c.getReal() + "#" + c.getImaginary() );
- }
-
- return string2str( strings );
-
- }
-
- public static String double2str( List<Double> doubl ) {
-
- List<String> strings = new ArrayList<String>( doubl.size() );
- Iterator<Double> i = doubl.iterator();
- while( i.hasNext() ) {
- strings.add( i.next().toString() );
- }
-
- return string2str( strings );
-
- }
-
- public static String integer2str( List<BigInteger> integer ) {
-
- List<String> strings = new ArrayList<String>( integer.size() );
- Iterator<BigInteger> i = integer.iterator();
- while( i.hasNext() ) {
- strings.add( i.next().toString() );
- }
-
- return string2str( strings );
-
- }
-
- public static List<Boolean> str2boolean( String string ) {
-
- List<String> strings = str2string( string );
-
- List<Boolean> booleans = new ArrayList<Boolean>( strings.size() );
- Iterator<String> i = strings.iterator();
- while( i.hasNext() ) {
- booleans.add( new Boolean( i.next().equals( "true" ) ) );
- }
-
- return booleans;
-
- }
-
- public static List<Complex> str2complex( String string ) {
-
- List<String> strings = str2string( string );
-
- List<Complex> complexes = new ArrayList<Complex>( strings.size() );
- Iterator<String> i = strings.iterator();
- while( i.hasNext() ) {
- String[] complex = i.next().split( "#" );
- complexes.add( new Complex( new Double( complex[0] ), new Double( complex[1] ) ) );
- }
-
- return complexes;
-
- }
-
- public static List<Double> str2double( String string ) {
-
- List<String> strings = str2string( string );
-
- List<Double> doubles = new ArrayList<Double>( strings.size() );
- Iterator<String> i = strings.iterator();
- while( i.hasNext() ) {
- doubles.add( new Double( i.next() ) );
- }
-
- return doubles;
-
- }
-
- public static List<BigInteger> str2integer( String string ) {
-
- List<String> strings = str2string( string );
-
- List<BigInteger> integers = new ArrayList<BigInteger>( strings.size() );
- Iterator<String> i = strings.iterator();
- while( i.hasNext() ) {
- integers.add( new BigInteger( i.next() ) );
- }
-
- return integers;
-
- }
-
- public static List<String> str2string( String string ) {
-
- List<String> strings;
-
- if( string.startsWith( "{" ) && string.contains( "," ) && string.endsWith( "}" ) ) {
- String[] components = string.substring( 1, string.length() - 1 ).split( "," );
-
- strings = new ArrayList<String>( components.length );
- for( int i = 0; i < components.length; i++ ) {
- strings.add( new String( components[i] ) );
- }
-
- return strings;
- }
- else {
- strings = new ArrayList<String>( 1 );
- strings.add( new String( string ) );
-
- return strings;
- }
-
- }
-
- public static String string2str( List<String> strin ) {
-
- String string = "{";
- Iterator<String> i = strin.iterator();
- while( i.hasNext() ) {
- string += i.next() + (i.hasNext() ? "," : "}" );
- }
-
- return string;
-
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.apache.commons.math.complex.Complex;
+
+import java.math.BigInteger;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+//This is a static utility class, which provides encoding and decoding of various datatypes
+//from/to strings. It also handles packing and unpacking of structures.
+
+//TODO: fix complex conversion
+
+class SDU
+{ // String Data Utility
+ public static String boolean2str(List<Boolean> boolea)
+ {
+ List<String> strings = new ArrayList<String>(boolea.size());
+ Iterator<Boolean> i = boolea.iterator();
+
+ while (i.hasNext())
+ {
+ strings.add(i.next().toString());
+ }
+
+ return string2str(strings);
+
+ }
+
+ public static String complex2str(List<Complex> complex)
+ {
+ List<String> strings = new ArrayList<String>(complex.size());
+ Iterator<Complex> i = complex.iterator();
+
+ while (i.hasNext())
+ {
+ Complex c = i.next();
+
+ strings.add(c.getReal() + "#" + c.getImaginary());
+ }
+
+ return string2str(strings);
+
+ }
+
+ public static String double2str(List<Double> doubl)
+ {
+ List<String> strings = new ArrayList<String>(doubl.size());
+ Iterator<Double> i = doubl.iterator();
+
+ while (i.hasNext())
+ {
+ strings.add(i.next().toString());
+ }
+
+ return string2str(strings);
+
+ }
+
+ public static String integer2str(List<BigInteger> integer)
+ {
+ List<String> strings = new ArrayList<String>(integer.size());
+ Iterator<BigInteger> i = integer.iterator();
+
+ while (i.hasNext())
+ {
+ strings.add(i.next().toString());
+ }
+
+ return string2str(strings);
+
+ }
+
+ public static List<Boolean> str2boolean(String string)
+ {
+ List<String> strings = str2string(string);
+
+ List<Boolean> booleans = new ArrayList<Boolean>(strings.size());
+ Iterator<String> i = strings.iterator();
+
+ while (i.hasNext())
+ {
+ booleans.add(new Boolean(i.next().equals("true")));
+ }
+
+ return booleans;
+
+ }
+
+ public static List<Complex> str2complex(String string)
+ {
+ List<String> strings = str2string(string);
+
+ List<Complex> complexes = new ArrayList<Complex>(strings.size());
+ Iterator<String> i = strings.iterator();
+
+ while (i.hasNext())
+ {
+ String[] complex = i.next().split("#");
+
+ complexes.add(new Complex(new Double(complex[0]), new Double(complex[1])));
+ }
+
+ return complexes;
+
+ }
+
+ public static List<Double> str2double(String string)
+ {
+ List<String> strings = str2string(string);
+
+ List<Double> doubles = new ArrayList<Double>(strings.size());
+ Iterator<String> i = strings.iterator();
+
+ while (i.hasNext())
+ {
+ doubles.add(new Double(i.next()));
+ }
+
+ return doubles;
+
+ }
+
+ public static List<BigInteger> str2integer(String string)
+ {
+ List<String> strings = str2string(string);
+
+ List<BigInteger> integers = new ArrayList<BigInteger>(strings.size());
+ Iterator<String> i = strings.iterator();
+
+ while (i.hasNext())
+ {
+ integers.add(new BigInteger(i.next()));
+ }
+
+ return integers;
+
+ }
+
+ public static List<String> str2string(String string)
+ {
+ List<String> strings;
+
+ if (string.startsWith("{") && string.contains(",") && string.endsWith("}"))
+ {
+ String[] components = string.substring(1, string.length() - 1).split(",");
+
+ strings = new ArrayList<String>(components.length);
+
+ for (int i = 0; i < components.length; i++)
+ {
+ strings.add(new String(components[i]));
+ }
+
+ return strings;
+ }
+ else
+ {
+ strings = new ArrayList<String>(1);
+ strings.add(new String(string));
+
+ return strings;
+ }
+
+ }
+
+ public static String string2str(List<String> strin)
+ {
+ String string = "{";
+ Iterator<String> i = strin.iterator();
+
+ while (i.hasNext())
+ {
+ string += i.next() + (i.hasNext()
+ ? ","
+ : "}");
+ }
+
+ return string;
+
+ }
+}
diff --git a/src/wcps/server/core/ScalarExprType.java b/src/wcps/server/core/ScalarExprType.java
index 007e18b..d0d8358 100644
--- a/src/wcps/server/core/ScalarExprType.java
+++ b/src/wcps/server/core/ScalarExprType.java
@@ -1,100 +1,139 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-
-public class ScalarExprType implements IRasNode {
- private String type; // can be simple (just a value), unary, binary, function or defered
- private String value;
- private String op;
- private IRasNode first,second;
-
- public ScalarExprType(Node node, ProcessCoverageRequest pcr) throws WCPSException {
- while (node.getNodeName().equals("#text")) node = node.getNextSibling();
- String nodeName = node.getNodeName();
-
- if (nodeName.equals("scalar")) {
- type = "simple";
- value = node.getFirstChild().getNodeValue();
- } else if (nodeName.equals("scalarUnaryPlus") || nodeName.equals("scalarUnaryMinus")) {
- type = "unary";
- op = (nodeName.equals("scalarUnaryPlus") ? "+" : "-");
- first = new ScalarExprType(node.getFirstChild(), pcr);
- } else if (nodeName.equals("scalarPlus") || nodeName.equals("scalarMinus") || nodeName.equals("scalarMult") || nodeName.equals("scalarDiv")) {
- type = "binary";
- if (nodeName.equals("scalarPlus")) op = "+";
- if (nodeName.equals("scalarMinus")) op = "-";
- if (nodeName.equals("scalarMult")) op = "*";
- if (nodeName.equals("scalarDiv")) op = "/";
- Node child = node.getFirstChild();
- first = new ScalarExprType(child, pcr);
- child = child.getNextSibling();
- second = new ScalarExprType(child, pcr);
- } else if (nodeName.equals("scalarAbs")) {
- type= "function";
- op = "abs";
- first = new ScalarExprType(node.getFirstChild(), pcr);
- } else {
- type = "defered";
- try {
- first = new BooleanScalarExprType(node, pcr);
- } catch (WCPSException e) {}
-
- if (first == null) {
- try {
- first = new ReduceScalarExprType(node, pcr);
- } catch (WCPSException e) {}
- }
-// TODO(smsorin): This should be added, eventually...
-/* if (first == null) {
- try {
- first = new CondenseScalarExprType(Node, pcr);
- } catch (WCPSException e) {}
- }
-
- if (first == null) {
- try {
- first = new GetMetadataScalarExprType(Node, pcr);
- } catch (WCPSException e) {}
- }*/
-
- if (first == null)
- throw new WCPSException("Unexpected Scalar Expression node : " + node.getNodeName());
- }
- }
-
- public String toRasQL() {
- if (type.equals("simple"))
- return value;
- if (type.equals("unary"))
- return op + "(" + first.toRasQL() + ")";
- if (type.equals("binary"))
- return "(" + first.toRasQL() + ")" + op + "(" + second.toRasQL() + ")";
- if (type.equals("function"))
- return op + "(" + first.toRasQL() + ")";
- if (type.equals("defered"))
- return first.toRasQL();
- return "";
- }
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class ScalarExprType implements IRasNode
+{
+// private IRasNode first, second;
+ private IRasNode child;
+// private String op;
+// private String type; // can be simple (just a value), unary, binary, function or defered
+// private String value;
+
+ public ScalarExprType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ while ((node != null) && node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ }
+
+ // Try one of the groups
+ child = null;
+
+// TODO: Implement class MetadataScalarExprType
+// MetadataScalarExprType
+ if (child == null)
+ {
+ try
+ {
+ child = new MetadataScalarExprType(node, pcr);
+ System.err.println("Matched metadata scalar expression.");
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to match metadata scalar expression: "
+ + e.toString() + "\nRetrying");
+ child = null;
+ }
+ }
+
+// BooleanScalarExprType
+ if (child == null)
+ {
+ try
+ {
+ child = new BooleanScalarExprType(node, pcr);
+ System.err.println("Matched boolean scalar expression.");
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to match boolean scalar expression : "
+ + e.toString() + "\nRetrying");
+ child = null;
+ }
+ }
+
+// NumericScalarExprType
+ if (child == null)
+ {
+ try
+ {
+ child = new NumericScalarExprType(node, pcr);
+ System.err.println("Matched numeric scalar expression.");
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to match numeric scalar expression : "
+ + e.toString() + "\nRetrying");
+ child = null;
+ }
+ }
+
+// ReduceScalarExprType
+ if (child == null)
+ {
+ try
+ {
+ child = new ReduceScalarExprType(node, pcr);
+ System.err.println("Matched reduce scalar expression.");
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to match reduce scalar expression: "
+ + e.toString() + "\nRetrying");
+ child = null;
+ }
+ }
+
+// StringScalarExprType
+ if (child == null)
+ {
+ try
+ {
+ child = new StringScalarExprType(node, pcr);
+ System.err.println("Matched string scalar expression.");
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("Failed to match string scalar expression: "
+ + e.toString() + "\nRetrying");
+ child = null;
+ }
+ }
+
+ // Error check
+ if (child == null)
+ {
+ throw new WCPSException("Invalid coverage Expression, next node: "
+ + node.getNodeName());
+ }
+ }
+
+ public String toRasQL()
+ {
+ return child.toRasQL();
+ }
+}
diff --git a/src/wcps/server/core/ScaleCoverageExprType.java b/src/wcps/server/core/ScaleCoverageExprType.java
new file mode 100644
index 0000000..82a88f2
--- /dev/null
+++ b/src/wcps/server/core/ScaleCoverageExprType.java
@@ -0,0 +1,46 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+// TODO: Implement class ScaleCoverageExprType
+public class ScaleCoverageExprType implements IRasNode, ICoverageInfo
+{
+ public ScaleCoverageExprType(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+ throw new WCPSException("Method not implemented");
+ }
+
+ public String toRasQL()
+ {
+ return "";
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return null;
+ }
+}
diff --git a/src/wcps/server/core/SetMetadataCoverageExprType.java b/src/wcps/server/core/SetMetadataCoverageExprType.java
new file mode 100644
index 0000000..09148fd
--- /dev/null
+++ b/src/wcps/server/core/SetMetadataCoverageExprType.java
@@ -0,0 +1,46 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+// TODO: Implement class SetMetadataCoverageExprType
+public class SetMetadataCoverageExprType implements IRasNode, ICoverageInfo
+{
+ public SetMetadataCoverageExprType(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+ throw new WCPSException("Method not implemented");
+ }
+
+ public String toRasQL()
+ {
+ return "";
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return null;
+ }
+}
diff --git a/src/wcps/server/core/SliceCoverageExprType.java b/src/wcps/server/core/SliceCoverageExprType.java
index b5660b1..206ac3c 100644
--- a/src/wcps/server/core/SliceCoverageExprType.java
+++ b/src/wcps/server/core/SliceCoverageExprType.java
@@ -1,117 +1,138 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.math.BigInteger;
-
-public class SliceCoverageExprType implements IRasNode, ICoverageInfo {
-
- private class axisSpec {
- public String axisName;
- public String crs;
- public int sliceId;
- };
-
- private List <axisSpec> axisList;
- private CoverageExprType coverageExprType;
- private CoverageInfo coverageInfo;
- private int dims;
- private String [] dim;
-
- public CoverageInfo getCoverageInfo() {
- return coverageInfo;
- }
-
- public SliceCoverageExprType (Node node, ProcessCoverageRequest source) throws WCPSException{
- Node child, axisNode;
- String nodeName;
- axisList = new ArrayList<axisSpec> ();
-
- for (child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- nodeName = child.getNodeName();
- if (nodeName.equals("#text"))
- continue;
-
- if (nodeName.equals("sliceAxisSpec")) {
- axisSpec axis = new axisSpec();
- String childName;
- for (axisNode = child.getFirstChild(); axisNode != null; axisNode = axisNode.getNextSibling()) {
- childName = axisNode.getNodeName();
- if (childName.equals("#text")) continue;
-
- if (childName.equals("axis")) {
- axis.axisName = axisNode.getFirstChild().getNodeValue();
- continue;
- }
- if (childName.equals("crs")) {
- axis.crs = axisNode.getFirstChild().getNodeValue();
- continue;
- }
- if (childName.equals("coord")) {
- CoordinateType coord = new CoordinateType(axisNode);
- axis.sliceId = coord.getValue();
- }
- }
- axisList.add(axis);
- continue;
- }
-
- // else is a coverage expression type
- coverageExprType = new CoverageExprType(child, source);
- coverageInfo = new CoverageInfo(coverageExprType.getCoverageInfo());
- }
- dims = coverageInfo.getNumDimensions();
- dim = new String[dims];
- for (int j=0; j<dims; ++j)
- dim[j]="*:*";
-
- Iterator <axisSpec> i = axisList.iterator();
- axisSpec axis;
- int axisId;
- int axisLo, axisHi;
- while (i.hasNext()) {
- axis = i.next();
- axisId = coverageInfo.getDomainIndexByName(axis.axisName);
- axisLo = axis.sliceId;
- axisHi = axis.sliceId;
- dim[axisId]=""+axisLo;
- coverageInfo.setCellDimension(axisId, new CellDomainElement(BigInteger.valueOf(axisLo), BigInteger.valueOf(axisHi)));
- }
-
- }
-
- public String toRasQL() {
- String result = coverageExprType.toRasQL()+"[";
- for (int j=0; j<dims; ++j) {
- if (j>0)
- result += ",";
- result += dim[j];
- }
- result += "]";
- return result;
- }
-};
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.w3c.dom.Node;
+
+public class SliceCoverageExprType implements IRasNode, ICoverageInfo
+{
+
+ private List<DimensionPointElement> axisList;
+ private CoverageExprType coverageExprType;
+ private CoverageInfo coverageInfo = null;
+ private String[] dim;
+ private DimensionPointElement elem;
+ private int dims;
+
+ public SliceCoverageExprType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ Node child = node.getFirstChild();
+ String nodeName;
+
+ axisList = new ArrayList<DimensionPointElement>();
+
+ while (child != null)
+ {
+ nodeName = child.getNodeName();
+
+ if (nodeName.equals("#text"))
+ {
+ child = child.getNextSibling();
+ continue;
+ }
+
+ try
+ {
+ System.err.println("Trying out an CoverageExprType group...");
+ coverageExprType = new CoverageExprType(child, pcr);
+ coverageInfo = coverageExprType.getCoverageInfo();
+ child = child.getNextSibling();
+ continue;
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("This was no CoverageExprType: " + nodeName);
+ }
+
+ try
+ {
+ // Start a new axis and save it
+ elem = new DimensionPointElement(child, pcr);
+ axisList.add(elem);
+ child = elem.getNextNode();
+ continue;
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("This was no Dimension Point ELement: " + child.getNodeName());
+ }
+
+ // else unknown element
+ throw new WCPSException("Unknown node for TrimCoverage expression:" + child.getNodeName());
+ }
+
+ dims = coverageInfo.getNumDimensions();
+ dim = new String[dims];
+
+ for (int j = 0; j < dims; ++j)
+ {
+ dim[j] = "*:*";
+ }
+
+ Iterator<DimensionPointElement> i = axisList.iterator();
+ DimensionPointElement axis;
+ int axisId;
+ int slicingPos;
+
+ while (i.hasNext())
+ {
+ axis = i.next();
+ axisId = coverageInfo.getDomainIndexByName(axis.getAxisName());
+ slicingPos = Integer.parseInt(axis.getSlicingPosition());
+ dim[axisId] = "" + slicingPos;
+ coverageInfo.setCellDimension(
+ axisId,
+ new CellDomainElement(
+ BigInteger.valueOf(slicingPos), BigInteger.valueOf(slicingPos)));
+ }
+
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return coverageInfo;
+ }
+
+ public String toRasQL()
+ {
+ String result = coverageExprType.toRasQL() + "[";
+
+ for (int j = 0; j < dims; ++j)
+ {
+ if (j > 0)
+ {
+ result += ",";
+ }
+
+ result += dim[j];
+ }
+
+ result += "]";
+ return result;
+ }
+} \ No newline at end of file
diff --git a/src/wcps/server/core/StringScalarExprType.java b/src/wcps/server/core/StringScalarExprType.java
new file mode 100644
index 0000000..caa11ff
--- /dev/null
+++ b/src/wcps/server/core/StringScalarExprType.java
@@ -0,0 +1,69 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+
+public class StringScalarExprType implements IRasNode
+{
+
+ private String op, string;
+ private CoverageExprType cov;
+ public StringScalarExprType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ while ((node != null) && (node.getNodeName().equals("#text")))
+ {
+ node = node.getNextSibling();
+ }
+
+ System.err.println("Parsing String Scalar expr : " + node.getNodeName());
+
+ if (node.getNodeName().equals("stringIdentifier"))
+ {
+ Node child = node.getFirstChild();
+ cov = new CoverageExprType(child, pcr);
+ op = "id";
+ }
+ else
+ if (node.getNodeName().equals("stringConstant"))
+ {
+ op = "constant";
+ string = node.getNodeValue();
+ }
+ else
+ throw new WCPSException("Unknown String expr node: " + node.getNodeName());
+ }
+
+ public String toRasQL()
+ {
+ String result = "";
+ if (op.equals("constant"))
+ result = string;
+ if (op.equals("id"))
+ result = cov.toRasQL();
+
+ return result;
+ }
+}
diff --git a/src/wcps/server/core/SubsetOperationCoverageExprType.java b/src/wcps/server/core/SubsetOperationCoverageExprType.java
new file mode 100644
index 0000000..e64069b
--- /dev/null
+++ b/src/wcps/server/core/SubsetOperationCoverageExprType.java
@@ -0,0 +1,80 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+// TODO: Implement class SubsetOperation
+public class SubsetOperationCoverageExprType implements IRasNode, ICoverageInfo
+{
+ private IRasNode child;
+ private CoverageInfo info = null;
+
+ public SubsetOperationCoverageExprType(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+
+ while ((node != null) && node.getNodeName().equals("#text"))
+ {
+ node = node.getNextSibling();
+ }
+
+ if (node == null)
+ {
+ throw new WCPSException("SubsetOperationCoverageExpr parsing error!");
+ }
+
+ String nodeName = node.getNodeName();
+
+ System.err.println("SubsetOperationCoverageExpr: node " + nodeName);
+
+ if (nodeName.equals("trim"))
+ {
+ child = new TrimCoverageExprType(node, pcr);
+ info = ((TrimCoverageExprType) child).getCoverageInfo();
+ }
+ else if (nodeName.equals("extend"))
+ {
+ child = new ExtendCoverageExprType(node, pcr);
+ info = ((ExtendCoverageExprType) child).getCoverageInfo();
+ }
+ else if (nodeName.equals("slice"))
+ {
+ child = new SliceCoverageExprType(node, pcr);
+ info = ((SliceCoverageExprType) child).getCoverageInfo();
+ }
+ else
+ throw new WCPSException("Failed to match SubsetOperation: " + nodeName);
+ }
+
+ public String toRasQL()
+ {
+ return child.toRasQL();
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return info;
+ }
+}
diff --git a/src/wcps/server/core/TrimCoverageExprType.java b/src/wcps/server/core/TrimCoverageExprType.java
index 3942546..445ea71 100644
--- a/src/wcps/server/core/TrimCoverageExprType.java
+++ b/src/wcps/server/core/TrimCoverageExprType.java
@@ -1,124 +1,148 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.math.BigInteger;
-
-
-public class TrimCoverageExprType implements IRasNode, ICoverageInfo {
-
- private class axisSpec {
- public String axisName;
- public String crs;
- public List<Integer> coords = new ArrayList<Integer> ();
- };
-
- private List <axisSpec> axisList;
- private CoverageExprType coverageExprType;
- private CoverageInfo coverageInfo;
- private int dims;
- private String [] dim;
-
- public CoverageInfo getCoverageInfo() {
- return coverageInfo;
- }
-
- public TrimCoverageExprType (Node node, ProcessCoverageRequest source) throws WCPSException{
- Node child, axisNode;
- String nodeName;
- axisList = new ArrayList<axisSpec> ();
-
- for (child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- nodeName = child.getNodeName();
- if (nodeName.equals("#text")) continue;
-
- if (nodeName.equals("trimAxisSpec")) {
- axisSpec axis = new axisSpec();
- String childName;
- for (axisNode = child.getFirstChild(); axisNode != null; axisNode = axisNode.getNextSibling()) {
- childName = axisNode.getNodeName();
- if (childName.equals("axis")) {
- axis.axisName = axisNode.getFirstChild().getNodeValue();
- continue;
- }
- if (childName.equals("crs")) {
- axis.crs = axisNode.getFirstChild().getNodeValue();
- continue;
- }
- if (childName.equals("cellCoord") || childName.equals("domainCoord")) {
- CoordinateType coord = new CoordinateType(axisNode);
- axis.coords.add(coord.getValue());
- }
- }
- axisList.add(axis);
- continue;
- }
-
- // else is a coverage expression type
- coverageExprType = new CoverageExprType(child, source);
- coverageInfo = coverageExprType.getCoverageInfo();
- }
-
- dims = coverageInfo.getNumDimensions();
- dim = new String[dims];
- for (int j=0; j<dims; ++j)
- dim[j]="*:*";
-
-
- Iterator <axisSpec> i = axisList.iterator();
- System.out.println("AxisList count:" + axisList.size());
- axisSpec axis;
- int axisId;
- int axisLo, axisHi;
- while (i.hasNext()) {
- axis = i.next();
- axisId = coverageInfo.getDomainIndexByName(axis.axisName);
- System.out.println("Axis ID: " + axisId);
- System.out.println("Axis name: " + axis.axisName);
- System.out.println("Axis coords size: " + axis.coords.size());
- System.out.print("Axis coords: ");
- for (int ii=0; ii < axis.coords.size(); ii++)
- System.out.print(axis.coords.get(ii) + ", ");
-
- axisLo = axis.coords.get(0);
- axisHi = axis.coords.get(1);
- dim[axisId]=axisLo+":"+axisHi;
- coverageInfo.setCellDimension(axisId, new CellDomainElement(BigInteger.valueOf(axisLo), BigInteger.valueOf(axisHi)));
- }
- }
-
- public String toRasQL() {
- String result = coverageExprType.toRasQL()+"[";
- for (int j=0; j<dims; ++j) {
- if (j>0)
- result += ",";
- result += dim[j];
- }
- result += "]";
- return result;
- }
-};
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+import java.math.BigInteger;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class TrimCoverageExprType implements IRasNode, ICoverageInfo
+{
+ private List<DimensionIntervalElement> axisList;
+ private CoverageExprType coverageExprType;
+ private CoverageInfo coverageInfo;
+ private String[] dim;
+ private int dims;
+ private DimensionIntervalElement elem;
+
+ public TrimCoverageExprType(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ Node child, axisNode;
+ String nodeName;
+
+ axisList = new ArrayList<DimensionIntervalElement>();
+
+ child = node.getFirstChild();
+ while (child != null)
+ {
+ nodeName = child.getNodeName();
+
+ if (nodeName.equals("#text"))
+ {
+ child = child.getNextSibling();
+ continue;
+ }
+
+ try
+ {
+ System.err.println("Trying out an CoverageExprType group...");
+ coverageExprType = new CoverageExprType(child, pcr);
+ coverageInfo = coverageExprType.getCoverageInfo();
+ child = child.getNextSibling();
+ continue;
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("This was no CoverageExprType: " + nodeName);
+ }
+
+ try
+ {
+ // Start a new axis and save it
+ elem = new DimensionIntervalElement(child, pcr);
+ axisList.add(elem);
+ child = elem.getNextNode();
+ continue;
+ }
+ catch (WCPSException e)
+ {
+ System.err.println("This was no Dimension Interval ELement: " + child.getNodeName());
+ }
+
+ // else unknown element
+ throw new WCPSException("Unknown node for TrimCoverage expression:" + child.getNodeName());
+ }
+
+ dims = coverageInfo.getNumDimensions();
+ dim = new String[dims];
+
+ for (int j = 0; j < dims; ++j)
+ {
+ dim[j] = "*:*";
+ }
+
+
+ Iterator<DimensionIntervalElement> i = axisList.iterator();
+
+ System.out.println("Axis List count:" + axisList.size());
+ DimensionIntervalElement axis;
+ int axisId;
+ int axisLo, axisHi;
+
+ while (i.hasNext())
+ {
+ axis = i.next();
+ axisId = coverageInfo.getDomainIndexByName(axis.getAxisName());
+ System.out.println("Axis ID: " + axisId);
+ System.out.println("Axis name: " + axis.getAxisName());
+ System.out.print("Axis coords: ");
+
+ axisLo = Integer.parseInt(axis.getLowCoord());
+ axisHi = Integer.parseInt(axis.getHighCoord());
+ dim[axisId] = axisLo + ":" + axisHi;
+ coverageInfo.setCellDimension(
+ axisId,
+ new CellDomainElement(
+ BigInteger.valueOf(axisLo), BigInteger.valueOf(axisHi)));
+ }
+
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return coverageInfo;
+ }
+
+ public String toRasQL()
+ {
+ String result = coverageExprType.toRasQL() + "[";
+
+ for (int j = 0; j < dims; ++j)
+ {
+ if (j > 0)
+ {
+ result += ",";
+ }
+
+ result += dim[j];
+ }
+
+ result += "]";
+ return result;
+ }
+}
diff --git a/src/wcps/server/core/UnaryOperationCoverageExprType.java b/src/wcps/server/core/UnaryOperationCoverageExprType.java
index c06558a..ace4812 100644
--- a/src/wcps/server/core/UnaryOperationCoverageExprType.java
+++ b/src/wcps/server/core/UnaryOperationCoverageExprType.java
@@ -1,118 +1,190 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import org.w3c.dom.*;
-
-public class UnaryOperationCoverageExprType implements IRasNode, ICoverageInfo {
-
- private String operation;
- private CoverageExprType child;
- private String params;
- private CoverageInfo info;
-
- public UnaryOperationCoverageExprType(Node node, ProcessCoverageRequest pcr) throws WCPSException {
- String nodeName = node.getNodeName();
- System.err.println("Trying to parse unary operation: " + nodeName);
- if (nodeName.equals("unaryPlus")) {
- operation = "+";
- child = new CoverageExprType(node.getFirstChild(), pcr);
- } else if (nodeName.equals("unaryMinus")) {
- operation = "-";
- child = new CoverageExprType(node.getFirstChild(), pcr);
- } else if (nodeName.equals("sqrt") || nodeName.equals("abs") || nodeName.equals("exp") || nodeName.equals("log") ||
- nodeName.equals("ln") || nodeName.equals("sin") || nodeName.equals("cos") || nodeName.equals("tan") ||
- nodeName.equals("sinh") || nodeName.equals("cosh") || nodeName.equals("tanh") || nodeName.equals("arcsin") ||
- nodeName.equals("arccos") || nodeName.equals("arctan") || nodeName.equals("not")) {
- operation = nodeName;
- child = new CoverageExprType(node.getFirstChild(), pcr);
- } else if (nodeName.equals("bit")) {
- operation = "bit";
- Node c = node.getFirstChild();
- while (c != null) {
- if (c.getNodeName().equals("#text")) {
- c = c.getNextSibling();
- continue;
- }
- if (c.getNodeName().equals("position")) {
- params = c.getFirstChild().getNodeValue();
- } else {
- child = new CoverageExprType(c, pcr);
- }
- c = c.getNextSibling();
- }
- } else if (nodeName.equals("cast")) {
- operation = "cast";
- Node c = node.getFirstChild();
- while (c != null) {
- if (c.getNodeName().equals("#text")) {
- c = c.getNextSibling();
- continue;
- }
- if (c.getNodeName().equals("type")) {
- params = c.getFirstChild().getNodeValue();
- } else {
- child = new CoverageExprType(c, pcr);
- }
- c = c.getNextSibling();
- }
- } else if (nodeName.equals("select")) {
- operation = "select";
- Node c = node.getFirstChild();
- while (c != null) {
- if (c.getNodeName().equals("#text")) {
- c = c.getNextSibling();
- continue;
- }
- if (c.getNodeName().equals("field")) {
- params = c.getFirstChild().getNodeValue();
- } else {
- child = new CoverageExprType(c, pcr);
- }
- c = c.getNextSibling();
- }
- } else throw new WCPSException("Unknown unary operation: " + nodeName);
- info = new CoverageInfo(child.getCoverageInfo());
- }
-
- public CoverageInfo getCoverageInfo() {
- return info;
- }
-
- public String toRasQL() {
- if (operation.equals("sqrt") || operation.equals("abs") || operation.equals("exp") || operation.equals("log") ||
- operation.equals("ln") || operation.equals("sin") || operation.equals("cos") || operation.equals("tan") ||
- operation.equals("sinh") || operation.equals("cosh") || operation.equals("tanh") || operation.equals("arcsin") ||
- operation.equals("arccos") || operation.equals("arctan") || operation.equals("not") || operation.equals("+") || operation.equals("-")) {
- return operation + "(" + child.toRasQL() + ")";
- } else if (operation.equals("cast")) {
- return "(" + params + ")(" + child.toRasQL() + ")";
- } else if (operation.equals("select")) {
- return "(" + child.toRasQL() + ")." + params;
- } else if (operation.equals("bit")) {
- return "bit(" + child.toRasQL() + "," + params +")";
- }
- return " error ";
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+import org.w3c.dom.*;
+
+public class UnaryOperationCoverageExprType implements IRasNode, ICoverageInfo
+{
+ private CoverageExprType child;
+ private CoverageInfo info;
+ private String operation;
+ private String params;
+
+ public UnaryOperationCoverageExprType(Node node, ProcessCoveragesRequest pcr)
+ throws WCPSException
+ {
+ String nodeName = node.getNodeName();
+
+ System.err.println("Trying to parse unary operation: " + nodeName);
+
+ if (nodeName.equals("unaryPlus"))
+ {
+ operation = "+";
+ child = new CoverageExprType(node.getFirstChild(), pcr);
+ }
+ else if (nodeName.equals("unaryMinus"))
+ {
+ operation = "-";
+ child = new CoverageExprType(node.getFirstChild(), pcr);
+ }
+ // TODO(andrei): Check if "re" and "im" operations work
+ else if (nodeName.equals("sqrt") || nodeName.equals("abs")
+ || nodeName.equals("exp") || nodeName.equals("log") || nodeName.equals("ln")
+ || nodeName.equals("sin") || nodeName.equals("cos") || nodeName.equals("tan")
+ || nodeName.equals("sinh") || nodeName.equals("cosh")
+ || nodeName.equals("tanh") || nodeName.equals("arcsin")
+ || nodeName.equals("arccos") || nodeName.equals("arctan")
+ || nodeName.equals("not") || nodeName.equals("re") || nodeName.equals("im"))
+ {
+ operation = nodeName;
+ child = new CoverageExprType(node.getFirstChild(), pcr);
+ }
+ else if (nodeName.equals("bit"))
+ {
+ operation = "bit";
+ Node c = node.getFirstChild();
+
+ while (c != null)
+ {
+ if (c.getNodeName().equals("#text"))
+ {
+ c = c.getNextSibling();
+ continue;
+ }
+
+ if (c.getNodeName().equals("bitIndex"))
+ {
+ try
+ {
+ params = c.getFirstChild().getNodeValue();
+ int i = Integer.parseInt(params);
+ System.err.println("Found bitIndex = " + params);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new WCPSException("Invalid Number as bitIndex: " + params);
+ }
+ }
+ else
+ {
+ child = new CoverageExprType(c, pcr);
+ }
+
+ c = c.getNextSibling();
+ }
+ }
+ else if (nodeName.equals("cast"))
+ {
+ operation = "cast";
+ Node c = node.getFirstChild();
+
+ while (c != null)
+ {
+ if (c.getNodeName().equals("#text"))
+ {
+ c = c.getNextSibling();
+ continue;
+ }
+
+ if (c.getNodeName().equals("type"))
+ {
+ RangeFieldType typeNode = new RangeFieldType(c, pcr);
+ params = typeNode.toRasQL();
+ }
+ else
+ {
+ child = new CoverageExprType(c, pcr);
+ }
+
+ c = c.getNextSibling();
+ }
+ }
+ else if (nodeName.equals("fieldSelect"))
+ {
+ operation = "select";
+ Node c = node.getFirstChild();
+
+ while (c != null)
+ {
+ if (c.getNodeName().equals("#text"))
+ {
+ c = c.getNextSibling();
+ continue;
+ }
+
+ if (c.getNodeName().equals("field"))
+ {
+ FieldNameType nameNode = new FieldNameType(c.getFirstChild(), pcr);
+ params = nameNode.toRasQL();
+ }
+ else
+ {
+ child = new CoverageExprType(c, pcr);
+ }
+
+ c = c.getNextSibling();
+ }
+ }
+ else
+ {
+ throw new WCPSException("Unknown unary operation: " + nodeName);
+ }
+
+ info = new CoverageInfo(child.getCoverageInfo());
+ }
+
+ public CoverageInfo getCoverageInfo()
+ {
+ return info;
+ }
+
+ public String toRasQL()
+ {
+ if (operation.equals("sqrt") || operation.equals("abs") || operation.equals("exp")
+ || operation.equals("log") || operation.equals("ln") || operation.equals("sin")
+ || operation.equals("cos") || operation.equals("tan")
+ || operation.equals("sinh") || operation.equals("cosh")
+ || operation.equals("tanh") || operation.equals("arcsin")
+ || operation.equals("arccos") || operation.equals("arctan")
+ || operation.equals("not") || operation.equals("+") || operation.equals("-"))
+ {
+ return operation + "(" + child.toRasQL() + ")";
+ }
+ else if (operation.equals("cast"))
+ {
+ return "(" + params + ")(" + child.toRasQL() + ")";
+ }
+ else if (operation.equals("select"))
+ {
+ return "(" + child.toRasQL() + ")." + params;
+ }
+ else if (operation.equals("bit"))
+ {
+ return "bit(" + child.toRasQL() + "," + params + ")";
+ }
+
+ return " error ";
+ }
+}
diff --git a/src/wcps/server/core/WCPS.java b/src/wcps/server/core/WCPS.java
index 3ed6c64..f17cfe4 100644
--- a/src/wcps/server/core/WCPS.java
+++ b/src/wcps/server/core/WCPS.java
@@ -1,156 +1,180 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import org.xml.sax.*;
-import org.odmg.Database;
-import org.odmg.DBag;
-import org.odmg.Implementation;
-import org.odmg.ODMGException;
-import org.odmg.OQLQuery;
-import org.odmg.QueryException;
-import org.odmg.Transaction;
-import org.w3c.dom.*;
-import org.xml.sax.SAXException;
-import rasj.RasGMArray;
-import rasj.RasImplementation;
-
-// This is the WCPS entry point. Processing a ProcessCoverage request happens in two stages. The first stage is the various pcPrepare functions, where XML is parsed, metadata is loaded, and the request is translated into an instance of a ProcessCoverageRequest. This data structure, for the time being, is just a list of rasdaman queries (RasQuery). The second stage is pcExecute, which executes a ProcessCoverageRequests and returns data.
-
-public class WCPS {
-
- private static final String SCHEMA_PACKAGE_PROCESSCOVERAGE = "wcps.xml.processcoverage";
-
- private MetadataSource metadataSource;
- private DocumentBuilder wcpsDocumentBuilder;
-
- public WCPS( File pcSchema, MetadataSource metadataSource ) throws WCPSException {
- try {
- DocumentBuilderFactory dbconfig = DocumentBuilderFactory.newInstance();
- dbconfig.setValidating(false); // use XML schema not DTD
- dbconfig.setIgnoringComments(true); // comments are not relevant
- dbconfig.setIgnoringElementContentWhitespace(true); // remve the ignorable whitespace
- Schema wcpsProcessCoverageSchema = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI ).newSchema( pcSchema );
- dbconfig.setSchema(wcpsProcessCoverageSchema);
- wcpsDocumentBuilder = dbconfig.newDocumentBuilder();
- } catch (Exception e) {
- throw new WCPSException("Error while loading the document builder interface!", e);
- }
-
- this.metadataSource = metadataSource;
- }
-
- public List<byte[]> pcExecute( String url, String database, ProcessCoverageRequest pcRequest ) throws ResourceException {
- throw new ResourceException("Mothod not implemented! pcExecute");
-/* List<RasQuery> queries = pcRequest.getQueries();
- List<byte[]> results = new ArrayList<byte[]>( queries.size() );
- synchronized( this ) {
- Implementation impl = new RasImplementation( url );
- Database db = impl.newDatabase();
- try {
- db.open( database, Database.OPEN_READ_ONLY );
- }
- catch( ODMGException odmge ) {
- try {
- db.close();
- }
- catch (ODMGException e) {}
- throw new ResourceException( "Could not connect to rasdaman at " + url + ", database " + database, odmge );
- }
- Transaction tr = impl.newTransaction();
- tr.begin();
- Iterator<RasQuery> queryIterator = queries.iterator();
- while( queryIterator.hasNext() ) {
- String query = queryIterator.next().toString();
- OQLQuery q = impl.newOQLQuery();
- DBag resultSet;
- try {
- q.create( query );
- resultSet = (DBag) q.execute();
- if( resultSet != null ) {
- Iterator resultIterator = resultSet.iterator();
- while( resultIterator.hasNext() ) {
- RasGMArray result = (RasGMArray) resultIterator.next();
- results.add( result.getArray() );
- }
- }
- }
- catch (QueryException qe) {
- tr.commit();
- try {
- db.close();
- }
- catch (ODMGException odmge) {}
- throw new ResourceException ( "Could not evaluate rasdaman query: '" + query + "'", qe );
- }
- }
- tr.commit();
- try {
- db.close();
- }
- catch (ODMGException odmge) {}
- }
- return results;
-*/
- }
-
- public ProcessCoverageRequest pcPrepare(String url, String database, File f) throws WCPSException, InvalidRequestException, ResourceException, SAXException, IOException {
- return pcPrepare(url, database, wcpsDocumentBuilder.parse(f));
- }
-
- public ProcessCoverageRequest pcPrepare(String url, String database, InputStream is, String systemId ) throws WCPSException, InvalidRequestException, ResourceException, SAXException, IOException {
- return pcPrepare(url, database, wcpsDocumentBuilder.parse(is, systemId));
- }
-
- public ProcessCoverageRequest pcPrepare(String url, String database, String uri) throws WCPSException, InvalidRequestException, ResourceException, SAXException, IOException {
- return pcPrepare(url, database, wcpsDocumentBuilder.parse(uri));
- }
-
- public ProcessCoverageRequest pcPrepare(String url, String database, InputSource is) throws WCPSException, InvalidRequestException, ResourceException, SAXException, IOException {
- return pcPrepare(url, database, wcpsDocumentBuilder.parse(is));
- }
-
- private ProcessCoverageRequest pcPrepare(String url, String database, Document doc ) throws WCPSException, InvalidRequestException, ResourceException {
- return new ProcessCoverageRequest(url, database, doc, metadataSource);
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+
+import org.w3c.dom.*;
+
+import org.xml.sax.*;
+import org.xml.sax.SAXException;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+/**
+ * This is the WCPS entry point. Processing a ProcessCoverage request happens in two stages.
+ The first stage is the various pcPrepare functions, where XML is parsed, metadata is loaded,
+ and the request is translated into an instance of a ProcessCoverageRequest. This data structure,
+ for the time being, is just a list of rasdaman queries (RasQuery). The second stage is pcExecute,
+ which executes a ProcessCoverageRequests and returns data.
+ */
+
+public class WCPS
+{
+ private static final String SCHEMA_PACKAGE_PROCESSCOVERAGE = "wcps.xml.processcoverage";
+ private MetadataSource metadataSource;
+ private DocumentBuilder wcpsDocumentBuilder;
+
+ public WCPS(File pcSchema, MetadataSource metadataSource) throws WCPSException
+ {
+ try
+ {
+ DocumentBuilderFactory dbconfig = DocumentBuilderFactory.newInstance();
+
+ dbconfig.setValidating(false); // use XML schema not DTD
+ dbconfig.setIgnoringComments(true); // comments are not relevant
+ dbconfig.setIgnoringElementContentWhitespace(true); // remve the ignorable whitespace
+ Schema wcpsProcessCoverageSchema =
+ SchemaFactory.newInstance(
+ XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(pcSchema);
+
+ dbconfig.setSchema(wcpsProcessCoverageSchema);
+
+ wcpsDocumentBuilder = dbconfig.newDocumentBuilder();
+ }
+ catch (Exception e)
+ {
+ throw new WCPSException(
+ "Error while loading the document builder interface!", e);
+ }
+
+ this.metadataSource = metadataSource;
+ }
+
+ public List<byte[]> pcExecute(String url, String database, ProcessCoveragesRequest pcRequest)
+ throws ResourceException
+ {
+ throw new ResourceException("Mothod not implemented! pcExecute");
+
+ /*
+ * List<RasQuery> queries = pcRequest.getQueries();
+ * List<byte[]> results = new ArrayList<byte[]>( queries.size() );
+ * synchronized( this ) {
+ * Implementation impl = new RasImplementation( url );
+ * Database db = impl.newDatabase();
+ * try {
+ * db.open( database, Database.OPEN_READ_ONLY );
+ * }
+ * catch( ODMGException odmge ) {
+ * try {
+ * db.close();
+ * }
+ * catch (ODMGException e) {}
+ * throw new ResourceException( "Could not connect to rasdaman at " + url + ", database " +
+ * database, odmge );
+ * }
+ * Transaction tr = impl.newTransaction();
+ * tr.begin();
+ * Iterator<RasQuery> queryIterator = queries.iterator();
+ * while( queryIterator.hasNext() ) {
+ * String query = queryIterator.next().toString();
+ * OQLQuery q = impl.newOQLQuery();
+ * DBag resultSet;
+ * try {
+ * q.create( query );
+ * resultSet = (DBag) q.execute();
+ * if( resultSet != null ) {
+ * Iterator resultIterator = resultSet.iterator();
+ * while( resultIterator.hasNext() ) {
+ * RasGMArray result = (RasGMArray) resultIterator.next();
+ * results.add( result.getArray() );
+ * }
+ * }
+ * }
+ * catch (QueryException qe) {
+ * tr.commit();
+ * try {
+ * db.close();
+ * }
+ * catch (ODMGException odmge) {}
+ * throw new ResourceException ( "Could not evaluate rasdaman query: '" + query + "'", qe );
+ * }
+ * }
+ * tr.commit();
+ * try {
+ * db.close();
+ * }
+ * catch (ODMGException odmge) {}
+ * }
+ * return results;
+ */
+ }
+
+ public ProcessCoveragesRequest pcPrepare(String url, String database, File f)
+ throws WCPSException, InvalidRequestException, ResourceException, SAXException,
+ IOException
+ {
+ return pcPrepare(url, database, wcpsDocumentBuilder.parse(f));
+ }
+
+ public ProcessCoveragesRequest pcPrepare(String url, String database, InputStream is,
+ String systemId)
+ throws WCPSException, InvalidRequestException, ResourceException, SAXException,
+ IOException
+ {
+ return pcPrepare(url, database, wcpsDocumentBuilder.parse(is, systemId));
+ }
+
+ public ProcessCoveragesRequest pcPrepare(String url, String database, String uri)
+ throws WCPSException, InvalidRequestException, ResourceException, SAXException,
+ IOException
+ {
+ return pcPrepare(url, database, wcpsDocumentBuilder.parse(uri));
+ }
+
+ public ProcessCoveragesRequest pcPrepare(String url, String database, InputSource is)
+ throws WCPSException, InvalidRequestException, ResourceException, SAXException,
+ IOException
+ {
+ return pcPrepare(url, database, wcpsDocumentBuilder.parse(is));
+ }
+
+ private ProcessCoveragesRequest pcPrepare(String url, String database, Document doc)
+ throws WCPSException, InvalidRequestException, ResourceException, SAXException, IOException
+ {
+ ProcessCoveragesRequest req = new ProcessCoveragesRequest(url, database, doc, metadataSource, this);
+ return req;
+ }
+}
diff --git a/src/wcps/server/core/WCPSException.java b/src/wcps/server/core/WCPSException.java
index 07e3fbb..c7050da 100644
--- a/src/wcps/server/core/WCPSException.java
+++ b/src/wcps/server/core/WCPSException.java
@@ -1,41 +1,42 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.core;
-
-// This is the superclass of all WCPS exceptions.
-
-public class WCPSException extends Exception {
-
- private static final long serialVersionUID = 113213254L;
-
- public WCPSException( String message) {
- super(message);
- }
-
- public WCPSException( String message, Throwable cause ) {
-
- super( message, cause );
-
- }
-
-}
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.core;
+
+//This is the superclass of all WCPS exceptions.
+
+public class WCPSException extends Exception
+{
+ private static final long serialVersionUID = 113213254L;
+
+ public WCPSException(String message)
+ {
+ super(message);
+ }
+
+ public WCPSException(String message, Throwable cause)
+ {
+ super(message, cause);
+
+ }
+}
diff --git a/src/wcps/server/core/XmlQuery.java b/src/wcps/server/core/XmlQuery.java
new file mode 100644
index 0000000..c584229
--- /dev/null
+++ b/src/wcps/server/core/XmlQuery.java
@@ -0,0 +1,141 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package wcps.server.core;
+
+
+import org.w3c.dom.*;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ *
+ * @author Andrei Aiordachioaie
+ */
+class XmlQuery implements IRasNode
+{
+ private String mime;
+ private ArrayList<CoverageIterator> iterators;
+ private BooleanScalarExprType where;
+ private IRasNode coverageExpr;
+
+ public String getMimeType()
+ {
+ return mime;
+ }
+
+ public XmlQuery()
+ {
+ super();
+ }
+
+ public void startParsing(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ System.err.println("Processing XML Request: " + node.getNodeName());
+
+ Node x = node.getFirstChild();
+ iterators = new ArrayList<CoverageIterator>();
+
+ while (x != null)
+ {
+ if (x.getNodeName().equals("#text"))
+ {
+ x = x.getNextSibling();
+ continue;
+ }
+
+ System.err.println("The current node is: " + x.getNodeName());
+
+ if (x.getNodeName().equals("coverageIterator"))
+ {
+ iterators.add(new CoverageIterator(x, pcr));
+ }
+ else if (x.getNodeName().equals("where"))
+ {
+ where = new BooleanScalarExprType(x.getFirstChild(), pcr);
+ }
+ else if (x.getNodeName().equals("encode"))
+ {
+ EncodeDataExprType encode;
+
+ encode = new EncodeDataExprType(x, pcr);
+ coverageExpr = encode;
+ mime = encode.getMime();
+ }
+ else
+ {
+ // It has to be a scalar Expr Type
+ coverageExpr = new ScalarExprType(x, pcr);
+ mime = "text/plain";
+ }
+
+ x = x.getNextSibling();
+ }
+ }
+
+ public XmlQuery(Node node, ProcessCoveragesRequest pcr) throws WCPSException
+ {
+ startParsing(node, pcr);
+ }
+
+ public Boolean isIteratorDefined(String iteratorName)
+ {
+ Iterator<CoverageIterator> it = iterators.iterator();
+
+ while (it.hasNext())
+ {
+ CoverageIterator tmp = it.next();
+
+ if (iteratorName.equals(tmp.getIteratorName()))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public Iterator<String> getCoverages(String iteratorName) throws WCPSException
+ {
+ for (int i = 0; i < iterators.size(); ++i)
+ {
+ if (iterators.get(i).getIteratorName().equals(iteratorName))
+ {
+ return iterators.get(i).getCoverages();
+ }
+ }
+
+ throw new WCPSException("Iterator " + iteratorName + " not defined");
+ }
+
+ public String toRasQL()
+ {
+ String result = "select " + coverageExpr.toRasQL() + " from ";
+ Iterator<CoverageIterator> it = iterators.iterator();
+ boolean first = true;
+
+ while (it.hasNext())
+ {
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ result += ", ";
+ }
+
+ result += it.next().toRasQL();
+ }
+
+ if (where != null)
+ {
+ result += " where " + where.toRasQL();
+ }
+
+ return result;
+ }
+} \ No newline at end of file
diff --git a/src/wcps/server/servlet/WCPSServlet.java b/src/wcps/server/servlet/WCPSServlet.java
new file mode 100644
index 0000000..e072614
--- /dev/null
+++ b/src/wcps/server/servlet/WCPSServlet.java
@@ -0,0 +1,323 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+
+
+package wcps.server.servlet;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+
+import org.xml.sax.InputSource;
+
+//This is the servlet interface of WCPS. It mostly consists of sanity checks and initialization,
+//the meat is onyl a few lines. The WCPS class does the actual work.
+
+import wcps.server.core.CachedMetadataSource;
+import wcps.server.core.DbMetadataSource;
+import wcps.server.core.ProcessCoveragesRequest;
+import wcps.server.core.WCPS;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+//import syntaxParser.SyntaxErrorException;
+import java.io.StringBufferInputStream;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+//Note an important limitation: this will only return the first result if several are available.
+//The reason is that WCPS currently has no standardized way to return multiple byte streams to
+//the user.
+public class WCPSServlet extends HttpServlet
+{
+ private static final long serialVersionUID = 84786549L;
+ private Properties dbParams;
+ private DbMetadataSource metadataSource;
+ private String rasdamanDatabase;
+ private String rasdamanUrl;
+ private WCPS wcps;
+
+ public void init() throws ServletException
+ {
+ try
+ {
+ dbParams = new Properties();
+ System.out.println("WCPS: loading database properties");
+ dbParams.load(
+ new FileInputStream(
+ getServletContext().getRealPath("/dbparams.properties")));
+ rasdamanUrl = dbParams.getProperty("rasdaman_url");
+ rasdamanDatabase = dbParams.getProperty("rasdaman_database");
+
+ System.out.println("WCPS: initializing metadata database");
+ metadataSource =
+ new DbMetadataSource(dbParams.getProperty("metadata_driver"),
+ dbParams.getProperty("metadata_url"),
+ dbParams.getProperty("metadata_user"),
+ dbParams.getProperty("metadata_pass"), false);
+
+ System.out.println("WCPS: initializing WCPS core");
+ wcps = new WCPS(
+ new File(getServletContext().getRealPath("/xml/wcps/wcpsProcessCoverages.xsd")),
+ new CachedMetadataSource(metadataSource));
+
+ System.out.println("WCPS: initialization complete");
+ }
+ catch (Exception e)
+ {
+ System.out.println("WCPS: initialization error");
+ System.out.println("WCPS: closing metadata database");
+
+ if (metadataSource != null)
+ {
+ metadataSource.close();
+ }
+
+ System.out.println("WCPS: done with init error");
+ throw new ServletException("WCPS initialization error", e);
+ }
+
+ }
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ System.out.println("WCPS: invoked with GET");
+ printUsage(response);
+
+ }
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException
+ {
+ System.out.println("WCPS: invoked with POST");
+ OutputStream webOut = null;
+
+ try
+ {
+ String xmlRequest = null;
+
+ if (ServletFileUpload.isMultipartContent(request))
+ {
+ @SuppressWarnings(
+ "unchecked") Iterator<FileItem> fileItems =
+ (Iterator<FileItem>) (new ServletFileUpload(
+ new DiskFileItemFactory())).parseRequest(
+ request).iterator();
+
+ if (!fileItems.hasNext())
+ {
+ throw new IOException(
+ "Multipart POST request contains no parts");
+ }
+
+ FileItem fileItem = fileItems.next();
+
+ if (fileItems.hasNext())
+ {
+ throw new IOException(
+ "Multipart POST request contains too many parts");
+ }
+
+ if (!fileItem.isFormField()
+ && fileItem.getContentType().equals("text/xml"))
+ {
+ xmlRequest = fileItem.getString();
+ }
+
+ if (xmlRequest == null)
+ {
+ System.out.println(
+ "WCPS: no XML file was uploaded within multipart POST request");
+ printUsage(response);
+ return;
+ }
+
+ System.out.println(
+ "WCPS: received XML via a multipart POST request");
+ }
+ else
+ {
+ String xml = request.getParameter("xml");
+ String query = request.getParameter("query");
+
+ if (xml != null)
+ {
+ System.out.println("WCPS: received XML via a 'xml' parameter in a POST request");
+ xmlRequest = xml;
+ }
+ else if (query != null)
+ {
+ System.out.println("WCPS: received the following query via a 'query' " +
+ "parameter in a POST request:");
+ System.out.println(query);
+
+ xmlRequest = ProcessCoveragesRequest.abstractQueryToXmlQuery(query);
+ System.out.println("WCPS: transformed the abstract syntax query into an XML query!");
+ }
+ else
+ {
+ System.out.println("WCPS: no request was received");
+ printUsage(response);
+ return;
+ }
+ }
+
+ System.out.println("WCPS: received the following request:");
+ System.out.println(xmlRequest);
+
+ System.out.println("WCPS: preparing request");
+ ProcessCoveragesRequest processCoverageRequest =
+ wcps.pcPrepare(
+ rasdamanUrl, rasdamanDatabase,
+ new InputSource(new StringBufferInputStream(xmlRequest)));
+
+ System.out.println("[" + processCoverageRequest.getMime() + "] "
+ + processCoverageRequest.getRasqlQuery());
+
+ String query = processCoverageRequest.getRasqlQuery();
+
+ System.out.println("Resulting RasQL query: " + query);
+ String mimetype = processCoverageRequest.getMime();
+
+ System.out.println("WCPS: executing request");
+
+ List<byte[]> results = processCoverageRequest.execute();
+
+ System.out.println("WCPS: setting response mimetype to " + mimetype);
+ response.setContentType(mimetype);
+ System.out.println("WCPS: returning response");
+ webOut = response.getOutputStream();
+ webOut.write(results.get(0));
+ System.out.println("WCPS: done");
+ }
+ catch (Exception e)
+ {
+ printError(response, "Error: " + e.getMessage(), e);
+ }
+ finally
+ {
+ if (webOut != null)
+ {
+ try
+ {
+ webOut.close();
+ }
+ catch (IOException e) {}
+ }
+ }
+ }
+
+ public void destroy()
+ {
+ super.destroy();
+
+ }
+
+ public String getServletInfo()
+ {
+ return "Web Coverage Processing Service";
+
+ }
+
+ private void printError(HttpServletResponse response, String message, Exception e)
+ throws IOException
+ {
+ System.out.println("WCPS: error");
+ System.out.println("WCPS: setting response mimetype to text/html; charset=utf-8");
+ response.setContentType("text/html; charset=utf-8");
+ System.out.println("WCPS: returning the following error message");
+ e.printStackTrace(System.out);
+ System.out.println("WCPS: end of error message");
+ PrintWriter out = new PrintWriter(response.getOutputStream());
+
+ out.println(
+ "<html><head><title>Web Coverage Processing Service</title></head><body>");
+ out.println("<h1>An error has occured</h1>");
+ out.println("<p>" + message + "</p>");
+ out.println("<p>Stack trace:<br/><small>");
+ e.printStackTrace(out);
+ out.println("</small></p></body></html>");
+ out.close();
+ System.out.println("WCPS: done with error");
+
+ }
+
+ private void printUsage(HttpServletResponse response) throws IOException
+ {
+ System.out.println("WCPS: setting response mimetype to text/html; charset=utf-8");
+ System.out.println("WCPS: returning usage message");
+ response.setContentType("text/html; charset=utf-8");
+ PrintWriter out = new PrintWriter(response.getOutputStream());
+
+ out.println(
+ "<html><head><title>Web Coverage Processing Service</title></head><body>");
+ out.println("<h1>Hello</h1>");
+ out.println("<p>There are 3 ways to invoke this service:</p>");
+ out.println(
+ "<p>1. Upload a ProcessCoverage XML request as a multupart/form-data POST request containing a file. You can use the form below.</p>");
+ out.println(
+ "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\"><input type=\"file\" accept=\"text/xml\" size=\"64\" name=\"xmlfile\"/> <input type=\"submit\" value=\"Send\"/></form>");
+ out.println(
+ "<p>2. Enter a ProcessCoverage XML request and submit it as a POST request with a parameter named <b>xml</b>. You can use the form below.</p>");
+ out.println(
+ "<form action=\"\" method=\"post\"><textarea cols=\"64\" rows=\"16\" name=\"xml\"></textarea><input type=\"submit\" value=\"Send\"/></form>");
+ out.println(
+ "<p>3. Enter a ProcessCoverage request in WCPS abstract syntax and submit it as a POST request with a parameter named <b>query</b>. You can use the form below.</p>");
+ out.println(
+ "<form action=\"\" method=\"post\"><textarea cols=\"64\" rows=\"4\" name=\"query\"></textarea><input type=\"submit\" value=\"Send\"/></form>");
+ out.println("</body></html>");
+ out.close();
+ System.out.println("WCPS: done nothing");
+
+ }
+
+ void FormatSyntaxException(Exception e, HttpServletResponse response, String query)
+ throws IOException
+ {
+ int column = 1;
+
+ response.setContentType("text/html; charset=utf-8");
+ PrintWriter o = new PrintWriter(response.getOutputStream());
+
+ o.println(
+ "<html><head><title>Web Coverage Processing Service</title></head><body>");
+ o.println("<p>There seems to be a syntax problem with your query:</p>");
+ o.println("<p><font color='00FF00'>" + query.substring(0, column)
+ + "</font><font color='FF0000'>" + query.substring(column)
+ + "</font></p>");
+ o.println("<p>Please correct it and try again.</p></body></html>");
+ o.close();
+ System.out.println("WCPS: Syntax Error reported");
+ }
+}
diff --git a/src/wcps/server/servlet/WCPService.java b/src/wcps/server/servlet/WCPService.java
deleted file mode 100644
index 980b45d..0000000
--- a/src/wcps/server/servlet/WCPService.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * This file is part of Petascope.
- *
- * Petascope is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * Petascope is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Petascope. If not, see <http://www.gnu.org/licenses/>.
- *
- * For more information please see <http://www.Petascope.org>
- * or contact Peter Baumann via <baumann@rasdaman.com>.
- *
- * Copyright 2009 Jacobs University Bremen, Peter Baumann.
- */
-
-package wcps.server.servlet;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.StringBufferInputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletException;
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.servlet.ServletFileUpload;
-
-import wcps.server.core.CachedMetadataSource;
-import wcps.server.core.DbMetadataSource;
-import wcps.server.core.ProcessCoverageRequest;
-import wcps.server.core.WCPS;
-import syntaxParser.WCPSParser;
-import syntaxParser.WCPSScanner;
-import syntaxParser.WCPSRequest;
-import syntaxParser.SyntaxErrorException;
-import java.io.StringBufferInputStream;
-import org.xml.sax.InputSource;
-
-// This is the servlet interface of WCPS. It mostly consists of sanity checks ana initialization, the meat is onyl a few lines. The WCPS class does the actual work.
-
-// Note an important limitation: this will only return the first result if several are available. The reason is that WCPS currently has no standardized way to return multiple byte streams to the user.
-
-public class WCPService extends HttpServlet {
-
- private static final long serialVersionUID = 84786549L;
-
- private Properties dbParams;
- private DbMetadataSource metadataSource;
- private String rasdamanUrl;
- private String rasdamanDatabase;
- private WCPS wcps;
-
- public void init() throws ServletException {
-
- try {
- dbParams = new Properties();
- System.out.println ("WCPS: loading database properties");
- dbParams.load( new FileInputStream( getServletContext().getRealPath( "/dbparams.properties" ) ) );
- rasdamanUrl = dbParams.getProperty( "rasdaman_url" );
- rasdamanDatabase = dbParams.getProperty( "rasdaman_database" );
-
- System.out.println ("WCPS: initializing metadata database");
- metadataSource = new DbMetadataSource( dbParams.getProperty( "metadata_driver" ), dbParams.getProperty( "metadata_url" ), dbParams.getProperty( "metadata_user" ), dbParams.getProperty( "metadata_pass" ), false );
-
- System.out.println( "WCPS: initializing WCPS core" );
- wcps = new WCPS( new File( getServletContext().getRealPath( "/xml/ogc/wcps/1.0.0/wcpsProcessCoverage.xsd" ) ), new CachedMetadataSource( metadataSource ) );
-
- System.out.println( "WCPS: initialization complete" );
- }
- catch( Exception e ) {
- System.out.println( "WCPS: initialization error" );
- System.out.println( "WCPS: closing metadata database" );
- if (metadataSource != null) {
- metadataSource.close();
- }
- System.out.println( "WCPS: done with init error" );
- throw new ServletException( "WCPS initialization error", e );
- }
-
- }
-
- public void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
-
- System.out.println( "WCPS: invoked with GET" );
- printUsage( response );
-
- }
-
- public void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-
- System.out.println ("WCPS: invoked with POST");
- OutputStream webOut = null;
- try {
- String xmlRequest = null;
-
- if( ServletFileUpload.isMultipartContent( request ) ) {
- @SuppressWarnings( "unchecked" ) Iterator<FileItem> fileItems = (Iterator<FileItem>) (new ServletFileUpload( new DiskFileItemFactory() )).parseRequest( request ).iterator();
- if( !fileItems.hasNext() ) {
- throw new IOException( "Multipart POST request contains no parts" );
- }
- FileItem fileItem = fileItems.next();
- if( fileItems.hasNext() ) {
- throw new IOException( "Multipart POST request contains too many parts" );
- }
- if( !fileItem.isFormField() && fileItem.getContentType().equals( "text/xml" ) ) {
- xmlRequest = fileItem.getString ();
- }
- if( xmlRequest == null ) {
- System.out.println ("WCPS: no XML file was uploaded within multipart POST request");
- printUsage( response );
- return;
- }
- System.out.println ("WCPS: received XML via a multipart POST request");
- }
-
- else {
- String xml = request.getParameter( "xml" );
- String query = request.getParameter( "query" );
- if( xml != null ) {
- System.out.println( "WCPS: received XML via a 'xml' parameter in a POST request" );
- xmlRequest = xml;
- }
- else if( query != null ) {
- System.out.println( "WCPS: received the following query via a 'query' parameter in a POST request:" );
- System.out.println( query );
- /* The JLex doesn't handle newlines well.
- We consider them as whitespace anyway so we substitute them here.
- */
- query = query.replace('\n', ' ');
- query = query.replace('\r', ' ');
- query = query.replace('\t', ' ');
- log(query);
- // Initialize the parser
- WCPSParser parser = new WCPSParser(new WCPSScanner(new StringBufferInputStream(query)));
- try {
- WCPSRequest wcpsRequest = (WCPSRequest)parser.debug_parse().value;
- xmlRequest = wcpsRequest.toXML();
- } catch (SyntaxErrorException e) {
- FormatSyntaxException(e, response, query);
- return;
- }
- System.out.println("The XML is: " + xmlRequest);
- }
- else {
- System.out.println( "WCPS: no request was received" );
- printUsage (response);
- return;
- }
- }
- System.out.println( "WCPS: received the following request:" );
- System.out.println( xmlRequest );
-
- System.out.println( "WCPS: preparing request" );
- ProcessCoverageRequest processCoverageRequest = wcps.pcPrepare(rasdamanUrl, rasdamanDatabase, new InputSource(new StringBufferInputStream(xmlRequest)));
- System.out.println( "[" + processCoverageRequest.getMime() + "] " + processCoverageRequest.getQuery());
-
- String query = processCoverageRequest.getQuery();
- log("Resulting RasQL query: " + query);
- String mimetype = processCoverageRequest.getMime();
- System.out.println( "WCPS: executing request" );
-
- List<byte[]> results = processCoverageRequest.execute();
-
- System.out.println( "WCPS: setting response mimetype to " + mimetype );
- response.setContentType( mimetype );
- System.out.println( "WCPS: returning response" );
- webOut = response.getOutputStream();
- webOut.write( results.get( 0 ) );
- System.out.println( "WCPS: done" );
- }
- catch( Exception e ) {
- printError( response, "Error: " + e.getMessage(), e );
- }
- finally {
- if( webOut != null ) {
- try {
- webOut.close();
- }
- catch( IOException e ) {}
- }
- }
- }
-
- public void destroy() {
-
- super.destroy();
-
- }
-
- public String getServletInfo() {
-
- return "Web Coverage Processing Service";
-
- }
-
- private void printError( HttpServletResponse response, String message, Exception e ) throws IOException {
-
- System.out.println( "WCPS: error" );
- System.out.println( "WCPS: setting response mimetype to text/html; charset=utf-8" );
- response.setContentType( "text/html; charset=utf-8" );
- System.out.println( "WCPS: returning the following error message" );
- e.printStackTrace( System.out );
- System.out.println( "WCPS: end of error message" );
- PrintWriter out = new PrintWriter( response.getOutputStream() );
- out.println( "<html><head><title>Web Coverage Processing Service</title></head><body>" );
- out.println( "<h1>An error has occured</h1>" );
- out.println( "<p>" + message + "</p>" );
- out.println( "<p>Stack trace:<br/><small>" );
- e.printStackTrace( out );
- out.println( "</small></p></body></html>" );
- out.close();
- System.out.println( "WCPS: done with error" );
-
- }
-
- private void printUsage( HttpServletResponse response ) throws IOException {
-
- System.out.println( "WCPS: setting response mimetype to text/html; charset=utf-8" );
- System.out.println( "WCPS: returning usage message" );
- response.setContentType( "text/html; charset=utf-8" );
- PrintWriter out = new PrintWriter( response.getOutputStream() );
- out.println( "<html><head><title>Web Coverage Processing Service</title></head><body>" );
- out.println( "<h1>Hello</h1>" );
- out.println( "<p>There are 3 ways to invoke this service:</p>" );
- out.println( "<p>1. Upload a ProcessCoverage XML request as a multupart/form-data POST request containing a file. You can use the form below.</p>" );
- out.println( "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\"><input type=\"file\" accept=\"text/xml\" size=\"64\" name=\"xmlfile\"/> <input type=\"submit\" value=\"Send\"/></form>" );
- out.println( "<p>2. Enter a ProcessCoverage XML request and submit it as a POST request with a parameter named <b>xml</b>. You can use the form below.</p>" );
- out.println( "<form action=\"\" method=\"post\"><textarea cols=\"64\" rows=\"16\" name=\"xml\"></textarea><input type=\"submit\" value=\"Send\"/></form>" );
- out.println( "<p>3. Enter a ProcessCoverage request in WCPS abstract syntax and submit it as a POST request with a parameter named <b>query</b>. You can use the form below.</p>" );
- out.println( "<form action=\"\" method=\"post\"><textarea cols=\"64\" rows=\"4\" name=\"query\"></textarea><input type=\"submit\" value=\"Send\"/></form>" );
- out.println( "</body></html>" );
- out.close();
- System.out.println( "WCPS: done nothing" );
-
- }
-
- void FormatSyntaxException(SyntaxErrorException e,
- HttpServletResponse response,
- String query) throws IOException {
-// response.setStatus(response.SC_INTERNAL_SERVER_ERROR);
- response.setContentType("text/html; charset=utf-8");
- PrintWriter o = new PrintWriter(response.getOutputStream());
- o.println("<html><head><title>Web Coverage Processing Service</title></head><body>" );
- o.println("<p>There seems to be a syntax problem with your query:</p>");
- o.println("<p><font color='00FF00'>" + query.substring(0, e.getColumn()-1) +
- "</font><font color='FF0000'>" + query.substring(e.getColumn()-1) +
- "</font></p>");
- o.println("<p>Please correct it and try again.</p></body></html>");
- o.close();
- System.out.println( "WCPS: Syntax Error reported");
- }
-
-}