diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/petascope/ConfigManager.java | 2 | ||||
-rw-r--r-- | src/petascope/wcps/grammar/RangeExpr.java | 2 | ||||
-rw-r--r-- | src/petascope/wcps/grammar/RangeExprList.java | 2 | ||||
-rw-r--r-- | src/petascope/wcps/grammar/wcps.g | 2 | ||||
-rw-r--r-- | src/petascope/wcps/grammar/wcpsLexer.java | 2 | ||||
-rw-r--r-- | src/petascope/wcps/grammar/wcpsParser.java | 34 | ||||
-rw-r--r-- | src/petascope/wcps/server/core/CoverageExpr.java | 15 | ||||
-rw-r--r-- | src/petascope/wcps/server/core/InducedOperationCoverageExpr.java | 4 | ||||
-rw-r--r-- | src/petascope/wcps/server/core/RangeComponent.java | 87 | ||||
-rw-r--r-- | src/petascope/wcps/server/core/RangeCoverageExpr.java | 53 | ||||
-rw-r--r-- | src/petascope/wcps/server/core/UnaryOperationCoverageExpr.java | 7 |
11 files changed, 155 insertions, 55 deletions
diff --git a/src/petascope/ConfigManager.java b/src/petascope/ConfigManager.java index f757d18..d5237f3 100644 --- a/src/petascope/ConfigManager.java +++ b/src/petascope/ConfigManager.java @@ -51,7 +51,7 @@ public class ConfigManager { v3 adds WGS84 handling in WCPS requests. */ private final static String MINOR = "3"; /* Bug-fix count. We have a hack: every WCPS response is written to disk. */ - private final static String BUGFIX = "7-hack"; + private final static String BUGFIX = "8-hack"; /* Petascope 1.2.0 contains WCS 1.1.0, WCS 2.0, WCS-T 1.0.0 and WCPS 1.0.0 */ public final static String PETASCOPE_VERSION = MAJOR + "." + MINOR + "." + BUGFIX; diff --git a/src/petascope/wcps/grammar/RangeExpr.java b/src/petascope/wcps/grammar/RangeExpr.java index b2af5c6..227de44 100644 --- a/src/petascope/wcps/grammar/RangeExpr.java +++ b/src/petascope/wcps/grammar/RangeExpr.java @@ -44,7 +44,7 @@ public class RangeExpr implements IParseTreeNode { tmp += "<field>" + field + "</field>";
tmp += expr.toXML();
- xml += "<componen>" + tmp + "</component>";
+ xml += "<component>" + tmp + "</component>";
}
public String toXML() {
diff --git a/src/petascope/wcps/grammar/RangeExprList.java b/src/petascope/wcps/grammar/RangeExprList.java index 1b3c137..68046ca 100644 --- a/src/petascope/wcps/grammar/RangeExprList.java +++ b/src/petascope/wcps/grammar/RangeExprList.java @@ -46,7 +46,7 @@ public class RangeExprList implements IParseTreeNode { Iterator<RangeExpr> it = list.iterator();
while (it.hasNext()) {
- result += "<null>" + it.next().toXML() + "</xml>";
+ result += "<null>" + it.next().toXML() + "</null>";
}
return result;
diff --git a/src/petascope/wcps/grammar/wcps.g b/src/petascope/wcps/grammar/wcps.g index 8838084..dd6c5b7 100644 --- a/src/petascope/wcps/grammar/wcps.g +++ b/src/petascope/wcps/grammar/wcps.g @@ -182,7 +182,7 @@ interpolationMethodList returns[InterpolationMethodList value] rangeExpr returns[RangeExpr value] : STRUCT LBRACE { $value=new RangeExpr(); } (field=fieldName COLON expr=scalarExpr { $value.add($field.value, $expr.value); } - (COLON field=fieldName COLON expr=scalarExpr { $value.add($field.value, $expr.value); })* + (COMMA field=fieldName COLON expr=scalarExpr { $value.add($field.value, $expr.value); })* )? RBRACE ; rangeConstructorExpr returns[RangeConstructorExpr value] diff --git a/src/petascope/wcps/grammar/wcpsLexer.java b/src/petascope/wcps/grammar/wcpsLexer.java index a806033..8413eaf 100644 --- a/src/petascope/wcps/grammar/wcpsLexer.java +++ b/src/petascope/wcps/grammar/wcpsLexer.java @@ -1,4 +1,4 @@ -// $ANTLR 3.2 Sep 23, 2009 12:02:23 src/petascope/wcps/grammar/wcps.g 2010-03-31 22:54:42 +// $ANTLR 3.2 Sep 23, 2009 12:02:23 src/petascope/wcps/grammar/wcps.g 2010-04-06 22:00:34 package petascope.wcps.grammar; import org.antlr.runtime.*; diff --git a/src/petascope/wcps/grammar/wcpsParser.java b/src/petascope/wcps/grammar/wcpsParser.java index 2863d1f..ed88903 100644 --- a/src/petascope/wcps/grammar/wcpsParser.java +++ b/src/petascope/wcps/grammar/wcpsParser.java @@ -1,4 +1,4 @@ -// $ANTLR 3.2 Sep 23, 2009 12:02:23 src/petascope/wcps/grammar/wcps.g 2010-03-31 22:54:40 +// $ANTLR 3.2 Sep 23, 2009 12:02:23 src/petascope/wcps/grammar/wcps.g 2010-04-06 22:00:32 package petascope.wcps.grammar; import org.antlr.runtime.*; @@ -4281,7 +4281,7 @@ public class wcpsParser extends Parser { }; // $ANTLR start "rangeExpr" - // src/petascope/wcps/grammar/wcps.g:182:1: rangeExpr returns [RangeExpr value] : STRUCT LBRACE (field= fieldName COLON expr= scalarExpr ( COLON field= fieldName COLON expr= scalarExpr )* )? RBRACE ; + // src/petascope/wcps/grammar/wcps.g:182:1: rangeExpr returns [RangeExpr value] : STRUCT LBRACE (field= fieldName COLON expr= scalarExpr ( COMMA field= fieldName COLON expr= scalarExpr )* )? RBRACE ; public final wcpsParser.rangeExpr_return rangeExpr() throws RecognitionException { wcpsParser.rangeExpr_return retval = new wcpsParser.rangeExpr_return(); retval.start = input.LT(1); @@ -4291,7 +4291,7 @@ public class wcpsParser extends Parser { Token STRUCT98=null; Token LBRACE99=null; Token COLON100=null; - Token COLON101=null; + Token COMMA101=null; Token COLON102=null; Token RBRACE103=null; wcpsParser.fieldName_return field = null; @@ -4302,14 +4302,14 @@ public class wcpsParser extends Parser { Object STRUCT98_tree=null; Object LBRACE99_tree=null; Object COLON100_tree=null; - Object COLON101_tree=null; + Object COMMA101_tree=null; Object COLON102_tree=null; Object RBRACE103_tree=null; try { if ( state.backtracking>0 && alreadyParsedRule(input, 32) ) { return retval; } - // src/petascope/wcps/grammar/wcps.g:183:2: ( STRUCT LBRACE (field= fieldName COLON expr= scalarExpr ( COLON field= fieldName COLON expr= scalarExpr )* )? RBRACE ) - // src/petascope/wcps/grammar/wcps.g:183:4: STRUCT LBRACE (field= fieldName COLON expr= scalarExpr ( COLON field= fieldName COLON expr= scalarExpr )* )? RBRACE + // src/petascope/wcps/grammar/wcps.g:183:2: ( STRUCT LBRACE (field= fieldName COLON expr= scalarExpr ( COMMA field= fieldName COLON expr= scalarExpr )* )? RBRACE ) + // src/petascope/wcps/grammar/wcps.g:183:4: STRUCT LBRACE (field= fieldName COLON expr= scalarExpr ( COMMA field= fieldName COLON expr= scalarExpr )* )? RBRACE { root_0 = (Object)adaptor.nil(); @@ -4326,7 +4326,7 @@ public class wcpsParser extends Parser { if ( state.backtracking==0 ) { retval.value =new RangeExpr(); } - // src/petascope/wcps/grammar/wcps.g:184:2: (field= fieldName COLON expr= scalarExpr ( COLON field= fieldName COLON expr= scalarExpr )* )? + // src/petascope/wcps/grammar/wcps.g:184:2: (field= fieldName COLON expr= scalarExpr ( COMMA field= fieldName COLON expr= scalarExpr )* )? int alt30=2; int LA30_0 = input.LA(1); @@ -4335,7 +4335,7 @@ public class wcpsParser extends Parser { } switch (alt30) { case 1 : - // src/petascope/wcps/grammar/wcps.g:184:3: field= fieldName COLON expr= scalarExpr ( COLON field= fieldName COLON expr= scalarExpr )* + // src/petascope/wcps/grammar/wcps.g:184:3: field= fieldName COLON expr= scalarExpr ( COMMA field= fieldName COLON expr= scalarExpr )* { pushFollow(FOLLOW_fieldName_in_rangeExpr1805); field=fieldName(); @@ -4357,25 +4357,25 @@ public class wcpsParser extends Parser { if ( state.backtracking==0 ) { retval.value.add((field!=null?field.value:null), (expr!=null?expr.value:null)); } - // src/petascope/wcps/grammar/wcps.g:185:3: ( COLON field= fieldName COLON expr= scalarExpr )* + // src/petascope/wcps/grammar/wcps.g:185:3: ( COMMA field= fieldName COLON expr= scalarExpr )* loop29: do { int alt29=2; int LA29_0 = input.LA(1); - if ( (LA29_0==COLON) ) { + if ( (LA29_0==COMMA) ) { alt29=1; } switch (alt29) { case 1 : - // src/petascope/wcps/grammar/wcps.g:185:4: COLON field= fieldName COLON expr= scalarExpr + // src/petascope/wcps/grammar/wcps.g:185:4: COMMA field= fieldName COLON expr= scalarExpr { - COLON101=(Token)match(input,COLON,FOLLOW_COLON_in_rangeExpr1818); if (state.failed) return retval; + COMMA101=(Token)match(input,COMMA,FOLLOW_COMMA_in_rangeExpr1818); if (state.failed) return retval; if ( state.backtracking==0 ) { - COLON101_tree = (Object)adaptor.create(COLON101); - adaptor.addChild(root_0, COLON101_tree); + COMMA101_tree = (Object)adaptor.create(COMMA101); + adaptor.addChild(root_0, COMMA101_tree); } pushFollow(FOLLOW_fieldName_in_rangeExpr1822); field=fieldName(); @@ -18043,11 +18043,11 @@ public class wcpsParser extends Parser { public static final BitSet FOLLOW_LBRACE_in_rangeExpr1797 = new BitSet(new long[]{0x0200000000000000L,0x0000080000014000L}); public static final BitSet FOLLOW_fieldName_in_rangeExpr1805 = new BitSet(new long[]{0x0000200000000000L}); public static final BitSet FOLLOW_COLON_in_rangeExpr1807 = new BitSet(new long[]{0x300007FFF8801840L,0x000010060001D000L}); - public static final BitSet FOLLOW_scalarExpr_in_rangeExpr1811 = new BitSet(new long[]{0x0200200000000000L}); - public static final BitSet FOLLOW_COLON_in_rangeExpr1818 = new BitSet(new long[]{0x0000000000000000L,0x0000080000014000L}); + public static final BitSet FOLLOW_scalarExpr_in_rangeExpr1811 = new BitSet(new long[]{0x0200000000000100L}); + public static final BitSet FOLLOW_COMMA_in_rangeExpr1818 = new BitSet(new long[]{0x0000000000000000L,0x0000080000014000L}); public static final BitSet FOLLOW_fieldName_in_rangeExpr1822 = new BitSet(new long[]{0x0000200000000000L}); public static final BitSet FOLLOW_COLON_in_rangeExpr1824 = new BitSet(new long[]{0x300007FFF8801840L,0x000010060001D000L}); - public static final BitSet FOLLOW_scalarExpr_in_rangeExpr1828 = new BitSet(new long[]{0x0200200000000000L}); + public static final BitSet FOLLOW_scalarExpr_in_rangeExpr1828 = new BitSet(new long[]{0x0200000000000100L}); public static final BitSet FOLLOW_RBRACE_in_rangeExpr1839 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_STRUCT_in_rangeConstructorExpr1856 = new BitSet(new long[]{0x0100000000000000L}); public static final BitSet FOLLOW_LBRACE_in_rangeConstructorExpr1860 = new BitSet(new long[]{0x0000000000000000L,0x0000080000014000L}); diff --git a/src/petascope/wcps/server/core/CoverageExpr.java b/src/petascope/wcps/server/core/CoverageExpr.java index 8046894..d9d9c70 100644 --- a/src/petascope/wcps/server/core/CoverageExpr.java +++ b/src/petascope/wcps/server/core/CoverageExpr.java @@ -32,6 +32,7 @@ public class CoverageExpr implements IRasNode, ICoverageInfo { private IRasNode child;
private String childInfo;
private CoverageInfo info;
+ private boolean scalarExpr = false;
// private String var;
private boolean simpleCoverage; // True is the coverage is just a string
@@ -130,6 +131,7 @@ public class CoverageExpr implements IRasNode, ICoverageInfo { if (child == null) {
try {
child = new ScalarExpr(node, xq);
+ this.scalarExpr = true;
System.err.println("Matched scalar expression.");
} catch (WCPSException e) {
System.err.println("Failed to match scalar expression: "
@@ -154,6 +156,19 @@ public class CoverageExpr implements IRasNode, ICoverageInfo { return info;
}
+ public boolean isScalarExpr()
+ {
+ return scalarExpr;
+ }
+
+ public ScalarExpr getScalarExpr()
+ {
+ ScalarExpr r = null;
+ if (scalarExpr)
+ r = (ScalarExpr) child;
+ return r;
+ }
+
public String toRasQL() {
if (simpleCoverage) {
return childInfo;
diff --git a/src/petascope/wcps/server/core/InducedOperationCoverageExpr.java b/src/petascope/wcps/server/core/InducedOperationCoverageExpr.java index f394b6c..4e20c4c 100644 --- a/src/petascope/wcps/server/core/InducedOperationCoverageExpr.java +++ b/src/petascope/wcps/server/core/InducedOperationCoverageExpr.java @@ -83,10 +83,6 @@ public class InducedOperationCoverageExpr implements IRasNode, ICoverageInfo { }
public String toRasQL() {
- if (operation.equals("rangeConstructor")) {
- return "<rangeConstructor>" + child.toRasQL() + "</rangeConstructor>";
- }
- // else: groups
return child.toRasQL();
}
}
diff --git a/src/petascope/wcps/server/core/RangeComponent.java b/src/petascope/wcps/server/core/RangeComponent.java new file mode 100644 index 0000000..c94698c --- /dev/null +++ b/src/petascope/wcps/server/core/RangeComponent.java @@ -0,0 +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 petascope.wcps.server.core;
+
+import petascope.wcps.server.exceptions.WCPSException;
+import org.w3c.dom.*;
+import petascope.wcps.server.exceptions.InvalidCrsException;
+
+
+/**
+ * This is a component of a RangeStructure.
+ * @author Andrei Aiordachioaie
+ */
+public class RangeComponent implements IRasNode, ICoverageInfo {
+
+ private String field = null;
+ private CoverageInfo info = null;
+ private CoverageExpr expr = null;
+
+ public RangeComponent(Node node, XmlQuery xq)
+ throws WCPSException {
+
+ String nodeName = node.getNodeName();
+ if (nodeName.equals("component"))
+ node = node.getFirstChild();
+
+ while (node != null)
+ {
+ nodeName = node.getNodeName();
+ if (nodeName.equals("#text"))
+ {
+ node = node.getNextSibling();
+ continue;
+ }
+
+ if (nodeName.equals("field"))
+ this.field = node.getTextContent();
+ else
+ try
+ {
+ this.expr = new CoverageExpr(node, xq);
+ this.info = expr.getCoverageInfo();
+ }
+ catch (InvalidCrsException e2)
+ {}
+ catch (WCPSException e)
+ {
+ System.err.println("Could not match CoverageExpr inside RangeExpr. Next node: " + nodeName);
+ throw e;
+ }
+
+ node = node.getNextSibling();
+ }
+ }
+
+ public CoverageInfo getCoverageInfo() {
+ return info;
+ }
+
+ public String toRasQL() {
+ String result = "";
+
+ if (this.expr != null)
+ result = expr.toRasQL();
+
+ return result;
+ }
+}
diff --git a/src/petascope/wcps/server/core/RangeCoverageExpr.java b/src/petascope/wcps/server/core/RangeCoverageExpr.java index 685ca23..2be4d61 100644 --- a/src/petascope/wcps/server/core/RangeCoverageExpr.java +++ b/src/petascope/wcps/server/core/RangeCoverageExpr.java @@ -36,50 +36,47 @@ public class RangeCoverageExpr implements IRasNode, ICoverageInfo { public RangeCoverageExpr(Node node, XmlQuery xq)
throws WCPSException {
- // TODO: Implement RangeCoverageExpr
- throw new WCPSException("Feature not yet implemented !");
-
- /*
components = new ArrayList<IRasNode>();
+ if (node.getNodeName().equals("rangeConstructor"))
+ node = node.getFirstChild();
+
+ if (node.getNodeName().equals("#text"))
+ node = node.getNextSibling();
+
String nodeName = node.getNodeName();
System.err.println("Trying to parse a range coverage expression... Starting at node "
- + nodeName);
-
- Node it = node.getFirstChild();
+ + nodeName);
- 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);
- }
+ while (node != null) {
+ if (node.getNodeName().equals("#text")) {
+ node = node.getNextSibling();
+ continue;
+ }
+ if (node.getNodeName().equals("component")) {
+ RangeComponent elem = new RangeComponent(node, xq);
+ info = elem.getCoverageInfo();
+ components.add(elem);
+ }
- it = it.getNextSibling();
+ node = node.getNextSibling();
}
- */
}
public CoverageInfo getCoverageInfo() {
+ // FIXME: Returns currently only the info for the last range component
return info;
}
public String toRasQL() {
String result = "";
- /*
- Iterator<IRasNode> i = components.iterator();
- while (i.hasNext())
- {
- result += i.next().toRasQL();
- }
- */
+ int length = components.size();
+ for (int i = 0; i < length - 1; i++)
+ result += components.get(i).toRasQL() + ",";
+ result += components.get(length - 1).toRasQL();
+
+ result = "{ " + result + " }";
return result;
}
diff --git a/src/petascope/wcps/server/core/UnaryOperationCoverageExpr.java b/src/petascope/wcps/server/core/UnaryOperationCoverageExpr.java index 48f3e94..00b80ec 100644 --- a/src/petascope/wcps/server/core/UnaryOperationCoverageExpr.java +++ b/src/petascope/wcps/server/core/UnaryOperationCoverageExpr.java @@ -136,7 +136,12 @@ public class UnaryOperationCoverageExpr implements IRasNode, ICoverageInfo { || operation.equals("not") || operation.equals("+") || operation.equals("-")) {
return operation + "(" + child.toRasQL() + ")";
} else if (operation.equals("cast")) {
- return "(" + params + ")(" + child.toRasQL() + ")";
+ // Use rasql's direct "type-casting" facility for constant scalar expressions
+ // For example, (char)1 does not work, but 1c is a valid expression.
+ if (child.isScalarExpr() && params.equals("char"))
+ return child.toRasQL() + "c";
+ else
+ return "(" + params + ")(" + child.toRasQL() + ")";
} else if (operation.equals("select")) {
return "(" + child.toRasQL() + ")." + params;
} else if (operation.equals("bit")) {
|