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 2010/09/16 06:04:31 UTC

svn commit: r997583 [2/2] - in /incubator/oodt/trunk: ./ xmlps/ xmlps/src/ xmlps/src/main/ xmlps/src/main/conf/ xmlps/src/main/java/ xmlps/src/main/java/org/ xmlps/src/main/java/org/apache/ xmlps/src/main/java/org/apache/oodt/ xmlps/src/main/java/org/a...

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/profile/XMLPSProfileHandler.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/profile/XMLPSProfileHandler.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/profile/XMLPSProfileHandler.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/profile/XMLPSProfileHandler.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,206 @@
+/**
+ * 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;
+
+//OODT imports
+import org.apache.oodt.xmlps.mapping.DatabaseTable;
+import org.apache.oodt.xmlps.mapping.MappingReader;
+import org.apache.oodt.xmlps.product.XMLPSProductHandler;
+import org.apache.oodt.xmlps.profile.DBMSExecutor;
+import org.apache.oodt.xmlps.queryparser.Expression;
+import org.apache.oodt.xmlps.queryparser.HandlerQueryParser;
+
+//JDK imports
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Stack;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//OODT imports
+import org.apache.oodt.profile.Profile;
+import org.apache.oodt.profile.ProfileException;
+import org.apache.oodt.profile.handlers.ProfileHandler;
+import org.apache.oodt.xmlquery.QueryElement;
+import org.apache.oodt.xmlquery.XMLQuery;
+
+/**
+ * 
+ * <p>
+ * An implementation of a {@link ProfileHandler} that extends the capabilities
+ * of the {@link XMLPSProductHandler}, and uses the XML Specification defined
+ * by the mapping file to represent its field mapping information.
+ * </p>.
+ */
+public class XMLPSProfileHandler extends XMLPSProductHandler implements
+        ProfileHandler {
+
+    private DBMSExecutor executor;
+
+    /* our log stream */
+    private static final Logger LOG = Logger.getLogger(XMLPSProfileHandler.class
+            .getName());
+
+    private String resLocationSpec;
+
+    public XMLPSProfileHandler() throws InstantiationException {
+        super(null);
+        String mappingFilePath = System
+                .getProperty("org.apache.oodt.xmlps.profile.xml.mapFilePath");
+
+        if (mappingFilePath == null) {
+            throw new InstantiationException(
+                    "Need to specify path to xml mapping file!");
+        }
+
+        try {
+            mapping = MappingReader.getMapping(mappingFilePath);
+        } catch (Exception e) {
+            throw new InstantiationException(
+                    "Unable to parse profile mapping xml file: ["
+                            + mappingFilePath + "]: reason: "
+                            + e.getMessage());
+        }
+
+        // load the db properties file
+                // if one exists: otherwise, don't bother and just print out the SQL to
+        // the console.
+        // 
+        String dbPropFilePath = System
+                .getProperty("org.apache.oodt.xmlps.profile.xml.dbPropFilePath");
+        if (dbPropFilePath != null) {
+            try {
+                System.getProperties()
+                        .load(new FileInputStream(dbPropFilePath));
+            } catch (FileNotFoundException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+                throw new InstantiationException(e.getMessage());
+            }
+
+            executor = new DBMSExecutor();
+        }
+
+        this.resLocationSpec = System
+                .getProperty("org.apache.oodt.xmlps.profile.xml.resLocationSpec");
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.oodt.profile.handlers.ProfileHandler#findProfiles(org.apache.oodt.xmlquery.XMLQuery)
+     */
+    public List<Profile> findProfiles(XMLQuery query) throws ProfileException {
+        List<QueryElement> whereSet = query.getWhereElementSet();
+        List<QueryElement> selectSet = query.getSelectElementSet();
+        try {
+            translateToDomain(selectSet, true);
+            translateToDomain(whereSet, false);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new ProfileException(e.getMessage());
+        }
+        List<Profile> profs = queryAndPackageProfiles(query);
+        return profs;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.oodt.profile.handlers.ProfileHandler#get(java.lang.String)
+     */
+    public Profile get(String id) throws ProfileException {
+        throw new ProfileException("Method not implemented!");
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.oodt.profile.handlers.ProfileHandler#getID()
+     */
+    public String getID() {
+        return mapping.getId();
+    }
+
+    protected List<Profile> queryAndPackageProfiles(XMLQuery query) {
+        Stack<QueryElement> queryStack = HandlerQueryParser
+                .createQueryStack(query.getWhereElementSet());
+        Expression parsedQuery = HandlerQueryParser.parse(queryStack,
+                this.mapping);
+        List<Profile> profs = null;
+
+        StringBuffer sqlBuf = new StringBuffer("SELECT *");
+        sqlBuf.append(" FROM ");
+        sqlBuf.append(mapping.getDefaultTable());
+        sqlBuf.append(" ");
+
+        if (mapping.getNumTables() > 0) {
+            for (Iterator<String> i = mapping.getTableNames().iterator(); i
+                    .hasNext();) {
+                String tableName = i.next();
+                DatabaseTable tbl = mapping.getTableByName(tableName);
+                sqlBuf.append("INNER JOIN ");
+                sqlBuf.append(tbl.getName());
+                sqlBuf.append(" ON ");
+                sqlBuf.append(tbl.getName());
+                sqlBuf.append(".");
+                sqlBuf.append(tbl.getJoinFieldName());
+                sqlBuf.append(" = ");
+                sqlBuf.append((tbl.getDefaultTableJoin() != null && !tbl
+                        .getDefaultTableJoin().equals("")) ? tbl
+                        .getDefaultTableJoin() : mapping.getDefaultTable());
+                sqlBuf.append(".");
+                sqlBuf.append(tbl.getDefaultTableJoinFieldName());
+                sqlBuf.append(" ");
+            }
+        }
+
+        if (parsedQuery != null) {
+            sqlBuf.append(" WHERE ");
+            sqlBuf.append(parsedQuery.evaluate());
+        }
+
+        LOG.log(Level.INFO, sqlBuf.toString());
+
+        if (executor != null) {
+            try {
+                profs = executor.executeLocalQuery(this.mapping, sqlBuf
+                        .toString(), this.resLocationSpec);
+
+            } catch (SQLException e) {
+                e.printStackTrace();
+                LOG.log(Level.WARNING, "Error executing sql: ["
+                        + sqlBuf.toString() + "]: Message: " + e.getMessage());
+            }
+        }
+
+        return profs;
+    }
+
+    protected void translateToDomain(List<QueryElement> elemSet,
+            boolean selectSet) throws Exception {
+        super.translateToDomain(elemSet, selectSet);
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/profile/XMLPSProfileHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/AndExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/AndExpression.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/AndExpression.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/AndExpression.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,30 @@
+/**
+ * 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 logical and expression</p>.
+ */
+public class AndExpression extends LogOpExpression implements ParseConstants{
+
+    public AndExpression(Expression lhs, Expression rhs) {
+        super(SQL_AND, lhs, rhs);
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/AndExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ContainsExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ContainsExpression.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ContainsExpression.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ContainsExpression.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,30 @@
+/**
+ * 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 contains expression.
+ */
+public class ContainsExpression extends RelOpExpression implements ParseConstants {
+
+    public ContainsExpression(String lhs, Expression literal) {
+        super(SQL_LIKE, lhs, literal);
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ContainsExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/EqualsExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/EqualsExpression.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/EqualsExpression.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/EqualsExpression.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,30 @@
+/**
+ * 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;
+
+/**
+ * 
+ * Operator equals expression.
+ */
+public class EqualsExpression extends RelOpExpression implements ParseConstants {
+
+    public EqualsExpression(String lhs, Expression literal) {
+        super(SQL_EQUAL, lhs, literal);
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/EqualsExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Expression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Expression.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Expression.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Expression.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,34 @@
+/**
+ * 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.
+     */
+    public String evaluate();
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Expression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanEqualsExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanEqualsExpression.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanEqualsExpression.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanEqualsExpression.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,31 @@
+/**
+ * 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);
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanEqualsExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanExpression.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanExpression.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanExpression.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,31 @@
+/**
+ * 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);
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/GreaterThanExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/HandlerQueryParser.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/HandlerQueryParser.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/HandlerQueryParser.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/HandlerQueryParser.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,129 @@
+/**
+ * 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 java.util.List;
+import java.util.Stack;
+
+//OODT imports
+import org.apache.oodt.xmlquery.QueryElement;
+import org.apache.oodt.xmlquery.XMLQuery;
+
+/**
+ * 
+ * Parsers the {@link 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 XMLQuery#getWhereElementSet()}.
+   * @return The parsed {@link Expression} tree.
+   */
+  public static Expression parse(Stack<QueryElement> queryStack) {
+    return parse(queryStack, null);
+  }
+
+  /**
+   * 
+   * Parses the {@link XMLQuery#getWhereElementSet()} using the provided
+   * <param>map</param>.
+   * 
+   * @param queryStack The {@link 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 = null;
+
+    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), parse(queryStack, map));
+      } else if (logOpType.equalsIgnoreCase(XMLQUERY_OR)) {
+        return new OrExpression(parse(queryStack), 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 (int i = 0; i < l.size(); i++) {
+      ret.push(l.get(i));
+    }
+
+    return ret;
+
+  }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/HandlerQueryParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanEqualsExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanEqualsExpression.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanEqualsExpression.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanEqualsExpression.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,33 @@
+/**
+ * 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);
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanEqualsExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanExpression.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanExpression.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanExpression.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,33 @@
+/**
+ * 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);
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LessThanExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Literal.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Literal.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Literal.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Literal.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,39 @@
+/**
+ * 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;
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/Literal.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LogOpExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LogOpExpression.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LogOpExpression.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LogOpExpression.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,79 @@
+/**
+ * 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;
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/LogOpExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/OrExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/OrExpression.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/OrExpression.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/OrExpression.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,30 @@
+/**
+ * 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);
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/OrExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ParseConstants.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ParseConstants.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ParseConstants.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ParseConstants.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,65 @@
+/**
+ * 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 {
+    
+    public final static String XMLQUERY_LOGOP = "LOGOP";
+    
+    public final static String XMLQUERY_AND = "AND";
+    
+    public final static String XMLQUERY_OR = "OR";
+    
+    public final static String XMLQUERY_RELOP = "RELOP";
+    
+    public final static String XMLQUERY_EQUAL = "EQ";
+    
+    public final static String XMLQUERY_LIKE = "LIKE";
+    
+    public final static String XMLQUERY_GREATER_THAN = "GT";
+    
+    public final static String XMLQUERY_GREATER_THAN_OR_EQUAL_TO = "GE";
+    
+    public final static String XMLQUERY_LESS_THAN = "LT";
+    
+    public final static String XMLQUERY_LESS_THAN_OR_EQUAL_TO = "LE";
+    
+    public final static String XMLQUERY_LITERAL = "LITERAL";
+    
+    
+    public final static String SQL_LIKE = "LIKE";
+    
+    public final static String SQL_EQUAL = "=";
+    
+    public final static String SQL_AND = "AND";
+    
+    public final static String SQL_OR = "OR";
+    
+    public final static String SQL_GREATER_THAN_OR_EQUAL_TO = ">=";
+    
+    public final static String SQL_GREATER_THAN = ">";
+    
+    public final static String SQL_LESS_THAN = "<";
+    
+    public final static String SQL_LESS_THAN_OR_EQUAL_TO = "<=";
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/ParseConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/RelOpExpression.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/RelOpExpression.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/RelOpExpression.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/RelOpExpression.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,75 @@
+/**
+ * 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;
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/RelOpExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/WildcardLiteral.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/WildcardLiteral.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/WildcardLiteral.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/WildcardLiteral.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,43 @@
+/**
+ * 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() {
+        return "%" + val + "%";
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/queryparser/WildcardLiteral.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEResult.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEResult.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEResult.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEResult.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,92 @@
+/**
+ * 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.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.commons.util.DateConvert;
+import org.apache.oodt.xmlquery.Result;
+
+/**
+ * 
+ * <p>
+ * A {@link List} of {@link CDERow}s returned from a query against a
+ * Product Server.
+ * </p>.
+ */
+public class CDEResult {
+
+    private List<CDERow> rows;
+
+    private static final String ROW_TERMINATOR = "$";
+
+    public CDEResult() {
+        rows = new Vector<CDERow>();
+    }
+
+    public Result toResult() {
+        String strVal = toString();
+        if (strVal == null || (strVal != null && strVal.equals(""))) {
+            return null;
+        }
+
+        Result r = new Result();
+        r.setID(DateConvert.isoFormat(new Date()));
+        r.setMimeType("text/plain");
+        r.setResourceID("UNKNOWN");
+        r.setValue(toString());
+        return r;
+    }
+
+    public String toString() {
+        StringBuffer rStr = new StringBuffer();
+        if (rows != null && rows.size() > 0) {
+            for (Iterator<CDERow> i = rows.iterator(); i.hasNext();) {
+                CDERow row = i.next();
+                rStr.append(row.toString());
+                rStr.append(ROW_TERMINATOR);
+            }
+
+            rStr.deleteCharAt(rStr.length() - 1);
+        }
+
+        return rStr.toString();
+
+    }
+
+    /**
+     * @return the rows
+     */
+    public List<CDERow> getRows() {
+        return rows;
+    }
+
+    /**
+     * @param rows
+     *            the rows to set
+     */
+    public void setRows(List<CDERow> rows) {
+        this.rows = rows;
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEResult.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDERow.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDERow.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDERow.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDERow.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,72 @@
+/**
+ * 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.Iterator;
+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() {
+        StringBuffer rStr = new StringBuffer();
+        if (vals != null && vals.size() > 0) {
+            for (Iterator<CDEValue> i = vals.iterator(); i.hasNext();) {
+                CDEValue v = i.next();
+                rStr.append(v.getVal() + 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;
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDERow.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEValue.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEValue.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEValue.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEValue.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,74 @@
+/**
+ * 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+"]";
+    }
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/structs/CDEValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/GenericCDEObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/GenericCDEObjectFactory.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/GenericCDEObjectFactory.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/GenericCDEObjectFactory.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,69 @@
+/**
+ * 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 java.util.logging.Level;
+import java.util.logging.Logger;
+
+//OODT imports
+import org.apache.oodt.xmlps.mapping.funcs.MappingFunc;
+
+/**
+ * 
+ * <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 = null;
+        Class funcClazz;
+        try {
+            funcClazz = Class.forName(className);
+            func = (MappingFunc) funcClazz.newInstance();
+            return func;
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+            LOG.log(Level.WARNING, "Unable to load class: [" + className
+                    + "]: class not found! message: " + e.getMessage(), e);
+            return null;
+        } catch (InstantiationException e) {
+            e.printStackTrace();
+            LOG.log(Level.WARNING, "Unable to load class: [" + className
+                    + "]: cannot instantiate! message: " + e.getMessage(), e);
+            return null;
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+            LOG.log(Level.WARNING, "Unable to load class: [" + className
+                    + "]: illegal access! message: " + e.getMessage(), e);
+            return null;
+        }
+
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/GenericCDEObjectFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryHelper.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryHelper.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryHelper.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryHelper.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,38 @@
+/**
+ * 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 */);
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryKeys.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryKeys.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryKeys.java (added)
+++ incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryKeys.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,30 @@
+/**
+ * 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 {
+    
+    public static final String ROLE_LITERAL = "LITERAL";
+    
+    public static final String ROLE_ELEMNAME = "elemName";
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/main/java/org/apache/oodt/xmlps/util/XMLQueryKeys.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/mapping/TestMappingReader.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/mapping/TestMappingReader.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/mapping/TestMappingReader.java (added)
+++ incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/mapping/TestMappingReader.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,147 @@
+/**
+ * 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;
+
+//JDK imports
+import java.io.InputStream;
+
+//Junit imports
+import junit.framework.TestCase;
+
+/**
+ * Test suite for XMLPS xml map file reader.
+ */
+public class TestMappingReader extends TestCase {
+
+    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");
+    }
+
+    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() {
+        Mapping mapping = null;
+
+        InputStream configFileIs = TestMappingReader.class
+                .getResourceAsStream("test-ps.xml");
+
+        try {
+            mapping = MappingReader.getMapping(configFileIs);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        return mapping;
+    }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/mapping/TestMappingReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/product/TestXMLPSProductHandler.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/product/TestXMLPSProductHandler.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/product/TestXMLPSProductHandler.java (added)
+++ incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/product/TestXMLPSProductHandler.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,143 @@
+/**
+ * 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.Iterator;
+import java.util.List;
+
+//APACHE imports
+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 static 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 TestXMLPSProductHandler() {
+        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 (Iterator<QueryElement> i = elemNames.iterator(); i.hasNext();) {
+            QueryElement elem = i.next();
+            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);
+
+    }
+}

Propchange: incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/product/TestXMLPSProductHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/profile/TestXMLPSProfileHandler.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/profile/TestXMLPSProfileHandler.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/profile/TestXMLPSProfileHandler.java (added)
+++ incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/profile/TestXMLPSProfileHandler.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,71 @@
+/**
+ * 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());
+    }
+
+  }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/profile/TestXMLPSProfileHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/queryparser/TestHandlerQueryParser.java
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/queryparser/TestHandlerQueryParser.java?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/queryparser/TestHandlerQueryParser.java (added)
+++ incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/queryparser/TestHandlerQueryParser.java Thu Sep 16 04:04:29 2010
@@ -0,0 +1,55 @@
+/**
+ * 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.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.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());
+  }
+
+}

Propchange: incubator/oodt/trunk/xmlps/src/test/java/org/apache/oodt/xmlps/queryparser/TestHandlerQueryParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/oodt/trunk/xmlps/src/test/resources/loging.properties
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/test/resources/loging.properties?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/test/resources/loging.properties (added)
+++ incubator/oodt/trunk/xmlps/src/test/resources/loging.properties Thu Sep 16 04:04:29 2010
@@ -0,0 +1,34 @@
+# 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

Added: incubator/oodt/trunk/xmlps/src/test/resources/test-ps.xml
URL: http://svn.apache.org/viewvc/incubator/oodt/trunk/xmlps/src/test/resources/test-ps.xml?rev=997583&view=auto
==============================================================================
--- incubator/oodt/trunk/xmlps/src/test/resources/test-ps.xml (added)
+++ incubator/oodt/trunk/xmlps/src/test/resources/test-ps.xml Thu Sep 16 04:04:29 2010
@@ -0,0 +1,120 @@
+<?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 &quot;query&quot;, which signifies that the field is only applicable when
+		translating queries: and &quot;return&quot;, 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