Search in sources :

Example 1 with ExternalFORMULAType

use of org.w3._2007.rif.ExternalFORMULAType in project hale by halestudio.

the class ModelRifToRifTranslator method createExternalPredicateFilter.

private void createExternalPredicateFilter(ModelRifMappingCondition mappingCondition, Formula filterFormula) {
    // create an <External>/<content>/<Atom> element hierarchy
    ExternalFORMULAType external = factory.createExternalFORMULAType();
    filterFormula.setExternal(external);
    ContentFORMULAType content = factory.createContentFORMULAType();
    external.setContent(content);
    Atom atom = factory.createAtom();
    content.setAtom(atom);
    Op op = factory.createOp();
    ArgsUNITERMType args = factory.createArgsUNITERMType();
    atom.setOp(op);
    Const opConst = factory.createConst();
    // $NON-NLS-1$
    opConst.setType("rif:iri");
    opConst.getContent().add(mappingCondition.getOperator().getRifPredicate());
    op.setConst(opConst);
    atom.setArgs(args);
    // $NON-NLS-1$
    args.setOrdered("yes");
    Var var = factory.createVar();
    var.getContent().add(mappingCondition.getLeft().getName());
    args.getTERM().add(var);
    Const argsConst = factory.createConst();
    argsConst.setType(getLiteralTypeFor(mappingCondition.getLiteralClass()));
    String literalValue = mappingCondition.getLiteralValue().toString();
    // remove any wildcards
    if (mappingCondition.getOperator().equals(ComparisonType.STRING_CONTAINS)) {
        // $NON-NLS-1$ //$NON-NLS-2$
        literalValue = literalValue.replaceAll("%", "");
    }
    argsConst.getContent().add(literalValue);
    args.getTERM().add(argsConst);
    // $NON-NLS-1$ //$NON-NLS-2$
    log.fine("Filter is a " + mappingCondition.getOperator().toString() + " filter");
}
Also used : Op(org.w3._2007.rif.Op) ExternalFORMULAType(org.w3._2007.rif.ExternalFORMULAType) ContentFORMULAType(org.w3._2007.rif.ContentFORMULAType) ActionVar(org.w3._2007.rif.Do.ActionVar) Var(org.w3._2007.rif.Var) Const(org.w3._2007.rif.Const) ArgsUNITERMType(org.w3._2007.rif.ArgsUNITERMType) Atom(org.w3._2007.rif.Atom)

Aggregations

ArgsUNITERMType (org.w3._2007.rif.ArgsUNITERMType)1 Atom (org.w3._2007.rif.Atom)1 Const (org.w3._2007.rif.Const)1 ContentFORMULAType (org.w3._2007.rif.ContentFORMULAType)1 ActionVar (org.w3._2007.rif.Do.ActionVar)1 ExternalFORMULAType (org.w3._2007.rif.ExternalFORMULAType)1 Op (org.w3._2007.rif.Op)1 Var (org.w3._2007.rif.Var)1