Package org.apache.oodt.xmlquery

Examples of org.apache.oodt.xmlquery.QueryElement


        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;
            }

        }
View Full Code Here


            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);

    }
View Full Code Here

            return Collections.emptyList();

        List<QueryElement> newSet = new Vector<QueryElement>();

        for (Iterator<QueryElement> i = origSet.iterator(); i.hasNext();) {
            QueryElement elem = i.next();
            if (elem.getRole().equals(XMLQueryHelper.ROLE_ELEMNAME)
                    && !mapping.constantField(elem.getValue())) {
                newSet.add(elem);

            }

        }
View Full Code Here

            return Collections.emptyList();

        List<QueryElement> newSet = new Vector<QueryElement>();

        for (Iterator<QueryElement> i = origSet.iterator(); i.hasNext();) {
            QueryElement elem = i.next();
            if (elem.getRole().equals(XMLQueryHelper.ROLE_ELEMNAME)
                    && mapping.constantField(elem.getValue())) {
                newSet.add(elem);
            }
        }

        return newSet;
View Full Code Here

            boolean selectSet) throws Exception {
        // go through each query element: use the mapping fields
        // to translate the names

        for (Iterator<QueryElement> i = elemSet.iterator(); i.hasNext();) {
            QueryElement elem = i.next();
            if (elem.getRole().equals(XMLQueryHelper.ROLE_ELEMNAME)) {
                // do the translation
                String elemValue = elem.getValue();
                MappingField fld = this.mapping.getFieldByName(elemValue);
                // make sure fld is not null
                if (fld == null) {
                    continue;
                }

                // make sure scope is null, or if it's not null, then it's
                // FieldScope.QUERY

                if (fld.getScope() != null
                        && fld.getScope().equals(FieldScope.RETURN)) {
                    // skip
                    continue;
                }

                // check to see if it has a dbname attr, if not, then the name
                // stays
                // the same
                String newFldName = fld.getLocalName();

                elem.setValue(newFldName);

                // now translate the domain vocab if there are translate funcs
                // present and this isn't the select set

                if (!selectSet && fld.getFuncs() != null
                        && fld.getFuncs().size() > 0) {
                    // the next query element should be
                    // XMLQueryHelper.ROLE_LITERAL
                    if (!i.hasNext())
                        break;
                    QueryElement litElem = i.next();
                    if (!litElem.getRole().equals(XMLQueryHelper.ROLE_LITERAL)) {
                        throw new Exception("next query element not "
                                + XMLQueryHelper.ROLE_LITERAL + "! role is "
                                + litElem.getRole() + " instead!");
                    }

                    for (Iterator<MappingFunc> j = fld.getFuncs().iterator(); j
                            .hasNext();) {
                        MappingFunc func = j.next();
                        CDEValue origVal = new CDEValue(fld.getName(),
                                litElem.getValue());
                        CDEValue newVal = func.inverseTranslate(origVal);
                        litElem.setValue(newVal.getVal());
                    }

                }

            }
View Full Code Here

    OFSNMetKeys {

  public static String extractFieldFromQuery(XMLQuery query, String name) {
    for (Iterator<QueryElement> i = query.getWhereElementSet().iterator(); i
        .hasNext();) {
      QueryElement element = i.next();
      if (element.getRole().equals(XMLQUERY_QUERYELEM_ROLE_ELEM)
          && element.getValue().equalsIgnoreCase(name)) {
        // get the next element and ensure that it is a LITERAL, and
        // return that
        QueryElement litElement = i.next();
        return litElement.getValue();
      }
    }

    return null;
  }
View Full Code Here

   * @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, 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);
View Full Code Here

    throws IOException, ServletException {
    // Find if the query should be targeted to specific handlers.
    Set ids = new HashSet();
    if (query.getFromElementSet() != null) {
      for (Iterator i = query.getFromElementSet().iterator(); i.hasNext();) {
        QueryElement qe = (QueryElement) i.next();
        if ("handler".equals(qe.getRole()) && qe.getValue() != null)
          ids.add(qe.getValue());
      }
    }
   
    res.setContentType("text/xml");                 // XML, comin' at ya
    res.getWriter().println("<?xml version='1.0' encoding='UTF-8'?>");     // UTF-8 no less.  Boo-ya.
View Full Code Here

    OFSNMetKeys {

  public static String extractFieldFromQuery(XMLQuery query, String name) {
    for (Iterator<QueryElement> i = query.getWhereElementSet().iterator(); i
        .hasNext();) {
      QueryElement element = i.next();
      if (element.getRole().equals(XMLQUERY_QUERYELEM_ROLE_ELEM)
          && element.getValue().equals(name)) {
        // get the next element and ensure that it is a LITERAL, and
        // return that
        QueryElement litElement = i.next();
        return litElement.getValue();
      }
    }

    return null;
  }
View Full Code Here

            return Collections.emptyList();

        List<QueryElement> newSet = new Vector<QueryElement>();

        for (Iterator<QueryElement> i = origSet.iterator(); i.hasNext();) {
            QueryElement elem = i.next();
            if (elem.getRole().equals(XMLQueryHelper.ROLE_ELEMNAME)
                    && !mapping.constantField(elem.getValue())) {
                newSet.add(elem);

            }

        }
View Full Code Here

TOP

Related Classes of org.apache.oodt.xmlquery.QueryElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.