You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ma...@apache.org on 2017/07/16 16:15:19 UTC
[03/53] [partial] oodt git commit: Record change for OODT-836,
OODT-837.
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Expression.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Expression.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Expression.java
deleted file mode 100644
index 6aece62..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Expression.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.queryparser;
-
-/**
- *
- * The abstract interface for our expression tree.
- */
-public interface Expression {
-
- /**
- * Defines how to turn this Expression into a String-readable query to an
- * underlying SQL database.
- *
- * @return A String-readable version of this Expression.
- */
- String evaluate();
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanEqualsExpression.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanEqualsExpression.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanEqualsExpression.java
deleted file mode 100644
index c5ce179..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanEqualsExpression.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.queryparser;
-
-/**
- *
- * Greater than or equals expression.
- */
-public class GreaterThanEqualsExpression extends RelOpExpression implements
- ParseConstants {
-
- public GreaterThanEqualsExpression(String lhs, Expression literal) {
- super(SQL_GREATER_THAN_OR_EQUAL_TO, lhs, literal);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanExpression.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanExpression.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanExpression.java
deleted file mode 100644
index 42582ef..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanExpression.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.queryparser;
-
-/**
- *
- * Greater than expression.
- */
-public class GreaterThanExpression extends RelOpExpression implements
- ParseConstants {
-
- public GreaterThanExpression(String lhs, Expression literal) {
- super(SQL_GREATER_THAN, lhs, literal);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/HandlerQueryParser.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/HandlerQueryParser.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/HandlerQueryParser.java
deleted file mode 100644
index 9e59747..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/HandlerQueryParser.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.queryparser;
-
-//JDK imports
-import org.apache.oodt.xmlps.mapping.Mapping;
-import org.apache.oodt.xmlps.mapping.MappingField;
-import org.apache.oodt.xmlquery.QueryElement;
-
-import java.util.List;
-import java.util.Stack;
-
-//OODT imports
-
-/**
- *
- * Parsers the {@link org.apache.oodt.xmlquery.XMLQuery} and its @link XMLQuery#getWhereElementSet()}
- * into an {@link Expression} tree.
- */
-public class HandlerQueryParser implements ParseConstants {
-
- /**
- * Calls {@link #parse(Stack, Mapping)} with a null mapping.
- *
- * @param queryStack The {@link org.apache.oodt.xmlquery.XMLQuery#getWhereElementSet()}.
- * @return The parsed {@link Expression} tree.
- */
- public static Expression parse(Stack<QueryElement> queryStack) {
- return parse(queryStack, null);
- }
-
- /**
- *
- * Parses the {@link org.apache.oodt.xmlquery.XMLQuery#getWhereElementSet()} using the provided
- * <param>map</param>.
- *
- * @param queryStack The {@link org.apache.oodt.xmlquery.XMLQuery#getWhereElementSet()}
- * @param map The provided ontological mapping.
- * @return The parsed {@link Expression} tree.
- */
- public static Expression parse(Stack<QueryElement> queryStack, Mapping map) {
-
- QueryElement qe;
-
- if (!queryStack.empty()) {
- qe = (QueryElement) queryStack.pop();
- } else {
- return null;
- }
-
- if (qe.getRole().equalsIgnoreCase(XMLQUERY_LOGOP)) {
-
- String logOpType = qe.getValue();
- if (logOpType.equalsIgnoreCase(XMLQUERY_AND)) {
- return new AndExpression(parse(queryStack, map), parse(queryStack, map));
- } else if (logOpType.equalsIgnoreCase(XMLQUERY_OR)) {
- return new OrExpression(parse(queryStack, map), parse(queryStack, map));
- } else {
- return null;
- }
-
- } else if (qe.getRole().equalsIgnoreCase(XMLQUERY_RELOP)) {
- String relOpType = qe.getValue();
- QueryElement rhsQE = (QueryElement) queryStack.pop();
- QueryElement lhsQE = (QueryElement) queryStack.pop();
-
- String rhsVal = (String) rhsQE.getValue();
- String lhsVal = (String) lhsQE.getValue();
-
- if (map != null) {
- // convert the right hand side, using
- // the local name
- MappingField fld = map.getFieldByLocalName(lhsVal);
- if (fld != null) {
- if (fld.isString()) {
- rhsVal = "'" + rhsVal + "'";
- }
- }
- }
-
- if (relOpType.equalsIgnoreCase(XMLQUERY_EQUAL)) {
- return new EqualsExpression(lhsVal, new Literal(rhsVal));
- } else if (relOpType.equalsIgnoreCase(XMLQUERY_LIKE)) {
- return new ContainsExpression(lhsVal, new WildcardLiteral(rhsVal));
- } else if (relOpType.equalsIgnoreCase(XMLQUERY_GREATER_THAN)) {
- return new GreaterThanExpression(lhsVal, new Literal(rhsVal));
- } else if (relOpType.equalsIgnoreCase(XMLQUERY_GREATER_THAN_OR_EQUAL_TO)) {
- return new GreaterThanEqualsExpression(lhsVal, new Literal(rhsVal));
- } else if (relOpType.equalsIgnoreCase(XMLQUERY_LESS_THAN)) {
- return new LessThanExpression(lhsVal, new Literal(rhsVal));
- } else if (relOpType.equalsIgnoreCase(XMLQUERY_LESS_THAN_OR_EQUAL_TO)) {
- return new LessThanEqualsExpression(lhsVal, new Literal(rhsVal));
- } else {
- return null;
- }
-
- } else if (qe.getRole().equalsIgnoreCase(XMLQUERY_LITERAL)) {
- return new Literal(qe.getValue());
- } else {
- return null;
- }
-
- }
-
- public static Stack<QueryElement> createQueryStack(List<QueryElement> l) {
-
- Stack<QueryElement> ret = new Stack<QueryElement>();
-
- for (QueryElement aL : l) {
- ret.push(aL);
- }
-
- return ret;
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanEqualsExpression.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanEqualsExpression.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanEqualsExpression.java
deleted file mode 100644
index 46e6975..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanEqualsExpression.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.queryparser;
-
-/**
- *
- * <p>
- * A less than or equals expression.
- * </p>.
- */
-public class LessThanEqualsExpression extends RelOpExpression implements
- ParseConstants {
-
- public LessThanEqualsExpression(String lhs, Expression literal) {
- super(SQL_LESS_THAN_OR_EQUAL_TO, lhs, literal);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanExpression.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanExpression.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanExpression.java
deleted file mode 100644
index 2184f19..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanExpression.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.queryparser;
-
-/**
- *
- * <p>
- * A less than expression.
- * </p>.
- */
-public class LessThanExpression extends RelOpExpression implements
- ParseConstants {
-
- public LessThanExpression(String lhs, Expression literal) {
- super(SQL_LESS_THAN, lhs, literal);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Literal.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Literal.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Literal.java
deleted file mode 100644
index 4ac3de5..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Literal.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.queryparser;
-
-/**
- *
- * A value literal.
- */
-public class Literal implements Expression{
-
- protected String val;
-
- public Literal(String val){
- this.val = val;
- }
-
- /* (non-Javadoc)
- * @see org.apache.oodt.xmlps.queryparser.Expression#evaluate()
- */
- public String evaluate() {
- return val;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LogOpExpression.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LogOpExpression.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LogOpExpression.java
deleted file mode 100644
index ae5a29f..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LogOpExpression.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.queryparser;
-
-/**
- *
- * A logical expression with a left-hand side
- * and right hind-side {@link Expression}.
- *
- */
-public class LogOpExpression implements Expression {
-
- private String logop;
-
- private Expression lhs;
-
- private Expression rhs;
-
-
-
- public LogOpExpression(String logop, Expression lhs, Expression rhs) {
- this.lhs = lhs;
- this.rhs = rhs;
- this.logop = logop;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.oodt.xmlps.queryparser.Expression#evaluate()
- */
- public String evaluate() {
- return "(" + lhs.evaluate() + " " + logop + " " + rhs.evaluate() + ")";
- }
-
- /**
- * @return the lhs
- */
- public Expression getLhs() {
- return lhs;
- }
-
- /**
- * @param lhs the lhs to set
- */
- public void setLhs(Expression lhs) {
- this.lhs = lhs;
- }
-
- /**
- * @return the rhs
- */
- public Expression getRhs() {
- return rhs;
- }
-
- /**
- * @param rhs the rhs to set
- */
- public void setRhs(Expression rhs) {
- this.rhs = rhs;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/OrExpression.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/OrExpression.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/OrExpression.java
deleted file mode 100644
index ff5531e..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/OrExpression.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.queryparser;
-
-/**
- *
- * An Or expression.
- */
-public class OrExpression extends LogOpExpression implements ParseConstants{
-
- public OrExpression(Expression lhs, Expression rhs) {
- super(SQL_OR, lhs, rhs);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ParseConstants.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ParseConstants.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ParseConstants.java
deleted file mode 100644
index b26de5c..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ParseConstants.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.queryparser;
-
-/**
- *
- * Constant met keys used in parsing the XMLQuery.
- */
-public interface ParseConstants {
-
- String XMLQUERY_LOGOP = "LOGOP";
-
- String XMLQUERY_AND = "AND";
-
- String XMLQUERY_OR = "OR";
-
- String XMLQUERY_RELOP = "RELOP";
-
- String XMLQUERY_EQUAL = "EQ";
-
- String XMLQUERY_LIKE = "LIKE";
-
- String XMLQUERY_GREATER_THAN = "GT";
-
- String XMLQUERY_GREATER_THAN_OR_EQUAL_TO = "GE";
-
- String XMLQUERY_LESS_THAN = "LT";
-
- String XMLQUERY_LESS_THAN_OR_EQUAL_TO = "LE";
-
- String XMLQUERY_LITERAL = "LITERAL";
-
-
- String SQL_LIKE = "LIKE";
-
- String SQL_EQUAL = "=";
-
- String SQL_AND = "AND";
-
- String SQL_OR = "OR";
-
- String SQL_GREATER_THAN_OR_EQUAL_TO = ">=";
-
- String SQL_GREATER_THAN = ">";
-
- String SQL_LESS_THAN = "<";
-
- String SQL_LESS_THAN_OR_EQUAL_TO = "<=";
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/RelOpExpression.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/RelOpExpression.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/RelOpExpression.java
deleted file mode 100644
index 9be99ff..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/RelOpExpression.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.queryparser;
-
-/**
- *
- * A relational operator.
- */
-public class RelOpExpression implements Expression {
-
- private String relop;
-
- private Expression literal;
-
- private String lhs;
-
- public RelOpExpression(String relop, String lhs, Expression literal) {
- this.relop = relop;
- this.lhs = lhs;
- this.literal = literal;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.oodt.xmlps.queryparser.Expression#evaluate()
- */
- public String evaluate() {
- return lhs + " " + relop + " " + literal.evaluate();
- }
-
- /**
- * @return the lhs
- */
- public String getLhs() {
- return lhs;
- }
-
- /**
- * @param lhs the lhs to set
- */
- public void setLhs(String lhs) {
- this.lhs = lhs;
- }
-
- /**
- * @return the literal
- */
- public Expression getLiteral() {
- return literal;
- }
-
- /**
- * @param literal the literal to set
- */
- public void setLiteral(Expression literal) {
- this.literal = literal;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/WildcardLiteral.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/WildcardLiteral.java b/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/WildcardLiteral.java
deleted file mode 100644
index 2f91b9c..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/WildcardLiteral.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.queryparser;
-
-/**
- *
- * A wildcard literal.
- */
-public class WildcardLiteral extends Literal {
-
- /**
- * @param val
- */
- public WildcardLiteral(String val) {
- super(val);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.oodt.xmlps.queryparser.Literal#evaluate()
- */
- @Override
- public String evaluate() {
- if(val.startsWith("'")){
- return "'%"+val.substring(1, val.length()-1)+"%'";
- }
- else {
- return "%" + val + "%";
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEResult.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEResult.java b/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEResult.java
deleted file mode 100644
index 1ed8732..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEResult.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.structs;
-
-//OODT imports
-
-import org.apache.oodt.xmlps.mapping.Mapping;
-import org.apache.oodt.xmlps.mapping.MappingField;
-import org.apache.oodt.xmlps.mapping.funcs.MappingFunc;
-import org.apache.oodt.xmlquery.QueryElement;
-import org.apache.oodt.xmlquery.Result;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-import java.util.concurrent.ConcurrentHashMap;
-
-//JDK imports
-
-/**
- * A {@link Result} that wraps a {@link ResultSet} and returns rows as Strings,
- * applying {@link MappingFuncs} if a {@link Mapping} is provided, and appending
- * constant fields if a {@link List} of {@link CDEValue}s is provided.
- */
-public class CDEResult extends Result {
-
- private static final long serialVersionUID = 1L;
-
- private static final String ROW_TERMINATOR = "$";
-
- private final ResultSet rs;
- private final Connection con;
- private Mapping mapping;
- private List<CDEValue> constValues;
- private List<QueryElement> orderedFields;
-
- public CDEResult(ResultSet rs, Connection con) {
- this.rs = rs;
- this.con = con;
- setMimeType("text/plain");
- }
-
- public void setOrderedFields(List<QueryElement> orderedFields){
- this.orderedFields = orderedFields;
- }
-
- public void setMapping(Mapping mapping) {
- this.mapping = mapping;
- }
-
- public void setConstValues(List<CDEValue> constValues) {
- this.constValues = constValues;
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- if (rs == null || con == null) {
- throw new IOException("InputStream not ready, ResultSet or Connection is null!");
- }
- return new CDEResultInputStream(this);
- }
-
- @Override
- public long getSize() {
- return -1;
- }
-
- public void close() throws SQLException {
- if (rs != null) {
- rs.close();
- }
- if (con != null) {
- con.close();
- }
- }
-
- public String getNextRowAsString() throws SQLException {
- if (rs.next()) {
- CDERow row = createCDERow();
- if (mapping != null) {
- applyMappingFuncs(row);
- }
- if (this.constValues != null && ((this.orderedFields == null) || (this.orderedFields.size() == 0))){
- addConstValues(row);
- }
- // if there is some kind of configurable response writer,
- // here would be a nice place to put it...
- return row.toString() + ROW_TERMINATOR;
- }
- return null;
- }
-
- private CDERow createCDERow() throws SQLException {
- CDERow row = new CDERow();
- ResultSetMetaData met = rs.getMetaData();
- int count = met.getColumnCount();
- Map<String, CDEValue> dbValMap = new HashMap<String, CDEValue>();
- Map<String, CDEValue> constValMap = cdeListToMap(this.constValues);
- List<CDEValue> orderedDbVals = new Vector<CDEValue>();
-
- for (int i = 1; i <= count; i++) {
- // since the SQL query was built with "SELECT ${fieldlocalname} as ${fieldname}"
- // we know that ResultSet column names equal CDE field names
- // and appear in the correct order as well
- String fieldLocalColName = met.getColumnLabel(i);
- String colValue = rs.getString(i);
- CDEValue val = new CDEValue(fieldLocalColName, colValue);
- dbValMap.put(fieldLocalColName, val);
- orderedDbVals.add(val);
- }
-
- // now have the constant values, and the db values, order the row
- if(this.orderedFields != null){
- for(QueryElement qe: this.orderedFields){
- String qeCdeVal = this.mapping.getFieldByLocalName(qe.getValue()).getName();
- if(dbValMap.containsKey(qeCdeVal)){
- row.getVals().add(dbValMap.get(qeCdeVal));
- }
- else if(constValMap.containsKey(qeCdeVal)){
- row.getVals().add(constValMap.get(qeCdeVal));
- }
- }
- }
- else {
- row.getVals().addAll(orderedDbVals);
- }
-
-
- return row;
- }
-
- private void applyMappingFuncs(CDERow row) {
- for (CDEValue value : row.getVals()) {
- MappingField fld = mapping.getFieldByName(value.getCdeName());
- if (fld != null) {
- for (MappingFunc func : fld.getFuncs()) {
- CDEValue newValue = func.translate(value);
- value.setVal(newValue.getVal());
- }
- }
- }
- }
-
- private void addConstValues(CDERow row) {
- row.getVals().addAll(constValues);
- }
-
- private Map<String, CDEValue> cdeListToMap(List<CDEValue> vals){
- Map<String, CDEValue> map = new HashMap<String, CDEValue>();
- if(vals != null){
- for(CDEValue val: vals){
- map.put(val.getCdeName(), val);
- }
- }
-
- return map;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEResultInputStream.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEResultInputStream.java b/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEResultInputStream.java
deleted file mode 100644
index 4d358aa..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEResultInputStream.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.oodt.xmlps.structs;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.SQLException;
-
-class CDEResultInputStream extends InputStream {
-
- private final CDEResult res;
- private ByteArrayInputStream rowStream;
-
- public CDEResultInputStream(CDEResult res) {
- this.res = res;
- }
-
- private boolean fetchNextRow() throws IOException {
- String s = null;
- try {
- s = res.getNextRowAsString();
- } catch (SQLException ignored) {
- }
- if (rowStream != null) {
- rowStream.close();
- }
- rowStream = s == null ? null : new ByteArrayInputStream(s.getBytes("UTF-8"));
- return rowStream != null;
- }
-
- private boolean ensureOpen() throws IOException {
- if (rowStream == null || rowStream.available() <= 0) {
- return fetchNextRow();
- }
- return true;
- }
-
- @Override
- public int read() throws IOException {
- return ensureOpen() ? rowStream.read() : -1;
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws IOException {
- if (!ensureOpen()) {
- return -1;
- }
-
- if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length)
- || ((off + len) < 0)) {
- throw new IndexOutOfBoundsException();
- } else if (len == 0) {
- return 0;
- }
-
- int total = 0;
- int n = rowStream.read(b, off, len);
- total += n;
- while (n != -1 && total < len) {
- if (!fetchNextRow()) {
- return total;
- }
- n = rowStream.read(b, off + total, len - total);
- total += n;
- }
- return total;
- }
-
- @Override
- public void close() throws IOException {
- if (rowStream != null) {
- rowStream.close();
- }
- rowStream = null;
-
- try {
- res.close();
- } catch (SQLException e) {
- throw new IOException(e);
- }
- }
-
- @Override
- public synchronized int available() throws IOException {
- if (rowStream == null) {
- return 0;
- }
- return rowStream.available();
- }
-
- @Override
- public synchronized void mark(int readlimit) {
- throw new UnsupportedOperationException("Mark not supported");
- }
-
- @Override
- public synchronized void reset() throws IOException {
- throw new UnsupportedOperationException("Reset not supported");
- }
-
- @Override
- public boolean markSupported() {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDERow.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDERow.java b/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDERow.java
deleted file mode 100644
index f7b92e0..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDERow.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.structs;
-
-//JDK imports
-import java.util.List;
-import java.util.Vector;
-
-
-/**
- *
- * <p>
- * A row of {@link CDEValue}s, returned
- * from a query against a Product Server.
- * </p>.
- */
-public class CDERow {
-
- private List<CDEValue> vals;
-
- private static final String COL_SEPARATOR = "\t";
-
- public CDERow() {
- vals = new Vector<CDEValue>();
- }
-
- public String toString() {
- StringBuilder rStr = new StringBuilder();
- if (vals != null && vals.size() > 0) {
- for (CDEValue v : vals) {
- rStr.append(v.getVal()).append(COL_SEPARATOR);
- }
-
- rStr.deleteCharAt(rStr.length() - 1);
- }
-
- return rStr.toString();
- }
-
- /**
- * @return the vals
- */
- public List<CDEValue> getVals() {
- return vals;
- }
-
- /**
- * @param vals
- * the vals to set
- */
- public void setVals(List<CDEValue> vals) {
- this.vals = vals;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEValue.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEValue.java b/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEValue.java
deleted file mode 100644
index 43a8400..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEValue.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.structs;
-
-/**
- *
- * <p>
- * A cde name and a value returned from a query against a Product Server
- * </p>.
- */
-public class CDEValue {
-
- private String cdeName;
-
- private String val;
-
- public CDEValue() {
-
- }
-
- public CDEValue(String cdeName, String val) {
- this.cdeName = cdeName;
- this.val = val;
- }
-
- /**
- * @return the cdeName
- */
- public String getCdeName() {
- return cdeName;
- }
-
- /**
- * @param cdeName
- * the cdeName to set
- */
- public void setCdeName(String cdeName) {
- this.cdeName = cdeName;
- }
-
- /**
- * @return the val
- */
- public String getVal() {
- return val;
- }
-
- /**
- * @param val
- * the val to set
- */
- public void setVal(String val) {
- this.val = val;
- }
-
- public String toString(){
- return "[cdeName="+this.cdeName+",val="+this.val+"]";
- }
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/util/GenericCDEObjectFactory.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/util/GenericCDEObjectFactory.java b/xmlps/src/main/java/org/apache/oodt/xmlps/util/GenericCDEObjectFactory.java
deleted file mode 100644
index ad1534a..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/util/GenericCDEObjectFactory.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.util;
-
-//JDK imports
-import org.apache.oodt.xmlps.mapping.funcs.MappingFunc;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-//OODT imports
-
-/**
- *
- * <p>
- * An object factory for creating CDE objects.
- * </p>.
- */
-public final class GenericCDEObjectFactory {
-
- /* our log stream */
- private static final Logger LOG = Logger
- .getLogger(GenericCDEObjectFactory.class.getName());
-
- private GenericCDEObjectFactory() throws InstantiationException {
- throw new InstantiationException("Don't construct object factories!");
- }
-
- public static MappingFunc getMappingFuncFromClassName(String className) {
- MappingFunc func;
- Class funcClazz;
- try {
- funcClazz = Class.forName(className);
- func = (MappingFunc) funcClazz.newInstance();
- return func;
- } catch (ClassNotFoundException e) {
- LOG.log(Level.SEVERE, e.getMessage());
- LOG.log(Level.WARNING, "Unable to load class: [" + className
- + "]: class not found! message: " + e.getMessage(), e);
- return null;
- } catch (InstantiationException e) {
- LOG.log(Level.SEVERE, e.getMessage());
- LOG.log(Level.WARNING, "Unable to load class: [" + className
- + "]: cannot instantiate! message: " + e.getMessage(), e);
- return null;
- } catch (IllegalAccessException e) {
- LOG.log(Level.SEVERE, e.getMessage());
- LOG.log(Level.WARNING, "Unable to load class: [" + className
- + "]: illegal access! message: " + e.getMessage(), e);
- return null;
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryHelper.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryHelper.java b/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryHelper.java
deleted file mode 100644
index c414102..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryHelper.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.util;
-
-//OODT imports
-import org.apache.oodt.xmlquery.XMLQuery;
-
-/**
- *
- * <p>
- * Helper methods to handle those pesky {@link XMLQuery} objects.
- * </p>.
- */
-public final class XMLQueryHelper implements XMLQueryKeys{
-
- public static XMLQuery getDefaultQueryFromQueryString(String query) {
- return new XMLQuery(query/* keywordQuery */, ""/* id */,
- ""/* title */, ""/* desc */, ""/* ddId */,
- ""/* resultModeId */, ""/* propType */, ""/* propLevels */,
- XMLQuery.DEFAULT_MAX_RESULTS/* maxResults */);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryKeys.java
----------------------------------------------------------------------
diff --git a/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryKeys.java b/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryKeys.java
deleted file mode 100644
index 137e54b..0000000
--- a/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryKeys.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.util;
-
-/**
- *
- * <p>Met Keys for dealing with {@link org.apache.oodt.xmlquery.XMLQuery}s</p>.
- */
-public interface XMLQueryKeys {
-
- String ROLE_LITERAL = "LITERAL";
-
- String ROLE_ELEMNAME = "elemName";
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/test/java/org/apache/oodt/xmlps/mapping/TestMappingReader.java
----------------------------------------------------------------------
diff --git a/xmlps/src/test/java/org/apache/oodt/xmlps/mapping/TestMappingReader.java b/xmlps/src/test/java/org/apache/oodt/xmlps/mapping/TestMappingReader.java
deleted file mode 100644
index d0b37ca..0000000
--- a/xmlps/src/test/java/org/apache/oodt/xmlps/mapping/TestMappingReader.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.mapping;
-
-//APACHE imports
-
-import org.apache.oodt.xmlps.mapping.funcs.MappingFunc;
-import org.apache.oodt.xmlps.structs.CDEValue;
-
-import java.io.InputStream;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import junit.framework.TestCase;
-
-/**
- * Test suite for XMLPS xml map file reader.
- */
-public class TestMappingReader extends TestCase {
- private static Logger LOG = Logger.getLogger(TestMappingReader.class.getName());
- private static final String expectedName = "Test Query Handler";
-
- private static final String expectedId = "urn:oodt:xmlps:testps";
-
- private static final int expectedFields = 43;
-
- private static final String SPECIMEN_CONTACT_EMAIL_TEXT = "SPECIMEN_CONTACT-EMAIL_TEXT";
-
- private static final String SPECIMEN_COLLECTED_CODE = "SPECIMEN_COLLECTED_CODE";
-
- private static final String SPECIMEN_TISSUE_ORGAN_SITE_CODE = "SPECIMEN_TISSUE_ORGAN-SITE_CODE";
-
- private static final String CONTACT_PERSON_EMAIL = "Brendan.Phalan@med.nyu.edu";
-
- private static final String expectedDefaultTable = "baseline";
-
- private static final String expectedJoinFld = "patient_id";
-
- public TestMappingReader() {
-
- }
-
- public void testReadTables() {
- Mapping mapping = getMappingOrFail();
- assertNotNull(mapping);
-
- assertEquals(1, mapping.getNumTables());
- assertNull(mapping.getTableByName("baseline"));
- assertNotNull(mapping.getTableByName("specimen"));
- assertNotNull(mapping.getDefaultTable());
- assertEquals(expectedDefaultTable, mapping.getDefaultTable());
- assertEquals(expectedJoinFld, mapping.getTableByName("specimen")
- .getJoinFieldName());
- }
-
- public void testReadBasicInfo() {
- Mapping mapping = getMappingOrFail();
-
- assertNotNull(mapping);
- assertEquals(expectedName, mapping.getName());
- assertEquals(expectedId, mapping.getId());
- }
-
- public void testReadFields() {
- Mapping mapping = getMappingOrFail();
- assertNotNull(mapping);
- assertEquals(expectedFields, mapping.getNumFields());
- containsSpecimenContactEmailTextOrFail(mapping);
- containsSpecimenCollectedCodeOrFail(mapping);
-
- }
-
- public void testReadFuncs() {
- Mapping mapping = getMappingOrFail();
- assertNotNull(mapping);
- assertTrue(mapping.getNumFields() > 0);
-
- MappingField funcField = mapping
- .getFieldByName(SPECIMEN_TISSUE_ORGAN_SITE_CODE);
- assertNotNull(funcField);
-
- assertNotNull(funcField.getFuncs());
- assertEquals(funcField.getFuncs().size(), 1);
-
- MappingFunc func = funcField.getFuncs().get(0);
- CDEValue val = new CDEValue("test", "16");
- CDEValue result = func.translate(val);
- assertNotNull(result);
- assertEquals(result.getVal(), "1");
- val.setVal("235");
- result = func.translate(val);
- assertEquals(result.getVal(), "235");
- }
-
- public void testMappingFieldGetLocalName() {
- Mapping mapping = getMappingOrFail("test-same-col-name-ps.xml");
-
- MappingField fieldOnly = mapping.getFieldByName("field_only");
- assertEquals("defaultTable.field_only", fieldOnly.getLocalName());
-
- MappingField fieldWithTable = mapping.getFieldByName("field_with_table");
- assertEquals("anotherTable.field_db", fieldWithTable.getLocalName());
-
- MappingField fieldUseDefault = mapping.getFieldByName("field_use_default");
- assertEquals("defaultTable.field_db", fieldUseDefault.getLocalName());
- }
-
- private void containsSpecimenCollectedCodeOrFail(Mapping mapping) {
-
- MappingField fld = mapping.getFieldByName(SPECIMEN_COLLECTED_CODE);
- assertNotNull(fld);
- assertTrue(fld.getType().equals(FieldType.DYNAMIC));
- assertFalse(fld.getType().equals(FieldType.CONSTANT));
- assertEquals("specimen_collected", fld.getDbName());
- assertEquals("specimen", fld.getTableName());
-
- }
-
- private void containsSpecimenContactEmailTextOrFail(Mapping mapping) {
- MappingField fld = mapping.getFieldByName(SPECIMEN_CONTACT_EMAIL_TEXT);
- assertNotNull(fld);
- assertEquals(fld.getConstantValue(), CONTACT_PERSON_EMAIL);
- assertTrue(fld.getType().equals(FieldType.CONSTANT));
- assertFalse(fld.getType().equals(FieldType.DYNAMIC));
- assertTrue(fld.getScope().equals(FieldScope.RETURN));
- assertFalse(fld.getScope().equals(FieldScope.QUERY));
-
- }
-
- private Mapping getMappingOrFail() {
- return getMappingOrFail("test-ps.xml");
- }
-
- private Mapping getMappingOrFail(String mapfile) {
- Mapping mapping = null;
-
- InputStream configFileIs = TestMappingReader.class
- .getResourceAsStream(mapfile);
-
- try {
- mapping = MappingReader.getMapping(configFileIs);
- } catch (Exception e) {
- LOG.log(Level.SEVERE, e.getMessage());
- fail(e.getMessage());
- }
-
- return mapping;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/test/java/org/apache/oodt/xmlps/product/TestXMLPSProductHandler.java
----------------------------------------------------------------------
diff --git a/xmlps/src/test/java/org/apache/oodt/xmlps/product/TestXMLPSProductHandler.java b/xmlps/src/test/java/org/apache/oodt/xmlps/product/TestXMLPSProductHandler.java
deleted file mode 100644
index a798d26..0000000
--- a/xmlps/src/test/java/org/apache/oodt/xmlps/product/TestXMLPSProductHandler.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.product;
-
-//JDK imports
-import java.util.List;
-import java.util.Set;
-
-//APACHE imports
-import org.apache.oodt.xmlps.mapping.DatabaseTable;
-import org.apache.oodt.xmlps.util.XMLQueryHelper;
-import org.apache.oodt.xmlquery.QueryElement;
-import org.apache.oodt.xmlquery.XMLQuery;
-
-//Junit imports
-import junit.framework.TestCase;
-
-/**
- * Tests the XMLPS product handler.
- */
-public class TestXMLPSProductHandler extends TestCase {
-
- private static final String expectedSpecimenFldName = "specimen.specimen_collected";
-
- private XMLPSProductHandler handler;
-
- private static final String specimenCollectedCodeField = "SPECIMEN_COLLECTED_CODE";
-
- private static final String studyProtocolIdField = "STUDY_PROTOCOL_ID";
-
- private static final String unconstrainedQuery = "RETURN = STUDY_PARTICIPANT_ID";
-
- private static final String queryStr = specimenCollectedCodeField
- + " = 3 AND " + studyProtocolIdField + " = 71 AND RETURN = "
- + specimenCollectedCodeField;
-
- public void setUp() {
- System.setProperty("org.apache.oodt.xmlps.xml.mapFilePath",
- "./src/test/resources/test-ps.xml");
-
- try {
- handler = new XMLPSProductHandler();
- } catch (InstantiationException e) {
- fail("Can't construct test suite: exception building test handler");
- }
- }
-
- public void testAllowUnConstrainedQuery(){
- XMLQuery query = XMLQueryHelper
- .getDefaultQueryFromQueryString(unconstrainedQuery);
-
-
- assertNotNull(query);
- assertNotNull(query.getWhereElementSet());
- assertTrue(query.getWhereElementSet().size() == 0);
- assertNotNull(query.getSelectElementSet());
- assertTrue(query.getSelectElementSet().size() == 1);
-
- try{
- handler.translateToDomain(query.getSelectElementSet(), true);
- }
- catch(Exception e){
- fail(e.getMessage());
- }
-
- try{
- handler.queryAndPackageResults(query);
- }
- catch(Exception e){
- fail(e.getMessage());
- }
-
- }
-
- public void testDomainTranslationWhereSet() {
- XMLQuery query = XMLQueryHelper
- .getDefaultQueryFromQueryString(queryStr);
-
- assertNotNull(query);
- assertNotNull(query.getWhereElementSet());
- assertEquals(7, query.getWhereElementSet().size());
-
- try {
- handler.translateToDomain(query.getWhereElementSet(), false);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- List<QueryElement> elemNames = handler
- .getElemNamesFromQueryElemSet(query.getWhereElementSet());
- assertNotNull(elemNames);
- assertEquals(1, elemNames.size()); // only 1 b/c one field is constant
-
- boolean gotSpecCollected = false;
- for (QueryElement elem : elemNames) {
- if (elem.getValue().equals("specimen.specimen_collected")) {
- gotSpecCollected = true;
- }
-
- }
-
- assertTrue(gotSpecCollected);
-
- }
-
- public void testDomainTranslationSelectSet() {
-
- XMLQuery query = XMLQueryHelper
- .getDefaultQueryFromQueryString(queryStr);
-
- assertNotNull(query);
- assertNotNull(query.getSelectElementSet());
- assertEquals(1, query.getSelectElementSet().size());
- try {
- handler.translateToDomain(query.getSelectElementSet(), true);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- assertNotNull(query.getSelectElementSet());
- assertEquals(1, query.getSelectElementSet().size());
- assertNotNull(query.getSelectElementSet().get(0));
- QueryElement elem = (QueryElement) query.getSelectElementSet().get(0);
- assertNotNull(elem.getValue());
- assertEquals("Expected: [" + expectedSpecimenFldName + "]: got: ["
- + elem.getValue() + "]", elem.getValue(),
- expectedSpecimenFldName);
-
- }
-
- public void testGetRequiredTables() {
- System.setProperty("org.apache.oodt.xmlps.xml.mapFilePath",
- "./src/test/resources/test-required-tables-ps.xml");
-
- try {
- handler = new XMLPSProductHandler();
- } catch (InstantiationException e) {
- fail(e.getMessage());
- }
-
- String queryStr = "RETURN = id AND RETURN = id_1 AND RETURN = id_2 AND RETURN = id_3 AND RETURN = id_4";
- XMLQuery query = XMLQueryHelper.getDefaultQueryFromQueryString(queryStr);
-
- List<QueryElement> where = query.getWhereElementSet();
- List<QueryElement> select = query.getSelectElementSet();
-
- try {
- handler.translateToDomain(where, false);
- handler.translateToDomain(select, true);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- List<QueryElement> whereNames = handler.getElemNamesFromQueryElemSet(where);
- List<QueryElement> selectNames = handler.getElemNamesFromQueryElemSet(select);
-
- Set<DatabaseTable> tables = handler.getRequiredTables(whereNames, selectNames);
-
- assertEquals(7, tables.size());
- assertTrue(tables.contains(handler.mapping.getTableByName("joinToDefault")));
- assertTrue(tables.contains(handler.mapping.getTableByName("joinToExtraDefault")));
- assertTrue(tables.contains(handler.mapping.getTableByName("joinToExtraJoin")));
- assertTrue(tables.contains(handler.mapping.getTableByName("joinToExtraOther")));
- assertTrue(tables.contains(handler.mapping.getTableByName("extraDefault")));
- assertTrue(tables.contains(handler.mapping.getTableByName("extraOther")));
- assertTrue(tables.contains(handler.mapping.getTableByName("other")));
- assertTrue(!tables.contains(handler.mapping.getTableByName("another")));
- }
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/test/java/org/apache/oodt/xmlps/profile/TestXMLPSProfileHandler.java
----------------------------------------------------------------------
diff --git a/xmlps/src/test/java/org/apache/oodt/xmlps/profile/TestXMLPSProfileHandler.java b/xmlps/src/test/java/org/apache/oodt/xmlps/profile/TestXMLPSProfileHandler.java
deleted file mode 100644
index 818d842..0000000
--- a/xmlps/src/test/java/org/apache/oodt/xmlps/profile/TestXMLPSProfileHandler.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.profile;
-
-//APACHE imports
-import org.apache.oodt.xmlps.util.XMLQueryHelper;
-import org.apache.oodt.xmlquery.XMLQuery;
-
-//Junit imports
-import junit.framework.TestCase;
-
-/**
- * Tests the XMLPS profile handler.
- */
-public class TestXMLPSProfileHandler extends TestCase {
-
- private static XMLPSProfileHandler handler;
-
- private static final String unconstrainedQuery = "RETURN = STUDY_PARTICIPANT_ID";
-
- public TestXMLPSProfileHandler() {
- System.setProperty("org.apache.oodt.xmlps.profile.xml.mapFilePath",
- "./src/test/resources/test-ps.xml");
-
- try {
- handler = new XMLPSProfileHandler();
- } catch (InstantiationException e) {
- fail("Can't construct test suite: exception building test handler");
- }
- }
-
- public void testAllowUnConstrainedQuery() {
- XMLQuery query = XMLQueryHelper
- .getDefaultQueryFromQueryString(unconstrainedQuery);
-
- assertNotNull(query);
- assertNotNull(query.getWhereElementSet());
- assertTrue(query.getWhereElementSet().size() == 0);
- assertNotNull(query.getSelectElementSet());
- assertTrue(query.getSelectElementSet().size() == 1);
-
- try {
- handler.translateToDomain(query.getSelectElementSet(), true);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- try {
- handler.queryAndPackageProfiles(query);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/test/java/org/apache/oodt/xmlps/queryparser/TestHandlerQueryParser.java
----------------------------------------------------------------------
diff --git a/xmlps/src/test/java/org/apache/oodt/xmlps/queryparser/TestHandlerQueryParser.java b/xmlps/src/test/java/org/apache/oodt/xmlps/queryparser/TestHandlerQueryParser.java
deleted file mode 100644
index 4591927..0000000
--- a/xmlps/src/test/java/org/apache/oodt/xmlps/queryparser/TestHandlerQueryParser.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.queryparser;
-
-//APACHE imports
-import org.apache.oodt.xmlps.mapping.Mapping;
-import org.apache.oodt.xmlps.mapping.MappingField;
-import org.apache.oodt.xmlps.queryparser.Expression;
-import org.apache.oodt.xmlps.queryparser.HandlerQueryParser;
-import org.apache.oodt.xmlps.util.XMLQueryHelper;
-import org.apache.oodt.xmlquery.QueryElement;
-import org.apache.oodt.xmlquery.XMLQuery;
-
-//JDK imports
-import java.util.List;
-import java.util.Stack;
-
-//Junit imports
-import junit.framework.TestCase;
-
-/**
- * Tests the XMLPS query handler parser.
- */
-public class TestHandlerQueryParser extends TestCase {
-
- public TestHandlerQueryParser() {
- }
-
- public void testParseQuery() {
- String queryStr = "A = B AND C = D";
- String expected = "(C = D AND A = B)";
-
- XMLQuery query = XMLQueryHelper.getDefaultQueryFromQueryString(queryStr);
- assertNotNull(query);
- Stack<QueryElement> queryStack = HandlerQueryParser.createQueryStack(query
- .getWhereElementSet());
- assertNotNull(queryStack);
- Expression parsedQuery = HandlerQueryParser.parse(queryStack);
- assertNotNull(parsedQuery);
- assertEquals(expected, parsedQuery.evaluate());
- }
-
- public void testParseWildcardWithMapping(){
- String queryStr = "bar LIKE 'FOO'";
- String expected = "bar LIKE '%FOO%'";
- Mapping mapping = new Mapping();
- MappingField mf = new MappingField();
- mf.setDbName("bar");
- mf.setName("foo");
- mf.setString(true);
- mapping.addField("foo", mf);
-
- XMLQuery query = XMLQueryHelper.getDefaultQueryFromQueryString(queryStr);
- assertNotNull(query);
- Stack<QueryElement> queryStack = HandlerQueryParser.createQueryStack(query
- .getWhereElementSet());
- assertNotNull(queryStack);
- Expression parsedQuery = HandlerQueryParser.parse(queryStack, mapping);
- assertNotNull(parsedQuery);
- assertEquals(expected, parsedQuery.evaluate());
- }
-
- private Mapping createFooBarMapping() {
- Mapping m = new Mapping();
- MappingField foof = new MappingField();
- foof.setName("foo");
- foof.setDbName("foo");
- foof.setString(true);
- MappingField barf = new MappingField();
- barf.setName("bar");
- barf.setDbName("bar");
- barf.setString(true);
- m.addField("foo", foof);
- m.addField("bar", barf);
- return m;
- }
-
- public void testParseLiteralQuotesWithParen() {
- Mapping m = createFooBarMapping();
-
- String q = "(foo = 'yes' OR bar = 'no') AND RETURN = foo AND RETURN = bar";
- String expected = "(bar = 'no' OR foo = 'yes')";
-
- XMLQuery query = XMLQueryHelper.getDefaultQueryFromQueryString(q);
- assertNotNull(query);
- Stack<QueryElement> where = HandlerQueryParser.createQueryStack(query.getWhereElementSet());
- assertNotNull(where);
- List<QueryElement> select = query.getSelectElementSet();
- assertNotNull(select);
-
- Expression parsed = HandlerQueryParser.parse(where, m);
- assertNotNull(parsed);
- assertEquals(expected, parsed.evaluate());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/test/java/org/apache/oodt/xmlps/structs/TestCDEResult.java
----------------------------------------------------------------------
diff --git a/xmlps/src/test/java/org/apache/oodt/xmlps/structs/TestCDEResult.java b/xmlps/src/test/java/org/apache/oodt/xmlps/structs/TestCDEResult.java
deleted file mode 100644
index 3cf23b3..0000000
--- a/xmlps/src/test/java/org/apache/oodt/xmlps/structs/TestCDEResult.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.structs;
-
-import static org.easymock.EasyMock.expect;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
-
-public class TestCDEResult extends TestCase {
-
- private static final String ID = "123";
- private static final String LAST = "doe";
- private static final String FIRST = "john";
- private static final String DOB = "1980-01-01 00:00:00.0";
-
- private static final String ID1 = "321";
- private static final String LAST1 = "smith";
- private static final String FIRST1 = "jane";
- private static final String DOB1 = "1990-01-01 00:00:00.0";
-
- private static final String FS = "\t";
- private static final String RS = "$";
-
- private ResultSet rs;
- private Connection con;
- private ResultSetMetaData rsmet;
- private CDEResult result;
- private IMocksControl ctrl;
-
- @Override
- protected void setUp() throws Exception {
- ctrl = EasyMock.createNiceControl();
- rs = ctrl.createMock(ResultSet.class);
- con = ctrl.createMock(Connection.class);
- rsmet = ctrl.createMock(ResultSetMetaData.class);
- expect(rs.next()).andReturn(true);
- expect(rsmet.getColumnCount()).andReturn(4).anyTimes();
- expect(rs.getMetaData()).andReturn(rsmet).anyTimes();
- expect(rs.getString(1)).andReturn(ID);
- expect(rs.getString(2)).andReturn(LAST);
- expect(rs.getString(3)).andReturn(FIRST);
- expect(rs.getString(4)).andReturn(DOB);
- expect(rs.next()).andReturn(true);
- expect(rs.getString(1)).andReturn(ID1);
- expect(rs.getString(2)).andReturn(LAST1);
- expect(rs.getString(3)).andReturn(FIRST1);
- expect(rs.getString(4)).andReturn(DOB1);
- expect(rs.next()).andReturn(false);
- ctrl.replay();
- result = new CDEResult(rs,con);
- }
-
- public void testGetInputStream() {
- InputStream in = null;
- try {
- in = result.getInputStream();
- } catch (IOException e) {
- fail("Could not get inputstream: " + e.getMessage());
- }
- assertNotNull(in);
- assertEquals(CDEResultInputStream.class, in.getClass());
-
- boolean thrown = false;
- try {
- in = new CDEResult(null, con).getInputStream();
- } catch (IOException e) {
- thrown = true;
- }
- assertTrue("InputStream should throw IOException with null ResultSet!", thrown);
-
- thrown = false;
- try {
- in = new CDEResult(rs, null).getInputStream();
- } catch (IOException e) {
- thrown = true;
- }
- assertTrue("InputStream should throw IOException with null Connection!", thrown);
- }
-
- public void testGetNextRowAsString() {
- try {
- assertEquals(ID + FS + LAST + FS + FIRST + FS + DOB + RS, result.getNextRowAsString());
- assertEquals(ID1 + FS + LAST1 + FS + FIRST1 + FS + DOB1 + RS, result.getNextRowAsString());
- } catch (SQLException e) {
- fail("Could not get next row: " + e.getMessage());
- }
- }
-
- public void testGetMimeType() {
- assertEquals("text/plain", result.getMimeType());
- }
-
- public void testGetSize() {
- assertEquals(-1, result.getSize());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/test/java/org/apache/oodt/xmlps/structs/TestCDEResultInputStream.java
----------------------------------------------------------------------
diff --git a/xmlps/src/test/java/org/apache/oodt/xmlps/structs/TestCDEResultInputStream.java b/xmlps/src/test/java/org/apache/oodt/xmlps/structs/TestCDEResultInputStream.java
deleted file mode 100644
index fd01cc5..0000000
--- a/xmlps/src/test/java/org/apache/oodt/xmlps/structs/TestCDEResultInputStream.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oodt.xmlps.structs;
-
-import static org.easymock.EasyMock.expect;
-
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-
-import junit.framework.TestCase;
-
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
-
-public class TestCDEResultInputStream extends TestCase {
-
- private static final String ID = "123";
- private static final String LAST = "doe";
- private static final String FIRST = "john";
- private static final String DOB = "1980-01-01 00:00:00.0";
-
- private static final String ID1 = "321";
- private static final String LAST1 = "smith";
- private static final String FIRST1 = "jane";
- private static final String DOB1 = "1990-01-01 00:00:00.0";
-
- private static final String FS = "\t";
- private static final String RS = "$";
-
- private ResultSet rs;
- private Connection con;
- private ResultSetMetaData rsmet;
- private CDEResult result;
- private CDEResultInputStream in;
- private IMocksControl ctrl;
-
- @Override
- protected void setUp() throws Exception {
- ctrl = EasyMock.createNiceControl();
- rs = ctrl.createMock(ResultSet.class);
- con = ctrl.createMock(Connection.class);
- rsmet = ctrl.createMock(ResultSetMetaData.class);
- expect(rs.next()).andReturn(true);
- expect(rsmet.getColumnCount()).andReturn(4).anyTimes();
- expect(rs.getMetaData()).andReturn(rsmet).anyTimes();
- expect(rs.getString(1)).andReturn(ID);
- expect(rs.getString(2)).andReturn(LAST);
- expect(rs.getString(3)).andReturn(FIRST);
- expect(rs.getString(4)).andReturn(DOB);
- expect(rs.next()).andReturn(true);
- expect(rs.getString(1)).andReturn(ID1);
- expect(rs.getString(2)).andReturn(LAST1);
- expect(rs.getString(3)).andReturn(FIRST1);
- expect(rs.getString(4)).andReturn(DOB1);
- expect(rs.next()).andReturn(false);
- ctrl.replay();
- result = new CDEResult(rs,con);
- in = new CDEResultInputStream(result);
- }
-
- @Override
- protected void tearDown() throws Exception {
- in.close();
- }
-
- public void testRead() {
- String expected = ID + FS + LAST + FS + FIRST + FS + DOB + RS;
- String expected1 = ID1 + FS + LAST1 + FS + FIRST1 + FS + DOB1 + RS;
- try {
- for (int i = 0; i < expected.length(); i++) {
- assertEquals((int)expected.charAt(i), in.read());
- }
- for (int i = 0; i < expected1.length(); i++) {
- assertEquals((int)expected1.charAt(i), in.read());
- }
- assertEquals(-1, in.read());
- } catch (IOException e) {
- fail("IOException: " + e.getMessage());
- }
- }
-
- public void testReadCharArrayIntInt() {
- byte[] buf = new byte[128];
- int n;
- int length;
- String expected;
-
- try {
- expected = ID + FS + LAST;
- length = expected.length();
- n = in.read(buf, 0, length);
- assertEquals(length, n);
- assertEquals(expected, new String(buf, 0, n));
-
- expected = FS + FIRST;
- length = expected.length();
- n = in.read(buf, 0, length);
- assertEquals(length, n);
- assertEquals(expected, new String(buf, 0, n));
-
- expected = FS + DOB.substring(0, length-1);
- length = expected.length();
- n = in.read(buf, 0, length);
- assertEquals(length, n);
- assertEquals(expected, new String(buf, 0, n));
-
- expected = DOB.substring(4) + RS + ID1 + FS + LAST1 + FS + FIRST1 + FS + DOB1 + RS;
- length = buf.length;
- n = in.read(buf, 0, length);
- assertEquals(expected.length(), n);
- assertEquals(expected, new String(buf, 0, n));
-
- n = in.read(buf, 0, 10);
- assertEquals(-1, n);
- } catch (IOException e) {
- fail("IOException: " + e.getMessage());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/test/resources/loging.properties
----------------------------------------------------------------------
diff --git a/xmlps/src/test/resources/loging.properties b/xmlps/src/test/resources/loging.properties
deleted file mode 100644
index 215e4a5..0000000
--- a/xmlps/src/test/resources/loging.properties
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-# Specify the handlers to create in the root logger
-# (all loggers are children of the root logger)
-# The following creates one handlers
-handlers = java.util.logging.ConsoleHandler
-
-# Set the default logging level for the root logger
-.level = ALL
-
-# Set the default logging level for new ConsoleHandler instances
-java.util.logging.ConsoleHandler.level = ALL
-
-# Set the default formatter for new ConsoleHandler instances
-java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
-
-# Set the default logging level
-# disable output of INFO messages from product handler
-org.apache.oodt.xmlps.product.level = SEVERE
-org.apache.oodt.xmlps.profile.level = SEVERE
http://git-wip-us.apache.org/repos/asf/oodt/blob/098cc4fa/xmlps/src/test/resources/test-ps.xml
----------------------------------------------------------------------
diff --git a/xmlps/src/test/resources/test-ps.xml b/xmlps/src/test/resources/test-ps.xml
deleted file mode 100644
index c073fc3..0000000
--- a/xmlps/src/test/resources/test-ps.xml
+++ /dev/null
@@ -1,120 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-<oodt:ps xmlns:oodt="http://oodt.jpl.nasa.gov/xmlps/1.0" name="Test Query Handler" id="urn:oodt:xmlps:testps">
-<tables default="baseline">
- <table name="specimen" join="patient_id" tofld="participant_num"/>
-</tables>
-
- <!--
- field:
-
- type (required): dyanmic or constant. If you choose dynamic, then the field
- value is read from the row in the ResultSet returned
- from the database. If constant, then each returned row
- from the ResultSet is annotated with the value specified
- in the 'value' attribute.
-
- dbname (optional): the name of the field within the underlying db. If not
- specified, then assumed to be name
-
- name (required): the name of the attribute that you want returned
- in the product server.
-
- table (optional): if provided, then the attribute a is selected as
- 'table'.'a',and then returned. If omitted, the attribute
- is assumed to come from the default table returned from the
- PS query.
-
- value (optional): is necessary to provide if type='constant' is selected.
-
- scope (optional): limits the scope of a field's existance: acceptable values
- are "query", which signifies that the field is only applicable when
- translating queries: and "return", which signifies the field is only
- applicable as a return field when converting database results into ERNEResults.
-
- -->
- <field type="dynamic" dbname="specimen_collected" table="specimen"
- name="SPECIMEN_COLLECTED_CODE" appendTableName="true"/>
- <field type="constant" name="STUDY_SITE_ID" value="71" />
- <field type="constant" name="STUDY_PROTOCOL_ID" value="XX" />
- <field type="dynamic" dbname="" name="STUDY_PARTICIPANT_ID" />
- <field type="constant" name="SPECIMEN_STUDY-DESIGN_CODE"
- value="prospective" />
- <field type="constant" name="SPECIMEN_CONTACT_NAME-TEXT"
- value="Brendan Phalan" />
- <field type="constant" name="SPECIMEN_CONTACT-EMAIL_TEXT"
- value="Brendan.Phalan@med.nyu.edu" scope="return"/>
- <field type="constant" name="BASELINE_DEMOGRAPHICS-GENDER_CODE"
- value="1" />
- <field type="constant" name="BASELINE_DEMOGRAPHICS-ETHNIC_CODE"
- value="1" />
- <field type="constant" name="BASELINE_DEMOGRAPHICS_RACE_CODE"
- value="1" />
- <field type="dynamic" name="BASELINE_DEMOGRAPHICS-RACE_OTHER_TEXT" />
- <field type="dynamic" name="BASELINE_DEMOGRAPHICS-BIRTH-YEAR_TEXT" />
- <field type="dynamic" name="BASELINE_SMOKE-REGULAR_1YEAR_CODE" />
- <field type="dynamic"
- name="BASELINE_SMOKE-HX_BEGIN-AGE-REGULAR_VALUE" />
- <field type="dynamic" name="BASELINE_SMOKE-HX_AVERAGE-DAY_VALUE" />
- <field type="dynamic" name="BASELINE_SMOKE-HX_QUIT-AGE_VALUE" />
- <field type="dynamic" name="BASELINE_CANCER-CONFIRMATION_CODE" />
- <field type="constant" name="BASELINE_CANCER-ICD9-CODE"
- value="UNKNOWN" />
- <field type="constant" name="BASELINE_CANCER-DIAGNOSIS_YEAR_TEXT"
- value="UNKNOWN" />
- <field type="constant" name="BASELINE_CANCER-AGE-DIAGNOSIS_VALUE"
- value="UNKNOWN" />
- <field type="dynamic"
- name="BASELINE_FAMILY_CANCER-CONFIRMATION_CODE" />
- <field type="dynamic" name="BASELINE_FAMILY_CANCER-LOCATION_CODE" />
- <field type="constant"
- name="BASELINE_FAMILY_CANCER-LOCATION-OTHER_TEXT" value="UNKNOWN" />
- <field type="dynamic" name="SPECIMEN_COLLECTION_TEXT" />
- <field type="dynamic" name="SPECIMEN_STORED_CODE" />
- <field type="dynamic" name="SPECIMEN_FINAL-STORE_CODE" />
- <field type="constant" name="SPECIMEN_FINAL-STORE-OTHER_TEXT"
- value="UNKNOWN" />
- <field type="dynamic" name="SPECIMEN_DAY-COLLECTED_VALUE" />
- <field type="constant" name="SPECIMEN_DAY-CA-DIAGNOSIS_VALUE"
- value="UNKNOWN" />
- <field type="dynamic" name="SPECIMEN_AGE-COLLECTED_VALUE" />
- <field type="dynamic" name="SPECIMEN_AMOUNT-STORED_VALUE" />
- <field type="constant" name="SPECIMEN_AMOUNT-STORED-UNIT_CODE"
- value="1" />
- <field type="dynamic" name="SPECIMEN_AMOUNT_REMAINING_VALUE" />
- <field type="dynamic" name="SPECIMEN_AMOUNT_REMAINING_UNIT_CODE" />
- <field type="dynamic" name="SPECIMEN_CONCENTRATION_VALUE" />
- <field type="dynamic" name="SPECIMEN_AVAILABLE_CODE" />
- <field type="dynamic" name="SPECIMEN_TISSUE_ORGAN-SITE_CODE">
- <translate>
- <func class="org.apache.oodt.xmlps.mapping.funcs.ReplaceFunc" orig="16" with="1" />
- </translate>
- </field>
- <field type="constant" name="SPECIMEN_TISSUE-ORGAN-SITE-OTHER_TEXT"
- value="UNKNOWN" />
- <field type="constant" name="SPECIMEN_TISSUE_DEGREE-INVASIVE_CODE"
- value="UNKNOWN" />
- <field type="constant"
- name="SPECIMEN_TISSUE_DEGREE-INVASIVE-TUMOR_CODE" value="UNKNOWN" />
- <field type="constant" name="SPECIMEN_BONE-MARROW_BLAST_VALUE"
- value="UNKNOWN" />
- <field type="constant" name="SPECIMEN_SPUTUM_PRESERVATIVE_CODE"
- value="UNKNOWN" />
- <field type="constant"
- name="SPECIMEN_SPUTUM-PRESERVATIVE-OTHER_TEXT" value="UNKOWN" />
-</oodt:ps>
\ No newline at end of file