private SWRLDataObject makeDataObject(final Expr expr) throws URISyntaxException {
      if (expr.isVariable()) {
        return swrlFactory.createDataVariable(new URI(varNS + expr.getVarName()));
      } else if (expr.isConstant()) {
        final NodeValue nv = (NodeValue) expr;
        OWLDataValue value;
        if (nv.isInteger()) value = owlModel.createDataValue(nv.getInteger());
        else if (nv.isDouble()) value = owlModel.createDataValue(Double.valueOf(nv.getDouble()));
        else if (nv.isFloat()) value = owlModel.createDataValue(Float.valueOf(nv.getFloat()));
        else if (nv.isBoolean()) value = owlModel.createDataValue(Boolean.valueOf(nv.getBoolean()));
        else if (nv.isString()) value = owlModel.createDataValue(nv.getString());
        else if (nv.isDecimal()) value = owlModel.createDataValue(nv.getDecimal());
        else if (nv.hasDateTime()) value = owlModel.createDataValue(nv.getDateTime());
        else /* if (nv.isLiteral()) */ throw new NotImplementedException();

        return swrlFactory.wrapDataValue(value);
      } else {
        throw new IllegalArgumentException(
            "Nested constraint (filter) near " + expr + " can not be transformed to SWRL atom.");
      }
    }
Esempio n. 2
0
  public void visit(NodeValue value) {
    logger.debug("visit NodeValue " + value);

    if (!convertable) {
      expression.push(Expression.FALSE); // prevent stack empty exceptions when conversion
      return; // fails in the middle of a multi-arg operator conversion
    }

    if (value.isDecimal()
        || value.isDouble()
        || value.isFloat()
        || value.isInteger()
        || value.isNumber()) {
      expression.push(new ConstantEx(value.asString(), value.asNode()));
    } else if (value.isDateTime()) {
      // Convert xsd:dateTime: CCYY-MM-DDThh:mm:ss
      // to SQL-92 TIMESTAMP: CCYY-MM-DD hh:mm:ss[.fraction]
      // TODO support time zones (WITH TIME ZONE columns)
      expression.push(new ConstantEx(value.asString().replace("T", " "), value.asNode()));
    } else {
      expression.push(new ConstantEx(value.asString(), value.asNode()));
    }
  }