@Override
    public void visit(ExprFunction1 func) {
      if (func instanceof E_Bound) {
        TermMap boundCheck = tms.pop();
        tms.push(translateIsBound(boundCheck));

      } else if (func instanceof E_LogicalNot) {
        TermMap notCheck = tms.pop();
        Expression bool = DataTypeHelper.uncast(notCheck.getLiteralValBool());
        if (bool instanceof IsNullExpression) {
          ((IsNullExpression) bool).setNot(!((IsNullExpression) bool).isNot());

        } else {
          Parenthesis parenthesis = new Parenthesis(bool);
          parenthesis.setNot();

          notCheck = tmf.createBoolTermMap(parenthesis);
        }

        tms.push(notCheck);

      } else if (func instanceof E_Lang) {
        TermMap langFunc = tms.pop();
        Expression lang = DataTypeHelper.uncast(langFunc.getLiteralLang());
        TermMap langTermMap = tmf.createStringTermMap(lang);
        tms.push(langTermMap);

      } else if (func instanceof E_Str) {
        TermMap strParam = tms.pop();

        // create the coalesce function here

        List<Expression> strExpressions = new ArrayList<Expression>();

        strExpressions.add(
            dth.cast(
                DataTypeHelper.uncast(strParam.getLiteralValBinary()), dth.getStringCastType()));
        strExpressions.add(
            dth.cast(DataTypeHelper.uncast(strParam.getLiteralValBool()), dth.getStringCastType()));
        strExpressions.add(
            dth.cast(DataTypeHelper.uncast(strParam.getLiteralValDate()), dth.getStringCastType()));
        strExpressions.add(
            dth.cast(
                DataTypeHelper.uncast(strParam.getLiteralValNumeric()), dth.getStringCastType()));
        strExpressions.add(
            dth.cast(
                DataTypeHelper.uncast(strParam.getLiteralValString()), dth.getStringCastType()));

        strExpressions.add(FilterUtil.concat(strParam.getExpressions().toArray(new Expression[0])));

        Expression toString = FilterUtil.coalesce(strExpressions.toArray(new Expression[0]));

        tms.push(tmf.createStringTermMap(toString));
      } else if (func instanceof E_IsBlank) {
        TermMap isBlank = tms.pop();
        EqualsTo eq = new EqualsTo();
        eq.setLeftExpression(isBlank.getTermType());
        eq.setRightExpression(new StringValue("'" + ColumnHelper.COL_VAL_TYPE_BLANK + "'"));
        tms.push(tmf.createBoolTermMap(eq));
      } else if (func instanceof E_IsIRI) {
        TermMap isIri = tms.pop();
        EqualsTo eq = new EqualsTo();
        eq.setLeftExpression(isIri.getTermType());
        eq.setRightExpression(new StringValue("'" + ColumnHelper.COL_VAL_TYPE_RESOURCE + "'"));
        tms.push(tmf.createBoolTermMap(eq));
      } else if (func instanceof E_IsLiteral) {
        TermMap isLiteral = tms.pop();
        EqualsTo eq = new EqualsTo();
        eq.setLeftExpression(isLiteral.getTermType());
        eq.setRightExpression(new StringValue("'" + ColumnHelper.COL_VAL_TYPE_LITERAL + "'"));
        tms.push(tmf.createBoolTermMap(eq));
      } else {
        throw new ImplementationException("Implement Conversion for " + func.toString());
      }
    }
Example #2
0
 public void visit(Parenthesis parenthesis) throws Exception {
   parenthesis.getExpression().accept(this);
 }
Example #3
0
 @Override
 public void visit(Parenthesis prnths) {
   prnths.getExpression().accept(this);
 }