[Mulgara-dev] Virtual model in mulgara.

Alex Cozzi alexcozzi at gmail.com
Mon Feb 5 21:58:09 UTC 2007


I am trying to add a resolver for a virtual model in Mulgara that contains a
potentially infinite number of triples. What I am trying to do is a simple
model that for each URI that it is actually a URL answer with the parent of
that URI. Example:


for URI http://www.example.com/path1/subpath

responds with the triple:

<http://www.example.com/path1/subpath> <http://www.schema.com#parent> <
http://www.example.com/path1>

My problem is that unconstrained queries for this model are disallowed, but
I can not make it work well with other queries. My issue is in the Resolver
class. Here is the excerpt:

    public Resolution resolve(Constraint constraint) throws QueryException {
        // Obtain the model of the constraint
        ConstraintElement modelElem = constraint.getModel();

        // Verify our model node is a local node
        if (!(modelElem instanceof LocalNode)) {
            if (logger.isInfoEnabled()) {
                logger.info("Ignoring non-local model in constraint "
                        + constraint);
            }

            return new EmptyResolution(constraint, false);
        }

        // Get the model id for the node
        // long model = ((LocalNode) modelElem).getValue();
        ConstraintElement ce = constraint.getElement(0);
        if (ce instanceof LocalNode) {
            LocalNode subject = (LocalNode) ce;
            Node node = null;
            try {
                node = resolverSession.globalize(subject.getValue());
            } catch (GlobalizeException e) {
                e.printStackTrace();
            }
            if (node instanceof URIReference) {
                Statements statements = new
URLpathStatements(resolverSession,
                        ((URIReference) node).getURI());
                return new StatementsWrapperResolution(constraint,
statements,
                        true);
            }

        }
        return new EmptyResolution(constraint, false);
    }

so, if I do a query like:

select $subject $predicate $object from <rmi://localhost/server1#sample>
where
<http://www.example.com/path/subpath> $predicate $object and
$subject $predicate $object;


The first constraints that I get in my resolve code is the one for
($subject, $predicate, $object) , which I can not resolve and I'd like to
pass along. I reply with an EmptyResolution to that constraint and then the
evaluation stops there (meaning, I do not see any more call to resolve). I
think I need to respond with some other kind of resolution so that the query
evaluation code will come back asking for more triples, this time proviiding
the second argument of the and: (<http://www.example.com/path/subpath>
$predicate $object), whereby I can aswer with the appropriate triple.

Is there something like WildcardResolution or am I completely misusing the
resolver API? I was trying to follow the xsd-resolver example but with
little success.

Thank you very much for you help.
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mulgara.org/pipermail/mulgara-dev/attachments/20070205/11cf395b/attachment.htm>


More information about the Mulgara-dev mailing list